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"
|
group = "com.aitrainer"
|
||||||
version = "1.0.29"
|
version = "1.0.30"
|
||||||
java.sourceCompatibility = JavaVersion.VERSION_1_8
|
java.sourceCompatibility = JavaVersion.VERSION_1_8
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
@ -27,7 +27,6 @@ dependencies {
|
|||||||
implementation("org.springframework.security.oauth.boot:spring-security-oauth2-autoconfigure:2.4.4")
|
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("org.springframework.security.oauth:spring-security-oauth2:2.5.0.RELEASE")
|
||||||
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
|
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
|
||||||
implementation("org.jetbrains.kotlin:kotlin-reflect")
|
|
||||||
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
|
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
|
||||||
implementation("org.apache.logging.log4j:log4j-core:2.14.0")
|
implementation("org.apache.logging.log4j:log4j-core:2.14.0")
|
||||||
implementation("org.apache.logging.log4j:log4j-api: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("org.yaml:snakeyaml:1.27")
|
||||||
implementation("com.google.code.gson:gson:2.8.6")
|
implementation("com.google.code.gson:gson:2.8.6")
|
||||||
implementation("org.projectlombok:lombok:1.18.16")
|
implementation("org.projectlombok:lombok:1.18.16")
|
||||||
|
implementation("org.jetbrains.kotlin:kotlin-reflect:1.4.32")
|
||||||
|
|
||||||
runtimeOnly("mysql:mysql-connector-java")
|
runtimeOnly("mysql:mysql-connector-java")
|
||||||
testImplementation("org.springframework.boot:spring-boot-starter-test") {
|
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',
|
`quantity_unit_quantity` DOUBLE NULL DEFAULT '0',
|
||||||
`serie` INT(11) NULL DEFAULT '0',
|
`serie` INT(11) NULL DEFAULT '0',
|
||||||
`resting_time` TIME NULL DEFAULT '00:00:00',
|
`resting_time` TIME NULL DEFAULT '00:00:00',
|
||||||
|
`sort` TINYINT(2) NULL DEFAULT NULL,
|
||||||
PRIMARY KEY (`exercise_plan_template_detail_id`) USING BTREE,
|
PRIMARY KEY (`exercise_plan_template_detail_id`) USING BTREE,
|
||||||
INDEX `exercise_type_id` (`exercise_type_id`) USING BTREE,
|
INDEX `exercise_type_id` (`exercise_type_id`) USING BTREE,
|
||||||
INDEX `exercise_plan_template_id` (`exercise_plan_template_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 (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);
|
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, '') */;
|
/*!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)
|
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.*(..))")
|
@Before("execution(* com.aitrainer.api.controller.CustomerPropertyController.*(..))")
|
||||||
fun customerPropertyControllerAspect(joinPoint: JoinPoint) {
|
fun customerPropertyControllerAspect(joinPoint: JoinPoint) {
|
||||||
println("customer property controller")
|
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)
|
val returnCustomer: Customer = customerRepository.findById(customerId).orElse(null)
|
||||||
?: return ResponseEntity.notFound().build()
|
?: return ResponseEntity.notFound().build()
|
||||||
|
|
||||||
val password: String? = newCustomer.password
|
val updatedCustomer = returnCustomer.copy()
|
||||||
val updatedCustomer: Customer
|
if (newCustomer.email != null) {
|
||||||
if ( password == null || password.isEmpty() ) {
|
updatedCustomer.email = newCustomer.email
|
||||||
updatedCustomer =
|
}
|
||||||
returnCustomer.copy(
|
if (newCustomer.name != null) {
|
||||||
name = newCustomer.name,
|
updatedCustomer.name = newCustomer.name
|
||||||
firstname = newCustomer.firstname,
|
}
|
||||||
sex = newCustomer.sex,
|
if (newCustomer.firstname != null) {
|
||||||
birthYear = newCustomer.birthYear,
|
updatedCustomer.firstname = newCustomer.firstname
|
||||||
fitnessLevel = newCustomer.fitnessLevel,
|
}
|
||||||
bodyType = newCustomer.bodyType,
|
if (newCustomer.goal != null) {
|
||||||
goal = newCustomer.goal,
|
updatedCustomer.goal = newCustomer.goal
|
||||||
dateChange = newCustomer.dateChange
|
}
|
||||||
)
|
if (newCustomer.dateChange != null) {
|
||||||
} else {
|
updatedCustomer.dateChange = newCustomer.dateChange
|
||||||
updatedCustomer =
|
}
|
||||||
returnCustomer.copy(
|
if (newCustomer.dataPolicyAllowed != null) {
|
||||||
name = newCustomer.name,
|
updatedCustomer.dataPolicyAllowed = newCustomer.dataPolicyAllowed
|
||||||
firstname = newCustomer.firstname,
|
}
|
||||||
password = newCustomer.password,
|
updatedCustomer.sex = newCustomer.sex
|
||||||
sex = newCustomer.sex,
|
updatedCustomer.birthYear = newCustomer.birthYear
|
||||||
birthYear = newCustomer.birthYear,
|
updatedCustomer.fitnessLevel = newCustomer.fitnessLevel
|
||||||
fitnessLevel = newCustomer.fitnessLevel,
|
|
||||||
bodyType = newCustomer.bodyType,
|
|
||||||
goal = newCustomer.goal,
|
|
||||||
dateChange = newCustomer.dateChange
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
return ResponseEntity.ok().body(customerRepository.save(updatedCustomer))
|
return ResponseEntity.ok().body(customerRepository.save(updatedCustomer))
|
||||||
}
|
}
|
||||||
@ -139,6 +136,9 @@ class CustomerController ( private val customerRepository: CustomerRepository) {
|
|||||||
password = serviceBeans!!.passwordEncoder().encode(newUser.password)
|
password = serviceBeans!!.passwordEncoder().encode(newUser.password)
|
||||||
firebaseUid = newUser.firebaseUid
|
firebaseUid = newUser.firebaseUid
|
||||||
dateAdd = nowFormatted
|
dateAdd = nowFormatted
|
||||||
|
firstname = ""
|
||||||
|
name = ""
|
||||||
|
email = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
val returnCustomer: Customer? = customerRepository.findByEmail(newUser.username).let {
|
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 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,
|
||||||
|
private val customerActivityRepository: CustomerActivityRepository) {
|
||||||
|
|
||||||
@GetMapping("/app_customer_package/{id}")
|
@GetMapping("/app_customer_package/{id}")
|
||||||
fun getCustomerPackageData(@PathVariable(value = "id") customerId: Long): ResponseEntity<String> {
|
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 listExerciseResult = exerciseResultRepository.getAllByCustomerId(customerId)
|
||||||
val listExerciseResultJson = gson.toJson(listExerciseResult)
|
val listExerciseResultJson = gson.toJson(listExerciseResult)
|
||||||
|
|
||||||
|
val listActivityResult = customerActivityRepository.findByCustomerId(customerId)
|
||||||
|
val listActivityJson = gson.toJson(listActivityResult)
|
||||||
|
|
||||||
val packageJson: String =
|
val packageJson: String =
|
||||||
getClassRecord(Customer::class.simpleName, customerJson) +
|
getClassRecord(Customer::class.simpleName, customerJson) +
|
||||||
"|||" + getClassRecord(CustomerExerciseDevice::class.simpleName, listCustomerExerciseDeviceJson) +
|
"|||" + getClassRecord(CustomerExerciseDevice::class.simpleName, listCustomerExerciseDeviceJson) +
|
||||||
@ -64,7 +68,8 @@ class CustomerPackageController( private val customerRepository: CustomerReposit
|
|||||||
"|||" + 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) +
|
||||||
"|||" + getClassRecord(ExerciseResult::class.simpleName, listExerciseResultJson)
|
"|||" + getClassRecord(ExerciseResult::class.simpleName, listExerciseResultJson+
|
||||||
|
"|||" + getClassRecord(CustomerActivity::class.simpleName, listActivityJson))
|
||||||
|
|
||||||
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,29 +1,30 @@
|
|||||||
package com.aitrainer.api.model
|
package com.aitrainer.api.model
|
||||||
|
|
||||||
import com.google.gson.annotations.Expose
|
import com.google.gson.annotations.Expose
|
||||||
|
import org.hibernate.annotations.Fetch
|
||||||
|
import org.hibernate.annotations.FetchMode
|
||||||
import javax.persistence.*
|
import javax.persistence.*
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
data class Customer (
|
data class Customer (
|
||||||
@Expose var name: String = "",
|
@Expose var name: String? = null,
|
||||||
@Expose var firstname: String = "",
|
@Expose var firstname: String? = null,
|
||||||
@Expose var email: String = "",
|
@Expose var email: String? = null,
|
||||||
@Expose var age: Int? = 0,
|
@Expose var age: Int? = 0,
|
||||||
@Expose var sex: String = "m",
|
@Expose var sex: String = "m",
|
||||||
@Expose var active: String = "N",
|
@Expose var active: String = "Y",
|
||||||
@Expose var dateAdd: String? = null,
|
@Expose var dateAdd: String? = null,
|
||||||
@Expose var dateChange: String? = null,
|
@Expose var dateChange: String? = null,
|
||||||
@Expose var dataPolicyAllowed: Int = 0,
|
@Expose var dataPolicyAllowed: Int? = 1,
|
||||||
@Expose var admin: Int = 0,
|
@Expose var admin: Boolean? = null,
|
||||||
@Expose var trainer: Int = 0,
|
@Expose var trainer: Boolean? = null,
|
||||||
@Expose var trainerId: Long = 0,
|
@Expose var trainerId: Long? = null,
|
||||||
@Expose var password: String? = "",
|
@Expose var password: String? = null,
|
||||||
@Expose var birthYear:Int = 0,
|
@Expose var birthYear:Int = 0,
|
||||||
@Expose var goal: String? = null,
|
@Expose var goal: String? = null,
|
||||||
@Expose var fitnessLevel: String = "beginner",
|
@Expose var fitnessLevel: String = "beginner",
|
||||||
@Expose var bodyType: String? = null,
|
@Expose var bodyType: String? = null,
|
||||||
@Expose var firebaseUid: String? = null,
|
@Expose var firebaseUid: String? = null,
|
||||||
|
|
||||||
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
|
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Expose var customerId: Long = 0
|
||||||
@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 serie: Int? = 0,
|
||||||
@Expose @get: Null var quantity: Double? = 0.0,
|
@Expose @get: Null var quantity: Double? = 0.0,
|
||||||
@Expose @get: Null var quantityUnitQuantity: 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
|
@Autowired
|
||||||
private lateinit var exerciseResultRepository: ExerciseResultRepository
|
private lateinit var exerciseResultRepository: ExerciseResultRepository
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private lateinit var customerActivityRepository: CustomerActivityRepository
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun customerPackageTest() {
|
fun customerPackageTest() {
|
||||||
val gson = Gson()
|
val gson = Gson()
|
||||||
|
|
||||||
val controller = CustomerPackageController(customerRepository, customerExerciseDeviceRepository,
|
val controller = CustomerPackageController(customerRepository, customerExerciseDeviceRepository,
|
||||||
exercisesRepository, productTestRepository, purchaseRepository, customerPropertyRepository,
|
exercisesRepository, productTestRepository, purchaseRepository, customerPropertyRepository,
|
||||||
exerciseResultRepository)
|
exerciseResultRepository, customerActivityRepository )
|
||||||
var response: ResponseEntity<*> = controller.getCustomerPackageData(91)
|
var response: ResponseEntity<*> = controller.getCustomerPackageData(91)
|
||||||
assertEquals(response.statusCode, HttpStatus.NOT_FOUND)
|
assertEquals(response.statusCode, HttpStatus.NOT_FOUND)
|
||||||
|
|
||||||
@ -61,46 +64,60 @@ class AppCustomerPackageTest {
|
|||||||
packages.forEach {
|
packages.forEach {
|
||||||
val record = it.split("***")
|
val record = it.split("***")
|
||||||
print(record[0] + "\n")
|
print(record[0] + "\n")
|
||||||
if (record[0] == Customer::class.simpleName) {
|
when {
|
||||||
val customerJson: String = record[1]
|
record[0] == Customer::class.simpleName -> {
|
||||||
val type = object : TypeToken<Customer?>() {}.type
|
val customerJson: String = record[1]
|
||||||
val customer: Customer = gson.fromJson(customerJson, type)
|
val type = object : TypeToken<Customer?>(){}.type
|
||||||
assertEquals(customer.email, "sw@andio.biz")
|
val customer: Customer = gson.fromJson(customerJson, type)
|
||||||
assertEquals(customer.birthYear, 1972)
|
assertEquals(customer.email, "sw@andio.biz")
|
||||||
} else if (record[0] == Exercises::class.simpleName) {
|
assertEquals(customer.birthYear, 1972)
|
||||||
val exercisesJson: String = record[1]
|
}
|
||||||
val type = object : TypeToken<List<Exercises?>?>() {}.type
|
record[0] == Exercises::class.simpleName -> {
|
||||||
val exerciseList: List<Exercises> = gson.fromJson(exercisesJson, type)
|
val exercisesJson: String = record[1]
|
||||||
assertTrue(exerciseList.isNotEmpty())
|
val type = object : TypeToken<List<Exercises?>?>() {}.type
|
||||||
assertEquals(exerciseList[0].exerciseTypeId, 2)
|
val exerciseList: List<Exercises> = gson.fromJson(exercisesJson, type)
|
||||||
assertEquals(exerciseList[0].quantity, 34.0)
|
assertTrue(exerciseList.isNotEmpty())
|
||||||
} else if (record[0] == CustomerExerciseDevice::class.simpleName) {
|
assertEquals(exerciseList[0].exerciseTypeId, 2)
|
||||||
val exerciseDeviceJson: String = record[1]
|
assertEquals(exerciseList[0].quantity, 34.0)
|
||||||
val type = object : TypeToken<List<CustomerExerciseDevice?>?>() {}.type
|
}
|
||||||
val customerExerciseDeviceList: List<CustomerExerciseDevice> = gson.fromJson(exerciseDeviceJson, type)
|
record[0] == CustomerExerciseDevice::class.simpleName -> {
|
||||||
assertTrue(customerExerciseDeviceList.isNotEmpty())
|
val exerciseDeviceJson: String = record[1]
|
||||||
assertEquals(customerExerciseDeviceList[1].exerciseDeviceId,2)
|
val type = object : TypeToken<List<CustomerExerciseDevice?>?>() {}.type
|
||||||
} else if (record[0] == ProductTest::class.simpleName) {
|
val customerExerciseDeviceList: List<CustomerExerciseDevice> = gson.fromJson(exerciseDeviceJson, type)
|
||||||
val productTestJson: String = record[1]
|
assertTrue(customerExerciseDeviceList.isNotEmpty())
|
||||||
val type = object : TypeToken<List<ProductTest?>?>() {}.type
|
assertEquals(customerExerciseDeviceList[1].exerciseDeviceId,2)
|
||||||
val productTestList: List<ProductTest> = gson.fromJson(productTestJson, type)
|
}
|
||||||
assertTrue(productTestList.isNotEmpty())
|
record[0] == ProductTest::class.simpleName -> {
|
||||||
assertEquals(productTestList[0].productId,1)
|
val productTestJson: String = record[1]
|
||||||
} else if (record[0] == CustomerProperty::class.simpleName) {
|
val type = object : TypeToken<List<ProductTest?>?>() {}.type
|
||||||
//actual values
|
val productTestList: List<ProductTest> = gson.fromJson(productTestJson, type)
|
||||||
val propertyJson: String = record[1]
|
assertTrue(productTestList.isNotEmpty())
|
||||||
val type = object : TypeToken<List<CustomerProperty?>?>() {}.type
|
assertEquals(productTestList[0].productId,1)
|
||||||
val propertyList: List<CustomerProperty> = gson.fromJson(propertyJson, type)
|
}
|
||||||
assertTrue(propertyList.isNotEmpty())
|
record[0] == CustomerProperty::class.simpleName -> {
|
||||||
assertEquals(propertyList[2].propertyId,4)
|
//actual values
|
||||||
assertEquals(propertyList[2].propertyValue,37.0)
|
val propertyJson: String = record[1]
|
||||||
} else if (record[0] == CustomerProperty::class.simpleName+"All") {
|
val type = object : TypeToken<List<CustomerProperty?>?>() {}.type
|
||||||
val propertyJson: String = record[1]
|
val propertyList: List<CustomerProperty> = gson.fromJson(propertyJson, type)
|
||||||
val type = object : TypeToken<List<CustomerProperty?>?>() {}.type
|
assertTrue(propertyList.isNotEmpty())
|
||||||
val propertyList: List<CustomerProperty> = gson.fromJson(propertyJson, type)
|
assertEquals(propertyList[2].propertyId,4)
|
||||||
assertTrue(propertyList.isNotEmpty())
|
assertEquals(propertyList[2].propertyValue,37.0)
|
||||||
assertEquals(propertyList[1].propertyId,1)
|
}
|
||||||
assertEquals(propertyList[1].propertyValue,82.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].translations[0].name, "Saját testes tesztek")
|
||||||
assertEquals(listTemplate[0].details[0].exerciseTypeId, 2)
|
assertEquals(listTemplate[0].details[0].exerciseTypeId, 2)
|
||||||
assertEquals(listTemplate[1].details[1].exerciseTypeId, 33)
|
assertEquals(listTemplate[1].details[1].exerciseTypeId, 33)
|
||||||
|
assertEquals(listTemplate[1].details[1].sort, 2)
|
||||||
} else if (record[0] == Evaluation::class.simpleName) {
|
} else if (record[0] == Evaluation::class.simpleName) {
|
||||||
val evaluationJson: String = record[1]
|
val evaluationJson: String = record[1]
|
||||||
val type = object : TypeToken<List<Evaluation?>?>() {}.type
|
val type = object : TypeToken<List<Evaluation?>?>() {}.type
|
||||||
@ -109,7 +110,7 @@ class AppPackageTest {
|
|||||||
assertTrue(evaluations.isNotEmpty())
|
assertTrue(evaluations.isNotEmpty())
|
||||||
assertEquals(evaluations.size, 2)
|
assertEquals(evaluations.size, 2)
|
||||||
assertEquals(evaluations[0].name, "PushUps")
|
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")
|
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)
|
assertNotNull (customer2)
|
||||||
|
|
||||||
assertEquals(customer2.email, "sw@andio.biz")
|
assertEquals(customer2.email, "sw@andio.biz")
|
||||||
|
assertEquals(customer2.dataPolicyAllowed, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -101,7 +102,7 @@ class CustomerTests {
|
|||||||
customer.customerId = id
|
customer.customerId = id
|
||||||
customer.firstname = "Tib"
|
customer.firstname = "Tib"
|
||||||
customer.name = "Bossi"
|
customer.name = "Bossi"
|
||||||
customer.admin = 1
|
customer.admin = true
|
||||||
customer.active = "Y"
|
customer.active = "Y"
|
||||||
customer.sex = "m"
|
customer.sex = "m"
|
||||||
|
|
||||||
@ -110,12 +111,21 @@ class CustomerTests {
|
|||||||
customer.dataPolicyAllowed = 1
|
customer.dataPolicyAllowed = 1
|
||||||
customer.fitnessLevel = "advanced"
|
customer.fitnessLevel = "advanced"
|
||||||
customer.dateChange = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"))
|
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.customerId, 90)
|
||||||
assertEquals(updatedCustomer.birthYear, 1972)
|
assertEquals(updatedCustomer.birthYear, 1972)
|
||||||
assertEquals(updatedCustomer.fitnessLevel, "advanced")
|
assertEquals(updatedCustomer.fitnessLevel, "advanced")
|
||||||
assertTrue(customer.dateChange != null)
|
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
|
@Test
|
||||||
@ -129,7 +139,7 @@ class CustomerTests {
|
|||||||
customer.password = null
|
customer.password = null
|
||||||
customer.firstname = "Tib"
|
customer.firstname = "Tib"
|
||||||
customer.name = "Bossi"
|
customer.name = "Bossi"
|
||||||
customer.admin = 1
|
customer.admin = true
|
||||||
customer.sex = "m"
|
customer.sex = "m"
|
||||||
customer.fitnessLevel = "intermediate"
|
customer.fitnessLevel = "intermediate"
|
||||||
//customer.weight = 79
|
//customer.weight = 79
|
||||||
@ -142,9 +152,9 @@ class CustomerTests {
|
|||||||
var newCustomer: Customer? = response.body as Customer
|
var newCustomer: Customer? = response.body as Customer
|
||||||
assertEquals(response.statusCode, HttpStatus.OK)
|
assertEquals(response.statusCode, HttpStatus.OK)
|
||||||
//assertEquals(newCustomer?.weight, 79)
|
//assertEquals(newCustomer?.weight, 79)
|
||||||
assertEquals(newCustomer!!.password, "123456789")
|
assertEquals(newCustomer!!.firstname, "Tib")
|
||||||
assertEquals(newCustomer.firstname, "Tib")
|
|
||||||
assertTrue(newCustomer.dateChange != null)
|
assertTrue(newCustomer.dateChange != null)
|
||||||
|
assertEquals(newCustomer.email, "sw@andio.biz")
|
||||||
|
|
||||||
// test not found
|
// test not found
|
||||||
id = 1000
|
id = 1000
|
||||||
@ -154,21 +164,30 @@ class CustomerTests {
|
|||||||
|
|
||||||
// update Password
|
// update Password
|
||||||
id = 103
|
id = 103
|
||||||
customer.password = "blabal"
|
// customer.password = "blabal"
|
||||||
customer.firstname = "Kakadu"
|
customer.firstname = "Kakadu"
|
||||||
customer.name = "Bos"
|
customer.name = "Bos"
|
||||||
|
customer.email = "mr@aitrainer.app"
|
||||||
response = customerController.updateCustomerById(id, customer, HttpHeaders.readOnlyHttpHeaders(HttpHeaders.EMPTY) )
|
response = customerController.updateCustomerById(id, customer, HttpHeaders.readOnlyHttpHeaders(HttpHeaders.EMPTY) )
|
||||||
assertEquals(response.statusCode, HttpStatus.OK)
|
assertEquals(response.statusCode, HttpStatus.OK)
|
||||||
newCustomer = response.body as Customer
|
newCustomer = response.body as Customer
|
||||||
assertEquals(newCustomer.password, "blabal")
|
//assertEquals(newCustomer.password, "blabal")
|
||||||
assertEquals(newCustomer.firstname, "Kakadu")
|
assertEquals(newCustomer.firstname, "Kakadu")
|
||||||
assertEquals(newCustomer.name, "Bos")
|
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
|
@Test
|
||||||
fun testRegistration() {
|
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)
|
val user: User = User().fromJson(json)
|
||||||
assertEquals(user.username, "bosi2@example.com")
|
assertEquals(user.username, "bosi2@example.com")
|
||||||
val customer = Customer()
|
val customer = Customer()
|
||||||
@ -179,16 +198,16 @@ class CustomerTests {
|
|||||||
}
|
}
|
||||||
val customerController = CustomerController(customerRepository)
|
val customerController = CustomerController(customerRepository)
|
||||||
customerController.serviceBeans = serviceBean
|
customerController.serviceBeans = serviceBean
|
||||||
var response: ResponseEntity<*> = customerController.registration(json)
|
val response: ResponseEntity<*> = customerController.registration(json)
|
||||||
print("body " + response.body)
|
print("body " + response.body)
|
||||||
val newCustomer: Customer = response.body as Customer
|
val newCustomer: Customer = response.body as Customer
|
||||||
assertEquals(response.statusCode, HttpStatus.OK)
|
assertEquals(response.statusCode, HttpStatus.OK)
|
||||||
assertEquals(newCustomer.firebaseUid, "3Firebase8Uid")
|
assertEquals(newCustomer.firebaseUid, "3Firebase8Uid1")
|
||||||
assertTrue(newCustomer.dateAdd != null)
|
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)
|
response = customerController.registration(json2)
|
||||||
assertEquals(response.statusCode, HttpStatus.BAD_REQUEST)
|
assertEquals(response.statusCode, HttpStatus.BAD_REQUEST)*/
|
||||||
|
|
||||||
customerRepository.delete(newCustomer)
|
customerRepository.delete(newCustomer)
|
||||||
}
|
}
|
||||||
@ -210,7 +229,7 @@ class CustomerTests {
|
|||||||
assertEquals(newCustomer2.name, "Bossanyi2")
|
assertEquals(newCustomer2.name, "Bossanyi2")
|
||||||
assertEquals(newCustomer2.age, 48)
|
assertEquals(newCustomer2.age, 48)
|
||||||
|
|
||||||
customerRepository.delete(newCustomer)
|
customerRepository.delete(newCustomer2)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@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())
|
assertTrue(evaluations.isNotEmpty())
|
||||||
assertEquals(evaluations.size, 2)
|
assertEquals(evaluations.size, 2)
|
||||||
assertEquals(evaluations[0].name, "PushUps")
|
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")
|
assertEquals(evaluations[0].attributes[0].name, "Fekvőtámasz_ffi_17-19_very_poor")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user