Skip to content

Commit

Permalink
Add inte tests for isInvalidated filter in GetPriorNotifications use …
Browse files Browse the repository at this point in the history
…case in Backend
  • Loading branch information
ivangabriele committed Sep 6, 2024
1 parent edc1eb4 commit 7a27558
Showing 1 changed file with 57 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -426,4 +426,61 @@ class GetPriorNotificationsITests : AbstractDBTests() {
},
).isTrue()
}

@Test
@Transactional
fun `execute should return a list of invalidated prior notifications`() {
// Given
val isInvalidated = true

// When
val result =
getPriorNotifications
.execute(
defaultFilter,
isInvalidated,
defaultSeafrontGroup,
defaultStates,
defaultSortColumn,
defaultSortDirection,
defaultPageNumber,
defaultPageSize,
)

// Then
assertThat(result.data).hasSizeGreaterThan(0)
assertThat(result.data.all { it.logbookMessageAndValue.value.isInvalidated == true }).isTrue()
}

@Test
@Transactional
fun `execute should return a list of either pending send or invalidated prior notifications`() {
// Given
val isInvalidated = true
val states = listOf(PriorNotificationState.PENDING_SEND)

// When
val result =
getPriorNotifications
.execute(
defaultFilter,
isInvalidated,
defaultSeafrontGroup,
states,
defaultSortColumn,
defaultSortDirection,
defaultPageNumber,
defaultPageSize,
)

// Then
val invalidatedPriorNotifications = result.data.filter { it.logbookMessageAndValue.value.isInvalidated == true }
val pendingSendPriorNotifications = result.data.filter { it.state == PriorNotificationState.PENDING_SEND }
val pendingSendPriorNotificationReportIds = pendingSendPriorNotifications.map { it.reportId!! }
assertThat(invalidatedPriorNotifications).hasSizeGreaterThan(0)
assertThat(pendingSendPriorNotifications).hasSizeGreaterThan(0)
assertThat(
invalidatedPriorNotifications.none { pendingSendPriorNotificationReportIds.contains(it.reportId!!) },
).isTrue()
}
}

0 comments on commit 7a27558

Please sign in to comment.