API 1.0.46 TrainingPlanDay
This commit is contained in:
parent
36c5bcbc49
commit
4fcdf02221
@ -11,7 +11,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = "com.aitrainer"
|
group = "com.aitrainer"
|
||||||
version = "1.0.45"
|
version = "1.0.46"
|
||||||
java.sourceCompatibility = JavaVersion.VERSION_1_8
|
java.sourceCompatibility = JavaVersion.VERSION_1_8
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
|
29
data/db/update_1_0_46.sql
Normal file
29
data/db/update_1_0_46.sql
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
START TRANSACTION;
|
||||||
|
|
||||||
|
CREATE TABLE `training_plan_day` (
|
||||||
|
`day_id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`name` CHAR(50) NOT NULL COLLATE 'utf8_hungarian_ci',
|
||||||
|
PRIMARY KEY (`day_id`) USING BTREE
|
||||||
|
)
|
||||||
|
COLLATE='utf8_hungarian_ci'
|
||||||
|
ENGINE=InnoDB
|
||||||
|
;
|
||||||
|
|
||||||
|
CREATE TABLE `training_plan_day_translation` (
|
||||||
|
`translation_id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`day_id` INT(11) NOT NULL DEFAULT '0',
|
||||||
|
`name_translation` CHAR(50) NOT NULL DEFAULT '0' COLLATE 'utf8_hungarian_ci',
|
||||||
|
`language_code` CHAR(2) NULL DEFAULT 'en' COLLATE 'utf8_hungarian_ci',
|
||||||
|
PRIMARY KEY (`translation_id`) USING BTREE,
|
||||||
|
INDEX `day_id` (`day_id`) USING BTREE
|
||||||
|
)
|
||||||
|
COLLATE='utf8_hungarian_ci'
|
||||||
|
ENGINE=InnoDB
|
||||||
|
;
|
||||||
|
|
||||||
|
ALTER TABLE `training_plan_detail`
|
||||||
|
ADD COLUMN `day_id` INT NULL DEFAULT NULL AFTER `day`;
|
||||||
|
|
||||||
|
UPDATE configuration set config_value = "1.0.46", date_change=CURRENT_DATE WHERE config_key = "db_version";
|
||||||
|
|
||||||
|
COMMIT;
|
@ -70,11 +70,6 @@ class ControllerAspect {
|
|||||||
Singleton.checkDBUpdate(configurationRepository, properties)
|
Singleton.checkDBUpdate(configurationRepository, properties)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before("execution(* com.aitrainer.api.controller.ProductTestController.*(..))")
|
|
||||||
fun productTestControllerAspect(joinPoint: JoinPoint) {
|
|
||||||
println("product test controller")
|
|
||||||
Singleton.checkDBUpdate(configurationRepository, properties)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Before("execution(* com.aitrainer.api.controller.PropertyController.*(..))")
|
@Before("execution(* com.aitrainer.api.controller.PropertyController.*(..))")
|
||||||
fun propertyControllerAspect(joinPoint: JoinPoint) {
|
fun propertyControllerAspect(joinPoint: JoinPoint) {
|
||||||
@ -94,4 +89,31 @@ class ControllerAspect {
|
|||||||
Singleton.checkDBUpdate(configurationRepository, properties)
|
Singleton.checkDBUpdate(configurationRepository, properties)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Before("execution(* com.aitrainer.api.controller.SportController.*(..))")
|
||||||
|
fun sportControllerAspect(joinPoint: JoinPoint) {
|
||||||
|
println("sport controller")
|
||||||
|
Singleton.checkDBUpdate(configurationRepository, properties)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Before("execution(* com.aitrainer.api.controller.TrackingController.*(..))")
|
||||||
|
fun trackingControllerAspect(joinPoint: JoinPoint) {
|
||||||
|
println("tracking controller")
|
||||||
|
Singleton.checkDBUpdate(configurationRepository, properties)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Before("execution(* com.aitrainer.api.controller.PackageController.*(..))")
|
||||||
|
fun packageControllerAspect(joinPoint: JoinPoint) {
|
||||||
|
println("package controller")
|
||||||
|
Singleton.checkDBUpdate(configurationRepository, properties)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Before("execution(* com.aitrainer.api.controller.CustomerPackageController.*(..))")
|
||||||
|
fun customerPackageControllerAspect(joinPoint: JoinPoint) {
|
||||||
|
println("customerPackage controller")
|
||||||
|
Singleton.checkDBUpdate(configurationRepository, properties)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -14,7 +14,6 @@ import org.springframework.web.bind.annotation.RestController
|
|||||||
class CustomerPackageController( private val customerRepository: CustomerRepository,
|
class CustomerPackageController( private val customerRepository: CustomerRepository,
|
||||||
private val customerExerciseDeviceRepository: CustomerExerciseDeviceRepository,
|
private val customerExerciseDeviceRepository: CustomerExerciseDeviceRepository,
|
||||||
private val exercisesRepository: ExercisesRepository,
|
private val exercisesRepository: ExercisesRepository,
|
||||||
private val productTestRepository: ProductTestRepository,
|
|
||||||
private val purchaseRepository: PurchaseRepository,
|
private val purchaseRepository: PurchaseRepository,
|
||||||
private val customerPropertyRepository: CustomerPropertyRepository,
|
private val customerPropertyRepository: CustomerPropertyRepository,
|
||||||
private val exerciseResultRepository: ExerciseResultRepository,
|
private val exerciseResultRepository: ExerciseResultRepository,
|
||||||
@ -44,9 +43,6 @@ class CustomerPackageController( private val customerRepository: CustomerReposit
|
|||||||
val listExercises = exercisesRepository.getAllByCustomerIdOrderByDateAddDesc(customerId)
|
val listExercises = exercisesRepository.getAllByCustomerIdOrderByDateAddDesc(customerId)
|
||||||
val listExercisesJson = gson.toJson(listExercises)
|
val listExercisesJson = gson.toJson(listExercises)
|
||||||
|
|
||||||
val listProductTest = productTestRepository.findByCustomerId(customerId)
|
|
||||||
val listProductTestJson = gson.toJson(listProductTest)
|
|
||||||
|
|
||||||
val listPurchase = purchaseRepository.findByCustomerId(customerId)
|
val listPurchase = purchaseRepository.findByCustomerId(customerId)
|
||||||
val listPurchaseJson = gson.toJson(listPurchase)
|
val listPurchaseJson = gson.toJson(listPurchase)
|
||||||
|
|
||||||
@ -69,7 +65,6 @@ class CustomerPackageController( private val customerRepository: CustomerReposit
|
|||||||
getClassRecord(Customer::class.simpleName, customerJson) +
|
getClassRecord(Customer::class.simpleName, customerJson) +
|
||||||
"|||" + getClassRecord(CustomerExerciseDevice::class.simpleName, listCustomerExerciseDeviceJson) +
|
"|||" + getClassRecord(CustomerExerciseDevice::class.simpleName, listCustomerExerciseDeviceJson) +
|
||||||
"|||" + getClassRecord(Exercises::class.simpleName, listExercisesJson) +
|
"|||" + getClassRecord(Exercises::class.simpleName, listExercisesJson) +
|
||||||
"|||" + getClassRecord(ProductTest::class.simpleName, listProductTestJson) +
|
|
||||||
"|||" + getClassRecord(Purchase::class.simpleName, listPurchaseJson) +
|
"|||" + getClassRecord(Purchase::class.simpleName, listPurchaseJson) +
|
||||||
"|||" + getClassRecord(CustomerProperty::class.simpleName+"All", listCustomerPropertyAllJson) +
|
"|||" + getClassRecord(CustomerProperty::class.simpleName+"All", listCustomerPropertyAllJson) +
|
||||||
"|||" + getClassRecord(CustomerProperty::class.simpleName, listCustomerPropertyJson) +
|
"|||" + getClassRecord(CustomerProperty::class.simpleName, listCustomerPropertyJson) +
|
||||||
|
@ -26,7 +26,8 @@ class PackageController(private val exerciseAbilityRepository: ExerciseAbilityRe
|
|||||||
private val descriptionRepository: DescriptionRepository,
|
private val descriptionRepository: DescriptionRepository,
|
||||||
private val faqRepository: FaqRepository,
|
private val faqRepository: FaqRepository,
|
||||||
private val trainingPlanRepository: TrainingPlanRepository,
|
private val trainingPlanRepository: TrainingPlanRepository,
|
||||||
private val splitTestsRepository: SplitTestsRepository
|
private val splitTestsRepository: SplitTestsRepository,
|
||||||
|
private val trainingPlanDayRepository: TrainingPlanDayRepository
|
||||||
) {
|
) {
|
||||||
private val logger = LoggerFactory.getLogger(javaClass)
|
private val logger = LoggerFactory.getLogger(javaClass)
|
||||||
|
|
||||||
@ -83,6 +84,9 @@ class PackageController(private val exerciseAbilityRepository: ExerciseAbilityRe
|
|||||||
val listSplitTests = splitTestsRepository.findAll()
|
val listSplitTests = splitTestsRepository.findAll()
|
||||||
val listSplitTestsJson = gson.toJson(listSplitTests)
|
val listSplitTestsJson = gson.toJson(listSplitTests)
|
||||||
|
|
||||||
|
val listTrainingPlanDay = trainingPlanDayRepository.findAll()
|
||||||
|
val listTrainingPlanDayJson = gson.toJson(listTrainingPlanDay)
|
||||||
|
|
||||||
val packageJson: String =
|
val packageJson: String =
|
||||||
getClassRecord(ExerciseDevice::class.simpleName, listDevicesJson) +
|
getClassRecord(ExerciseDevice::class.simpleName, listDevicesJson) +
|
||||||
"|||" + getClassRecord(Product::class.simpleName, listProductsJson) +
|
"|||" + getClassRecord(Product::class.simpleName, listProductsJson) +
|
||||||
@ -98,7 +102,8 @@ class PackageController(private val exerciseAbilityRepository: ExerciseAbilityRe
|
|||||||
"|||" + getClassRecord(Description::class.simpleName, listDescriptionJson) +
|
"|||" + getClassRecord(Description::class.simpleName, listDescriptionJson) +
|
||||||
"|||" + getClassRecord(Faq::class.simpleName, listFaqJson) +
|
"|||" + getClassRecord(Faq::class.simpleName, listFaqJson) +
|
||||||
"|||" + getClassRecord(TrainingPlan::class.simpleName, listTrainingPlanJson) +
|
"|||" + getClassRecord(TrainingPlan::class.simpleName, listTrainingPlanJson) +
|
||||||
"|||" + getClassRecord(SplitTests::class.simpleName, listSplitTestsJson)
|
"|||" + getClassRecord(SplitTests::class.simpleName, listSplitTestsJson) +
|
||||||
|
"|||" + getClassRecord(TrainingPlanDay::class.simpleName, listTrainingPlanDayJson)
|
||||||
|
|
||||||
return if (packageJson.isEmpty()) ResponseEntity.notFound().build() else
|
return if (packageJson.isEmpty()) ResponseEntity.notFound().build() else
|
||||||
ResponseEntity.ok().body(packageJson)
|
ResponseEntity.ok().body(packageJson)
|
||||||
|
@ -1,32 +0,0 @@
|
|||||||
package com.aitrainer.api.controller
|
|
||||||
|
|
||||||
import com.aitrainer.api.model.ProductTest
|
|
||||||
import com.aitrainer.api.repository.ProductTestRepository
|
|
||||||
import org.slf4j.LoggerFactory
|
|
||||||
import org.springframework.http.ResponseEntity
|
|
||||||
import org.springframework.web.bind.annotation.*
|
|
||||||
import javax.validation.Valid
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/api")
|
|
||||||
class ProductTestController(private val productTestRepository: ProductTestRepository) {
|
|
||||||
private val logger = LoggerFactory.getLogger(javaClass)
|
|
||||||
|
|
||||||
@GetMapping("/product_test/customer/{id}")
|
|
||||||
fun getAllByCustomerId(@PathVariable(value = "id") customerId: Long): ResponseEntity<List<ProductTest>> {
|
|
||||||
|
|
||||||
val productTestList = productTestRepository.findByCustomerId(customerId)
|
|
||||||
logger.info("Get all productTest by customerId $productTestList")
|
|
||||||
|
|
||||||
return if(productTestList.isNotEmpty())
|
|
||||||
ResponseEntity.ok().body(productTestList) else
|
|
||||||
ResponseEntity.notFound().build()
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/product_test")
|
|
||||||
fun insertProductTest(@Valid @RequestBody productTest: ProductTest): ResponseEntity<ProductTest> {
|
|
||||||
val newProductTest = productTestRepository.save(productTest)
|
|
||||||
logger.info("Create new productTest: $newProductTest")
|
|
||||||
return ResponseEntity.ok().body(newProductTest)
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
package com.aitrainer.api.model
|
|
||||||
|
|
||||||
import com.google.gson.annotations.Expose
|
|
||||||
import org.springframework.lang.NonNull
|
|
||||||
import javax.persistence.Entity
|
|
||||||
import javax.persistence.GeneratedValue
|
|
||||||
import javax.persistence.GenerationType
|
|
||||||
import javax.persistence.Id
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
data class ProductTest (
|
|
||||||
@Expose @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @get: NonNull var productTestId: Int = 0,
|
|
||||||
@Expose @get: NonNull var customerId: Long = 0,
|
|
||||||
@Expose @get: NonNull var productId: Int = 0,
|
|
||||||
@Expose @get: NonNull var dateView: String? = null,
|
|
||||||
@Expose @get: NonNull var purchaseClick: Boolean = false
|
|
||||||
)
|
|
19
src/main/kotlin/com/aitrainer/api/model/TrainingPlanDay.kt
Normal file
19
src/main/kotlin/com/aitrainer/api/model/TrainingPlanDay.kt
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package com.aitrainer.api.model
|
||||||
|
|
||||||
|
import com.google.gson.annotations.Expose
|
||||||
|
import org.hibernate.annotations.Fetch
|
||||||
|
import org.hibernate.annotations.FetchMode
|
||||||
|
import org.springframework.lang.NonNull
|
||||||
|
import javax.persistence.*
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
data class TrainingPlanDay (
|
||||||
|
@Expose @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @get: NonNull var dayId: Long = 0,
|
||||||
|
@Expose @get: NonNull var name: String,
|
||||||
|
|
||||||
|
) {
|
||||||
|
@OneToMany(cascade = [(CascadeType.ALL)], fetch = FetchType.EAGER, mappedBy = "trainingPlanDay")
|
||||||
|
@Fetch(value = FetchMode.SUBSELECT)
|
||||||
|
@Expose val translations: List<TrainingPlanDayTranslation> = mutableListOf<TrainingPlanDayTranslation>().toList()
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
package com.aitrainer.api.model
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore
|
||||||
|
import com.google.gson.annotations.Expose
|
||||||
|
import org.springframework.lang.NonNull
|
||||||
|
import javax.persistence.*
|
||||||
|
import javax.validation.constraints.NotBlank
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
data class TrainingPlanDayTranslation (
|
||||||
|
@Expose @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @get: NonNull var translationId: Long = 0,
|
||||||
|
@Expose @get: NotBlank var languageCode: String? = "hu",
|
||||||
|
@Expose @get: NonNull var nameTranslation: String? = null,
|
||||||
|
) {
|
||||||
|
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||||
|
@JoinColumn(name = "dayId", nullable = false)
|
||||||
|
@JsonIgnore val trainingPlanDay: TrainingPlanDay? = null
|
||||||
|
}
|
@ -17,6 +17,7 @@ data class TrainingPlanDetail (
|
|||||||
@Expose var restingTime: Int? = 0,
|
@Expose var restingTime: Int? = 0,
|
||||||
@Expose var parallel: Boolean? = false,
|
@Expose var parallel: Boolean? = false,
|
||||||
@Expose var day: String? = null,
|
@Expose var day: String? = null,
|
||||||
|
@Expose var dayId: Int? = 0,
|
||||||
|
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
package com.aitrainer.api.repository
|
|
||||||
|
|
||||||
import com.aitrainer.api.model.ProductTest
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository
|
|
||||||
import org.springframework.stereotype.Repository
|
|
||||||
|
|
||||||
@Repository
|
|
||||||
interface ProductTestRepository : JpaRepository<ProductTest, Long> {
|
|
||||||
fun findByCustomerId(customerId: Long): List<ProductTest>
|
|
||||||
}
|
|
@ -0,0 +1,9 @@
|
|||||||
|
package com.aitrainer.api.repository
|
||||||
|
|
||||||
|
import com.aitrainer.api.model.TrainingPlanDay
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository
|
||||||
|
import org.springframework.stereotype.Repository
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
interface TrainingPlanDayRepository: JpaRepository<TrainingPlanDay, Long> {
|
||||||
|
}
|
@ -17,6 +17,6 @@ logging.config=classpath:logback-spring.xml
|
|||||||
logging.file=logs
|
logging.file=logs
|
||||||
|
|
||||||
# if the database structure has been changed, increment this version number
|
# if the database structure has been changed, increment this version number
|
||||||
application.version=1.0.45
|
application.version=1.0.46
|
||||||
|
|
||||||
jwt.secret=aitrainer
|
jwt.secret=aitrainer
|
@ -17,7 +17,7 @@ logging.config=classpath:logback-spring.xml
|
|||||||
logging.file=logs
|
logging.file=logs
|
||||||
|
|
||||||
# if the database structure has been changed, increment this version number
|
# if the database structure has been changed, increment this version number
|
||||||
application.version=1.0.45
|
application.version=1.0.46
|
||||||
|
|
||||||
jwt.secret=aitrainer
|
jwt.secret=aitrainer
|
||||||
jasypt.encryptor.password=Tibor
|
jasypt.encryptor.password=Tibor
|
||||||
|
@ -27,9 +27,6 @@ class AppCustomerPackageTest {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private lateinit var exercisesRepository: ExercisesRepository
|
private lateinit var exercisesRepository: ExercisesRepository
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private lateinit var productTestRepository: ProductTestRepository
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private lateinit var purchaseRepository: PurchaseRepository
|
private lateinit var purchaseRepository: PurchaseRepository
|
||||||
|
|
||||||
@ -50,7 +47,7 @@ class AppCustomerPackageTest {
|
|||||||
val gson = Gson()
|
val gson = Gson()
|
||||||
|
|
||||||
val controller = CustomerPackageController(customerRepository, customerExerciseDeviceRepository,
|
val controller = CustomerPackageController(customerRepository, customerExerciseDeviceRepository,
|
||||||
exercisesRepository, productTestRepository, purchaseRepository, customerPropertyRepository,
|
exercisesRepository, purchaseRepository, customerPropertyRepository,
|
||||||
exerciseResultRepository, customerActivityRepository, customerTrainingPlanRepository )
|
exerciseResultRepository, customerActivityRepository, customerTrainingPlanRepository )
|
||||||
var response: ResponseEntity<*> = controller.getCustomerPackageData(91)
|
var response: ResponseEntity<*> = controller.getCustomerPackageData(91)
|
||||||
assertEquals(response.statusCode, HttpStatus.NOT_FOUND)
|
assertEquals(response.statusCode, HttpStatus.NOT_FOUND)
|
||||||
@ -90,13 +87,7 @@ class AppCustomerPackageTest {
|
|||||||
assertTrue(customerExerciseDeviceList.isNotEmpty())
|
assertTrue(customerExerciseDeviceList.isNotEmpty())
|
||||||
assertEquals(customerExerciseDeviceList[1].exerciseDeviceId,2)
|
assertEquals(customerExerciseDeviceList[1].exerciseDeviceId,2)
|
||||||
}
|
}
|
||||||
record[0] == ProductTest::class.simpleName -> {
|
|
||||||
val productTestJson: String = record[1]
|
|
||||||
val type = object : TypeToken<List<ProductTest?>?>() {}.type
|
|
||||||
val productTestList: List<ProductTest> = gson.fromJson(productTestJson, type)
|
|
||||||
assertTrue(productTestList.isNotEmpty())
|
|
||||||
assertEquals(productTestList[0].productId,1)
|
|
||||||
}
|
|
||||||
record[0] == CustomerProperty::class.simpleName -> {
|
record[0] == CustomerProperty::class.simpleName -> {
|
||||||
//actual values
|
//actual values
|
||||||
val propertyJson: String = record[1]
|
val propertyJson: String = record[1]
|
||||||
|
@ -47,6 +47,8 @@ class AppPackageTest {
|
|||||||
private lateinit var trainingPlanRepository: TrainingPlanRepository
|
private lateinit var trainingPlanRepository: TrainingPlanRepository
|
||||||
@Autowired
|
@Autowired
|
||||||
private lateinit var splitTestsRepository: SplitTestsRepository
|
private lateinit var splitTestsRepository: SplitTestsRepository
|
||||||
|
@Autowired
|
||||||
|
private lateinit var trainingPlanDayRepository: TrainingPlanDayRepository
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testAppPackage() {
|
fun testAppPackage() {
|
||||||
@ -67,7 +69,8 @@ class AppPackageTest {
|
|||||||
descriptionRepository,
|
descriptionRepository,
|
||||||
faqRepository,
|
faqRepository,
|
||||||
trainingPlanRepository,
|
trainingPlanRepository,
|
||||||
splitTestsRepository
|
splitTestsRepository,
|
||||||
|
trainingPlanDayRepository
|
||||||
)
|
)
|
||||||
val response: ResponseEntity<*> = controller.getPackageData()
|
val response: ResponseEntity<*> = controller.getPackageData()
|
||||||
|
|
||||||
@ -191,6 +194,13 @@ class AppPackageTest {
|
|||||||
assertEquals(tests[2].name, "sales_text")
|
assertEquals(tests[2].name, "sales_text")
|
||||||
assertEquals(tests[2].testValue, "")
|
assertEquals(tests[2].testValue, "")
|
||||||
assertEquals(tests[2].source, "description.name")
|
assertEquals(tests[2].source, "description.name")
|
||||||
|
} else if (record[0] == TrainingPlanDay::class.simpleName) {
|
||||||
|
val trainingPlanDayJson: String = record[1]
|
||||||
|
val type = object : TypeToken<List<TrainingPlanDay?>?>() {}.type
|
||||||
|
val days: List<TrainingPlanDay> = gson.fromJson(trainingPlanDayJson, type)
|
||||||
|
assertEquals(days.size,3)
|
||||||
|
assertEquals(days[0].name, "Mo")
|
||||||
|
assertEquals(days[0].translations[0].nameTranslation, "H")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,64 +0,0 @@
|
|||||||
package com.aitrainer.api.test
|
|
||||||
|
|
||||||
|
|
||||||
import com.aitrainer.api.controller.ProductTestController
|
|
||||||
import com.aitrainer.api.repository.ProductTestRepository
|
|
||||||
import org.junit.jupiter.api.Test
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired
|
|
||||||
import org.springframework.boot.test.context.SpringBootTest
|
|
||||||
import kotlin.test.assertEquals
|
|
||||||
import kotlin.test.assertTrue
|
|
||||||
import com.aitrainer.api.model.ProductTest
|
|
||||||
import org.junit.jupiter.api.TestInstance
|
|
||||||
|
|
||||||
|
|
||||||
@SpringBootTest
|
|
||||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
|
||||||
class ProductTestTest {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private lateinit var productTestRepository: ProductTestRepository
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun testGetProductTests() {
|
|
||||||
val list = productTestRepository.findByCustomerId(1)
|
|
||||||
print("List $list")
|
|
||||||
|
|
||||||
val controller = ProductTestController(productTestRepository)
|
|
||||||
val response = controller.getAllByCustomerId(62)
|
|
||||||
|
|
||||||
val productTest = response.body
|
|
||||||
|
|
||||||
print ("resp $response.body" )
|
|
||||||
|
|
||||||
assertTrue(productTest is List)
|
|
||||||
assertTrue(productTest.isNotEmpty())
|
|
||||||
assertEquals(productTest.size, 2)
|
|
||||||
assertEquals(productTest[0].productId, 2)
|
|
||||||
assertEquals(productTest[0].dateView, "2020-10-01 12:00:00")
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun testInsertProductTest() {
|
|
||||||
val productTest = ProductTest(
|
|
||||||
customerId = 2,
|
|
||||||
productId = 2,
|
|
||||||
dateView = "2020-11-01 12:00:00",
|
|
||||||
purchaseClick = false
|
|
||||||
)
|
|
||||||
val controller = ProductTestController(productTestRepository)
|
|
||||||
val response = controller.insertProductTest(productTest)
|
|
||||||
|
|
||||||
val productTestNew = response.body
|
|
||||||
|
|
||||||
assertTrue(productTestNew is ProductTest)
|
|
||||||
assertEquals(productTestNew.productId, 2)
|
|
||||||
assertEquals(productTestNew.customerId, 2)
|
|
||||||
|
|
||||||
productTestRepository.delete(productTestNew)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user