-
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.
feat(services): add list of services to a mission
- update service repository to return service with list of control units - create use case to getserviceWith control unit - update getNavMission to return services attributes - Add services to service Entity - Update graphQl definition of mission to add services - Test every steps
- Loading branch information
1 parent
349573b
commit 1422ff4
Showing
15 changed files
with
309 additions
and
8 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
10 changes: 10 additions & 0 deletions
10
...lin/fr/gouv/dgampa/rapportnav/domain/repositories/mission/crew/IAgentServiceRepository.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,10 @@ | ||
package fr.gouv.dgampa.rapportnav.domain.repositories.mission.crew | ||
|
||
import fr.gouv.dgampa.rapportnav.infrastructure.database.model.mission.crew.AgentModel | ||
|
||
interface IAgentRepository { | ||
|
||
fun findAll(): List<AgentModel> | ||
fun findByServiceId(serviceId: Int): List<AgentModel> | ||
|
||
} |
2 changes: 2 additions & 0 deletions
2
...n/kotlin/fr/gouv/dgampa/rapportnav/domain/repositories/mission/crew/IServiceRepository.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 |
---|---|---|
@@ -1,10 +1,12 @@ | ||
package fr.gouv.dgampa.rapportnav.domain.repositories.mission.crew | ||
|
||
import fr.gouv.dgampa.rapportnav.domain.entities.mission.fish.ControlUnit | ||
import fr.gouv.dgampa.rapportnav.infrastructure.database.model.mission.ServiceModel | ||
import java.util.* | ||
|
||
interface IServiceRepository { | ||
fun existsById(id: Int): Boolean | ||
fun findById(id: Int): Optional<ServiceModel> | ||
fun findAll(): List<ServiceModel> | ||
fun findByControlUnitId(controlUnitIds: List<Int>): List<ServiceModel> | ||
} |
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
17 changes: 17 additions & 0 deletions
17
...kotlin/fr/gouv/dgampa/rapportnav/domain/use_cases/mission/crew/GetServiceByControlUnit.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,17 @@ | ||
package fr.gouv.dgampa.rapportnav.domain.use_cases.mission.crew | ||
|
||
import fr.gouv.dgampa.rapportnav.config.UseCase | ||
import fr.gouv.dgampa.rapportnav.domain.entities.mission.env.controlResources.LegacyControlUnitEntity | ||
import fr.gouv.dgampa.rapportnav.domain.entities.mission.nav.ServiceEntity | ||
import fr.gouv.dgampa.rapportnav.domain.repositories.mission.crew.IServiceRepository | ||
|
||
@UseCase | ||
class GetServiceByControlUnit(private val serviceRepository: IServiceRepository) { | ||
|
||
fun execute(controlUnits: List<LegacyControlUnitEntity>? = null): List<ServiceEntity> { | ||
if (controlUnits == null) return listOf<ServiceEntity>(); | ||
return this.serviceRepository.findByControlUnitId(controlUnits.map { controlUnit -> controlUnit.id }) | ||
.map { it.toServiceEntity() } | ||
.sortedBy { it.id }; | ||
} | ||
} |
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
101 changes: 101 additions & 0 deletions
101
...c/test/kotlin/fr/gouv/gmampa/rapportnav/domain/use_cases/mission/GetNavMissionByIdTest.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,101 @@ | ||
package fr.gouv.gmampa.rapportnav.domain.use_cases.mission | ||
|
||
import fr.gouv.dgampa.rapportnav.domain.entities.mission.env.controlResources.LegacyControlUnitEntity | ||
import fr.gouv.dgampa.rapportnav.domain.entities.mission.nav.ServiceEntity | ||
import fr.gouv.dgampa.rapportnav.domain.repositories.mission.action.* | ||
import fr.gouv.dgampa.rapportnav.domain.use_cases.mission.GetNavMissionById | ||
import fr.gouv.dgampa.rapportnav.domain.use_cases.mission.action.AttachControlsToActionControl | ||
import fr.gouv.dgampa.rapportnav.domain.use_cases.mission.crew.GetAgentsCrewByMissionId | ||
import fr.gouv.dgampa.rapportnav.domain.use_cases.mission.crew.GetServiceByControlUnit | ||
import fr.gouv.dgampa.rapportnav.domain.use_cases.mission.generalInfo.GetMissionGeneralInfoByMissionId | ||
import org.assertj.core.api.Assertions.assertThat | ||
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 = [GetNavMissionById::class]) | ||
class GetNavMissionByIdTest { | ||
|
||
@Autowired | ||
private lateinit var getMissionNavById: GetNavMissionById | ||
|
||
@MockBean | ||
private lateinit var getServiceByControlUnit: GetServiceByControlUnit | ||
|
||
private val controlUnits: List<LegacyControlUnitEntity> = listOf( | ||
LegacyControlUnitEntity( | ||
id = 3, | ||
administration = "Administration", | ||
isArchived = false, name = "Themis", | ||
resources = listOf(), | ||
) | ||
) | ||
|
||
@MockBean | ||
private lateinit var navActionControlRepository: INavActionControlRepository; | ||
|
||
@MockBean | ||
private lateinit var navStatusRepository: INavActionStatusRepository; | ||
|
||
@MockBean | ||
private lateinit var navFreeNoteRepository: INavActionFreeNoteRepository; | ||
|
||
@MockBean | ||
private lateinit var attachControlsToActionControl: AttachControlsToActionControl; | ||
|
||
@MockBean | ||
private lateinit var getMissionGeneralInfoByMissionId: GetMissionGeneralInfoByMissionId; | ||
|
||
@MockBean | ||
private lateinit var getAgentsCrewByMissionId: GetAgentsCrewByMissionId; | ||
|
||
@MockBean | ||
private lateinit var navRescueRepository: INavActionRescueRepository; | ||
|
||
@MockBean | ||
private lateinit var navNauticalEventRepository: INavActionNauticalEventRepository; | ||
|
||
@MockBean | ||
private lateinit var navVigimerRepository: INavActionVigimerRepository; | ||
|
||
@MockBean | ||
private lateinit var navAntiPollutionRepository: INavActionAntiPollutionRepository; | ||
|
||
@MockBean | ||
private lateinit var navBAAEMRepository: INavActionBAAEMRepository; | ||
|
||
@MockBean | ||
private lateinit var navPublicOrderRepository: INavActionPublicOrderRepository; | ||
|
||
@MockBean | ||
private lateinit var navRepresentationRepository: INavActionRepresentationRepository; | ||
|
||
@MockBean | ||
private lateinit var navIllegalImmigrationRepository: INavActionIllegalImmigrationRepository | ||
|
||
private val serviceEntities: List<ServiceEntity> = listOf( | ||
ServiceEntity( | ||
id = 3, | ||
name = "firstService", | ||
controlUnits = listOf(1, 3) | ||
), ServiceEntity( | ||
id = 4, | ||
name = "SecondService", | ||
controlUnits = listOf(3, 4) | ||
) | ||
); | ||
|
||
@Test | ||
fun `execute should have services in nav mission entity`() { | ||
Mockito.`when`(getServiceByControlUnit.execute(controlUnits)).thenReturn(serviceEntities); | ||
val response = getMissionNavById.execute(2, controlUnits) | ||
|
||
assertThat(response).isNotNull(); | ||
assertThat(response.services).isNotNull(); | ||
assertThat(response.services?.size).isEqualTo(2); | ||
assertThat(response.services?.map { service -> service.id }).containsAll(listOf(3, 4)); | ||
} | ||
|
||
} |
Oops, something went wrong.