-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
546 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 0 additions & 64 deletions
64
...in/fr/gouv/gmampa/rapportnav/domain/use_cases/mission/export/ExportZipMissionsAEMTests.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
...v/gmampa/rapportnav/domain/use_cases/mission/export/v2/ExportMissionPatrolCombinedTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package fr.gouv.gmampa.rapportnav.domain.use_cases.mission.export.v2 | ||
|
||
import fr.gouv.dgampa.rapportnav.domain.entities.mission.nav.export.MissionExportEntity | ||
import fr.gouv.dgampa.rapportnav.domain.use_cases.mission.GetMission | ||
import fr.gouv.dgampa.rapportnav.domain.use_cases.mission.export.v2.ExportMissionPatrolCombined | ||
import fr.gouv.dgampa.rapportnav.domain.use_cases.mission.export.v2.ExportMissionPatrolSingle | ||
import fr.gouv.dgampa.rapportnav.domain.use_cases.utils.FormatDateTime | ||
import fr.gouv.gmampa.rapportnav.mocks.mission.MissionEntityMock | ||
import org.junit.jupiter.api.Assertions.assertEquals | ||
import org.junit.jupiter.api.Assertions.assertNotNull | ||
import org.junit.jupiter.api.Test | ||
import org.mockito.Mockito | ||
import org.springframework.beans.factory.annotation.Autowired | ||
import org.springframework.boot.test.context.SpringBootTest | ||
import org.springframework.boot.test.mock.mockito.MockBean | ||
|
||
@SpringBootTest(classes = [ExportMissionPatrolCombined::class, FormatDateTime::class]) | ||
class ExportMissionPatrolCombinedTest { | ||
|
||
@Autowired | ||
private lateinit var exportMissionPatrolCombined: ExportMissionPatrolCombined | ||
|
||
@MockBean | ||
private lateinit var exportMissionPatrolSingle: ExportMissionPatrolSingle | ||
|
||
@MockBean | ||
private lateinit var getMission: GetMission | ||
|
||
@Test | ||
fun `should return null for empty mission list`() { | ||
val result = exportMissionPatrolCombined.execute(emptyList()) | ||
assertEquals(null, result) | ||
} | ||
|
||
@Test | ||
fun `should export a file`() { | ||
val missionIds = listOf(1) | ||
val mission = MissionEntityMock.create(id = missionIds.first()) | ||
Mockito.`when`(exportMissionPatrolSingle.createFile(Mockito.any())).thenReturn( | ||
MissionExportEntity( | ||
fileName = "exportMissionPatrolSingle.odt", | ||
fileContent = "MockContent" | ||
) | ||
) | ||
Mockito.`when`(getMission.execute(Mockito.anyInt(), Mockito.any())).thenReturn( | ||
mission | ||
) | ||
|
||
val result = exportMissionPatrolCombined.execute(missionIds) | ||
|
||
assertNotNull(result) | ||
assertEquals("rapports-patrouille-combinés_2022-01-02.odt", result?.fileName) | ||
} | ||
|
||
@Test | ||
fun `should handle exception and return null`() { | ||
// Arrange: Force an exception when getMission.execute is called | ||
val missionIds = listOf(1) | ||
Mockito.`when`(getMission.execute(Mockito.anyInt(), Mockito.any())) | ||
.thenThrow(RuntimeException("Mock exception")) | ||
|
||
// Act: Call the method | ||
val result = exportMissionPatrolCombined.execute(missionIds) | ||
|
||
// Assert: Verify the result is null and no further interactions happen | ||
assertEquals(null, result) | ||
Mockito.verifyNoInteractions(exportMissionPatrolSingle) | ||
} | ||
|
||
} |
Oops, something went wrong.