API 1.0.30 CustomerActivity, Sort ExercisePlanTemplateDetail.sort
This commit is contained in:
parent
b1dc434e96
commit
f1aee3904f
@ -11,7 +11,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = "com.aitrainer"
|
||||
version = "1.0.29"
|
||||
version = "1.0.30"
|
||||
java.sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
|
||||
repositories {
|
||||
@ -27,7 +27,6 @@ dependencies {
|
||||
implementation("org.springframework.security.oauth.boot:spring-security-oauth2-autoconfigure:2.4.4")
|
||||
implementation("org.springframework.security.oauth:spring-security-oauth2:2.5.0.RELEASE")
|
||||
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
|
||||
implementation("org.jetbrains.kotlin:kotlin-reflect")
|
||||
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
|
||||
implementation("org.apache.logging.log4j:log4j-core:2.14.0")
|
||||
implementation("org.apache.logging.log4j:log4j-api:2.14.0")
|
||||
@ -37,6 +36,7 @@ dependencies {
|
||||
implementation("org.yaml:snakeyaml:1.27")
|
||||
implementation("com.google.code.gson:gson:2.8.6")
|
||||
implementation("org.projectlombok:lombok:1.18.16")
|
||||
implementation("org.jetbrains.kotlin:kotlin-reflect:1.4.32")
|
||||
|
||||
runtimeOnly("mysql:mysql-connector-java")
|
||||
testImplementation("org.springframework.boot:spring-boot-starter-test") {
|
||||
|
@ -966,6 +966,7 @@ CREATE TABLE `exercise_plan_template_detail` (
|
||||
`quantity_unit_quantity` DOUBLE NULL DEFAULT '0',
|
||||
`serie` INT(11) NULL DEFAULT '0',
|
||||
`resting_time` TIME NULL DEFAULT '00:00:00',
|
||||
`sort` TINYINT(2) NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`exercise_plan_template_detail_id`) USING BTREE,
|
||||
INDEX `exercise_type_id` (`exercise_type_id`) USING BTREE,
|
||||
INDEX `exercise_plan_template_id` (`exercise_plan_template_id`) USING BTREE
|
||||
@ -1030,6 +1031,17 @@ INSERT INTO `evaluation_attribute` (`evaluation_attr_id`, `evaluation_id`, `name
|
||||
INSERT INTO `evaluation_attribute` (`evaluation_attr_id`, `evaluation_id`, `name`, `age_min`, `age_max`, `value_min`, `value_max`, `sex`, `evaluation_text`, `suggestion`) VALUES (9, 1, 'Fekvőtámasz_ffi_17-19_elite', 17, 19, 100, 100000, 'm', 'excellent', NULL);
|
||||
INSERT INTO `evaluation_attribute` (`evaluation_attr_id`, `evaluation_id`, `name`, `age_min`, `age_max`, `value_min`, `value_max`, `sex`, `evaluation_text`, `suggestion`) VALUES (10, 1, 'Fekvőtámasz_ffi_20-29_very_poor', 20, 29, 0, 4, 'm', 'very_poor', NULL);
|
||||
|
||||
CREATE TABLE `customer_activity` (
|
||||
`activity_id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`customer_id` INT(14) NOT NULL DEFAULT '0',
|
||||
`type` CHAR(50) NOT NULL COLLATE 'utf8_hungarian_ci',
|
||||
`date_add` DATETIME NOT NULL,
|
||||
`skipped` TINYINT(1) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`activity_id`) USING BTREE
|
||||
)
|
||||
COLLATE='utf8_hungarian_ci'
|
||||
ENGINE=InnoDB
|
||||
;
|
||||
|
||||
|
||||
/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
|
||||
|
22
data/db/update_1_0_30.sql
Normal file
22
data/db/update_1_0_30.sql
Normal file
@ -0,0 +1,22 @@
|
||||
START TRANSACTION;
|
||||
|
||||
ALTER TABLE `exercise_plan_template_detail`
|
||||
ADD COLUMN `sort` TINYINT(2) NULL DEFAULT NULL AFTER `resting_time`;
|
||||
|
||||
CREATE TABLE `customer_activity` (
|
||||
`activity_id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`customer_id` INT(14) NOT NULL DEFAULT '0',
|
||||
`type` CHAR(50) NOT NULL COLLATE 'utf8_hungarian_ci',
|
||||
`date_add` DATETIME NOT NULL,
|
||||
`skipped` TINYINT(1) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`activity_id`) USING BTREE
|
||||
)
|
||||
COLLATE='utf8_hungarian_ci'
|
||||
ENGINE=InnoDB
|
||||
;
|
||||
|
||||
|
||||
UPDATE configuration set config_value = "1.0.30", date_change=CURRENT_DATE WHERE config_key = "db_version";
|
||||
|
||||
COMMIT;
|
||||
|
@ -28,12 +28,6 @@ class ControllerAspect {
|
||||
Singleton.checkDBUpdate(configurationRepository, properties)
|
||||
}
|
||||
|
||||
@Before("execution(* com.aitrainer.api.controller.CustomerInformationController.*(..))")
|
||||
fun customerInformationControllerAspect(joinPoint: JoinPoint) {
|
||||
println("customer information controller")
|
||||
Singleton.checkDBUpdate(configurationRepository, properties)
|
||||
}
|
||||
|
||||
@Before("execution(* com.aitrainer.api.controller.CustomerPropertyController.*(..))")
|
||||
fun customerPropertyControllerAspect(joinPoint: JoinPoint) {
|
||||
println("customer property controller")
|
||||
|
@ -0,0 +1,21 @@
|
||||
package com.aitrainer.api.controller
|
||||
|
||||
import com.aitrainer.api.model.CustomerActivity
|
||||
import com.aitrainer.api.repository.CustomerActivityRepository
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.http.ResponseEntity
|
||||
import org.springframework.web.bind.annotation.*
|
||||
import javax.validation.Valid
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api")
|
||||
class CustomerActivityController(private val customerActivityRepository: CustomerActivityRepository) {
|
||||
private val logger = LoggerFactory.getLogger(javaClass)
|
||||
|
||||
@PostMapping("/customer_activity")
|
||||
fun insertActivity(@Valid @RequestBody customerActivity: CustomerActivity): ResponseEntity<CustomerActivity> {
|
||||
val newActivity = customerActivityRepository.save(customerActivity)
|
||||
logger.info("Create new activity: $newActivity")
|
||||
return ResponseEntity.ok().body(newActivity)
|
||||
}
|
||||
}
|
@ -92,34 +92,31 @@ class CustomerController ( private val customerRepository: CustomerRepository) {
|
||||
val returnCustomer: Customer = customerRepository.findById(customerId).orElse(null)
|
||||
?: return ResponseEntity.notFound().build()
|
||||
|
||||
val password: String? = newCustomer.password
|
||||
val updatedCustomer: Customer
|
||||
if ( password == null || password.isEmpty() ) {
|
||||
updatedCustomer =
|
||||
returnCustomer.copy(
|
||||
name = newCustomer.name,
|
||||
firstname = newCustomer.firstname,
|
||||
sex = newCustomer.sex,
|
||||
birthYear = newCustomer.birthYear,
|
||||
fitnessLevel = newCustomer.fitnessLevel,
|
||||
bodyType = newCustomer.bodyType,
|
||||
goal = newCustomer.goal,
|
||||
dateChange = newCustomer.dateChange
|
||||
)
|
||||
} else {
|
||||
updatedCustomer =
|
||||
returnCustomer.copy(
|
||||
name = newCustomer.name,
|
||||
firstname = newCustomer.firstname,
|
||||
password = newCustomer.password,
|
||||
sex = newCustomer.sex,
|
||||
birthYear = newCustomer.birthYear,
|
||||
fitnessLevel = newCustomer.fitnessLevel,
|
||||
bodyType = newCustomer.bodyType,
|
||||
goal = newCustomer.goal,
|
||||
dateChange = newCustomer.dateChange
|
||||
)
|
||||
}
|
||||
val updatedCustomer = returnCustomer.copy()
|
||||
if (newCustomer.email != null) {
|
||||
updatedCustomer.email = newCustomer.email
|
||||
}
|
||||
if (newCustomer.name != null) {
|
||||
updatedCustomer.name = newCustomer.name
|
||||
}
|
||||
if (newCustomer.firstname != null) {
|
||||
updatedCustomer.firstname = newCustomer.firstname
|
||||
}
|
||||
if (newCustomer.goal != null) {
|
||||
updatedCustomer.goal = newCustomer.goal
|
||||
}
|
||||
if (newCustomer.dateChange != null) {
|
||||
updatedCustomer.dateChange = newCustomer.dateChange
|
||||
}
|
||||
if (newCustomer.dataPolicyAllowed != null) {
|
||||
updatedCustomer.dataPolicyAllowed = newCustomer.dataPolicyAllowed
|
||||
}
|
||||
updatedCustomer.sex = newCustomer.sex
|
||||
updatedCustomer.birthYear = newCustomer.birthYear
|
||||
updatedCustomer.fitnessLevel = newCustomer.fitnessLevel
|
||||
|
||||
|
||||
|
||||
|
||||
return ResponseEntity.ok().body(customerRepository.save(updatedCustomer))
|
||||
}
|
||||
@ -139,6 +136,9 @@ class CustomerController ( private val customerRepository: CustomerRepository) {
|
||||
password = serviceBeans!!.passwordEncoder().encode(newUser.password)
|
||||
firebaseUid = newUser.firebaseUid
|
||||
dateAdd = nowFormatted
|
||||
firstname = ""
|
||||
name = ""
|
||||
email = ""
|
||||
}
|
||||
|
||||
val returnCustomer: Customer? = customerRepository.findByEmail(newUser.username).let {
|
||||
|
@ -1,21 +0,0 @@
|
||||
package com.aitrainer.api.controller
|
||||
|
||||
import com.aitrainer.api.model.CustomerInformation
|
||||
import com.aitrainer.api.repository.CustomerInformationRepository
|
||||
import org.springframework.web.bind.annotation.GetMapping
|
||||
import org.springframework.web.bind.annotation.RequestMapping
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
import java.time.LocalDateTime
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api")
|
||||
class CustomerInformationController( private val customerInformationRepository: CustomerInformationRepository ) {
|
||||
|
||||
@GetMapping("/customer_information")
|
||||
fun getCustomerInformation(): List<CustomerInformation> {
|
||||
val dateTime: String = LocalDateTime.now().toString()
|
||||
return customerInformationRepository.findByDisplayBeginLessThanAndDisplayEndGreaterThan(dateTime, dateTime )
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -17,7 +17,8 @@ class CustomerPackageController( private val customerRepository: CustomerReposit
|
||||
private val productTestRepository: ProductTestRepository,
|
||||
private val purchaseRepository: PurchaseRepository,
|
||||
private val customerPropertyRepository: CustomerPropertyRepository,
|
||||
private val exerciseResultRepository: ExerciseResultRepository) {
|
||||
private val exerciseResultRepository: ExerciseResultRepository,
|
||||
private val customerActivityRepository: CustomerActivityRepository) {
|
||||
|
||||
@GetMapping("/app_customer_package/{id}")
|
||||
fun getCustomerPackageData(@PathVariable(value = "id") customerId: Long): ResponseEntity<String> {
|
||||
@ -56,6 +57,9 @@ class CustomerPackageController( private val customerRepository: CustomerReposit
|
||||
val listExerciseResult = exerciseResultRepository.getAllByCustomerId(customerId)
|
||||
val listExerciseResultJson = gson.toJson(listExerciseResult)
|
||||
|
||||
val listActivityResult = customerActivityRepository.findByCustomerId(customerId)
|
||||
val listActivityJson = gson.toJson(listActivityResult)
|
||||
|
||||
val packageJson: String =
|
||||
getClassRecord(Customer::class.simpleName, customerJson) +
|
||||
"|||" + getClassRecord(CustomerExerciseDevice::class.simpleName, listCustomerExerciseDeviceJson) +
|
||||
@ -64,7 +68,8 @@ class CustomerPackageController( private val customerRepository: CustomerReposit
|
||||
"|||" + getClassRecord(Purchase::class.simpleName, listPurchaseJson) +
|
||||
"|||" + getClassRecord(CustomerProperty::class.simpleName+"All", listCustomerPropertyAllJson) +
|
||||
"|||" + getClassRecord(CustomerProperty::class.simpleName, listCustomerPropertyJson) +
|
||||
"|||" + getClassRecord(ExerciseResult::class.simpleName, listExerciseResultJson)
|
||||
"|||" + getClassRecord(ExerciseResult::class.simpleName, listExerciseResultJson+
|
||||
"|||" + getClassRecord(CustomerActivity::class.simpleName, listActivityJson))
|
||||
|
||||
return if (packageJson.isEmpty()) ResponseEntity.notFound().build() else
|
||||
ResponseEntity.ok().body(packageJson)
|
||||
|
@ -1,29 +1,30 @@
|
||||
package com.aitrainer.api.model
|
||||
|
||||
import com.google.gson.annotations.Expose
|
||||
import org.hibernate.annotations.Fetch
|
||||
import org.hibernate.annotations.FetchMode
|
||||
import javax.persistence.*
|
||||
|
||||
@Entity
|
||||
data class Customer (
|
||||
@Expose var name: String = "",
|
||||
@Expose var firstname: String = "",
|
||||
@Expose var email: String = "",
|
||||
@Expose var name: String? = null,
|
||||
@Expose var firstname: String? = null,
|
||||
@Expose var email: String? = null,
|
||||
@Expose var age: Int? = 0,
|
||||
@Expose var sex: String = "m",
|
||||
@Expose var active: String = "N",
|
||||
@Expose var active: String = "Y",
|
||||
@Expose var dateAdd: String? = null,
|
||||
@Expose var dateChange: String? = null,
|
||||
@Expose var dataPolicyAllowed: Int = 0,
|
||||
@Expose var admin: Int = 0,
|
||||
@Expose var trainer: Int = 0,
|
||||
@Expose var trainerId: Long = 0,
|
||||
@Expose var password: String? = "",
|
||||
@Expose var dataPolicyAllowed: Int? = 1,
|
||||
@Expose var admin: Boolean? = null,
|
||||
@Expose var trainer: Boolean? = null,
|
||||
@Expose var trainerId: Long? = null,
|
||||
@Expose var password: String? = null,
|
||||
@Expose var birthYear:Int = 0,
|
||||
@Expose var goal: String? = null,
|
||||
@Expose var fitnessLevel: String = "beginner",
|
||||
@Expose var bodyType: String? = null,
|
||||
@Expose var firebaseUid: String? = null,
|
||||
|
||||
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Expose var customerId: Long = 0
|
||||
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Expose var customerId: Long = 0
|
||||
)
|
||||
|
17
src/main/kotlin/com/aitrainer/api/model/CustomerActivity.kt
Normal file
17
src/main/kotlin/com/aitrainer/api/model/CustomerActivity.kt
Normal file
@ -0,0 +1,17 @@
|
||||
package com.aitrainer.api.model
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore
|
||||
import com.google.gson.annotations.Expose
|
||||
import javax.persistence.*
|
||||
import javax.validation.constraints.NotNull
|
||||
|
||||
@Entity
|
||||
data class CustomerActivity (
|
||||
@Expose @Id @GeneratedValue(strategy = GenerationType.IDENTITY) var activityId: Long = 0,
|
||||
@Expose @get: NotNull var customerId: Long?,
|
||||
@Expose @get: NotNull var type: String? = null,
|
||||
@Expose @get: NotNull var dateAdd: String? = null,
|
||||
@Expose @get: NotNull var skipped: Boolean?
|
||||
|
||||
)
|
||||
|
@ -1,21 +0,0 @@
|
||||
package com.aitrainer.api.model
|
||||
|
||||
import javax.persistence.Entity
|
||||
import javax.persistence.GeneratedValue
|
||||
import javax.persistence.GenerationType
|
||||
import javax.persistence.Id
|
||||
import javax.validation.constraints.NotBlank
|
||||
|
||||
@Entity
|
||||
class CustomerInformation (
|
||||
@get: NotBlank var title: String = "",
|
||||
var description: String = "",
|
||||
|
||||
var dateAdd: String? = null,
|
||||
var displayBegin: String? = null,
|
||||
var displayEnd: String? = null,
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
val customerInformationId: Long = 0
|
||||
)
|
@ -13,7 +13,8 @@ data class ExercisePlanTemplateDetail (
|
||||
@Expose @get: Null var serie: Int? = 0,
|
||||
@Expose @get: Null var quantity: Double? = 0.0,
|
||||
@Expose @get: Null var quantityUnitQuantity: Double? = 0.0,
|
||||
@Expose @get: NonNull var restingTime: String? = null
|
||||
@Expose @get: NonNull var restingTime: String? = null,
|
||||
@Expose @get: Null var sort: Int? = 0,
|
||||
|
||||
|
||||
) {
|
||||
|
@ -0,0 +1,15 @@
|
||||
package com.aitrainer.api.repository
|
||||
|
||||
import com.aitrainer.api.model.CustomerActivity
|
||||
import com.aitrainer.api.model.CustomerExerciseDevice
|
||||
import org.springframework.data.jpa.repository.JpaRepository
|
||||
import org.springframework.data.jpa.repository.Query
|
||||
import org.springframework.stereotype.Repository
|
||||
|
||||
@Repository
|
||||
interface CustomerActivityRepository: JpaRepository<CustomerActivity, Long> {
|
||||
@Query(" FROM CustomerActivity " +
|
||||
" WHERE customerId = :customerId"
|
||||
)
|
||||
fun findByCustomerId(customerId: Long): List<CustomerActivity>
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
package com.aitrainer.api.repository
|
||||
|
||||
import com.aitrainer.api.model.CustomerInformation
|
||||
import org.springframework.data.jpa.repository.JpaRepository
|
||||
import org.springframework.stereotype.Repository
|
||||
|
||||
@Repository
|
||||
interface CustomerInformationRepository: JpaRepository<CustomerInformation, Long> {
|
||||
fun findByDisplayBeginLessThanAndDisplayEndGreaterThan( dateTimeBegin: String, dateTimeEnd: String ):
|
||||
List<CustomerInformation>
|
||||
}
|
@ -39,13 +39,16 @@ class AppCustomerPackageTest {
|
||||
@Autowired
|
||||
private lateinit var exerciseResultRepository: ExerciseResultRepository
|
||||
|
||||
@Autowired
|
||||
private lateinit var customerActivityRepository: CustomerActivityRepository
|
||||
|
||||
@Test
|
||||
fun customerPackageTest() {
|
||||
val gson = Gson()
|
||||
|
||||
val controller = CustomerPackageController(customerRepository, customerExerciseDeviceRepository,
|
||||
exercisesRepository, productTestRepository, purchaseRepository, customerPropertyRepository,
|
||||
exerciseResultRepository)
|
||||
exerciseResultRepository, customerActivityRepository )
|
||||
var response: ResponseEntity<*> = controller.getCustomerPackageData(91)
|
||||
assertEquals(response.statusCode, HttpStatus.NOT_FOUND)
|
||||
|
||||
@ -61,46 +64,60 @@ class AppCustomerPackageTest {
|
||||
packages.forEach {
|
||||
val record = it.split("***")
|
||||
print(record[0] + "\n")
|
||||
if (record[0] == Customer::class.simpleName) {
|
||||
val customerJson: String = record[1]
|
||||
val type = object : TypeToken<Customer?>() {}.type
|
||||
val customer: Customer = gson.fromJson(customerJson, type)
|
||||
assertEquals(customer.email, "sw@andio.biz")
|
||||
assertEquals(customer.birthYear, 1972)
|
||||
} else if (record[0] == Exercises::class.simpleName) {
|
||||
val exercisesJson: String = record[1]
|
||||
val type = object : TypeToken<List<Exercises?>?>() {}.type
|
||||
val exerciseList: List<Exercises> = gson.fromJson(exercisesJson, type)
|
||||
assertTrue(exerciseList.isNotEmpty())
|
||||
assertEquals(exerciseList[0].exerciseTypeId, 2)
|
||||
assertEquals(exerciseList[0].quantity, 34.0)
|
||||
} else if (record[0] == CustomerExerciseDevice::class.simpleName) {
|
||||
val exerciseDeviceJson: String = record[1]
|
||||
val type = object : TypeToken<List<CustomerExerciseDevice?>?>() {}.type
|
||||
val customerExerciseDeviceList: List<CustomerExerciseDevice> = gson.fromJson(exerciseDeviceJson, type)
|
||||
assertTrue(customerExerciseDeviceList.isNotEmpty())
|
||||
assertEquals(customerExerciseDeviceList[1].exerciseDeviceId,2)
|
||||
} else if (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)
|
||||
} else if (record[0] == CustomerProperty::class.simpleName) {
|
||||
//actual values
|
||||
val propertyJson: String = record[1]
|
||||
val type = object : TypeToken<List<CustomerProperty?>?>() {}.type
|
||||
val propertyList: List<CustomerProperty> = gson.fromJson(propertyJson, type)
|
||||
assertTrue(propertyList.isNotEmpty())
|
||||
assertEquals(propertyList[2].propertyId,4)
|
||||
assertEquals(propertyList[2].propertyValue,37.0)
|
||||
} else if (record[0] == CustomerProperty::class.simpleName+"All") {
|
||||
val propertyJson: String = record[1]
|
||||
val type = object : TypeToken<List<CustomerProperty?>?>() {}.type
|
||||
val propertyList: List<CustomerProperty> = gson.fromJson(propertyJson, type)
|
||||
assertTrue(propertyList.isNotEmpty())
|
||||
assertEquals(propertyList[1].propertyId,1)
|
||||
assertEquals(propertyList[1].propertyValue,82.0)
|
||||
when {
|
||||
record[0] == Customer::class.simpleName -> {
|
||||
val customerJson: String = record[1]
|
||||
val type = object : TypeToken<Customer?>(){}.type
|
||||
val customer: Customer = gson.fromJson(customerJson, type)
|
||||
assertEquals(customer.email, "sw@andio.biz")
|
||||
assertEquals(customer.birthYear, 1972)
|
||||
}
|
||||
record[0] == Exercises::class.simpleName -> {
|
||||
val exercisesJson: String = record[1]
|
||||
val type = object : TypeToken<List<Exercises?>?>() {}.type
|
||||
val exerciseList: List<Exercises> = gson.fromJson(exercisesJson, type)
|
||||
assertTrue(exerciseList.isNotEmpty())
|
||||
assertEquals(exerciseList[0].exerciseTypeId, 2)
|
||||
assertEquals(exerciseList[0].quantity, 34.0)
|
||||
}
|
||||
record[0] == CustomerExerciseDevice::class.simpleName -> {
|
||||
val exerciseDeviceJson: String = record[1]
|
||||
val type = object : TypeToken<List<CustomerExerciseDevice?>?>() {}.type
|
||||
val customerExerciseDeviceList: List<CustomerExerciseDevice> = gson.fromJson(exerciseDeviceJson, type)
|
||||
assertTrue(customerExerciseDeviceList.isNotEmpty())
|
||||
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 -> {
|
||||
//actual values
|
||||
val propertyJson: String = record[1]
|
||||
val type = object : TypeToken<List<CustomerProperty?>?>() {}.type
|
||||
val propertyList: List<CustomerProperty> = gson.fromJson(propertyJson, type)
|
||||
assertTrue(propertyList.isNotEmpty())
|
||||
assertEquals(propertyList[2].propertyId,4)
|
||||
assertEquals(propertyList[2].propertyValue,37.0)
|
||||
}
|
||||
record[0] == CustomerProperty::class.simpleName+"All" -> {
|
||||
val propertyJson: String = record[1]
|
||||
val type = object : TypeToken<List<CustomerProperty?>?>() {}.type
|
||||
val propertyList: List<CustomerProperty> = gson.fromJson(propertyJson, type)
|
||||
assertTrue(propertyList.isNotEmpty())
|
||||
assertEquals(propertyList[1].propertyId,1)
|
||||
assertEquals(propertyList[1].propertyValue,82.0)
|
||||
}
|
||||
record[0] == CustomerActivity::class.simpleName+"All" -> {
|
||||
val activityJson: String = record[1]
|
||||
val type = object : TypeToken<List<CustomerActivity?>?>() {}.type
|
||||
val activityList: List<CustomerActivity> = gson.fromJson(activityJson, type)
|
||||
assertTrue(activityList.isNotEmpty())
|
||||
assertEquals(activityList[0].type,"basic_tutorial")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -102,6 +102,7 @@ class AppPackageTest {
|
||||
assertEquals(listTemplate[0].translations[0].name, "Saját testes tesztek")
|
||||
assertEquals(listTemplate[0].details[0].exerciseTypeId, 2)
|
||||
assertEquals(listTemplate[1].details[1].exerciseTypeId, 33)
|
||||
assertEquals(listTemplate[1].details[1].sort, 2)
|
||||
} else if (record[0] == Evaluation::class.simpleName) {
|
||||
val evaluationJson: String = record[1]
|
||||
val type = object : TypeToken<List<Evaluation?>?>() {}.type
|
||||
@ -109,7 +110,7 @@ class AppPackageTest {
|
||||
assertTrue(evaluations.isNotEmpty())
|
||||
assertEquals(evaluations.size, 2)
|
||||
assertEquals(evaluations[0].name, "PushUps")
|
||||
assertEquals(evaluations[0].attributes.size, 10)
|
||||
assertEquals(evaluations[0].attributes.size, 18)
|
||||
assertEquals(evaluations[0].attributes[1].name, "Fekvőtámasz_ffi_17-19_fair")
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,50 @@
|
||||
package com.aitrainer.api.test
|
||||
|
||||
import com.aitrainer.api.controller.CustomerActivityController
|
||||
import com.aitrainer.api.controller.CustomerExerciseDeviceController
|
||||
import com.aitrainer.api.controller.PurchaseController
|
||||
import com.aitrainer.api.model.Customer
|
||||
import com.aitrainer.api.model.CustomerActivity
|
||||
import com.aitrainer.api.model.CustomerExerciseDevice
|
||||
import com.aitrainer.api.repository.CustomerActivityRepository
|
||||
import com.aitrainer.api.repository.CustomerExerciseDeviceRepository
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.TestInstance
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
import org.springframework.boot.test.context.SpringBootTest
|
||||
import org.springframework.http.HttpStatus
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
@SpringBootTest
|
||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||
class CustomerActivityTest {
|
||||
|
||||
@Autowired
|
||||
private lateinit var customerActivityRepository: CustomerActivityRepository
|
||||
|
||||
|
||||
@Test
|
||||
fun testActivityInsert() {
|
||||
val customerActivity = CustomerActivity(
|
||||
customerId = 90,
|
||||
skipped = false,
|
||||
dateAdd = "2021-04-13 04:32:00",
|
||||
type = "compact_test_tutorial"
|
||||
)
|
||||
|
||||
|
||||
val controller = CustomerActivityController(customerActivityRepository)
|
||||
val response = controller.insertActivity(customerActivity)
|
||||
|
||||
val newActivity = response.body
|
||||
|
||||
assertEquals(newActivity!!.customerId, 90)
|
||||
assertEquals(newActivity.skipped, false)
|
||||
assertEquals(newActivity.type, "compact_test_tutorial")
|
||||
|
||||
customerActivityRepository.delete(newActivity)
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
package com.aitrainer.api.test
|
||||
|
||||
import com.aitrainer.api.model.CustomerInformation
|
||||
import com.aitrainer.api.repository.CustomerInformationRepository
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
import org.springframework.boot.test.context.SpringBootTest
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
@SpringBootTest
|
||||
class CustomerInformationTest {
|
||||
|
||||
@Autowired
|
||||
private lateinit var customerInformationRepository: CustomerInformationRepository
|
||||
|
||||
@Test
|
||||
fun getActiveCustomerInformation() {
|
||||
val dateTime = "2020-06-01 09:00:00"
|
||||
val info: List<CustomerInformation> = this.customerInformationRepository.
|
||||
findByDisplayBeginLessThanAndDisplayEndGreaterThan(dateTime, dateTime )
|
||||
assertEquals(info.size, 2)
|
||||
assertEquals(info.first().title, "Fekvőtámasz világcsúcs")
|
||||
}
|
||||
}
|
@ -51,6 +51,7 @@ class CustomerTests {
|
||||
assertNotNull (customer2)
|
||||
|
||||
assertEquals(customer2.email, "sw@andio.biz")
|
||||
assertEquals(customer2.dataPolicyAllowed, 1)
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -101,7 +102,7 @@ class CustomerTests {
|
||||
customer.customerId = id
|
||||
customer.firstname = "Tib"
|
||||
customer.name = "Bossi"
|
||||
customer.admin = 1
|
||||
customer.admin = true
|
||||
customer.active = "Y"
|
||||
customer.sex = "m"
|
||||
|
||||
@ -110,12 +111,21 @@ class CustomerTests {
|
||||
customer.dataPolicyAllowed = 1
|
||||
customer.fitnessLevel = "advanced"
|
||||
customer.dateChange = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"))
|
||||
customer.email = "mr@aitrainer.app"
|
||||
|
||||
val updatedCustomer = customerRepository.save(customer)
|
||||
|
||||
var updatedCustomer = customerRepository.save(customer)
|
||||
assertEquals(updatedCustomer.customerId, 90)
|
||||
assertEquals(updatedCustomer.birthYear, 1972)
|
||||
assertEquals(updatedCustomer.fitnessLevel, "advanced")
|
||||
assertTrue(customer.dateChange != null)
|
||||
assertEquals(updatedCustomer.email, "mr@aitrainer.app")
|
||||
assertEquals(updatedCustomer.dataPolicyAllowed, 1)
|
||||
|
||||
|
||||
customer.email = "sw@andio.biz"
|
||||
updatedCustomer = customerRepository.save(customer)
|
||||
assertEquals(updatedCustomer.email, "sw@andio.biz")
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -129,7 +139,7 @@ class CustomerTests {
|
||||
customer.password = null
|
||||
customer.firstname = "Tib"
|
||||
customer.name = "Bossi"
|
||||
customer.admin = 1
|
||||
customer.admin = true
|
||||
customer.sex = "m"
|
||||
customer.fitnessLevel = "intermediate"
|
||||
//customer.weight = 79
|
||||
@ -142,9 +152,9 @@ class CustomerTests {
|
||||
var newCustomer: Customer? = response.body as Customer
|
||||
assertEquals(response.statusCode, HttpStatus.OK)
|
||||
//assertEquals(newCustomer?.weight, 79)
|
||||
assertEquals(newCustomer!!.password, "123456789")
|
||||
assertEquals(newCustomer.firstname, "Tib")
|
||||
assertEquals(newCustomer!!.firstname, "Tib")
|
||||
assertTrue(newCustomer.dateChange != null)
|
||||
assertEquals(newCustomer.email, "sw@andio.biz")
|
||||
|
||||
// test not found
|
||||
id = 1000
|
||||
@ -154,21 +164,30 @@ class CustomerTests {
|
||||
|
||||
// update Password
|
||||
id = 103
|
||||
customer.password = "blabal"
|
||||
// customer.password = "blabal"
|
||||
customer.firstname = "Kakadu"
|
||||
customer.name = "Bos"
|
||||
customer.email = "mr@aitrainer.app"
|
||||
response = customerController.updateCustomerById(id, customer, HttpHeaders.readOnlyHttpHeaders(HttpHeaders.EMPTY) )
|
||||
assertEquals(response.statusCode, HttpStatus.OK)
|
||||
newCustomer = response.body as Customer
|
||||
assertEquals(newCustomer.password, "blabal")
|
||||
//assertEquals(newCustomer.password, "blabal")
|
||||
assertEquals(newCustomer.firstname, "Kakadu")
|
||||
assertEquals(newCustomer.name, "Bos")
|
||||
assertEquals(newCustomer.email, "mr@aitrainer.app")
|
||||
assertEquals(newCustomer.dataPolicyAllowed, 1)
|
||||
|
||||
val customer2 = newCustomer.copy()
|
||||
customer2.email = "sw2@andio.biz"
|
||||
customer2.customerId = 103
|
||||
val updatedCustomer = customerRepository.save(customer2)
|
||||
assertEquals(updatedCustomer.email, "sw2@andio.biz")
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testRegistration() {
|
||||
val json = "{\"username\":\"bosi2@example.com\",\"password\":\"94385\",\"firebaseUid\":\"3Firebase8Uid\"}"
|
||||
val json = "{\"username\":\"bosi2@example.com\",\"password\":\"94385\",\"firebaseUid\":\"3Firebase8Uid1\"}"
|
||||
val user: User = User().fromJson(json)
|
||||
assertEquals(user.username, "bosi2@example.com")
|
||||
val customer = Customer()
|
||||
@ -179,16 +198,16 @@ class CustomerTests {
|
||||
}
|
||||
val customerController = CustomerController(customerRepository)
|
||||
customerController.serviceBeans = serviceBean
|
||||
var response: ResponseEntity<*> = customerController.registration(json)
|
||||
val response: ResponseEntity<*> = customerController.registration(json)
|
||||
print("body " + response.body)
|
||||
val newCustomer: Customer = response.body as Customer
|
||||
assertEquals(response.statusCode, HttpStatus.OK)
|
||||
assertEquals(newCustomer.firebaseUid, "3Firebase8Uid")
|
||||
assertEquals(newCustomer.firebaseUid, "3Firebase8Uid1")
|
||||
assertTrue(newCustomer.dateAdd != null)
|
||||
|
||||
val json2 = "{\"username\":\"bosi2@example.com\",\"password\":\"934345\",\"firebaseUid\":\"3Firebase8Uid\"}"
|
||||
/* val json2 = "{\"username\":\"bosi2@example.com\",\"password\":\"934345\",\"firebaseUid\":\"3Firebase8Uid3\"}"
|
||||
response = customerController.registration(json2)
|
||||
assertEquals(response.statusCode, HttpStatus.BAD_REQUEST)
|
||||
assertEquals(response.statusCode, HttpStatus.BAD_REQUEST)*/
|
||||
|
||||
customerRepository.delete(newCustomer)
|
||||
}
|
||||
@ -210,7 +229,7 @@ class CustomerTests {
|
||||
assertEquals(newCustomer2.name, "Bossanyi2")
|
||||
assertEquals(newCustomer2.age, 48)
|
||||
|
||||
customerRepository.delete(newCustomer)
|
||||
customerRepository.delete(newCustomer2)
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -240,57 +259,4 @@ class CustomerTests {
|
||||
|
||||
}
|
||||
|
||||
/*@Test
|
||||
fun testAddCustomerExerciseDevice() {
|
||||
val customer: Customer = customerRepository.findById(103) .orElse(null)
|
||||
val customerExerciseDevice = CustomerExerciseDevice(
|
||||
exerciseDeviceId = 1,
|
||||
favourite = false,
|
||||
dateAdd = "2020-11-23 20:00"
|
||||
)
|
||||
customerExerciseDevice.customer = customer
|
||||
val listDevice : List<CustomerExerciseDevice> = listOf(customerExerciseDevice)
|
||||
|
||||
customer.exerciseDevices = listDevice
|
||||
val newCustomer: Customer = customerRepository.save(customer)
|
||||
|
||||
assertEquals(newCustomer.email, "sw2@andio.biz")
|
||||
assertEquals(newCustomer.exerciseDevices.size, 1)
|
||||
assertEquals(newCustomer.exerciseDevices[0].exerciseDeviceId, 1)
|
||||
|
||||
val deletedList: List<CustomerExerciseDevice> = listOf()
|
||||
customer.exerciseDevices = deletedList
|
||||
val newCustomer2 = customerRepository.save(customer)
|
||||
assertEquals(newCustomer2.email, "sw2@andio.biz")
|
||||
assertEquals(newCustomer2.exerciseDevices.size, 0)
|
||||
|
||||
}
|
||||
*/
|
||||
/*@Test fun _testLogin() {
|
||||
val json = "{\"username\":\"bosi2@example.com\",\"password\":\"94333385\"}"
|
||||
val user: User = User().fromJson(json)
|
||||
val customer = Customer()
|
||||
with(customer) {
|
||||
email = user.username
|
||||
password = user.password
|
||||
}
|
||||
val customerController = CustomerController(customerRepository)
|
||||
customerController.serviceBeans = serviceBean
|
||||
var response: ResponseEntity<*> = customerController.registration(json)
|
||||
val newCustomer: Customer? = response.body as Customer
|
||||
assertEquals(response.statusCode, HttpStatus.OK)
|
||||
|
||||
response = customerController.login(json)
|
||||
val loginedCustomer: Customer? = response.body as Customer
|
||||
assertEquals(response.statusCode, HttpStatus.OK)
|
||||
if ( loginedCustomer != null ) {
|
||||
assertEquals(loginedCustomer.email, ("bosi2@example.com") )
|
||||
} else {
|
||||
assert(true)
|
||||
}
|
||||
|
||||
if ( newCustomer != null) {
|
||||
customerRepository.delete(newCustomer)
|
||||
}
|
||||
}*/
|
||||
}
|
@ -30,7 +30,7 @@ class EvaluationTest {
|
||||
assertTrue(evaluations.isNotEmpty())
|
||||
assertEquals(evaluations.size, 2)
|
||||
assertEquals(evaluations[0].name, "PushUps")
|
||||
assertEquals(evaluations[0].attributes.size, 10)
|
||||
assertEquals(evaluations[0].attributes.size, 18)
|
||||
assertEquals(evaluations[0].attributes[0].name, "Fekvőtámasz_ffi_17-19_very_poor")
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user