Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update and rename GetEnvMissionById.kt to GetEnvMissionById2.kt #486

Merged
merged 4 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import org.slf4j.LoggerFactory
import org.springframework.cache.annotation.Cacheable

@UseCase
class GetEnvMissionById(
class GetEnvMissionById2(
private val monitorEnvApiRepo: IEnvMissionRepository
) {
private val logger = LoggerFactory.getLogger(GetEnvMissionById::class.java)
private val logger = LoggerFactory.getLogger(GetEnvMissionById2::class.java)

@Cacheable(value = ["envMission"], key = "#missionId")
fun execute(missionId: Int?): MissionEntity? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import fr.gouv.dgampa.rapportnav.config.UseCase
import fr.gouv.dgampa.rapportnav.domain.entities.aem.v2.AEMTableExport2
import fr.gouv.dgampa.rapportnav.domain.entities.mission.nav.export.MissionExportEntity
import fr.gouv.dgampa.rapportnav.domain.use_cases.mission.action.v2.GetEnvActionListByMissionId
import fr.gouv.dgampa.rapportnav.domain.use_cases.mission.action.v2.GetEnvMissionById
import fr.gouv.dgampa.rapportnav.domain.use_cases.mission.action.v2.GetEnvMissionById2
import fr.gouv.dgampa.rapportnav.domain.use_cases.mission.action.v2.GetFishActionListByMissionId
import fr.gouv.dgampa.rapportnav.domain.use_cases.mission.action.v2.GetNavActionListByMissionId
import fr.gouv.dgampa.rapportnav.domain.use_cases.mission.generalInfo.GetMissionGeneralInfoByMissionId
Expand All @@ -25,7 +25,7 @@ class ExportMissionAEM2(
@Value("\${rapportnav.aem.tmp_xlsx.path}") private val aemTmpXLSXPath: String,
@Value("\${rapportnav.aem.tmp_ods.path}") private val aemTmpODSPath: String,
private val fillAEMExcelRow: FillAEMExcelRow,
private val getEnvMissionById: GetEnvMissionById,
private val getEnvMissionById2: GetEnvMissionById2,
private val getEnvActionByMissionId: GetEnvActionListByMissionId,
private val getNavActionByMissionId: GetNavActionListByMissionId,
private val getFIshListActionByMissionId: GetFishActionListByMissionId,
Expand Down Expand Up @@ -77,7 +77,7 @@ class ExportMissionAEM2(
}

private fun getAemTableExport(missionIds: List<Int>) = missionIds.map {
val envMission = getEnvMissionById.execute(it)
val envMission = getEnvMissionById2.execute(it)
val envActions = getEnvActionByMissionId.execute(it)
val navActions = getNavActionByMissionId.execute(it)
val fishActions = getFIshListActionByMissionId.execute(it)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import fr.gouv.dgampa.rapportnav.domain.entities.mission.env.MissionEntity
import fr.gouv.dgampa.rapportnav.domain.entities.mission.env.MissionSourceEnum
import fr.gouv.dgampa.rapportnav.domain.entities.mission.env.MissionTypeEnum
import fr.gouv.dgampa.rapportnav.domain.repositories.mission.IEnvMissionRepository
import fr.gouv.dgampa.rapportnav.domain.use_cases.mission.action.v2.GetEnvMissionById
import fr.gouv.dgampa.rapportnav.domain.use_cases.mission.action.v2.GetEnvMissionById2
import org.junit.jupiter.api.Assertions.assertNotNull
import org.junit.jupiter.api.Test
import org.mockito.Mockito.*
Expand All @@ -13,11 +13,11 @@ import org.springframework.boot.test.context.SpringBootTest
import org.springframework.boot.test.mock.mockito.MockBean
import java.time.Instant

@SpringBootTest(classes = [GetEnvMissionById::class])
class GetEnvMissionByIdTest {
@SpringBootTest(classes = [GetEnvMissionById2::class])
class GetEnvMissionById2Test {

@Autowired
private lateinit var getEnvMissionById: GetEnvMissionById
private lateinit var getEnvMissionById2: GetEnvMissionById2

@MockBean
private lateinit var monitorEnvApiRepo: IEnvMissionRepository
Expand All @@ -40,10 +40,10 @@ class GetEnvMissionByIdTest {
// Mock behavior of findMissionById to return a MissionEntity
`when`(monitorEnvApiRepo.findMissionById(missionId)).thenReturn(missionEntity)

getEnvMissionById = GetEnvMissionById(monitorEnvApiRepo)
getEnvMissionById2 = GetEnvMissionById2(monitorEnvApiRepo)

// When
val result = getEnvMissionById.execute(missionId)
val result = getEnvMissionById2.execute(missionId)

// Then
assertNotNull(result)
Expand Down
Loading