Skip to content

Commit

Permalink
Préavis – Ajout du CFR dans la recherche de navires (#3497)
Browse files Browse the repository at this point in the history
## Linked issues

- Resolve #3456

----

- [ ] Tests E2E (Cypress)
  • Loading branch information
louptheron authored Aug 7, 2024
2 parents bd371d8 + 3521d37 commit b34ae94
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ interface DBLogbookReportRepository :
AND (:portLocodes IS NULL OR lr.value->>'port' IN (:portLocodes))
-- Search Query
AND (:searchQuery IS NULL OR unaccent(lower(lr.vessel_name)) ILIKE CONCAT('%', unaccent(lower(:searchQuery)), '%'))
AND (
:searchQuery IS NULL OR
unaccent(lower(lr.vessel_name)) ILIKE CONCAT('%', unaccent(lower(:searchQuery)), '%') OR
lower(lr.cfr) ILIKE CONCAT('%', lower(:searchQuery), '%')
)
-- Will Arrive After
AND lr.value->>'predictedArrivalDatetimeUtc' >= :willArriveAfter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ interface DBManualPriorNotificationRepository : JpaRepository<ManualPriorNotific
AND (:portLocodes IS NULL OR mpn.value->>'port' IN (:portLocodes))
-- Search Query
AND (:searchQuery IS NULL OR unaccent(lower(mpn.vessel_name)) ILIKE CONCAT('%', unaccent(lower(:searchQuery)), '%'))
AND (
:searchQuery IS NULL OR
unaccent(lower(mpn.vessel_name)) ILIKE CONCAT('%', unaccent(lower(:searchQuery)), '%') OR
lower(mpn.cfr) ILIKE CONCAT('%', lower(:searchQuery), '%')
)
-- Will Arrive After
AND mpn.value->>'predictedArrivalDatetimeUtc' >= :willArriveAfter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ class JpaLogbookReportRepositoryITests : AbstractDBTests() {

@Test
@Transactional
fun `findAllPriorNotifications Should return PNO logbook reports for PHENOMENE vessel`() {
fun `findAllPriorNotifications Should return PNO logbook reports When using a vessel name`() {
// Given
val firstFilter = PriorNotificationsFilter(
searchQuery = "pheno",
Expand Down Expand Up @@ -770,6 +770,50 @@ class JpaLogbookReportRepositoryITests : AbstractDBTests() {
assertThat(secondResultVessels.all { it.vesselName == "PHENOMENE" }).isTrue()
}

@Test
@Transactional
fun `findAllPriorNotifications Should return PNO logbook reports When using a CFR`() {
// Given
val firstFilter = PriorNotificationsFilter(
searchQuery = "FAK000999999",
willArriveAfter = "2000-01-01T00:00:00Z",
willArriveBefore = "2100-01-01T00:00:00Z",
)

// When
val firstResult = jpaLogbookReportRepository.findAllPriorNotifications(firstFilter)

// Then
assertThat(firstResult).hasSizeGreaterThan(0)
val firstResultVessels = firstResult.mapNotNull {
jpaVesselRepository.findFirstByInternalReferenceNumber(
it.logbookMessageAndValue.logbookMessage.internalReferenceNumber!!,
)
}
assertThat(firstResultVessels).hasSize(firstResult.size)
assertThat(firstResultVessels.all { it.vesselName == "PHENOMENE" }).isTrue()

// Given
val secondFilter = PriorNotificationsFilter(
searchQuery = "999999",
willArriveAfter = "2000-01-01T00:00:00Z",
willArriveBefore = "2100-01-01T00:00:00Z",
)

// When
val secondResult = jpaLogbookReportRepository.findAllPriorNotifications(secondFilter)

// Then
assertThat(secondResult).hasSizeGreaterThan(0)
val secondResultVessels = secondResult.mapNotNull {
jpaVesselRepository.findFirstByInternalReferenceNumber(
it.logbookMessageAndValue.logbookMessage.internalReferenceNumber!!,
)
}
assertThat(secondResultVessels).hasSize(secondResult.size)
assertThat(secondResultVessels.all { it.vesselName == "PHENOMENE" }).isTrue()
}

@Test
@Transactional
fun `findAllPriorNotifications Should return PNO logbook reports for COD & HKE species`() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ class JpaManualPriorNotificationRepositoryITests : AbstractDBTests() {

@Test
@Transactional
fun `findAll Should return manual prior notifications for NAVIRE RENOMMÉ vessel`() {
fun `findAll Should return manual prior notifications When searching a vessel name`() {
// Given
val firstFilter = defaultPriorNotificationsFilter.copy(searchQuery = "renom")

Expand Down Expand Up @@ -242,6 +242,48 @@ class JpaManualPriorNotificationRepositoryITests : AbstractDBTests() {
assertThat(secondResultVessels.all { it.vesselName == "NAVIRE RENOMMÉ (NOUVEAU NOM)" }).isTrue()
}

@Test
@Transactional
fun `findAll Should return manual prior notifications When searching a vessel cfr`() {
// Given
val firstFilter = defaultPriorNotificationsFilter.copy(searchQuery = "CFR116")

// When
val firstResult = jpaManualPriorNotificationRepository.findAll(firstFilter)

// Then
assertThat(firstResult).hasSizeBetween(1, allManualPriorNotificationsLength - 1)
assertThat(
firstResult.all { it.logbookMessageAndValue.logbookMessage.vesselName == "NAVIRE RENOMMÉ (ANCIEN NOM)" },
).isTrue()
val firstResultVessels = firstResult.mapNotNull {
jpaVesselRepository.findFirstByInternalReferenceNumber(
it.logbookMessageAndValue.logbookMessage.internalReferenceNumber!!,
)
}
assertThat(firstResultVessels).hasSize(firstResult.size)
assertThat(firstResultVessels.all { it.vesselName == "NAVIRE RENOMMÉ (NOUVEAU NOM)" }).isTrue()

// Given
val secondFilter = defaultPriorNotificationsFilter.copy(searchQuery = "116")

// When
val secondResult = jpaManualPriorNotificationRepository.findAll(secondFilter)

// Then
assertThat(secondResult).hasSizeBetween(1, allManualPriorNotificationsLength - 1)
assertThat(
secondResult.all { it.logbookMessageAndValue.logbookMessage.vesselName == "NAVIRE RENOMMÉ (ANCIEN NOM)" },
).isTrue()
val secondResultVessels = secondResult.mapNotNull {
jpaVesselRepository.findFirstByInternalReferenceNumber(
it.logbookMessageAndValue.logbookMessage.internalReferenceNumber!!,
)
}
assertThat(secondResultVessels).hasSize(secondResult.size)
assertThat(secondResultVessels.all { it.vesselName == "NAVIRE RENOMMÉ (NOUVEAU NOM)" }).isTrue()
}

@Test
@Transactional
fun `findAll Should return manual prior notifications for BIB & BFT species`() {
Expand Down

0 comments on commit b34ae94

Please sign in to comment.