diff --git a/src/main/kotlin/com/aitrainer/api/controller/ExerciesController.kt b/src/main/kotlin/com/aitrainer/api/controller/ExerciesController.kt index c0e8eed..36da824 100644 --- a/src/main/kotlin/com/aitrainer/api/controller/ExerciesController.kt +++ b/src/main/kotlin/com/aitrainer/api/controller/ExerciesController.kt @@ -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, diff --git a/src/main/kotlin/com/aitrainer/api/controller/ExerciseTypeController.kt b/src/main/kotlin/com/aitrainer/api/controller/ExerciseTypeController.kt index b6143b7..85319e1 100644 --- a/src/main/kotlin/com/aitrainer/api/controller/ExerciseTypeController.kt +++ b/src/main/kotlin/com/aitrainer/api/controller/ExerciseTypeController.kt @@ -16,7 +16,7 @@ class ExerciseTypeController ( private val exerciseTypeRepository: ExerciseTypeR @GetMapping("/exercise_type") fun getAllExerciseType(): List { val list: List = 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 { logger.info("Update exercise type by id: $exerciseTypeId with object $newExerciseType") diff --git a/src/main/kotlin/com/aitrainer/api/model/Exercises.kt b/src/main/kotlin/com/aitrainer/api/model/Exercises.kt index bb2736c..6770c95 100644 --- a/src/main/kotlin/com/aitrainer/api/model/Exercises.kt +++ b/src/main/kotlin/com/aitrainer/api/model/Exercises.kt @@ -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 diff --git a/src/main/resources/simplelogger.properties b/src/main/resources/simplelogger.properties deleted file mode 100644 index 05ff3de..0000000 --- a/src/main/resources/simplelogger.properties +++ /dev/null @@ -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 \ No newline at end of file diff --git a/src/test/kotlin/com/aitrainer/api/test/ExerciseTest.kt b/src/test/kotlin/com/aitrainer/api/test/ExerciseTest.kt index 497423f..3196656 100644 --- a/src/test/kotlin/com/aitrainer/api/test/ExerciseTest.kt +++ b/src/test/kotlin/com/aitrainer/api/test/ExerciseTest.kt @@ -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) + } } \ No newline at end of file