Skip to content

Commit

Permalink
missing entries
Browse files Browse the repository at this point in the history
  • Loading branch information
crizzzly committed Jan 6, 2025
1 parent c9ff9b2 commit aabbe2e
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ data class MoveRequestDTO(
val name: String?, // TODO: check if this can be nullable to remove issue in test
val description: String?,
val level: Int?,
val link: String?,
val isCoreMove: Boolean?,
val intensity: Int?,
val frequency: Int?,
val repetitions: Int?,
val timePreparation: Int?,
val timeExercise: Int?,
val formula: String?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ class MoveResponseDTO(
val description: String?,
val subcategoryIds: List<Int?>?,
val level: Int?,
val link: String?,
val isCoreMove: Boolean?,
val intensity: Int?,
val frequency: Int?,
val repetitions: Int?,
val timePreparation: Int?,
val timeExercise: Int?,
val formula: String?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class Move(
var timePreparation: Int? = null,
var timeExercise: Int? = null,
var formula: String? = null,
var link: String? = null,

@ManyToMany(cascade = [CascadeType.MERGE])
@JoinTable(
Expand Down Expand Up @@ -68,17 +69,18 @@ class Move(
var sports: List<Sport>? = mutableListOf(),
) {
// No-argument constructor
constructor() : this(null, "", null, null, null, null, null, null, null, null, null)
constructor() : this(null, "", null, null, null, null, null, null, null, null, null, null, null, null, null, null)

fun toResponseDTO(): MoveResponseDTO = MoveResponseDTO(
id = id,
name = name,
description = description,
subcategoryIds = subcategories?.map { it.id }!!,
link = link,
level = level,
isCoreMove = isCoreMove,
intensity = intensity,
frequency = repetitions,
repetitions = repetitions,
timePreparation = timePreparation,
timeExercise = timeExercise,
formula = formula,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class MoveService {
move.isCoreMove = moveRequestDTO.isCoreMove ?: false
move.level = moveRequestDTO.level ?: 0
move.intensity = moveRequestDTO.intensity ?: 0
move.repetitions = moveRequestDTO.frequency ?: 0
move.repetitions = moveRequestDTO.repetitions ?: 0
move.timePreparation = moveRequestDTO.timePreparation ?: 0
move.timeExercise = moveRequestDTO.timeExercise ?: 0
move.formula = moveRequestDTO.formula
Expand Down Expand Up @@ -106,11 +106,12 @@ class MoveService {
val move = moveDao.findByIdOrNull(id)
?: throw NoSuchElementException("Move with ID $id not found")
move.name = moveRequestDTO.name.toString()
move.link = moveRequestDTO.link
move.description = moveRequestDTO.description
move.isCoreMove = moveRequestDTO.isCoreMove
move.level = moveRequestDTO.level
move.intensity = moveRequestDTO.intensity
move.repetitions = moveRequestDTO.frequency
move.repetitions = moveRequestDTO.repetitions
move.timePreparation = moveRequestDTO.timePreparation
move.timeExercise = moveRequestDTO.timeExercise
move.formula = moveRequestDTO.formula
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
package com.affenbande.affenbandeBackend.services

import com.affenbande.affenbandeBackend.dao.ImagePathDao
import com.affenbande.affenbandeBackend.dao.MoveDao
import com.affenbande.affenbandeBackend.dao.SportDao
import com.affenbande.affenbandeBackend.dao.SubcategoryDao
import com.affenbande.affenbandeBackend.dto.MoveRequestDTO
import com.affenbande.affenbandeBackend.dto.MoveResponseDTO
import com.affenbande.affenbandeBackend.model.ImagePath
import com.affenbande.affenbandeBackend.model.Move
import com.affenbande.affenbandeBackend.model.Sport
import com.affenbande.affenbandeBackend.model.Subcategory
import com.affenbande.affenbandeBackend.services.MoveService
import io.mockk.*
import io.mockk.impl.annotations.InjectMockKs
import io.mockk.impl.annotations.MockK
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.Assertions.assertEquals
import org.mockito.kotlin.any
import java.util.*

class MoveServiceTest {

Expand Down Expand Up @@ -50,7 +44,7 @@ class MoveServiceTest {
isCoreMove = false,
level = 0,
intensity = 0,
frequency = 0,
repetitions = 0,
timePreparation = 0,
timeExercise = 0,
formula = null,
Expand Down

0 comments on commit aabbe2e

Please sign in to comment.