Test case add new exercise.

This commit is contained in:
Bossanyi Tibor 2020-05-24 08:21:40 +02:00
parent 2eb5a6ae03
commit 5c85e28269
5 changed files with 21 additions and 40 deletions

View File

@ -22,8 +22,9 @@ class ExerciesController(private val exercisesRepository: ExercisesRepository) {
exercisesRepository.getAllByCustomerId(customerId)
@PostMapping("/exercises")
fun createNewExercise(@Valid @RequestBody exercises: Exercises): Exercises =
exercisesRepository.save(exercises)
fun createNewExercise(@Valid @RequestBody exercise: Exercises): Exercises {
return exercisesRepository.save(exercise)
}
@PutMapping("/exercises/{id}")
fun updateExerciseById(@PathVariable(value = "id") exerciseId: Long,

View File

@ -16,7 +16,7 @@ class ExerciseTypeController ( private val exerciseTypeRepository: ExerciseTypeR
@GetMapping("/exercise_type")
fun getAllExerciseType(): List<ExerciseType> {
val list: List<ExerciseType> = exerciseTypeRepository.findAll()
logger.info("Get All exercise types: $list")
logger.info(" -- Get All exercise types..")
return list
}
@ -44,7 +44,7 @@ class ExerciseTypeController ( private val exerciseTypeRepository: ExerciseTypeR
}.orElse(ResponseEntity.notFound().build())
}*/
@PutMapping("/exercise_type/{id}")
@PostMapping("/exercise_type/{id}")
fun updateExerciseTypesById(@PathVariable(value = "id") exerciseTypeId: Long,
@Valid @RequestBody newExerciseType: ExerciseType): ResponseEntity<ExerciseType> {
logger.info("Update exercise type by id: $exerciseTypeId with object $newExerciseType")

View File

@ -1,7 +1,6 @@
package com.aitrainer.api.model
import org.springframework.lang.NonNull
import java.sql.Date
import javax.persistence.Entity
import javax.persistence.GeneratedValue
import javax.persistence.GenerationType
@ -12,7 +11,7 @@ import javax.validation.constraints.Null
data class Exercises (
@get: NonNull var exerciseTypeId: Long = 0,
@get: NonNull var customerId: Long = 0,
@get: NonNull var datetimeExercise: Date? = null,
@get: NonNull var datetimeExercise: String? = null,
@get: NonNull var quantity: Int = 0,
@get: Null var restTime: Int?, // in seconds

View File

@ -1,34 +0,0 @@
# SLF4J's SimpleLogger configuration file
# Simple implementation of Logger that sends all enabled log messages, for all defined loggers, to System.err.
# Default logging detail level for all instances of SimpleLogger.
# Must be one of ("trace", "debug", "info", "warn", or "error").
# If not specified, defaults to "info".
org.slf4j.simpleLogger.defaultLogLevel=debug
# Logging detail level for a SimpleLogger instance named "xxxxx".
# Must be one of ("trace", "debug", "info", "warn", or "error").
# If not specified, the default logging detail level is used.
#org.slf4j.simpleLogger.log.xxxxx=
# Set to true if you want the current date and time to be included in output messages.
# Default is false, and will output the number of milliseconds elapsed since startup.
org.slf4j.simpleLogger.showDateTime=true
# The date and time format to be used in the output messages.
# The pattern describing the date and time format is the same that is used in java.text.SimpleDateFormat.
# If the format is not specified or is invalid, the default format is used.
# The default format is yyyy-MM-dd HH:mm:ss:SSS Z.
#org.slf4j.simpleLogger.dateTimeFormat=yyyy-MM-dd HH:mm:ss:SSS Z
# Set to true if you want to output the current thread name.
# Defaults to true.
#org.slf4j.simpleLogger.showThreadName=true
# Set to true if you want the Logger instance name to be included in output messages.
# Defaults to true.
#org.slf4j.simpleLogger.showLogName=true
# Set to true if you want the last component of the name to be included in output messages.
# Defaults to false.
org.slf4j.simpleLogger.showShortLogName=true

View File

@ -6,6 +6,7 @@ import org.junit.jupiter.api.Test
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import kotlin.test.assertEquals
import kotlin.test.assertTrue
@SpringBootTest
class ExerciseTest {
@ -25,4 +26,18 @@ class ExerciseTest {
assertEquals( exercises2.size, 0)
}
@Test
fun testInsert() {
val exercise = Exercises(
exerciseTypeId = 3,
customerId = 11,
quantity = 100,
datetimeExercise = "2020-05-13 04:32:00",
restTime = null
)
val exerciseNew = exerciseRepository.save(exercise)
assertTrue(exerciseNew.exerciseId > 2)
exerciseRepository.delete(exercise)
}
}