Merge branch 'zalan' into 'master'
Test for ExerciseType (Error) See merge request bossanyit/aitrainer_server!6
This commit is contained in:
commit
e76c65babe
@ -11,7 +11,7 @@ import javax.validation.Valid
|
||||
class ExerciseTypeController ( private val exerciseTypeRepository: ExerciseTypeRepository ) {
|
||||
|
||||
@GetMapping("/exercise_type")
|
||||
fun getAllExerciseTypes(): List<ExerciseType> =
|
||||
fun getAllExerciseType(): List<ExerciseType> =
|
||||
exerciseTypeRepository.findAll()
|
||||
|
||||
@PostMapping("/exercise_type")
|
||||
|
@ -1,20 +1,21 @@
|
||||
package com.aitrainer.api.model
|
||||
|
||||
import org.hibernate.type.BinaryType
|
||||
import javax.persistence.Entity
|
||||
import javax.persistence.GeneratedValue
|
||||
import javax.persistence.GenerationType
|
||||
import javax.persistence.Id
|
||||
import javax.validation.constraints.NotBlank
|
||||
import javax.validation.constraints.Null
|
||||
|
||||
@Entity
|
||||
data class ExerciseType (
|
||||
@get: NotBlank
|
||||
|
||||
val name: String = "",
|
||||
val description: String = "",
|
||||
val video: Long = 0,
|
||||
@get: NotBlank var name: String = "",
|
||||
@get: NotBlank var description: String = "",
|
||||
@get: Null var video: BinaryType?,
|
||||
|
||||
|
||||
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
val type_id: Long = 0
|
||||
val exerciseTypeId: Long = 0
|
||||
)
|
||||
|
35
src/test/kotlin/com/aitrainer/api/test/ExerciseTypeTest.kt
Normal file
35
src/test/kotlin/com/aitrainer/api/test/ExerciseTypeTest.kt
Normal file
@ -0,0 +1,35 @@
|
||||
package com.aitrainer.api.test
|
||||
|
||||
import com.aitrainer.api.model.ExerciseType
|
||||
import com.aitrainer.api.repository.ExerciseTypeRepository
|
||||
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 ExerciseTypeTest {
|
||||
|
||||
@Autowired
|
||||
private val exerciseTypeId: Long = 4
|
||||
private var insertedId: Long? = null
|
||||
private lateinit var exerciseTypeRepository: ExerciseTypeRepository
|
||||
|
||||
@Test
|
||||
fun testGet() {
|
||||
val id: Long = 7
|
||||
val extype: ExerciseType = exerciseTypeRepository.findById( id ).orElse(null)
|
||||
assertEquals( extype.name, "4x10m-es ingafutás")
|
||||
}
|
||||
fun testInsert(){
|
||||
val newEx = ExerciseType( "Húzodszkodás", " A legtöbb húzodszkodás 24 óra alatt John Ort érte el 7600-al 2016-ban. ", null )
|
||||
val savedEx: ExerciseType = exerciseTypeRepository.save(newEx)
|
||||
assertEquals(savedEx.name, "Húzodszkodás")
|
||||
|
||||
this.insertedId = savedEx.exerciseTypeId
|
||||
|
||||
val extype: ExerciseType = exerciseTypeRepository.findById( savedEx.exerciseTypeId ).orElse(null)
|
||||
assertEquals( extype.name, "Húzodszkodás")
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user