1
1
package fr.gouv.cnsp.monitorfish.domain.use_cases.prior_notification
2
2
3
3
import fr.gouv.cnsp.monitorfish.config.MapperConfiguration
4
+ import fr.gouv.cnsp.monitorfish.domain.entities.facade.Seafront
4
5
import fr.gouv.cnsp.monitorfish.domain.entities.facade.SeafrontGroup
6
+ import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationState
5
7
import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.filters.PriorNotificationsFilter
6
8
import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.sorters.PriorNotificationsSortColumn
7
9
import fr.gouv.cnsp.monitorfish.domain.repositories.*
@@ -50,6 +52,7 @@ class GetPriorNotificationsITests : AbstractDBTests() {
50
52
willArriveBefore = " 2099-12-31T00:00:00Z" ,
51
53
)
52
54
private val defaultSeafrontGroup = SeafrontGroup .ALL
55
+ private val defaultStates = null
53
56
private val defaultSortColumn = PriorNotificationsSortColumn .EXPECTED_ARRIVAL_DATE
54
57
private val defaultSortDirection = Sort .Direction .ASC
55
58
private val defaultPageSize = 100
@@ -64,7 +67,15 @@ class GetPriorNotificationsITests : AbstractDBTests() {
64
67
65
68
// When
66
69
val result = getPriorNotifications
67
- .execute(defaultFilter, defaultSeafrontGroup, sortColumn, sortDirection, defaultPageNumber, defaultPageSize)
70
+ .execute(
71
+ defaultFilter,
72
+ defaultSeafrontGroup,
73
+ defaultStates,
74
+ sortColumn,
75
+ sortDirection,
76
+ defaultPageNumber,
77
+ defaultPageSize,
78
+ )
68
79
69
80
// Then
70
81
val firstPriorNotificationWithNonNullArrivalDate = result.data
@@ -85,7 +96,15 @@ class GetPriorNotificationsITests : AbstractDBTests() {
85
96
86
97
// When
87
98
val result = getPriorNotifications
88
- .execute(defaultFilter, defaultSeafrontGroup, sortColumn, sortDirection, defaultPageNumber, defaultPageSize)
99
+ .execute(
100
+ defaultFilter,
101
+ defaultSeafrontGroup,
102
+ defaultStates,
103
+ sortColumn,
104
+ sortDirection,
105
+ defaultPageNumber,
106
+ defaultPageSize,
107
+ )
89
108
90
109
// Then
91
110
val firstPriorNotificationWithNonNullArrivalDate = result.data
@@ -106,7 +125,15 @@ class GetPriorNotificationsITests : AbstractDBTests() {
106
125
107
126
// When
108
127
val result = getPriorNotifications
109
- .execute(defaultFilter, defaultSeafrontGroup, sortColumn, sortDirection, defaultPageNumber, defaultPageSize)
128
+ .execute(
129
+ defaultFilter,
130
+ defaultSeafrontGroup,
131
+ defaultStates,
132
+ sortColumn,
133
+ sortDirection,
134
+ defaultPageNumber,
135
+ defaultPageSize,
136
+ )
110
137
111
138
// Then
112
139
val firstPriorNotificationWithNonNullLandingDate = result.data
@@ -127,7 +154,15 @@ class GetPriorNotificationsITests : AbstractDBTests() {
127
154
128
155
// When
129
156
val result = getPriorNotifications
130
- .execute(defaultFilter, defaultSeafrontGroup, sortColumn, sortDirection, defaultPageNumber, defaultPageSize)
157
+ .execute(
158
+ defaultFilter,
159
+ defaultSeafrontGroup,
160
+ defaultStates,
161
+ sortColumn,
162
+ sortDirection,
163
+ defaultPageNumber,
164
+ defaultPageSize,
165
+ )
131
166
132
167
// Then
133
168
val firstPriorNotificationWithNonNullLandingDate = result.data
@@ -148,7 +183,15 @@ class GetPriorNotificationsITests : AbstractDBTests() {
148
183
149
184
// When
150
185
val result = getPriorNotifications
151
- .execute(defaultFilter, defaultSeafrontGroup, sortColumn, sortDirection, defaultPageNumber, defaultPageSize)
186
+ .execute(
187
+ defaultFilter,
188
+ defaultSeafrontGroup,
189
+ defaultStates,
190
+ sortColumn,
191
+ sortDirection,
192
+ defaultPageNumber,
193
+ defaultPageSize,
194
+ )
152
195
153
196
// Then
154
197
val firstPriorNotificationWithNonNullPort = result.data.first { it.port != null }
@@ -166,7 +209,15 @@ class GetPriorNotificationsITests : AbstractDBTests() {
166
209
167
210
// When
168
211
val result = getPriorNotifications
169
- .execute(defaultFilter, defaultSeafrontGroup, sortColumn, sortDirection, defaultPageNumber, defaultPageSize)
212
+ .execute(
213
+ defaultFilter,
214
+ defaultSeafrontGroup,
215
+ defaultStates,
216
+ sortColumn,
217
+ sortDirection,
218
+ defaultPageNumber,
219
+ defaultPageSize,
220
+ )
170
221
171
222
// Then
172
223
val firstPriorNotificationWithNonNullPort = result.data.first { it.port != null }
@@ -184,7 +235,15 @@ class GetPriorNotificationsITests : AbstractDBTests() {
184
235
185
236
// When
186
237
val result = getPriorNotifications
187
- .execute(defaultFilter, defaultSeafrontGroup, sortColumn, sortDirection, defaultPageNumber, defaultPageSize)
238
+ .execute(
239
+ defaultFilter,
240
+ defaultSeafrontGroup,
241
+ defaultStates,
242
+ sortColumn,
243
+ sortDirection,
244
+ defaultPageNumber,
245
+ defaultPageSize,
246
+ )
188
247
189
248
// Then
190
249
val firstPriorNotificationWithKnownVessel = result.data.first { it.vessel!! .id != - 1 }
@@ -207,7 +266,15 @@ class GetPriorNotificationsITests : AbstractDBTests() {
207
266
208
267
// When
209
268
val result = getPriorNotifications
210
- .execute(defaultFilter, defaultSeafrontGroup, sortColumn, sortDirection, defaultPageNumber, defaultPageSize)
269
+ .execute(
270
+ defaultFilter,
271
+ defaultSeafrontGroup,
272
+ defaultStates,
273
+ sortColumn,
274
+ sortDirection,
275
+ defaultPageNumber,
276
+ defaultPageSize,
277
+ )
211
278
212
279
// Then
213
280
val firstPriorNotificationWithKnownVessel = result.data.first { it.vessel!! .id != - 1 }
@@ -230,10 +297,19 @@ class GetPriorNotificationsITests : AbstractDBTests() {
230
297
231
298
// When
232
299
val result = getPriorNotifications
233
- .execute(defaultFilter, defaultSeafrontGroup, sortColumn, sortDirection, defaultPageNumber, defaultPageSize)
300
+ .execute(
301
+ defaultFilter,
302
+ defaultSeafrontGroup,
303
+ defaultStates,
304
+ sortColumn,
305
+ sortDirection,
306
+ defaultPageNumber,
307
+ defaultPageSize,
308
+ )
234
309
235
310
// Then
236
- val firstPriorNotificationWithNonNullRiskFactor = result.data.first { it.logbookMessageTyped.typedMessage.riskFactor != null }
311
+ val firstPriorNotificationWithNonNullRiskFactor =
312
+ result.data.first { it.logbookMessageTyped.typedMessage.riskFactor != null }
237
313
assertThat(firstPriorNotificationWithNonNullRiskFactor.logbookMessageTyped.typedMessage.riskFactor!! ).isEqualTo(
238
314
1.5 ,
239
315
)
@@ -249,13 +325,75 @@ class GetPriorNotificationsITests : AbstractDBTests() {
249
325
250
326
// When
251
327
val result = getPriorNotifications
252
- .execute(defaultFilter, defaultSeafrontGroup, sortColumn, sortDirection, defaultPageNumber, defaultPageSize)
328
+ .execute(
329
+ defaultFilter,
330
+ defaultSeafrontGroup,
331
+ defaultStates,
332
+ sortColumn,
333
+ sortDirection,
334
+ defaultPageNumber,
335
+ defaultPageSize,
336
+ )
253
337
254
338
// Then
255
- val firstPriorNotificationWithNonNullRiskFactor = result.data.first { it.logbookMessageTyped.typedMessage.riskFactor != null }
339
+ val firstPriorNotificationWithNonNullRiskFactor =
340
+ result.data.first { it.logbookMessageTyped.typedMessage.riskFactor != null }
256
341
assertThat(firstPriorNotificationWithNonNullRiskFactor.logbookMessageTyped.typedMessage.riskFactor!! ).isEqualTo(
257
342
3.9 ,
258
343
)
259
344
assertThat(result.data).hasSizeGreaterThan(0 )
260
345
}
346
+
347
+ @Test
348
+ @Transactional
349
+ fun `execute should return a list of NAMO seafront group prior notifications` () {
350
+ // Given
351
+ val seafrontGroup = SeafrontGroup .NAMO
352
+
353
+ // When
354
+ val result = getPriorNotifications
355
+ .execute(
356
+ defaultFilter,
357
+ seafrontGroup,
358
+ defaultStates,
359
+ defaultSortColumn,
360
+ defaultSortDirection,
361
+ defaultPageNumber,
362
+ defaultPageSize,
363
+ )
364
+
365
+ // Then
366
+ assertThat(result.data).hasSizeGreaterThan(0 )
367
+ assertThat(result.data.all { it.seafront == = Seafront .NAMO }).isTrue()
368
+ }
369
+
370
+ @Test
371
+ @Transactional
372
+ fun `execute should return a list of pending sent and out of verification scope prior notifications` () {
373
+ // Given
374
+ val states = listOf (PriorNotificationState .PENDING_SEND , PriorNotificationState .OUT_OF_VERIFICATION_SCOPE )
375
+
376
+ // When
377
+ val result = getPriorNotifications
378
+ .execute(
379
+ defaultFilter,
380
+ defaultSeafrontGroup,
381
+ states,
382
+ defaultSortColumn,
383
+ defaultSortDirection,
384
+ defaultPageNumber,
385
+ defaultPageSize,
386
+ )
387
+
388
+ // Then
389
+ assertThat(result.data).hasSizeGreaterThan(0 )
390
+ assertThat(
391
+ result.data.all {
392
+ listOf (
393
+ PriorNotificationState .PENDING_SEND ,
394
+ PriorNotificationState .OUT_OF_VERIFICATION_SCOPE ,
395
+ ).contains(it.state)
396
+ },
397
+ ).isTrue()
398
+ }
261
399
}
0 commit comments