API 1.0.29 Evaluation
This commit is contained in:
parent
4d9f2307aa
commit
b1dc434e96
@ -2,16 +2,16 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
|
||||
|
||||
plugins {
|
||||
id("org.springframework.boot") version "2.4.2"
|
||||
id("io.spring.dependency-management") version "1.0.10.RELEASE"
|
||||
kotlin("jvm") version "1.4.21"
|
||||
kotlin("plugin.spring") version "1.4.30-RC"
|
||||
kotlin("plugin.jpa") version "1.4.30-RC"
|
||||
kotlin("plugin.serialization") version "1.4.30-RC"
|
||||
id("org.springframework.boot") version "2.4.4"
|
||||
id("io.spring.dependency-management") version "1.0.11.RELEASE"
|
||||
kotlin("jvm") version "1.4.32"
|
||||
kotlin("plugin.spring") version "1.5.0-M2"
|
||||
kotlin("plugin.jpa") version "1.5.0-M2"
|
||||
kotlin("plugin.serialization") version "1.5.0-M2"
|
||||
}
|
||||
|
||||
group = "com.aitrainer"
|
||||
version = "1.0.28"
|
||||
version = "1.0.29"
|
||||
java.sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
|
||||
repositories {
|
||||
@ -24,7 +24,7 @@ dependencies {
|
||||
implementation("org.springframework.boot:spring-boot-starter-aop")
|
||||
implementation("org.springframework.boot:spring-boot-starter-validation")
|
||||
implementation("org.springframework.boot:spring-boot-starter-security")
|
||||
implementation("org.springframework.security.oauth.boot:spring-security-oauth2-autoconfigure:2.4.2")
|
||||
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")
|
||||
@ -43,7 +43,7 @@ dependencies {
|
||||
exclude(group = "org.junit.vintage", module = "junit-vintage-engine")
|
||||
}
|
||||
testImplementation("junit:junit:4.13.1")
|
||||
testImplementation("org.jetbrains.kotlin:kotlin-test-junit5:1.4.30-RC")
|
||||
testImplementation("org.jetbrains.kotlin:kotlin-test-junit5:1.5.0-M2")
|
||||
|
||||
}
|
||||
|
||||
|
@ -529,7 +529,7 @@ CREATE TABLE IF NOT EXISTS `exercise_plan` (
|
||||
`private` tinyint(4) DEFAULT 0,
|
||||
`date_add` datetime DEFAULT NULL,
|
||||
`date_upd` datetime DEFAULT NULL,
|
||||
`type` ENUM('custom','mini_test_set','special') NULL DEFAULT NULL COLLATE 'utf8mb4_general_ci',
|
||||
`type` char(50) DEFAULT NULL,
|
||||
`exercise_plan_template_id` INT(11) NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`exercise_plan_id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=104 DEFAULT CHARSET=utf8mb4;
|
||||
@ -987,6 +987,51 @@ ENGINE=InnoDB
|
||||
;
|
||||
|
||||
|
||||
CREATE TABLE `evaluation` (
|
||||
`evaluation_id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`exercise_type_id` INT(11) NOT NULL,
|
||||
`name` CHAR(100) NULL DEFAULT NULL COLLATE 'utf8_hungarian_ci',
|
||||
`unit` CHAR(50) NULL DEFAULT NULL COMMENT 'repeats, second, etc' COLLATE 'utf8_hungarian_ci',
|
||||
PRIMARY KEY (`evaluation_id`) USING BTREE
|
||||
)
|
||||
COLLATE='utf8_hungarian_ci'
|
||||
ENGINE=InnoDB
|
||||
;
|
||||
|
||||
INSERT INTO `evaluation` (`evaluation_id`, `exercise_type_id`, `name`, `unit`) VALUES (1, 33, 'PushUps', 'repeats');
|
||||
INSERT INTO `evaluation` (`evaluation_id`, `exercise_type_id`, `name`, `unit`) VALUES (2, 35, 'Squats', 'repeats');
|
||||
|
||||
CREATE TABLE `evaluation_attribute` (
|
||||
`evaluation_attr_id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`evaluation_id` INT(11) NOT NULL,
|
||||
`name` CHAR(50) NOT NULL DEFAULT '' COLLATE 'utf8_hungarian_ci',
|
||||
`age_min` INT(3) NOT NULL DEFAULT '0',
|
||||
`age_max` INT(3) NOT NULL DEFAULT '0',
|
||||
`value_min` DOUBLE NOT NULL DEFAULT '0',
|
||||
`value_max` DOUBLE NOT NULL DEFAULT '0',
|
||||
`sex` ENUM('m','w') NOT NULL DEFAULT 'm' COLLATE 'utf8_hungarian_ci',
|
||||
`evaluation_text` CHAR(50) NOT NULL COLLATE 'utf8_hungarian_ci',
|
||||
`suggestion` TEXT NULL DEFAULT NULL COLLATE 'utf8_hungarian_ci',
|
||||
PRIMARY KEY (`evaluation_attr_id`) USING BTREE,
|
||||
INDEX `evalutation_id` (`evaluation_id`) USING BTREE
|
||||
)
|
||||
COLLATE='utf8_hungarian_ci'
|
||||
ENGINE=InnoDB
|
||||
;
|
||||
|
||||
INSERT INTO `evaluation_attribute` (`evaluation_attr_id`, `evaluation_id`, `name`, `age_min`, `age_max`, `value_min`, `value_max`, `sex`, `evaluation_text`, `suggestion`) VALUES (1, 1, 'Fekvőtámasz_ffi_17-19_very_poor', 17, 19, 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 (2, 1, 'Fekvőtámasz_ffi_17-19_fair', 17, 19, 20, 34, 'm', 'fair', NULL);
|
||||
INSERT INTO `evaluation_attribute` (`evaluation_attr_id`, `evaluation_id`, `name`, `age_min`, `age_max`, `value_min`, `value_max`, `sex`, `evaluation_text`, `suggestion`) VALUES (3, 1, 'Fekvőtámasz_ffi_17-19_avg', 17, 19, 19, 34, 'm', 'average', NULL);
|
||||
INSERT INTO `evaluation_attribute` (`evaluation_attr_id`, `evaluation_id`, `name`, `age_min`, `age_max`, `value_min`, `value_max`, `sex`, `evaluation_text`, `suggestion`) VALUES (4, 1, 'Fekvőtámasz_ffi_17-19_below_avg', 17, 19, 10, 18, 'm', 'below_average', NULL);
|
||||
INSERT INTO `evaluation_attribute` (`evaluation_attr_id`, `evaluation_id`, `name`, `age_min`, `age_max`, `value_min`, `value_max`, `sex`, `evaluation_text`, `suggestion`) VALUES (5, 1, 'Fekvőtámasz_ffi_17-19_poor', 17, 19, 4, 10, 'm', '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 (6, 1, 'Fekvőtámasz_ffi_17-19_above_avg', 17, 19, 19, 34, 'm', 'average', NULL);
|
||||
INSERT INTO `evaluation_attribute` (`evaluation_attr_id`, `evaluation_id`, `name`, `age_min`, `age_max`, `value_min`, `value_max`, `sex`, `evaluation_text`, `suggestion`) VALUES (7, 1, 'Fekvőtámasz_ffi_17-19_good', 17, 19, 47, 56, 'm', 'good', NULL);
|
||||
INSERT INTO `evaluation_attribute` (`evaluation_attr_id`, `evaluation_id`, `name`, `age_min`, `age_max`, `value_min`, `value_max`, `sex`, `evaluation_text`, `suggestion`) VALUES (8, 1, 'Fekvőtámasz_ffi_17-19_excellent', 17, 19, 56, 99, '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);
|
||||
|
||||
|
||||
|
||||
/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
|
||||
/*!40014 SET FOREIGN_KEY_CHECKS=IF(@OLD_FOREIGN_KEY_CHECKS IS NULL, 1, @OLD_FOREIGN_KEY_CHECKS) */;
|
||||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||
|
36
data/db/update_1_0_29.sql
Normal file
36
data/db/update_1_0_29.sql
Normal file
@ -0,0 +1,36 @@
|
||||
START TRANSACTION;
|
||||
|
||||
CREATE TABLE `evaluation` (
|
||||
`evaluation_id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`exercise_type_id` INT(11) NOT NULL,
|
||||
`name` CHAR(100) NULL DEFAULT NULL COLLATE 'utf8_hungarian_ci',
|
||||
`unit` CHAR(50) NULL DEFAULT NULL COMMENT 'repeats, second, etc' COLLATE 'utf8_hungarian_ci',
|
||||
PRIMARY KEY (`evaluation_id`) USING BTREE
|
||||
)
|
||||
COLLATE='utf8_hungarian_ci'
|
||||
ENGINE=InnoDB
|
||||
;
|
||||
|
||||
CREATE TABLE `evaluation_attribute` (
|
||||
`evaluation_attr_id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`evaluation_id` INT(11) NOT NULL,
|
||||
`name` CHAR(50) NOT NULL DEFAULT '' COLLATE 'utf8_hungarian_ci',
|
||||
`age_min` INT(3) NOT NULL DEFAULT '0',
|
||||
`age_max` INT(3) NOT NULL DEFAULT '0',
|
||||
`value_min` DOUBLE NOT NULL DEFAULT '0',
|
||||
`value_max` DOUBLE NOT NULL DEFAULT '0',
|
||||
`sex` ENUM('m','w') NOT NULL DEFAULT 'm' COLLATE 'utf8_hungarian_ci',
|
||||
`evaluation_text` CHAR(50) NOT NULL COLLATE 'utf8_hungarian_ci',
|
||||
`suggestion` TEXT NULL DEFAULT NULL COLLATE 'utf8_hungarian_ci',
|
||||
PRIMARY KEY (`evaluation_attr_id`) USING BTREE,
|
||||
INDEX `evalutation_id` (`evaluation_id`) USING BTREE
|
||||
)
|
||||
COLLATE='utf8_hungarian_ci'
|
||||
ENGINE=InnoDB
|
||||
;
|
||||
|
||||
|
||||
UPDATE configuration set config_value = "1.0.29", date_change=CURRENT_DATE WHERE config_key = "db_version";
|
||||
|
||||
COMMIT;
|
||||
|
@ -0,0 +1,26 @@
|
||||
package com.aitrainer.api.controller
|
||||
|
||||
import com.aitrainer.api.model.Evaluation
|
||||
import com.aitrainer.api.model.ExerciseTree
|
||||
import com.aitrainer.api.repository.EvaluationRepository
|
||||
import com.aitrainer.api.repository.ExerciseTreeParentsRepository
|
||||
import com.aitrainer.api.repository.ExerciseTreeRepository
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.http.ResponseEntity
|
||||
import org.springframework.web.bind.annotation.GetMapping
|
||||
import org.springframework.web.bind.annotation.RequestMapping
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api")
|
||||
class EvaluationController (private val evaluationRepository: EvaluationRepository) {
|
||||
private val logger = LoggerFactory.getLogger(javaClass)
|
||||
|
||||
@GetMapping("/evaluation")
|
||||
fun getEvaluation(): ResponseEntity<List<Evaluation>> {
|
||||
val list: List<Evaluation> = evaluationRepository.findAll()
|
||||
logger.info(" -- Get All Evaluations.")
|
||||
return if (list.isEmpty()) ResponseEntity.notFound().build() else
|
||||
ResponseEntity.ok().body(list)
|
||||
}
|
||||
}
|
@ -19,9 +19,17 @@ class ExerciseController(private val exercisesRepository: ExercisesRepository) {
|
||||
}
|
||||
|
||||
@GetMapping("/exercises/customer/{id}")
|
||||
fun getAllExersicesByCustomerId(@PathVariable( value = "id" ) customerId: Long? ): List<Exercises> =
|
||||
fun getAllExercisesByCustomerId(@PathVariable( value = "id" ) customerId: Long? ): List<Exercises> =
|
||||
exercisesRepository.getAllByCustomerIdOrderByDateAddDesc(customerId)
|
||||
|
||||
@GetMapping("/exercises/exercise_type/{id}")
|
||||
fun getAllExercisesByExerciseTypeId(@PathVariable( value = "id" ) exerciseTypeId: Long ): ResponseEntity<List<Exercises>> {
|
||||
val exercises:List<Exercises> = exercisesRepository.getAllByExerciseTypeId(exerciseTypeId)
|
||||
return if (exercises.isEmpty()) ResponseEntity.notFound().build() else
|
||||
ResponseEntity.ok().body(exercises)
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/exercises")
|
||||
fun createNewExercise(@Valid @RequestBody exercise: Exercises): ResponseEntity<Exercises> {
|
||||
return ResponseEntity.ok().body(exercisesRepository.save(exercise))
|
||||
|
@ -19,7 +19,8 @@ class PackageController(private val exerciseAbilityRepository: ExerciseAbilityRe
|
||||
private val productRepository: ProductRepository,
|
||||
private val exerciseDeviceRepository: ExerciseDeviceRepository,
|
||||
private val exerciseTreeParentsRepository: ExerciseTreeParentsRepository,
|
||||
private val exercisePlanTemplateRepository: ExercisePlanTemplateRepository
|
||||
private val exercisePlanTemplateRepository: ExercisePlanTemplateRepository,
|
||||
private val evaluationRepository: EvaluationRepository
|
||||
) {
|
||||
private val logger = LoggerFactory.getLogger(javaClass)
|
||||
|
||||
@ -55,6 +56,9 @@ class PackageController(private val exerciseAbilityRepository: ExerciseAbilityRe
|
||||
val listPlanTemplate = exercisePlanTemplateRepository.findAll()
|
||||
val listPlanTemplateJson: String = gson.toJson(listPlanTemplate)
|
||||
|
||||
val listEvaluations = evaluationRepository.findAll()
|
||||
val listEvaluationJson: String = gson.toJson(listEvaluations)
|
||||
|
||||
|
||||
val packageJson: String =
|
||||
getClassRecord(ExerciseDevice::class.simpleName, listDevicesJson) +
|
||||
@ -64,7 +68,8 @@ class PackageController(private val exerciseAbilityRepository: ExerciseAbilityRe
|
||||
"|||" + getClassRecord(ExerciseType::class.simpleName, listExerciseTypeJson) +
|
||||
"|||" + getClassRecord(ExerciseAbility::class.simpleName, listExerciseAbilityJson) +
|
||||
"|||" + getClassRecord(ExerciseTreeParents::class.simpleName, listExerciseTreeParentsJson) +
|
||||
"|||" + getClassRecord(ExercisePlanTemplate::class.simpleName, listPlanTemplateJson)
|
||||
"|||" + getClassRecord(ExercisePlanTemplate::class.simpleName, listPlanTemplateJson) +
|
||||
"|||" + getClassRecord(Evaluation::class.simpleName, listEvaluationJson)
|
||||
|
||||
return if (packageJson.isEmpty()) ResponseEntity.notFound().build() else
|
||||
ResponseEntity.ok().body(packageJson)
|
||||
|
20
src/main/kotlin/com/aitrainer/api/model/Evaluation.kt
Normal file
20
src/main/kotlin/com/aitrainer/api/model/Evaluation.kt
Normal file
@ -0,0 +1,20 @@
|
||||
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.*
|
||||
import javax.validation.constraints.NotBlank
|
||||
|
||||
@Entity
|
||||
data class Evaluation (
|
||||
@Expose @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @get: NonNull var evaluationId: Int,
|
||||
@Expose @get: NonNull var exerciseTypeId: Long = 0,
|
||||
@Expose @get: NotBlank var name: String = "",
|
||||
@Expose @get: NonNull var unit: String = "",
|
||||
) {
|
||||
@OneToMany(cascade = [(CascadeType.ALL)], fetch = FetchType.EAGER, mappedBy = "evaluation")
|
||||
@Fetch(value = FetchMode.SUBSELECT)
|
||||
@Expose val attributes: List<EvaluationAttribute> = mutableListOf()
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
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 EvaluationAttribute (
|
||||
@Expose @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @get: NonNull var evaluationAttrId: Int,
|
||||
//@Expose @get: NonNull var evaluationId: Long = 0,
|
||||
@Expose @get: NotBlank var name: String = "",
|
||||
@Expose var sex: String = "m",
|
||||
@Expose @get: NonNull var ageMin: Int = 0,
|
||||
@Expose @get: NonNull var ageMax: Int = 0,
|
||||
@Expose @get: NonNull var valueMin: Double = 0.0,
|
||||
@Expose @get: NonNull var valueMax: Double = 0.0,
|
||||
|
||||
@Expose @get: NonNull var evaluation_text: String = "",
|
||||
@Expose var suggestion: String?,
|
||||
) {
|
||||
@ManyToOne(fetch = FetchType.EAGER, optional = false)
|
||||
@JoinColumn(name="evaluationId", nullable=false)
|
||||
@JsonIgnore
|
||||
val evaluation: Evaluation? = null
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package com.aitrainer.api.repository
|
||||
|
||||
import com.aitrainer.api.model.Evaluation
|
||||
import com.aitrainer.api.model.ExerciseTree
|
||||
import org.springframework.data.jpa.repository.JpaRepository
|
||||
import org.springframework.data.jpa.repository.Query
|
||||
import org.springframework.stereotype.Repository
|
||||
|
||||
@Repository
|
||||
interface EvaluationRepository : JpaRepository<Evaluation, Int> {
|
||||
}
|
@ -7,4 +7,6 @@ import org.springframework.stereotype.Repository
|
||||
@Repository
|
||||
interface ExercisesRepository : JpaRepository<Exercises, Long> {
|
||||
fun getAllByCustomerIdOrderByDateAddDesc( customerId: Long? ):List<Exercises>
|
||||
|
||||
fun getAllByExerciseTypeId(exerciseTypeId: Long): List<Exercises>
|
||||
}
|
@ -17,6 +17,6 @@ logging.config=classpath:logback-spring.xml
|
||||
logging.file=logs
|
||||
|
||||
# if the database structure has been changed, increment this version number
|
||||
application.version=1.0.28
|
||||
application.version=1.0.29
|
||||
|
||||
jwt.secret=aitrainer
|
@ -17,6 +17,6 @@ logging.config=classpath:logback-spring.xml
|
||||
logging.file=logs
|
||||
|
||||
# if the database structure has been changed, increment this version number
|
||||
application.version=1.0.28
|
||||
application.version=1.0.29
|
||||
|
||||
jwt.secret=aitrainer
|
@ -72,8 +72,8 @@ class AppCustomerPackageTest {
|
||||
val type = object : TypeToken<List<Exercises?>?>() {}.type
|
||||
val exerciseList: List<Exercises> = gson.fromJson(exercisesJson, type)
|
||||
assertTrue(exerciseList.isNotEmpty())
|
||||
assertEquals(exerciseList[0].exerciseTypeId, 37)
|
||||
assertEquals(exerciseList[0].quantity, 40.0)
|
||||
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
|
||||
|
@ -33,6 +33,8 @@ class AppPackageTest {
|
||||
private lateinit var exerciseTreeParentsRepository: ExerciseTreeParentsRepository
|
||||
@Autowired
|
||||
private lateinit var exercisePlanTemplateRepository: ExercisePlanTemplateRepository
|
||||
@Autowired
|
||||
private lateinit var evaluationRepository: EvaluationRepository
|
||||
|
||||
@Test
|
||||
fun testAppPackage() {
|
||||
@ -46,7 +48,8 @@ class AppPackageTest {
|
||||
productRepository,
|
||||
exerciseDeviceRepository,
|
||||
exerciseTreeParentsRepository,
|
||||
exercisePlanTemplateRepository
|
||||
exercisePlanTemplateRepository,
|
||||
evaluationRepository
|
||||
)
|
||||
val response: ResponseEntity<*> = controller.getPackageData()
|
||||
|
||||
@ -99,6 +102,15 @@ 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)
|
||||
} else if (record[0] == Evaluation::class.simpleName) {
|
||||
val evaluationJson: String = record[1]
|
||||
val type = object : TypeToken<List<Evaluation?>?>() {}.type
|
||||
val evaluations: List<Evaluation> = gson.fromJson(evaluationJson, type)
|
||||
assertTrue(evaluations.isNotEmpty())
|
||||
assertEquals(evaluations.size, 2)
|
||||
assertEquals(evaluations[0].name, "PushUps")
|
||||
assertEquals(evaluations[0].attributes.size, 10)
|
||||
assertEquals(evaluations[0].attributes[1].name, "Fekvőtámasz_ffi_17-19_fair")
|
||||
}
|
||||
}
|
||||
|
||||
|
37
src/test/kotlin/com/aitrainer/api/test/EvaluationTest.kt
Normal file
37
src/test/kotlin/com/aitrainer/api/test/EvaluationTest.kt
Normal file
@ -0,0 +1,37 @@
|
||||
package com.aitrainer.api.test
|
||||
|
||||
import com.aitrainer.api.controller.EvaluationController
|
||||
import com.aitrainer.api.controller.ProductController
|
||||
import com.aitrainer.api.repository.EvaluationRepository
|
||||
import com.aitrainer.api.repository.ProductRepository
|
||||
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 kotlin.test.assertEquals
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
@SpringBootTest
|
||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||
class EvaluationTest {
|
||||
|
||||
@Autowired
|
||||
private lateinit var evaluationRepository: EvaluationRepository
|
||||
|
||||
|
||||
@Test
|
||||
fun testGetEvaluations() {
|
||||
val controller = EvaluationController(evaluationRepository)
|
||||
val response = controller.getEvaluation()
|
||||
|
||||
val evaluations = response.body
|
||||
|
||||
assertTrue(evaluations is List)
|
||||
assertTrue(evaluations.isNotEmpty())
|
||||
assertEquals(evaluations.size, 2)
|
||||
assertEquals(evaluations[0].name, "PushUps")
|
||||
assertEquals(evaluations[0].attributes.size, 10)
|
||||
assertEquals(evaluations[0].attributes[0].name, "Fekvőtámasz_ffi_17-19_very_poor")
|
||||
}
|
||||
|
||||
}
|
@ -9,10 +9,8 @@ import org.springframework.beans.factory.annotation.Autowired
|
||||
import org.springframework.boot.test.context.SpringBootTest
|
||||
import org.springframework.http.HttpStatus
|
||||
import org.springframework.http.ResponseEntity
|
||||
import org.springframework.web.bind.annotation.RequestHeader
|
||||
import java.util.*
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertNull
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
@SpringBootTest
|
||||
|
@ -30,6 +30,23 @@ class ExerciseTest {
|
||||
assertEquals( exercises2.size, 0)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testGetByExerciseTypeId() {
|
||||
val id: Long = 2
|
||||
val exerciseController = ExerciseController(exerciseRepository)
|
||||
val response: ResponseEntity<List<Exercises>> = exerciseController.getAllExercisesByExerciseTypeId(id)
|
||||
|
||||
val exercises = response.body
|
||||
|
||||
assertTrue(exercises is List)
|
||||
assertTrue(exercises.isNotEmpty())
|
||||
assertEquals(exercises.size, 3)
|
||||
assertEquals(exercises[2].customerId, 90)
|
||||
|
||||
val response2: ResponseEntity<List<Exercises>> = exerciseController.getAllExercisesByExerciseTypeId(22)
|
||||
assertEquals(response2.statusCode, HttpStatus.NOT_FOUND)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testInsert() {
|
||||
var exercise = Exercises(
|
||||
|
Loading…
Reference in New Issue
Block a user