-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Préavis – Afficher la liste de diffusion (unités et leurs contacts) d…
…ans les préavis et si la diffusion a réussi ou non (#3669) ## Cas non gérés - La liste des inscrits est générée à partir de l'historique des messages envoyés, cela veut donc dire qu'elle est vide tant qu'un message n'a pas encore été envoyé. ## Linked issues - Resolve #3598 ## Screenshots ![image](https://github.com/user-attachments/assets/369d8c1a-d10d-4f70-882e-29bfe90c2689) ---- - [x] Tests E2E (Cypress)
- Loading branch information
Showing
47 changed files
with
3,049 additions
and
2,758 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
.../gouv/cnsp/monitorfish/domain/entities/prior_notification/PriorNotificationSentMessage.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,16 @@ | ||
package fr.gouv.cnsp.monitorfish.domain.entities.prior_notification | ||
|
||
import java.time.ZonedDateTime | ||
|
||
data class PriorNotificationSentMessage( | ||
val id: Int, | ||
val communicationMeans: String, | ||
val dateTimeUtc: ZonedDateTime, | ||
val errorMessage: String?, | ||
val priorNotificationReportId: String?, | ||
val priorNotificationSource: String, | ||
val recipientAddressOrNumber: String, | ||
val recipientName: String, | ||
val recipientOrganization: String, | ||
val success: Boolean, | ||
) |
7 changes: 7 additions & 0 deletions
7
...in/fr/gouv/cnsp/monitorfish/domain/repositories/PriorNotificationSentMessageRepository.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,7 @@ | ||
package fr.gouv.cnsp.monitorfish.domain.repositories | ||
|
||
import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationSentMessage | ||
|
||
interface PriorNotificationSentMessageRepository { | ||
fun findAllByReportId(reportId: String): List<PriorNotificationSentMessage> | ||
} |
14 changes: 14 additions & 0 deletions
14
.../cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSentMessages.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,14 @@ | ||
package fr.gouv.cnsp.monitorfish.domain.use_cases.prior_notification | ||
|
||
import fr.gouv.cnsp.monitorfish.config.UseCase | ||
import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationSentMessage | ||
import fr.gouv.cnsp.monitorfish.domain.repositories.* | ||
|
||
@UseCase | ||
class GetPriorNotificationSentMessages( | ||
private val priorNotificationSentMessageRepository: PriorNotificationSentMessageRepository, | ||
) { | ||
fun execute(reportId: String): List<PriorNotificationSentMessage> { | ||
return priorNotificationSentMessageRepository.findAllByReportId(reportId) | ||
} | ||
} |
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
32 changes: 32 additions & 0 deletions
32
...ouv/cnsp/monitorfish/infrastructure/api/outputs/PriorNotificationSentMessageDataOutput.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,32 @@ | ||
package fr.gouv.cnsp.monitorfish.infrastructure.api.outputs | ||
|
||
import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationSentMessage | ||
import java.time.ZonedDateTime | ||
|
||
data class PriorNotificationSentMessageDataOutput( | ||
val id: Int, | ||
val communicationMeans: String, | ||
val dateTimeUtc: ZonedDateTime, | ||
val errorMessage: String?, | ||
val recipientAddressOrNumber: String, | ||
val recipientName: String, | ||
val recipientOrganization: String, | ||
val success: Boolean, | ||
) { | ||
companion object { | ||
fun fromPriorNotificationSentMessage( | ||
priorNotificationSentMessage: PriorNotificationSentMessage, | ||
): PriorNotificationSentMessageDataOutput { | ||
return PriorNotificationSentMessageDataOutput( | ||
id = priorNotificationSentMessage.id, | ||
communicationMeans = priorNotificationSentMessage.communicationMeans, | ||
dateTimeUtc = priorNotificationSentMessage.dateTimeUtc, | ||
errorMessage = priorNotificationSentMessage.errorMessage, | ||
recipientAddressOrNumber = priorNotificationSentMessage.recipientAddressOrNumber, | ||
recipientName = priorNotificationSentMessage.recipientName, | ||
recipientOrganization = priorNotificationSentMessage.recipientOrganization, | ||
success = priorNotificationSentMessage.success, | ||
) | ||
} | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
...v/cnsp/monitorfish/infrastructure/database/entities/PriorNotificationSentMessageEntity.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,49 @@ | ||
package fr.gouv.cnsp.monitorfish.infrastructure.database.entities | ||
|
||
import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationSentMessage | ||
import jakarta.persistence.* | ||
import org.hibernate.annotations.Immutable | ||
import java.time.ZonedDateTime | ||
|
||
@Entity | ||
@Immutable | ||
@Table(name = "prior_notification_sent_messages") | ||
data class PriorNotificationSentMessageEntity( | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "id", unique = true, nullable = false) | ||
val id: Int, | ||
@Column(name = "communication_means", nullable = false) | ||
val communicationMeans: String, | ||
@Column(name = "date_time_utc", nullable = false) | ||
val dateTimeUtc: ZonedDateTime, | ||
@Column(name = "error_message", nullable = true) | ||
val errorMessage: String?, | ||
@Column(name = "prior_notification_report_id", nullable = false) | ||
val priorNotificationReportId: String?, | ||
@Column(name = "prior_notification_source", nullable = false) | ||
val priorNotificationSource: String, | ||
@Column(name = "recipient_address_or_number", nullable = false) | ||
val recipientAddressOrNumber: String, | ||
@Column(name = "recipient_name", nullable = false) | ||
val recipientName: String, | ||
@Column(name = "recipient_organization", nullable = false) | ||
val recipientOrganization: String, | ||
@Column(name = "success", nullable = false) | ||
val success: Boolean, | ||
) { | ||
fun toPriorNotificationSentMessage(): PriorNotificationSentMessage { | ||
return PriorNotificationSentMessage( | ||
id = id, | ||
communicationMeans = communicationMeans, | ||
dateTimeUtc = dateTimeUtc, | ||
errorMessage = errorMessage, | ||
priorNotificationReportId = priorNotificationReportId, | ||
priorNotificationSource = priorNotificationSource, | ||
recipientAddressOrNumber = recipientAddressOrNumber, | ||
recipientName = recipientName, | ||
recipientOrganization = recipientOrganization, | ||
success = success, | ||
) | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...torfish/infrastructure/database/repositories/JpaPriorNotificationSentMessageRepository.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.cnsp.monitorfish.infrastructure.database.repositories | ||
|
||
import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationSentMessage | ||
import fr.gouv.cnsp.monitorfish.domain.repositories.PriorNotificationSentMessageRepository | ||
import fr.gouv.cnsp.monitorfish.infrastructure.database.repositories.interfaces.DBPriorNotificationSentMessageRepository | ||
import org.springframework.stereotype.Repository | ||
|
||
@Repository | ||
class JpaPriorNotificationSentMessageRepository( | ||
private val dbPriorNotificationSentMessageRepository: DBPriorNotificationSentMessageRepository, | ||
) : PriorNotificationSentMessageRepository { | ||
override fun findAllByReportId(reportId: String): List<PriorNotificationSentMessage> { | ||
return dbPriorNotificationSentMessageRepository | ||
.findAllByReportId(reportId) | ||
.map { it.toPriorNotificationSentMessage() } | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...frastructure/database/repositories/interfaces/DBPriorNotificationSentMessageRepository.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.cnsp.monitorfish.infrastructure.database.repositories.interfaces | ||
|
||
import fr.gouv.cnsp.monitorfish.infrastructure.database.entities.PriorNotificationSentMessageEntity | ||
import org.springframework.data.jpa.repository.JpaRepository | ||
import org.springframework.data.jpa.repository.Query | ||
|
||
interface DBPriorNotificationSentMessageRepository : JpaRepository<PriorNotificationSentMessageEntity, String> { | ||
@Query( | ||
""" | ||
SELECT * | ||
FROM prior_notification_sent_messages | ||
WHERE prior_notification_report_id = :reportId | ||
""", | ||
nativeQuery = true, | ||
) | ||
fun findAllByReportId(reportId: String): List<PriorNotificationSentMessageEntity> | ||
} |
5 changes: 5 additions & 0 deletions
5
...resources/db/migration/internal/V0.280__Update_prior_notification_sent_messages_table.sql
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,5 @@ | ||
DELETE FROM public.prior_notification_sent_messages; | ||
|
||
ALTER TABLE public.prior_notification_sent_messages | ||
ADD COLUMN recipient_name VARCHAR NOT NULL, | ||
ADD COLUMN recipient_organization VARCHAR NOT NULL; |
39 changes: 39 additions & 0 deletions
39
...src/main/resources/db/testdata/V666.29__Insert_dummy_prior_notification_sent_messages.sql
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,39 @@ | ||
INSERT INTO public.prior_notification_sent_messages ( | ||
prior_notification_report_id, prior_notification_source, date_time_utc, communication_means, recipient_address_or_number, success, error_message, recipient_name, recipient_organization | ||
) VALUES | ||
( 'FAKE_OPERATION_103', 'LOGBOOK', NOW() AT TIME ZONE 'UTC' - INTERVAL '2.0 minutes', 'EMAIL', '[email protected]', TRUE, NULL, 'Unité 1', 'Douane'), | ||
|
||
( 'FAKE_OPERATION_106', 'LOGBOOK', NOW() AT TIME ZONE 'UTC' - INTERVAL '2.0 minutes', 'EMAIL', '[email protected]', TRUE, NULL, 'Unité 1', 'Douane'), | ||
( 'FAKE_OPERATION_106', 'LOGBOOK', NOW() AT TIME ZONE 'UTC' - INTERVAL '2.0 minutes', 'EMAIL', '[email protected]', TRUE, NULL, 'Unité 3', 'Gendarmerie'), | ||
|
||
( 'FAKE_OPERATION_108', 'LOGBOOK', NOW() AT TIME ZONE 'UTC' - INTERVAL '2.3 minutes', 'EMAIL', '[email protected]', FALSE, NULL, 'Unité 3', 'Gendarmerie'), | ||
( 'FAKE_OPERATION_108', 'LOGBOOK', NOW() AT TIME ZONE 'UTC' - INTERVAL '2.0 minutes', 'EMAIL', '[email protected]', FALSE, NULL, 'Unité 4', 'Gendarmerie'), | ||
( 'FAKE_OPERATION_108', 'LOGBOOK', NOW() AT TIME ZONE 'UTC' - INTERVAL '2.1 minutes', 'SMS', '+33123456789', FALSE, NULL, 'Unité 3', 'Gendarmerie'), | ||
( 'FAKE_OPERATION_108', 'LOGBOOK', NOW() AT TIME ZONE 'UTC' - INTERVAL '2.2 minutes', 'SMS', '+33987654321', FALSE, NULL, 'Unité 4', 'Gendarmerie'), | ||
|
||
( 'FAKE_OPERATION_108', 'LOGBOOK', NOW() AT TIME ZONE 'UTC' - INTERVAL '4.0 minutes', 'EMAIL', '[email protected]', FALSE, NULL, 'Unité 3', 'Gendarmerie'), | ||
( 'FAKE_OPERATION_108', 'LOGBOOK', NOW() AT TIME ZONE 'UTC' - INTERVAL '4.1 minutes', 'EMAIL', '[email protected]', TRUE, NULL, 'Unité 4', 'Gendarmerie'), | ||
( 'FAKE_OPERATION_108', 'LOGBOOK', NOW() AT TIME ZONE 'UTC' - INTERVAL '4.2 minutes', 'EMAIL', '[email protected]', FALSE, NULL, 'Unité 5', 'DDTM 40'), | ||
( 'FAKE_OPERATION_108', 'LOGBOOK', NOW() AT TIME ZONE 'UTC' - INTERVAL '4.3 minutes', 'SMS', '+33123456789', TRUE, NULL, 'Unité 3', 'Gendarmerie'), | ||
( 'FAKE_OPERATION_108', 'LOGBOOK', NOW() AT TIME ZONE 'UTC' - INTERVAL '4.4 minutes', 'SMS', '+33987654321', FALSE, NULL, 'Unité 4', 'Gendarmerie'), | ||
( 'FAKE_OPERATION_108', 'LOGBOOK', NOW() AT TIME ZONE 'UTC' - INTERVAL '4.5 minutes', 'SMS', '+33000000000', FALSE, NULL, 'Unité 5', 'DDTM 40'), | ||
|
||
( 'FAKE_OPERATION_108', 'LOGBOOK', NOW() AT TIME ZONE 'UTC' - INTERVAL '9.3 minutes', 'EMAIL', '[email protected]', TRUE, NULL, 'Unité 3', 'Gendarmerie'), | ||
( 'FAKE_OPERATION_108', 'LOGBOOK', NOW() AT TIME ZONE 'UTC' - INTERVAL '9.2 minutes', 'EMAIL', '[email protected]', TRUE, NULL, 'Unité 4', 'Gendarmerie'), | ||
( 'FAKE_OPERATION_108', 'LOGBOOK', NOW() AT TIME ZONE 'UTC' - INTERVAL '9.1 minutes', 'SMS', '+33123456789', TRUE, NULL, 'Unité 3', 'Gendarmerie'), | ||
( 'FAKE_OPERATION_108', 'LOGBOOK', NOW() AT TIME ZONE 'UTC' - INTERVAL '9.0 minutes', 'SMS', '+33987654321', TRUE, NULL, 'Unité 4', 'Gendarmerie'), | ||
|
||
( 'FAKE_OPERATION_110', 'LOGBOOK', NOW() AT TIME ZONE 'UTC' - INTERVAL '2.0 minutes', 'EMAIL', '[email protected]', TRUE, NULL, 'Unité 6', 'DDTM'), | ||
( 'FAKE_OPERATION_110', 'LOGBOOK', NOW() AT TIME ZONE 'UTC' - INTERVAL '2.0 minutes', 'EMAIL', '[email protected]', FALSE, NULL, 'Unité 7', 'Office Français de la Biodiversité'), | ||
( 'FAKE_OPERATION_110', 'LOGBOOK', NOW() AT TIME ZONE 'UTC' - INTERVAL '2.0 minutes', 'SMS', '+33111111111', FALSE, NULL, 'Unité 7', 'Office Français de la Biodiversité'), | ||
|
||
('00000000-0000-4000-0000-000000000003', 'MANUAL', NOW() AT TIME ZONE 'UTC' - INTERVAL '2.0 minutes', 'EMAIL', '[email protected]', TRUE, NULL, 'Unité 9', 'DDTM'), | ||
('00000000-0000-4000-0000-000000000003', 'MANUAL', NOW() AT TIME ZONE 'UTC' - INTERVAL '2.0 minutes', 'EMAIL', '[email protected]', FALSE, NULL, 'Unité 10', 'DIRM / DM'), | ||
|
||
('00000000-0000-4000-0000-000000000004', 'MANUAL', NOW() AT TIME ZONE 'UTC' - INTERVAL '2.0 minutes', 'EMAIL', '[email protected]', FALSE, NULL, 'Unité 11', 'DDTM'), | ||
|
||
('00000000-0000-4000-0000-000000000006', 'MANUAL', NOW() AT TIME ZONE 'UTC' - INTERVAL '2.0 minutes', 'EMAIL', '[email protected]', TRUE, NULL, 'Unité 11', 'DDTM'), | ||
|
||
('00000000-0000-4000-0000-000000000008', 'MANUAL', NOW() AT TIME ZONE 'UTC' - INTERVAL '2.0 minutes', 'EMAIL', '[email protected]', FALSE, NULL, 'Unité 12', 'DIRM / DM'), | ||
|
||
('00000000-0000-4000-0000-000000000010', 'MANUAL', NOW() AT TIME ZONE 'UTC' - INTERVAL '2.0 minutes', 'EMAIL', '[email protected]', TRUE, NULL, 'Unité 12', 'DIRM / DM'); |
59 changes: 59 additions & 0 deletions
59
...monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSentMessagesUTests.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,59 @@ | ||
package fr.gouv.cnsp.monitorfish.domain.use_cases.prior_notification | ||
|
||
import com.nhaarman.mockitokotlin2.given | ||
import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationSentMessage | ||
import fr.gouv.cnsp.monitorfish.domain.repositories.PriorNotificationSentMessageRepository | ||
import org.assertj.core.api.Assertions.assertThat | ||
import org.junit.jupiter.api.Test | ||
import org.junit.jupiter.api.extension.ExtendWith | ||
import org.springframework.boot.test.mock.mockito.MockBean | ||
import org.springframework.test.context.junit.jupiter.SpringExtension | ||
import java.time.ZonedDateTime | ||
|
||
@ExtendWith(SpringExtension::class) | ||
class GetPriorNotificationSentMessagesUTests { | ||
@MockBean | ||
private lateinit var priorNotificationSentMessageRepository: PriorNotificationSentMessageRepository | ||
|
||
@Test | ||
fun `execute Should return a list of prior notification types`() { | ||
// Given | ||
val fakeReportId = "FAKE_REPORT_ID" | ||
given(priorNotificationSentMessageRepository.findAllByReportId(fakeReportId)).willReturn( | ||
listOf( | ||
PriorNotificationSentMessage( | ||
id = 1, | ||
communicationMeans = "EMAIL", | ||
dateTimeUtc = ZonedDateTime.now(), | ||
errorMessage = null, | ||
priorNotificationReportId = fakeReportId, | ||
priorNotificationSource = "LOGBOOK", | ||
recipientAddressOrNumber = "[email protected]", | ||
recipientName = "DREAL 01", | ||
recipientOrganization = "DREAL", | ||
success = true, | ||
), | ||
PriorNotificationSentMessage( | ||
id = 2, | ||
communicationMeans = "SMS", | ||
dateTimeUtc = ZonedDateTime.now(), | ||
errorMessage = null, | ||
priorNotificationReportId = fakeReportId, | ||
priorNotificationSource = "MANUAL", | ||
recipientAddressOrNumber = "+33123456789", | ||
recipientName = "DREAL 02", | ||
recipientOrganization = "DREAL", | ||
success = true, | ||
), | ||
), | ||
) | ||
|
||
// When | ||
val result = GetPriorNotificationSentMessages(priorNotificationSentMessageRepository).execute(fakeReportId) | ||
|
||
// Then | ||
assertThat(result).hasSize(2) | ||
assertThat(result[0].communicationMeans).isEqualTo("EMAIL") | ||
assertThat(result[1].communicationMeans).isEqualTo("SMS") | ||
} | ||
} |
Oops, something went wrong.