From 24bbcb81ee09af31d8996d69dc77a3240771e58b Mon Sep 17 00:00:00 2001 From: Claire Dagan Date: Thu, 23 May 2024 15:23:40 +0200 Subject: [PATCH] [Reporting] add isInfractionProven prop --- .../entities/reporting/ReportingEntity.kt | 1 + .../CreateOrUpdateReportingDataInput.kt | 2 + .../outputs/reportings/ReportingDataOutput.kt | 2 + .../reportings/ReportingsDataOutput.kt | 2 + .../database/model/ReportingModel.kt | 3 + .../V0.129__update_reportings_table.sql | 1 + .../CreateOrUpdateReportingUTests.kt | 11 + .../controlUnit/CanDeleteControlUnitUTests.kt | 1 + .../use_cases/missions/DeleteMissionUTests.kt | 240 ++++++++++-------- .../domain/use_cases/missions/TestUtils.kt | 2 + .../api/endpoints/bff/MissionsITests.kt | 5 +- .../api/endpoints/bff/ReportingsITests.kt | 21 +- .../JpaReportingRepositoryITests.kt | 1 + frontend/src/domain/entities/reporting.ts | 22 ++ .../Reportings/ReportingForm/FormContent.tsx | 20 +- frontend/src/features/Reportings/style.ts | 7 + frontend/src/features/Reportings/utils.tsx | 1 + 17 files changed, 223 insertions(+), 119 deletions(-) create mode 100644 backend/src/main/resources/db/migration/internal/V0.129__update_reportings_table.sql diff --git a/backend/src/main/kotlin/fr/gouv/cacem/monitorenv/domain/entities/reporting/ReportingEntity.kt b/backend/src/main/kotlin/fr/gouv/cacem/monitorenv/domain/entities/reporting/ReportingEntity.kt index c2a061697..5d8d0c33f 100644 --- a/backend/src/main/kotlin/fr/gouv/cacem/monitorenv/domain/entities/reporting/ReportingEntity.kt +++ b/backend/src/main/kotlin/fr/gouv/cacem/monitorenv/domain/entities/reporting/ReportingEntity.kt @@ -35,6 +35,7 @@ data class ReportingEntity( val attachedEnvActionId: UUID? = null, val updatedAtUtc: ZonedDateTime? = null, val withVHFAnswer: Boolean? = null, + val isInfractionProven: Boolean, ) { fun validate() { when (sourceType) { diff --git a/backend/src/main/kotlin/fr/gouv/cacem/monitorenv/infrastructure/api/adapters/bff/inputs/CreateOrUpdateReportingDataInput.kt b/backend/src/main/kotlin/fr/gouv/cacem/monitorenv/infrastructure/api/adapters/bff/inputs/CreateOrUpdateReportingDataInput.kt index 69d5c8f85..8c25b5fa3 100644 --- a/backend/src/main/kotlin/fr/gouv/cacem/monitorenv/infrastructure/api/adapters/bff/inputs/CreateOrUpdateReportingDataInput.kt +++ b/backend/src/main/kotlin/fr/gouv/cacem/monitorenv/infrastructure/api/adapters/bff/inputs/CreateOrUpdateReportingDataInput.kt @@ -38,6 +38,7 @@ data class CreateOrUpdateReportingDataInput( val attachedEnvActionId: UUID? = null, val updatedAtUtc: ZonedDateTime? = null, val withVHFAnswer: Boolean? = null, + val isInfractionProven: Boolean, ) { fun toReportingEntity(): ReportingEntity { return ReportingEntity( @@ -69,6 +70,7 @@ data class CreateOrUpdateReportingDataInput( attachedEnvActionId = this.attachedEnvActionId, updatedAtUtc = this.updatedAtUtc, withVHFAnswer = this.withVHFAnswer, + isInfractionProven = this.isInfractionProven, ) } } diff --git a/backend/src/main/kotlin/fr/gouv/cacem/monitorenv/infrastructure/api/adapters/bff/outputs/reportings/ReportingDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cacem/monitorenv/infrastructure/api/adapters/bff/outputs/reportings/ReportingDataOutput.kt index 666604baf..fe20a645c 100644 --- a/backend/src/main/kotlin/fr/gouv/cacem/monitorenv/infrastructure/api/adapters/bff/outputs/reportings/ReportingDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cacem/monitorenv/infrastructure/api/adapters/bff/outputs/reportings/ReportingDataOutput.kt @@ -47,6 +47,7 @@ data class ReportingDataOutput( val controlStatus: ControlStatusEnum? = null, val updatedAtUtc: ZonedDateTime? = null, val withVHFAnswer: Boolean? = null, + val isInfractionProven: Boolean, ) { companion object { fun fromReportingDTO( @@ -118,6 +119,7 @@ data class ReportingDataOutput( controlStatus = dto.controlStatus, updatedAtUtc = dto.reporting.updatedAtUtc, withVHFAnswer = dto.reporting.withVHFAnswer, + isInfractionProven = dto.reporting.isInfractionProven, ) } } diff --git a/backend/src/main/kotlin/fr/gouv/cacem/monitorenv/infrastructure/api/adapters/bff/outputs/reportings/ReportingsDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cacem/monitorenv/infrastructure/api/adapters/bff/outputs/reportings/ReportingsDataOutput.kt index 7e085dcaf..dbd4f277d 100644 --- a/backend/src/main/kotlin/fr/gouv/cacem/monitorenv/infrastructure/api/adapters/bff/outputs/reportings/ReportingsDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cacem/monitorenv/infrastructure/api/adapters/bff/outputs/reportings/ReportingsDataOutput.kt @@ -41,6 +41,7 @@ data class ReportingsDataOutput( val attachedEnvActionId: UUID? = null, val controlStatus: ControlStatusEnum? = null, val withVHFAnswer: Boolean? = null, + val isInfractionProven: Boolean, ) { companion object { fun fromReportingDTO( @@ -87,6 +88,7 @@ data class ReportingsDataOutput( attachedEnvActionId = dto.reporting.attachedEnvActionId, controlStatus = dto.controlStatus, withVHFAnswer = dto.reporting.withVHFAnswer, + isInfractionProven = dto.reporting.isInfractionProven, ) } } diff --git a/backend/src/main/kotlin/fr/gouv/cacem/monitorenv/infrastructure/database/model/ReportingModel.kt b/backend/src/main/kotlin/fr/gouv/cacem/monitorenv/infrastructure/database/model/ReportingModel.kt index ea212570e..7d7c67934 100644 --- a/backend/src/main/kotlin/fr/gouv/cacem/monitorenv/infrastructure/database/model/ReportingModel.kt +++ b/backend/src/main/kotlin/fr/gouv/cacem/monitorenv/infrastructure/database/model/ReportingModel.kt @@ -129,6 +129,7 @@ class ReportingModel( val attachedEnvAction: EnvActionModel? = null, @Column(name = "updated_at_utc") @UpdateTimestamp val updatedAtUtc: Instant? = null, @Column(name = "with_vhf_answer") val withVHFAnswer: Boolean? = null, + @Column(name = "is_infraction_proven") val isInfractionProven: Boolean, ) { fun toReporting() = @@ -162,6 +163,7 @@ class ReportingModel( attachedEnvActionId = attachedEnvAction?.id, updatedAtUtc = updatedAtUtc?.atZone(UTC), withVHFAnswer = withVHFAnswer, + isInfractionProven = isInfractionProven, ) fun toReportingDTO(objectMapper: ObjectMapper) = @@ -236,6 +238,7 @@ class ReportingModel( attachedEnvAction = envActionReference, updatedAtUtc = reporting.updatedAtUtc?.toInstant(), withVHFAnswer = reporting.withVHFAnswer, + isInfractionProven = reporting.isInfractionProven, ) } } diff --git a/backend/src/main/resources/db/migration/internal/V0.129__update_reportings_table.sql b/backend/src/main/resources/db/migration/internal/V0.129__update_reportings_table.sql new file mode 100644 index 000000000..053f40cc9 --- /dev/null +++ b/backend/src/main/resources/db/migration/internal/V0.129__update_reportings_table.sql @@ -0,0 +1 @@ +ALTER TABLE public.reportings ADD COLUMN is_infraction_proven boolean NOT NULL DEFAULT TRUE; \ No newline at end of file diff --git a/backend/src/test/kotlin/fr/gouv/cacem/monitorenv/domain/use_cases/CreateOrUpdateReportingUTests.kt b/backend/src/test/kotlin/fr/gouv/cacem/monitorenv/domain/use_cases/CreateOrUpdateReportingUTests.kt index 615dd2899..ade4d34e9 100644 --- a/backend/src/test/kotlin/fr/gouv/cacem/monitorenv/domain/use_cases/CreateOrUpdateReportingUTests.kt +++ b/backend/src/test/kotlin/fr/gouv/cacem/monitorenv/domain/use_cases/CreateOrUpdateReportingUTests.kt @@ -100,6 +100,7 @@ class CreateOrUpdateReportingUTests { isDeleted = false, updatedAtUtc = ZonedDateTime.now(), openBy = "CDA", + isInfractionProven = true, ) val reportingWithSemaphoreDTO = ReportingDTO( @@ -124,6 +125,7 @@ class CreateOrUpdateReportingUTests { isDeleted = false, updatedAtUtc = ZonedDateTime.now(), openBy = "CDA", + isInfractionProven = true, ), ) val reportingWithControlUnit = @@ -147,6 +149,7 @@ class CreateOrUpdateReportingUTests { isDeleted = false, updatedAtUtc = ZonedDateTime.now(), openBy = "CDA", + isInfractionProven = true, ) val reportingWithControlUnitDTO = ReportingDTO( @@ -171,6 +174,7 @@ class CreateOrUpdateReportingUTests { isDeleted = false, updatedAtUtc = ZonedDateTime.now(), openBy = "CDA", + isInfractionProven = true, ), ) @@ -270,6 +274,7 @@ class CreateOrUpdateReportingUTests { isDeleted = false, updatedAtUtc = ZonedDateTime.now(), openBy = "CDA", + isInfractionProven = true, ) // When @@ -319,6 +324,7 @@ class CreateOrUpdateReportingUTests { isDeleted = false, updatedAtUtc = ZonedDateTime.now(), openBy = "CDA", + isInfractionProven = true, ) // When @@ -368,6 +374,7 @@ class CreateOrUpdateReportingUTests { isDeleted = false, updatedAtUtc = ZonedDateTime.now(), openBy = "CDA", + isInfractionProven = true, ) val reportingWithSemaphoreId = @@ -390,6 +397,7 @@ class CreateOrUpdateReportingUTests { isDeleted = false, updatedAtUtc = ZonedDateTime.now(), openBy = "CDA", + isInfractionProven = true, ) val reportingWithoutSourceName = ReportingEntity( @@ -410,6 +418,7 @@ class CreateOrUpdateReportingUTests { isDeleted = false, updatedAtUtc = ZonedDateTime.now(), openBy = "CDA", + isInfractionProven = true, ) // When @@ -496,6 +505,7 @@ class CreateOrUpdateReportingUTests { attachedToMissionAtUtc = ZonedDateTime.parse("2022-01-15T04:50:09Z"), detachedFromMissionAtUtc = null, updatedAtUtc = ZonedDateTime.now(), + isInfractionProven = true, ) // given(reportingRepository.save(reportingWithNewAttachedMission)) @@ -528,6 +538,7 @@ class CreateOrUpdateReportingUTests { ZonedDateTime.parse("2023-08-15T04:50:09Z"), detachedFromMissionAtUtc = null, updatedAtUtc = ZonedDateTime.now(), + isInfractionProven = true, ), ), ) diff --git a/backend/src/test/kotlin/fr/gouv/cacem/monitorenv/domain/use_cases/controlUnit/CanDeleteControlUnitUTests.kt b/backend/src/test/kotlin/fr/gouv/cacem/monitorenv/domain/use_cases/controlUnit/CanDeleteControlUnitUTests.kt index cff04227e..cdb418132 100644 --- a/backend/src/test/kotlin/fr/gouv/cacem/monitorenv/domain/use_cases/controlUnit/CanDeleteControlUnitUTests.kt +++ b/backend/src/test/kotlin/fr/gouv/cacem/monitorenv/domain/use_cases/controlUnit/CanDeleteControlUnitUTests.kt @@ -63,6 +63,7 @@ val FAKE_REPORTING = attachedToMissionAtUtc = null, detachedFromMissionAtUtc = null, attachedEnvActionId = null, + isInfractionProven = true, ) @ExtendWith(SpringExtension::class) diff --git a/backend/src/test/kotlin/fr/gouv/cacem/monitorenv/domain/use_cases/missions/DeleteMissionUTests.kt b/backend/src/test/kotlin/fr/gouv/cacem/monitorenv/domain/use_cases/missions/DeleteMissionUTests.kt index 5e9ba58dd..7dac84645 100644 --- a/backend/src/test/kotlin/fr/gouv/cacem/monitorenv/domain/use_cases/missions/DeleteMissionUTests.kt +++ b/backend/src/test/kotlin/fr/gouv/cacem/monitorenv/domain/use_cases/missions/DeleteMissionUTests.kt @@ -27,77 +27,83 @@ import java.util.* @ExtendWith(SpringExtension::class) class DeleteMissionUTests { - @MockBean - private lateinit var missionRepository: IMissionRepository + @MockBean private lateinit var missionRepository: IMissionRepository - @MockBean - private lateinit var reportingRepository: IReportingRepository + @MockBean private lateinit var reportingRepository: IReportingRepository - @MockBean - private lateinit var canDeleteMission: CanDeleteMission + @MockBean private lateinit var canDeleteMission: CanDeleteMission @Test fun `execute Should detach reporting attached to mission and action attached to reporting`() { val missionId = 100 - val reporting = ReportingEntity( - id = 1, - attachedEnvActionId = UUID.fromString("33310163-4e22-4d3d-b585-dac4431eb4b5"), - detachedFromMissionAtUtc = null, - isArchived = false, - createdAt = ZonedDateTime.parse("2022-01-23T20:29:03Z"), - isDeleted = false, - ) - val envActions = listOf( - EnvActionControlEntity( - id = - UUID.fromString( - "33310163-4e22-4d3d-b585-dac4431eb4b5", + val reporting = + ReportingEntity( + id = 1, + attachedEnvActionId = + UUID.fromString("33310163-4e22-4d3d-b585-dac4431eb4b5"), + detachedFromMissionAtUtc = null, + isArchived = false, + createdAt = ZonedDateTime.parse("2022-01-23T20:29:03Z"), + isDeleted = false, + isInfractionProven = true, + ) + val envActions = + listOf( + EnvActionControlEntity( + id = + UUID.fromString( + "33310163-4e22-4d3d-b585-dac4431eb4b5", + ), + geom = null, ), + ) + val missionToDelete = + MissionEntity( + id = missionId, + endDateTimeUtc = ZonedDateTime.parse("2022-01-23T20:29:03Z"), + envActions = envActions, + facade = "Outre-Mer", geom = null, - ), - ) - val missionToDelete = MissionEntity( - id = missionId, - endDateTimeUtc = ZonedDateTime.parse("2022-01-23T20:29:03Z"), - envActions = envActions, - facade = "Outre-Mer", - geom = null, - hasMissionOrder = false, - isDeleted = false, - isGeometryComputedFromControls = false, - isUnderJdp = false, - missionSource = MissionSourceEnum.MONITORENV, - missionTypes = listOf(MissionTypeEnum.LAND), - startDateTimeUtc = ZonedDateTime.parse("2022-01-27T20:29:03Z"), - ) + hasMissionOrder = false, + isDeleted = false, + isGeometryComputedFromControls = false, + isUnderJdp = false, + missionSource = MissionSourceEnum.MONITORENV, + missionTypes = listOf(MissionTypeEnum.LAND), + startDateTimeUtc = ZonedDateTime.parse("2022-01-27T20:29:03Z"), + ) - val expectedUpdatedReporting = ReportingEntity( - id = 1, - attachedEnvActionId = null, - createdAt = ZonedDateTime.parse("2022-01-23T20:29:03Z"), - detachedFromMissionAtUtc = ZonedDateTime.now(), - isArchived = false, - isDeleted = false, - ) + val expectedUpdatedReporting = + ReportingEntity( + id = 1, + attachedEnvActionId = null, + createdAt = ZonedDateTime.parse("2022-01-23T20:29:03Z"), + detachedFromMissionAtUtc = ZonedDateTime.now(), + isArchived = false, + isDeleted = false, + isInfractionProven = true, + ) given(canDeleteMission.execute(missionId, MissionSourceEnum.MONITORFISH)) .willReturn(CanDeleteMissionResponse(true, listOf())) - given(missionRepository.findFullMissionById(missionId)).willReturn( - MissionDTO( - mission = missionToDelete, - attachedReportingIds = listOf(1), - ), - - ) + given(missionRepository.findFullMissionById(missionId)) + .willReturn( + MissionDTO( + mission = missionToDelete, + attachedReportingIds = listOf(1), + ), + ) given(reportingRepository.findById(1)).willReturn(ReportingDTO(reporting = reporting)) - given(reportingRepository.save(expectedUpdatedReporting)).willReturn( - ReportingDTO(reporting = expectedUpdatedReporting), - ) + given(reportingRepository.save(expectedUpdatedReporting)) + .willReturn( + ReportingDTO(reporting = expectedUpdatedReporting), + ) DeleteMission( missionRepository = missionRepository, reportingRepository = reportingRepository, canDeleteMission = canDeleteMission, - ).execute(missionId, MissionSourceEnum.MONITORFISH) + ) + .execute(missionId, MissionSourceEnum.MONITORFISH) argumentCaptor().apply { verify(reportingRepository).save(capture()) @@ -124,81 +130,91 @@ class DeleteMissionUTests { geom = polygon, ) - val missionToDelete = MissionEntity( - id = missionId, - missionTypes = listOf(MissionTypeEnum.LAND), - facade = "Outre-Mer", - geom = null, - startDateTimeUtc = ZonedDateTime.parse("2022-01-15T04:50:09Z"), - endDateTimeUtc = ZonedDateTime.parse("2022-01-23T20:29:03Z"), - isDeleted = false, - missionSource = MissionSourceEnum.MONITORENV, - hasMissionOrder = false, - isUnderJdp = false, - isGeometryComputedFromControls = false, - envActions = listOf(envActionControl), - ) + val missionToDelete = + MissionEntity( + id = missionId, + missionTypes = listOf(MissionTypeEnum.LAND), + facade = "Outre-Mer", + geom = null, + startDateTimeUtc = ZonedDateTime.parse("2022-01-15T04:50:09Z"), + endDateTimeUtc = ZonedDateTime.parse("2022-01-23T20:29:03Z"), + isDeleted = false, + missionSource = MissionSourceEnum.MONITORENV, + hasMissionOrder = false, + isUnderJdp = false, + isGeometryComputedFromControls = false, + envActions = listOf(envActionControl), + ) given(canDeleteMission.execute(missionId, MissionSourceEnum.MONITORFISH)) .willReturn(CanDeleteMissionResponse(false, listOf(MissionSourceEnum.MONITORENV))) - given(missionRepository.findFullMissionById(missionId)).willReturn( - MissionDTO( - mission = missionToDelete, - attachedReportingIds = null, - ), - ) - - val throwable = Assertions.catchThrowable { - DeleteMission( - missionRepository = missionRepository, - reportingRepository = reportingRepository, - canDeleteMission = canDeleteMission, - ).execute(missionId, MissionSourceEnum.MONITORFISH) - } + given(missionRepository.findFullMissionById(missionId)) + .willReturn( + MissionDTO( + mission = missionToDelete, + attachedReportingIds = null, + ), + ) - val errorSources = object { - var sources = listOf(MissionSourceEnum.MONITORENV) - } - Assertions.assertThat(throwable).isInstanceOf( - BackendUsageException( - code = BackendUsageErrorCode.EXISTING_MISSION_ACTION, - data = errorSources, - )::class.java, - ) + val throwable = + Assertions.catchThrowable { + DeleteMission( + missionRepository = missionRepository, + reportingRepository = reportingRepository, + canDeleteMission = canDeleteMission, + ) + .execute(missionId, MissionSourceEnum.MONITORFISH) + } + + val errorSources = + object { + var sources = listOf(MissionSourceEnum.MONITORENV) + } + Assertions.assertThat(throwable) + .isInstanceOf( + BackendUsageException( + code = BackendUsageErrorCode.EXISTING_MISSION_ACTION, + data = errorSources, + )::class + .java, + ) } @Test fun `execute should delete mission when canDeleteMission returns true`() { val missionId = 100 - val missionToDelete = MissionEntity( - id = missionId, - missionTypes = listOf(MissionTypeEnum.LAND), - facade = "Outre-Mer", - geom = null, - startDateTimeUtc = ZonedDateTime.parse("2022-01-15T04:50:09Z"), - endDateTimeUtc = ZonedDateTime.parse("2022-01-23T20:29:03Z"), - isDeleted = false, - missionSource = MissionSourceEnum.MONITORENV, - hasMissionOrder = false, - isUnderJdp = false, - isGeometryComputedFromControls = false, - envActions = listOf(), - ) + val missionToDelete = + MissionEntity( + id = missionId, + missionTypes = listOf(MissionTypeEnum.LAND), + facade = "Outre-Mer", + geom = null, + startDateTimeUtc = ZonedDateTime.parse("2022-01-15T04:50:09Z"), + endDateTimeUtc = ZonedDateTime.parse("2022-01-23T20:29:03Z"), + isDeleted = false, + missionSource = MissionSourceEnum.MONITORENV, + hasMissionOrder = false, + isUnderJdp = false, + isGeometryComputedFromControls = false, + envActions = listOf(), + ) given(canDeleteMission.execute(missionId, MissionSourceEnum.MONITORFISH)) .willReturn(CanDeleteMissionResponse(true, listOf())) - given(missionRepository.findFullMissionById(missionId)).willReturn( - MissionDTO( - mission = missionToDelete, - attachedReportingIds = listOf(), - ), - ) + given(missionRepository.findFullMissionById(missionId)) + .willReturn( + MissionDTO( + mission = missionToDelete, + attachedReportingIds = listOf(), + ), + ) DeleteMission( missionRepository = missionRepository, reportingRepository = reportingRepository, canDeleteMission = canDeleteMission, - ).execute(missionId, MissionSourceEnum.MONITORFISH) + ) + .execute(missionId, MissionSourceEnum.MONITORFISH) verify(missionRepository).delete(missionId) } diff --git a/backend/src/test/kotlin/fr/gouv/cacem/monitorenv/domain/use_cases/missions/TestUtils.kt b/backend/src/test/kotlin/fr/gouv/cacem/monitorenv/domain/use_cases/missions/TestUtils.kt index a4a01f5e2..fadd6c397 100644 --- a/backend/src/test/kotlin/fr/gouv/cacem/monitorenv/domain/use_cases/missions/TestUtils.kt +++ b/backend/src/test/kotlin/fr/gouv/cacem/monitorenv/domain/use_cases/missions/TestUtils.kt @@ -42,6 +42,7 @@ object TestUtils { isArchived = false, isDeleted = false, openBy = "CDA", + isInfractionProven = true, ), ) } @@ -84,6 +85,7 @@ object TestUtils { "2022-01-15T04:50:09Z", ), detachedFromMissionAtUtc = null, + isInfractionProven = true, ), ) } diff --git a/backend/src/test/kotlin/fr/gouv/cacem/monitorenv/infrastructure/api/endpoints/bff/MissionsITests.kt b/backend/src/test/kotlin/fr/gouv/cacem/monitorenv/infrastructure/api/endpoints/bff/MissionsITests.kt index 2f521dbc2..828da94ea 100644 --- a/backend/src/test/kotlin/fr/gouv/cacem/monitorenv/infrastructure/api/endpoints/bff/MissionsITests.kt +++ b/backend/src/test/kotlin/fr/gouv/cacem/monitorenv/infrastructure/api/endpoints/bff/MissionsITests.kt @@ -147,7 +147,8 @@ class MissionsITests { MissionEntity( id = 10, missionTypes = listOf(MissionTypeEnum.SEA), - startDateTimeUtc = ZonedDateTime.parse("2022-01-15T04:50:09Z"), + startDateTimeUtc = + ZonedDateTime.parse("2022-01-15T04:50:09Z"), isDeleted = false, missionSource = MissionSourceEnum.MONITORFISH, hasMissionOrder = false, @@ -292,6 +293,7 @@ class MissionsITests { isArchived = false, isDeleted = false, openBy = "OpenBy", + isInfractionProven = true, ), semaphore = SemaphoreEntity( @@ -602,6 +604,7 @@ class MissionsITests { isArchived = false, isDeleted = false, openBy = "OpenBy", + isInfractionProven = true, ), semaphore = SemaphoreEntity( diff --git a/backend/src/test/kotlin/fr/gouv/cacem/monitorenv/infrastructure/api/endpoints/bff/ReportingsITests.kt b/backend/src/test/kotlin/fr/gouv/cacem/monitorenv/infrastructure/api/endpoints/bff/ReportingsITests.kt index 85bfa2d9e..8c9059928 100644 --- a/backend/src/test/kotlin/fr/gouv/cacem/monitorenv/infrastructure/api/endpoints/bff/ReportingsITests.kt +++ b/backend/src/test/kotlin/fr/gouv/cacem/monitorenv/infrastructure/api/endpoints/bff/ReportingsITests.kt @@ -107,6 +107,7 @@ class ReportingsITests { "2022-01-15T14:50:09Z", ), withVHFAnswer = null, + isInfractionProven = true, ), semaphore = SemaphoreEntity( @@ -146,6 +147,7 @@ class ReportingsITests { ZonedDateTime.parse( "2022-01-15T14:50:09Z", ), + isInfractionProven = true, ) given(createOrUpdateReporting.execute(any())).willReturn(reporting) @@ -224,6 +226,7 @@ class ReportingsITests { ZonedDateTime.parse( "2022-01-15T14:50:09Z", ), + isInfractionProven = true, ), semaphore = SemaphoreEntity( @@ -305,6 +308,7 @@ class ReportingsITests { isArchived = false, isDeleted = false, openBy = "CDA", + isInfractionProven = true, ), ) @@ -370,6 +374,7 @@ class ReportingsITests { ZonedDateTime.parse( "2022-01-15T14:50:09Z", ), + isInfractionProven = true, ), semaphore = SemaphoreEntity( @@ -409,6 +414,7 @@ class ReportingsITests { ZonedDateTime.parse( "2022-01-15T14:50:09Z", ), + isInfractionProven = true, ), ) @@ -524,6 +530,7 @@ class ReportingsITests { ZonedDateTime.parse( "2022-01-15T14:50:09Z", ), + isInfractionProven = true, ), ), ) @@ -543,11 +550,17 @@ class ReportingsITests { // Then val missionUpdateEvent = - mockedApi.perform(get("/bff/v1/reportings/sse")) + mockedApi + .perform(get("/bff/v1/reportings/sse")) .andExpect(status().isOk) .andExpect(MockMvcResultMatchers.request().asyncStarted()) - .andExpect(MockMvcResultMatchers.request().asyncResult(Matchers.nullValue())) - .andExpect(MockMvcResultMatchers.header().string("Content-Type", "text/event-stream")) + .andExpect( + MockMvcResultMatchers.request().asyncResult(Matchers.nullValue()), + ) + .andExpect( + MockMvcResultMatchers.header() + .string("Content-Type", "text/event-stream"), + ) .andDo(MockMvcResultHandlers.log()) .andReturn() .response @@ -556,7 +569,7 @@ class ReportingsITests { Assertions.assertThat(missionUpdateEvent).contains("event:REPORTING_UPDATE") Assertions.assertThat(missionUpdateEvent) .contains( - "data:{\"id\":1,\"reportingId\":null,\"sourceType\":\"SEMAPHORE\",\"semaphoreId\":1,\"semaphore\":null,\"controlUnitId\":null,\"controlUnit\":null,\"displayedSource\":null,\"sourceName\":null,\"targetType\":null,\"vehicleType\":null,\"targetDetails\":[],\"geom\":{\"type\":\"MultiPolygon\",\"coordinates\":[[[[-61,14],[-61,15],[-60,15],[-60,14],[-61,14]]]]},\"seaFront\":null,\"description\":\"description\",\"reportType\":\"INFRACTION_SUSPICION\",\"themeId\":12,\"subThemeIds\":[64,82],\"actionTaken\":null,\"isControlRequired\":true,\"hasNoUnitAvailable\":true,\"createdAt\":\"2022-01-15T04:50:09Z\",\"validityTime\":10,\"isArchived\":false,\"openBy\":\"CDA\",\"missionId\":null,\"attachedToMissionAtUtc\":null,\"detachedFromMissionAtUtc\":null,\"attachedEnvActionId\":null,\"attachedMission\":null,\"controlStatus\":\"CONTROL_TO_BE_DONE\",\"updatedAtUtc\":\"2022-01-15T14:50:09Z\",\"withVHFAnswer\":null}\n", + "data:{\"id\":1,\"reportingId\":null,\"sourceType\":\"SEMAPHORE\",\"semaphoreId\":1,\"semaphore\":null,\"controlUnitId\":null,\"controlUnit\":null,\"displayedSource\":null,\"sourceName\":null,\"targetType\":null,\"vehicleType\":null,\"targetDetails\":[],\"geom\":{\"type\":\"MultiPolygon\",\"coordinates\":[[[[-61,14],[-61,15],[-60,15],[-60,14],[-61,14]]]]},\"seaFront\":null,\"description\":\"description\",\"reportType\":\"INFRACTION_SUSPICION\",\"themeId\":12,\"subThemeIds\":[64,82],\"actionTaken\":null,\"isControlRequired\":true,\"hasNoUnitAvailable\":true,\"createdAt\":\"2022-01-15T04:50:09Z\",\"validityTime\":10,\"isArchived\":false,\"openBy\":\"CDA\",\"missionId\":null,\"attachedToMissionAtUtc\":null,\"detachedFromMissionAtUtc\":null,\"attachedEnvActionId\":null,\"attachedMission\":null,\"controlStatus\":\"CONTROL_TO_BE_DONE\",\"updatedAtUtc\":\"2022-01-15T14:50:09Z\",\"withVHFAnswer\":null,\"isInfractionProven\":true}\n", ) } } diff --git a/backend/src/test/kotlin/fr/gouv/cacem/monitorenv/infrastructure/database/repositories/JpaReportingRepositoryITests.kt b/backend/src/test/kotlin/fr/gouv/cacem/monitorenv/infrastructure/database/repositories/JpaReportingRepositoryITests.kt index 6b98b8a8f..759c3f580 100644 --- a/backend/src/test/kotlin/fr/gouv/cacem/monitorenv/infrastructure/database/repositories/JpaReportingRepositoryITests.kt +++ b/backend/src/test/kotlin/fr/gouv/cacem/monitorenv/infrastructure/database/repositories/JpaReportingRepositoryITests.kt @@ -391,6 +391,7 @@ class JpaReportingRepositoryITests : AbstractDBTests() { isArchived = false, isDeleted = false, openBy = "CDA", + isInfractionProven = true, ) jpaReportingRepository.save(newReporting) diff --git a/frontend/src/domain/entities/reporting.ts b/frontend/src/domain/entities/reporting.ts index 569afa07c..fefd5115a 100644 --- a/frontend/src/domain/entities/reporting.ts +++ b/frontend/src/domain/entities/reporting.ts @@ -20,6 +20,7 @@ export type Reporting = { id: number | string isArchived: boolean isControlRequired: boolean | undefined + isInfractionProven: boolean missionId: number | undefined openBy: string reportType: ReportingTypeEnum @@ -49,6 +50,27 @@ export type DetachedReporting = { reportingId: number } +export enum InfractionProvenEnum { + NOT_PROVEN = 'NOT_PROVEN', + PROVEN = 'PROVEN' +} + +export const InfractionProvenLabels = { + PROVEN: { + label: 'Avéré', + value: true + }, + // eslint-disable-next-line sort-keys-fix/sort-keys-fix + NOT_PROVEN: { + label: 'Non avéré', + value: false + } +} + +export enum ProvenFiltersLabels { + PROVEN = 'Avéré', + NOT_PROVEN = 'Non avéré' +} export enum ControlStatusEnum { CONTROL_TO_BE_DONE = 'CONTROL_TO_BE_DONE', CONTROL_DONE = 'CONTROL_DONE', diff --git a/frontend/src/features/Reportings/ReportingForm/FormContent.tsx b/frontend/src/features/Reportings/ReportingForm/FormContent.tsx index ea6e67045..f66f662f4 100644 --- a/frontend/src/features/Reportings/ReportingForm/FormContent.tsx +++ b/frontend/src/features/Reportings/ReportingForm/FormContent.tsx @@ -6,6 +6,7 @@ import { FormikMultiRadio, FormikTextarea, getOptionsFromLabelledEnum, + Label, Toggle } from '@mtes-mct/monitor-ui' import { getDateAsLocalizedStringVeryCompact } from '@utils/getDateAsLocalizedString' @@ -33,7 +34,8 @@ import { ReportingTypeEnum, ReportingTypeLabels, type ReportingDetailed, - INDIVIDUAL_ANCHORING_THEME_ID + INDIVIDUAL_ANCHORING_THEME_ID, + InfractionProvenLabels } from '../../../domain/entities/reporting' import { setReportingFormVisibility, @@ -59,7 +61,8 @@ import { StyledFormikTextInput, ReportTypeMultiRadio, SaveBanner, - StyledItalic + StyledItalic, + StyledInfractionProven } from '../style' import type { AtLeast } from '../../../types' @@ -120,6 +123,7 @@ export function FormContent({ reducedReportingsOnContext, selectedReporting }: F useSyncFormValuesWithRedux(isAutoSaveEnabled) + const infractionProvenOptions = Object.values(InfractionProvenLabels) const reportTypeOptions = getOptionsFromLabelledEnum(ReportingTypeLabels) const withVHFAnswerOptions = [ { label: 'Oui', value: true }, @@ -319,6 +323,18 @@ export function FormContent({ reducedReportingsOnContext, selectedReporting }: F + + + + + | Reporting): AtLeast { return { geom: undefined, + isInfractionProven: true, sourceType: ReportingSourceEnum.SEMAPHORE, validityTime: 24, ...reporting