Skip to content

Commit

Permalink
Add GetPrioNotifications use case unit test in Backend
Browse files Browse the repository at this point in the history
  • Loading branch information
ivangabriele committed Mar 24, 2024
1 parent 96604ed commit bb3fae1
Showing 1 changed file with 108 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
package fr.gouv.cnsp.monitorfish.domain.use_cases.prior_notification

import com.nhaarman.mockitokotlin2.any
import com.nhaarman.mockitokotlin2.given
import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotification
import fr.gouv.cnsp.monitorfish.domain.filters.LogbookReportFilter
import fr.gouv.cnsp.monitorfish.domain.repositories.*
import org.assertj.core.api.Assertions
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

@ExtendWith(SpringExtension::class)
class GetPrioNotificationsUTests {
@MockBean
private lateinit var facadeAreasRepository: FacadeAreasRepository

@MockBean
private lateinit var logbookReportRepository: LogbookReportRepository

@MockBean
private lateinit var portRepository: PortRepository

@MockBean
private lateinit var reportingRepository: ReportingRepository

@Test
fun `execute Should return a list prior notifications`() {
// Given
given(logbookReportRepository.findAllPriorNotifications(LogbookReportFilter())).willReturn(
listOf(
PriorNotification(id = 1,
expectedArrivalDate = null,
expectedLandingDate = null,
isVesselUnderCharter = null,
notificationTypeLabel = null,
onboardCatches = emptyList(),
portLocode = null,
portName = null,
purposeCode = null,
reportingsCount = null,
seaFront = null,
sentAt = null,
tripGears = emptyList(),
tripSegments = emptyList(),
types = emptyList(),
vesselId = 1,
vesselExternalReferenceNumber = null,
vesselFlagCountryCode = null,
vesselInternalReferenceNumber = null,
vesselIrcs = null,
vesselLastControlDate = null,
vesselLength = null,
vesselMmsi = null,
vesselName = null,
vesselRiskFactorImpact = null,
vesselRiskFactorProbability = null,
vesselRiskFactorDetectability = null,
vesselRiskFactor = null,
),

PriorNotification(id = 2,
expectedArrivalDate = null,
expectedLandingDate = null,
isVesselUnderCharter = null,
notificationTypeLabel = null,
onboardCatches = emptyList(),
portLocode = null,
portName = null,
purposeCode = null,
reportingsCount = null,
seaFront = null,
sentAt = null,
tripGears = emptyList(),
tripSegments = emptyList(),
types = emptyList(),
vesselId = 2,
vesselExternalReferenceNumber = null,
vesselFlagCountryCode = null,
vesselInternalReferenceNumber = null,
vesselIrcs = null,
vesselLastControlDate = null,
vesselLength = null,
vesselMmsi = null,
vesselName = null,
vesselRiskFactorImpact = null,
vesselRiskFactorProbability = null,
vesselRiskFactorDetectability = null,
vesselRiskFactor = null,
),
),
)

// When
val result = GetPriorNotifications(
facadeAreasRepository,
logbookReportRepository,
portRepository,
reportingRepository
).execute(LogbookReportFilter())

// Then
Assertions.assertThat(result).hasSize(2)
Assertions.assertThat(result[0].id).isEqualTo(1)
Assertions.assertThat(result[1].id).isEqualTo(2)
}
}

0 comments on commit bb3fae1

Please sign in to comment.