diff --git a/backend/build.gradle.kts b/backend/build.gradle.kts index 55d111b748..1f079b72be 100644 --- a/backend/build.gradle.kts +++ b/backend/build.gradle.kts @@ -2,14 +2,19 @@ plugins { `java-library` `maven-publish` id("org.springframework.boot") version "3.3.5" - id("org.jetbrains.kotlin.plugin.spring") version "2.0.21" - kotlin("jvm") version "2.0.21" + id("org.jetbrains.kotlin.plugin.spring") version "2.1.0" + kotlin("jvm") version "2.1.0" id("org.jetbrains.kotlin.plugin.allopen") version "2.1.0" - kotlin("plugin.noarg") version "2.0.21" - kotlin("plugin.jpa") version "2.0.21" + kotlin("plugin.noarg") version "2.1.0" + kotlin("plugin.jpa") version "2.1.0" id("org.jlleitschuh.gradle.ktlint") version "12.1.2" - kotlin("plugin.serialization") version "2.0.21" - id("io.spring.dependency-management") version "1.1.6" + kotlin("plugin.serialization") version "2.1.0" + id("io.spring.dependency-management") version "1.1.7" +} + +// this is to address https://github.com/JLLeitschuh/ktlint-gradle/issues/809 +ktlint { + version = "1.5.0" } dependencyManagement { @@ -45,8 +50,8 @@ tasks.named("compileKotlin", org.jetbrains.kotlin.gradle.tasks.KotlinCompilation dependencies { api("org.springframework.boot:spring-boot-starter-web:3.3.5") - api("org.springframework.security:spring-security-oauth2-resource-server:6.4.1") - api("org.springframework.security:spring-security-oauth2-jose:6.4.1") + api("org.springframework.security:spring-security-oauth2-resource-server:6.4.2") + api("org.springframework.security:spring-security-oauth2-jose:6.4.2") api("org.springframework.boot:spring-boot-starter-actuator:3.3.5") api("org.springframework.boot:spring-boot-starter-json:3.3.5") api("org.springframework.boot:spring-boot-starter-security:3.3.5") @@ -56,31 +61,31 @@ dependencies { api("org.springframework.boot:spring-boot-starter-log4j2:3.3.5") runtimeOnly("org.springframework.boot:spring-boot-devtools:3.3.5") api("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3") - api("io.ktor:ktor-client-core-jvm:3.0.1") - api("io.ktor:ktor-client-java-jvm:3.0.1") - api("io.ktor:ktor-client-content-negotiation-jvm:3.0.1") - api("io.ktor:ktor-serialization-kotlinx-json-jvm:3.0.1") - api("org.hibernate.validator:hibernate-validator:8.0.1.Final") + api("io.ktor:ktor-client-core-jvm:3.0.3") + api("io.ktor:ktor-client-java-jvm:3.0.3") + api("io.ktor:ktor-client-content-negotiation-jvm:3.0.3") + api("io.ktor:ktor-serialization-kotlinx-json-jvm:3.0.3") + api("org.hibernate.validator:hibernate-validator:8.0.2.Final") api("jakarta.validation:jakarta.validation-api:3.1.0") api("com.fasterxml.jackson.module:jackson-module-kotlin:2.18.2") api("com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0") api("org.flywaydb:flyway-core:10.21.0") api("org.flywaydb:flyway-database-postgresql:10.21.0") api("org.springdoc:springdoc-openapi-ui:1.8.0") - api("org.jetbrains.kotlin:kotlin-reflect:2.0.21") - api("org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.0.21") - api("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0") + api("org.jetbrains.kotlin:kotlin-reflect:2.1.0") + api("org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.1.0") + api("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.1") api("com.neovisionaries:nv-i18n:1.29") api("com.github.ben-manes.caffeine:caffeine:3.1.8") api("io.hypersistence:hypersistence-utils-hibernate-63:3.9.0") api("org.locationtech.jts:jts-core:1.20.0") - api("org.hibernate:hibernate-spatial:6.6.3.Final") - api("io.sentry:sentry:7.18.1") - api("io.sentry:sentry-log4j2:7.18.1") - implementation("org.springframework.cloud:spring-cloud-gateway-mvc:4.1.6") + api("org.hibernate:hibernate-spatial:6.6.4.Final") + api("io.sentry:sentry:7.19.1") + api("io.sentry:sentry-log4j2:7.19.1") + implementation("org.springframework.cloud:spring-cloud-gateway-mvc:4.2.0") runtimeOnly("org.postgresql:postgresql:42.7.4") - testImplementation("io.ktor:ktor-client-mock-jvm:3.0.1") - testImplementation("org.assertj:assertj-core:3.26.3") + testImplementation("io.ktor:ktor-client-mock-jvm:3.0.3") + testImplementation("org.assertj:assertj-core:3.27.1") testImplementation("org.testcontainers:postgresql:1.20.4") testImplementation("org.testcontainers:testcontainers:1.20.4") testImplementation("org.testcontainers:junit-jupiter:1.20.4") diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/Utils.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/Utils.kt index 2672f38afd..b7ee92d1cd 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/Utils.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/Utils.kt @@ -27,12 +27,11 @@ class Utils { start: ZonedDateTime, end: ZonedDateTime, isInclusive: Boolean = false, - ): Boolean { - return if (isInclusive) { + ): Boolean = + if (isInclusive) { zonedDateTime >= start && zonedDateTime <= end } else { zonedDateTime > start && zonedDateTime < end } - } } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/config/AJPConfig.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/config/AJPConfig.kt index 8b9235fbf3..17cba158d0 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/config/AJPConfig.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/config/AJPConfig.kt @@ -15,13 +15,12 @@ class AJPConfig { private val AJPProperties: AJPProperties? = null @Bean - fun servletContainer(): WebServerFactoryCustomizer? { - return WebServerFactoryCustomizer { server: TomcatServletWebServerFactory? -> + fun servletContainer(): WebServerFactoryCustomizer? = + WebServerFactoryCustomizer { server: TomcatServletWebServerFactory? -> if (server is TomcatServletWebServerFactory) { server.addAdditionalTomcatConnectors(redirectConnector()) } } - } private fun redirectConnector(): Connector? { val connector = Connector("AJP/1.3") diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/config/ApiClient.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/config/ApiClient.kt index 20b2e55864..449d4ce350 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/config/ApiClient.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/config/ApiClient.kt @@ -9,7 +9,9 @@ import kotlinx.serialization.json.Json import org.springframework.context.annotation.Configuration @Configuration -class ApiClient(engine: HttpClientEngine = Java.create()) { +class ApiClient( + engine: HttpClientEngine = Java.create(), +) { val httpClient = HttpClient(engine) { expectSuccess = true diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/config/ClockConfiguration.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/config/ClockConfiguration.kt index 7362b57d6f..5f121e1d04 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/config/ClockConfiguration.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/config/ClockConfiguration.kt @@ -7,7 +7,5 @@ import java.time.Clock @Configuration class ClockConfiguration { @Bean - fun clock(): Clock { - return Clock.systemUTC() - } + fun clock(): Clock = Clock.systemUTC() } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/config/CustomProxyExchangeConfig.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/config/CustomProxyExchangeConfig.kt index fada931a55..a7d418fefe 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/config/CustomProxyExchangeConfig.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/config/CustomProxyExchangeConfig.kt @@ -16,7 +16,9 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer havingValue = "true", matchIfMissing = false, ) -class CustomProxyExchangeConfig(private val restTemplate: RestTemplate) : WebMvcConfigurer { +class CustomProxyExchangeConfig( + private val restTemplate: RestTemplate, +) : WebMvcConfigurer { override fun addArgumentResolvers(resolvers: MutableList) { resolvers.add(ProxyExchangeArgumentResolver(restTemplate)) } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/config/LoggingConfig.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/config/LoggingConfig.kt index 6a73b5db50..e282bf99a7 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/config/LoggingConfig.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/config/LoggingConfig.kt @@ -10,7 +10,9 @@ import org.springframework.web.servlet.config.annotation.InterceptorRegistry import org.springframework.web.servlet.config.annotation.WebMvcConfigurer @Configuration -class LoggingConfig(val mapper: ObjectMapper) : WebMvcConfigurer { +class LoggingConfig( + val mapper: ObjectMapper, +) : WebMvcConfigurer { override fun addInterceptors(registry: InterceptorRegistry) { registry.addInterceptor(CorrelationInterceptor()).order(CORRELATION_ID_PRECEDENCE) registry.addInterceptor(LogGETRequests(mapper)).order(LOG_REQUEST_PRECEDENCE) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/config/MapperConfiguration.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/config/MapperConfiguration.kt index 7453e8285d..8751863bc5 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/config/MapperConfiguration.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/config/MapperConfiguration.kt @@ -42,7 +42,8 @@ class MapperConfiguration { mapper: ObjectMapper, enumOfTypeToAdd: Class, ) where E : Enum?, E : IAlertsHasImplementation? { - Arrays.stream(enumOfTypeToAdd.enumConstants) + Arrays + .stream(enumOfTypeToAdd.enumConstants) .map { enumItem -> NamedType(enumItem.getImplementation(), enumItem.name) } .forEach { type -> mapper.registerSubtypes(type) } } @@ -51,7 +52,8 @@ class MapperConfiguration { mapper: ObjectMapper, enumOfTypeToAdd: Class, ) where E : Enum?, E : IReportingsHasImplementation? { - Arrays.stream(enumOfTypeToAdd.enumConstants) + Arrays + .stream(enumOfTypeToAdd.enumConstants) .map { enumItem -> NamedType(enumItem.getImplementation(), enumItem.name) } .forEach { type -> mapper.registerSubtypes(type) } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/config/SecurityConfig.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/config/SecurityConfig.kt index 9856b239c6..4a6e0c3422 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/config/SecurityConfig.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/config/SecurityConfig.kt @@ -42,38 +42,39 @@ class SecurityConfig( """.trimIndent(), ) - authorize.requestMatchers( - "/", - "/*.jpg", - "/*.js", - "/*.png", - "/*.svg", - "/api/**", - "/asset-manifest.json", - "/assets/**", - "/backoffice", - "/backoffice/**", - // Used to redirect to the frontend SPA, see SpaController.kt - "/error", - "/ext", - "/favicon-32.ico", - "/favicon.ico", - "/flags/**", - "/index.html", - "/light", - "/load_light", - "/login", - "/map-icons/**", - "/proxy/**", - "/realms/**", - "/register", - "/resources/**", - "/robots.txt", - "/side_window", - "/static/**", - "/swagger-ui/**", - "/version", - ).permitAll() + authorize + .requestMatchers( + "/", + "/*.jpg", + "/*.js", + "/*.png", + "/*.svg", + "/api/**", + "/asset-manifest.json", + "/assets/**", + "/backoffice", + "/backoffice/**", + // Used to redirect to the frontend SPA, see SpaController.kt + "/error", + "/ext", + "/favicon-32.ico", + "/favicon.ico", + "/flags/**", + "/index.html", + "/light", + "/load_light", + "/login", + "/map-icons/**", + "/proxy/**", + "/realms/**", + "/register", + "/resources/**", + "/robots.txt", + "/side_window", + "/static/**", + "/swagger-ui/**", + "/version", + ).permitAll() .anyRequest() .authenticated() } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/config/SwaggerConfig.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/config/SwaggerConfig.kt index d4694498f4..537c63ec66 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/config/SwaggerConfig.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/config/SwaggerConfig.kt @@ -14,18 +14,17 @@ class SwaggerConfig { private val hostProperties: HostProperties? = null @Bean - fun api(): OpenAPI { - return OpenAPI() + fun api(): OpenAPI = + OpenAPI() .info( - Info().title("MonitorFish API") + Info() + .title("MonitorFish API") .description("MonitorFish") .version("v1.19.2") .license(License().name("Apache 2.0").url("https://monitorfish.readthedocs.io/en/latest")), - ) - .externalDocs( + ).externalDocs( ExternalDocumentation() .description("MonitorFish Documentation") .url("https://monitorfish.readthedocs.io/en/latest"), ) - } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/alerts/type/AlertTypeMapping.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/alerts/type/AlertTypeMapping.kt index 07adf82af6..32d6a960fa 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/alerts/type/AlertTypeMapping.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/alerts/type/AlertTypeMapping.kt @@ -42,7 +42,5 @@ enum class AlertTypeMapping( ), ; - override fun getImplementation(): Class { - return clazz - } + override fun getImplementation(): Class = clazz } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/beacon_malfunctions/BeaconMalfunction.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/beacon_malfunctions/BeaconMalfunction.kt index 207f0975df..f09cd43f8a 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/beacon_malfunctions/BeaconMalfunction.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/beacon_malfunctions/BeaconMalfunction.kt @@ -26,15 +26,18 @@ data class BeaconMalfunction( val beaconStatusAtMalfunctionCreation: BeaconStatus, ) { companion object { - fun getVesselFromBeaconMalfunction(beaconMalfunction: BeaconMalfunction): (LastPosition) -> Boolean { - return { lastPosition -> + fun getVesselFromBeaconMalfunction(beaconMalfunction: BeaconMalfunction): (LastPosition) -> Boolean = + { lastPosition -> when (beaconMalfunction.vesselIdentifier) { - VesselIdentifier.INTERNAL_REFERENCE_NUMBER -> lastPosition.internalReferenceNumber == beaconMalfunction.internalReferenceNumber + VesselIdentifier.INTERNAL_REFERENCE_NUMBER -> + lastPosition.internalReferenceNumber == + beaconMalfunction.internalReferenceNumber VesselIdentifier.IRCS -> lastPosition.ircs == beaconMalfunction.ircs - VesselIdentifier.EXTERNAL_REFERENCE_NUMBER -> lastPosition.externalReferenceNumber == beaconMalfunction.externalReferenceNumber + VesselIdentifier.EXTERNAL_REFERENCE_NUMBER -> + lastPosition.externalReferenceNumber == + beaconMalfunction.externalReferenceNumber else -> false } } - } } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/beacon_malfunctions/VesselBeaconMalfunctionsResume.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/beacon_malfunctions/VesselBeaconMalfunctionsResume.kt index 8defd92b8f..e772fee089 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/beacon_malfunctions/VesselBeaconMalfunctionsResume.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/beacon_malfunctions/VesselBeaconMalfunctionsResume.kt @@ -45,11 +45,11 @@ data class VesselBeaconMalfunctionsResume( private fun getNumberOfBeaconsMalfunctionsAt( vesselStatus: VesselStatus, lastYearBeaconMalfunctionsWithDetails: List, - ): Int { - return lastYearBeaconMalfunctionsWithDetails.filter { beaconMalfunctionsWithDetails -> - getFirstVesselStatus(beaconMalfunctionsWithDetails) == vesselStatus - }.size - } + ): Int = + lastYearBeaconMalfunctionsWithDetails + .filter { beaconMalfunctionsWithDetails -> + getFirstVesselStatus(beaconMalfunctionsWithDetails) == vesselStatus + }.size private fun getFirstVesselStatus(beaconMalfunctionsWithDetails: BeaconMalfunctionWithDetails): VesselStatus { val beaconMalfunctionVesselStatusActions = @@ -60,7 +60,8 @@ data class VesselBeaconMalfunctionsResume( true -> beaconMalfunctionsWithDetails.beaconMalfunction.vesselStatus false -> beaconMalfunctionVesselStatusActions - .minByOrNull { action -> action.dateTime }?.let { action -> + .minByOrNull { action -> action.dateTime } + ?.let { action -> VesselStatus.valueOf(action.previousValue) }!! } @@ -68,9 +69,12 @@ data class VesselBeaconMalfunctionsResume( private fun getLastVesselStatus(beaconMalfunction: BeaconMalfunctionWithDetails?): VesselStatus? { val lastVesselStatus = - beaconMalfunction?.actions?.filter { action -> - action.propertyName == BeaconMalfunctionActionPropertyName.VESSEL_STATUS - }?.maxByOrNull { action -> action.dateTime }?.nextValue + beaconMalfunction + ?.actions + ?.filter { action -> + action.propertyName == BeaconMalfunctionActionPropertyName.VESSEL_STATUS + }?.maxByOrNull { action -> action.dateTime } + ?.nextValue return lastVesselStatus?.let { VesselStatus.valueOf(lastVesselStatus) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/ControlUnitResourceType.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/ControlUnitResourceType.kt index 98f2cf1a83..ec1d0cd592 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/ControlUnitResourceType.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/ControlUnitResourceType.kt @@ -3,7 +3,9 @@ package fr.gouv.cnsp.monitorfish.domain.entities.control_unit import kotlinx.serialization.Serializable @Serializable -enum class ControlUnitResourceType(val label: String) { +enum class ControlUnitResourceType( + val label: String, +) { AIRPLANE("Avion"), BARGE("Barge"), CAR("Voiture"), diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/facade/Seafront.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/facade/Seafront.kt index 3ae1c3d6c0..7ccb5fb4b1 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/facade/Seafront.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/facade/Seafront.kt @@ -3,7 +3,9 @@ package fr.gouv.cnsp.monitorfish.domain.entities.facade /** * This Seafront enum is used as a type safeguard to prevent storing any string to a postgres `facade` column */ -enum class Seafront(private val storedValue: String) { +enum class Seafront( + private val storedValue: String, +) { MARTINIQUE("Martinique"), SUD_OCEAN_INDIEN("Sud Océan Indien"), GUADELOUPE("Guadeloupe"), @@ -19,16 +21,13 @@ enum class Seafront(private val storedValue: String) { ; companion object { - infix fun from(storedValue: String): Seafront { - return try { + infix fun from(storedValue: String): Seafront = + try { entries.first { it.storedValue == storedValue } } catch (e: NoSuchElementException) { throw NoSuchElementException("Seafront $storedValue not found.", e) } - } } - override fun toString(): String { - return storedValue - } + override fun toString(): String = storedValue } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/facade/SeafrontGroup.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/facade/SeafrontGroup.kt index 8df90366ec..b5c60d108d 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/facade/SeafrontGroup.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/facade/SeafrontGroup.kt @@ -24,10 +24,9 @@ enum class SeafrontGroup { NONE to emptyList(), ) - fun fromSeafront(seafront: Seafront?): SeafrontGroup { - return seafront?.let { groupToSeafronts.entries.first { it.key != ALL && it.value.contains(seafront) }.key } + fun fromSeafront(seafront: Seafront?): SeafrontGroup = + seafront?.let { groupToSeafronts.entries.first { it.key != ALL && it.value.contains(seafront) }.key } ?: NONE - } } fun hasSeafront(seafront: Seafront?): Boolean { @@ -41,7 +40,5 @@ enum class SeafrontGroup { return groupToSeafronts[this]?.contains(seafront) ?: false } - fun toSeafronts(): List { - return groupToSeafronts[this] ?: emptyList() - } + fun toSeafronts(): List = groupToSeafronts[this] ?: emptyList() } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/fleet_segment/FleetSegment.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/fleet_segment/FleetSegment.kt index 10df9cbddc..bdb0780fff 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/fleet_segment/FleetSegment.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/fleet_segment/FleetSegment.kt @@ -19,7 +19,5 @@ data class FleetSegment( val impactRiskFactor: Double, val year: Int, ) { - fun toLogbookTripSegment(): LogbookTripSegment { - return LogbookTripSegment(segment, segmentName) - } + fun toLogbookTripSegment(): LogbookTripSegment = LogbookTripSegment(segment, segmentName) } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/last_position/Gear.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/last_position/Gear.kt index c9aa5fdf5b..bac81c949f 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/last_position/Gear.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/last_position/Gear.kt @@ -1,6 +1,6 @@ package fr.gouv.cnsp.monitorfish.domain.entities.last_position -class Gear() { +class Gear { var gear: String? = null var mesh: Double? = null var dimensions: String? = null diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/EffortTargetSpeciesGroup.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/EffortTargetSpeciesGroup.kt index 378a1b5194..15e0663f2e 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/EffortTargetSpeciesGroup.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/EffortTargetSpeciesGroup.kt @@ -1,6 +1,8 @@ package fr.gouv.cnsp.monitorfish.domain.entities.logbook -enum class EffortTargetSpeciesGroup(val value: String) { +enum class EffortTargetSpeciesGroup( + val value: String, +) { DEM("Démersal"), SCA("Coquille"), CRA("Crabe comestible et araignée de mer"), diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/Haul.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/Haul.kt index ba9d821d02..8fd419e056 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/Haul.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/Haul.kt @@ -5,7 +5,7 @@ import com.fasterxml.jackson.annotation.JsonTypeName import java.time.ZonedDateTime @JsonTypeName("haul") -class Haul() { +class Haul { var gear: String? = null var gearName: String? = null var catches: List = listOf() diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/LogbookMessage.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/LogbookMessage.kt index cc6a669058..edd08fedcb 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/LogbookMessage.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/LogbookMessage.kt @@ -183,22 +183,21 @@ data class LogbookMessage( } } - private fun filterRelatedLogbookMessages(messages: List): List { - return messages.filter { - it.messageType == messageType && ( - (reportId.isNullOrEmpty() && it.referencedReportId == reportId) || - (referencedReportId.isNullOrEmpty() && it.referencedReportId == referencedReportId) - ) + private fun filterRelatedLogbookMessages(messages: List): List = + messages.filter { + it.messageType == messageType && + ( + (reportId.isNullOrEmpty() && it.referencedReportId == reportId) || + (referencedReportId.isNullOrEmpty() && it.referencedReportId == referencedReportId) + ) } - } - private fun findReferencedLogbookMessages(messages: List): List { - return if (!referencedReportId.isNullOrEmpty()) { + private fun findReferencedLogbookMessages(messages: List): List = + if (!referencedReportId.isNullOrEmpty()) { messages.filter { it.reportId == referencedReportId } } else { listOf() } - } private fun setAcknowledgeAsSuccessful() { this.acknowledgment = Acknowledgment(isSuccess = true) @@ -219,9 +218,10 @@ data class LogbookMessage( ) { message.targetSpeciesOnEntry?.let { targetSpeciesOnEntry -> message.targetSpeciesNameOnEntry = - EffortTargetSpeciesGroup.entries.find { - it.name == targetSpeciesOnEntry - }?.value + EffortTargetSpeciesGroup.entries + .find { + it.name == targetSpeciesOnEntry + }?.value if (message.targetSpeciesNameOnEntry == null) { message.targetSpeciesNameOnEntry = allSpecies.find { it.code == targetSpeciesOnEntry }?.name @@ -235,9 +235,10 @@ data class LogbookMessage( ) { message.targetSpeciesOnExit?.let { targetSpeciesOnExit -> message.targetSpeciesNameOnExit = - EffortTargetSpeciesGroup.entries.find { - it.name == targetSpeciesOnExit - }?.value + EffortTargetSpeciesGroup.entries + .find { + it.name == targetSpeciesOnExit + }?.value if (message.targetSpeciesNameOnExit == null) { message.targetSpeciesNameOnExit = allSpecies.find { it.code == targetSpeciesOnExit }?.name @@ -251,9 +252,10 @@ data class LogbookMessage( ) { message.targetSpeciesOnExit?.let { targetSpeciesOnExit -> message.targetSpeciesNameOnExit = - EffortTargetSpeciesGroup.entries.find { - it.name == targetSpeciesOnExit - }?.value + EffortTargetSpeciesGroup.entries + .find { + it.name == targetSpeciesOnExit + }?.value if (message.targetSpeciesNameOnExit == null) { message.targetSpeciesNameOnExit = allSpecies.find { it.code == targetSpeciesOnExit }?.name @@ -262,9 +264,10 @@ data class LogbookMessage( message.targetSpeciesOnEntry?.let { targetSpeciesOnEntry -> message.targetSpeciesNameOnEntry = - EffortTargetSpeciesGroup.entries.find { - it.name == targetSpeciesOnEntry - }?.value + EffortTargetSpeciesGroup.entries + .find { + it.name == targetSpeciesOnEntry + }?.value if (message.targetSpeciesNameOnEntry == null) { message.targetSpeciesNameOnEntry = allSpecies.find { it.code == targetSpeciesOnEntry }?.name diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/LogbookMessageTypeMapping.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/LogbookMessageTypeMapping.kt index 1dc940bb92..8fc9e8dd11 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/LogbookMessageTypeMapping.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/LogbookMessageTypeMapping.kt @@ -14,7 +14,9 @@ import fr.gouv.cnsp.monitorfish.domain.entities.logbook.messages.NotImplemented import fr.gouv.cnsp.monitorfish.domain.entities.logbook.messages.PNO as PNOMessage import fr.gouv.cnsp.monitorfish.domain.entities.logbook.messages.RTP as RTPMessage -enum class LogbookMessageTypeMapping(private val clazz: Class) : IHasImplementation { +enum class LogbookMessageTypeMapping( + private val clazz: Class, +) : IHasImplementation { FAR(FARMessage::class.java), CPS(CPSMessage::class.java), DEP(DEPMessage::class.java), @@ -37,17 +39,14 @@ enum class LogbookMessageTypeMapping(private val clazz: Class { - return clazz - } + override fun getImplementation(): Class = clazz companion object { - fun getClassFromName(messageType: String): Class { - return try { + fun getClassFromName(messageType: String): Class = + try { entries.first { it.name == messageType }.getImplementation() } catch (e: Exception) { throw NoSuchElementException("Message type $messageType not found", e) } - } } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/LogbookOperationTypeMapping.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/LogbookOperationTypeMapping.kt index 9175477b4f..4d335c5c76 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/LogbookOperationTypeMapping.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/LogbookOperationTypeMapping.kt @@ -3,22 +3,21 @@ package fr.gouv.cnsp.monitorfish.domain.entities.logbook import fr.gouv.cnsp.monitorfish.domain.entities.logbook.messages.Acknowledgment import fr.gouv.cnsp.monitorfish.domain.entities.logbook.messages.LogbookMessageValue -enum class LogbookOperationTypeMapping(private val clazz: Class) : IHasImplementation { +enum class LogbookOperationTypeMapping( + private val clazz: Class, +) : IHasImplementation { RET(Acknowledgment::class.java), ; - override fun getImplementation(): Class { - return clazz - } + override fun getImplementation(): Class = clazz companion object { - fun getClassFromName(operationType: String): Class { - return try { + fun getClassFromName(operationType: String): Class = + try { entries.first { it.name == operationType }.getImplementation() } catch (e: Exception) { throw NoSuchElementException("Operation type $operationType not found", e) } - } } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/LogbookSoftware.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/LogbookSoftware.kt index 92e89f7fa6..a62327a093 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/LogbookSoftware.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/LogbookSoftware.kt @@ -1,6 +1,8 @@ package fr.gouv.cnsp.monitorfish.domain.entities.logbook -enum class LogbookSoftware(val software: String) { +enum class LogbookSoftware( + val software: String, +) { /** * Examples: * - JP/05883989/VISIOCaptures V1.7.6 diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/LogbookTripGear.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/LogbookTripGear.kt index 7a79e10de1..707973aa7f 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/LogbookTripGear.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/LogbookTripGear.kt @@ -3,7 +3,7 @@ package fr.gouv.cnsp.monitorfish.domain.entities.logbook import com.fasterxml.jackson.annotation.JsonTypeName @JsonTypeName("gear") -class LogbookTripGear() { +class LogbookTripGear { /** Gear code. */ var gear: String? = null var gearName: String? = null diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/RETReturnErrorCode.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/RETReturnErrorCode.kt index 2642088b97..b205def59b 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/RETReturnErrorCode.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/RETReturnErrorCode.kt @@ -1,6 +1,8 @@ package fr.gouv.cnsp.monitorfish.domain.entities.logbook -enum class RETReturnErrorCode(val number: String) { +enum class RETReturnErrorCode( + val number: String, +) { SUCCESS("000"), NO_AUTHORIZATION1("001"), CROSS_CHECK_FAILED("002"), diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/messages/COE.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/messages/COE.kt index f06d66d130..834093077e 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/messages/COE.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/messages/COE.kt @@ -3,7 +3,7 @@ package fr.gouv.cnsp.monitorfish.domain.entities.logbook.messages import com.fasterxml.jackson.annotation.JsonProperty import java.time.ZonedDateTime -class COE() : LogbookMessageValue { +class COE : LogbookMessageValue { var latitudeEntered: Double? = null var longitudeEntered: Double? = null var faoZoneEntered: String? = null diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/messages/COX.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/messages/COX.kt index 9f3f217c23..8bb4ab168c 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/messages/COX.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/messages/COX.kt @@ -3,7 +3,7 @@ package fr.gouv.cnsp.monitorfish.domain.entities.logbook.messages import com.fasterxml.jackson.annotation.JsonProperty import java.time.ZonedDateTime -class COX() : LogbookMessageValue { +class COX : LogbookMessageValue { var latitudeExited: Double? = null var longitudeExited: Double? = null var faoZoneExited: String? = null diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/messages/CRO.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/messages/CRO.kt index 4eb043bfcd..c89d7fbe77 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/messages/CRO.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/messages/CRO.kt @@ -3,7 +3,7 @@ package fr.gouv.cnsp.monitorfish.domain.entities.logbook.messages import com.fasterxml.jackson.annotation.JsonProperty import java.time.ZonedDateTime -class CRO() : LogbookMessageValue { +class CRO : LogbookMessageValue { var latitudeExited: Double? = null var longitudeExited: Double? = null var faoZoneExited: String? = null diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/messages/DEP.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/messages/DEP.kt index 4e4fbfa230..7e6845701e 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/messages/DEP.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/messages/DEP.kt @@ -5,7 +5,7 @@ import fr.gouv.cnsp.monitorfish.domain.entities.logbook.LogbookFishingCatch import fr.gouv.cnsp.monitorfish.domain.entities.logbook.LogbookTripGear import java.time.ZonedDateTime -class DEP() : LogbookMessageValue { +class DEP : LogbookMessageValue { var anticipatedActivity: String? = null var departurePort: String? = null var departurePortName: String? = null diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/messages/DIS.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/messages/DIS.kt index 36fa025f7e..7cb47e844c 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/messages/DIS.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/messages/DIS.kt @@ -4,7 +4,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import fr.gouv.cnsp.monitorfish.domain.entities.logbook.LogbookFishingCatch import java.time.ZonedDateTime -class DIS() : LogbookMessageValue { +class DIS : LogbookMessageValue { var catches: List = listOf() @JsonProperty("discardDatetimeUtc") diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/messages/EOF.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/messages/EOF.kt index b4e5d82016..91642e69a5 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/messages/EOF.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/messages/EOF.kt @@ -3,7 +3,7 @@ package fr.gouv.cnsp.monitorfish.domain.entities.logbook.messages import com.fasterxml.jackson.annotation.JsonProperty import java.time.ZonedDateTime -class EOF() : LogbookMessageValue { +class EOF : LogbookMessageValue { @JsonProperty("endOfFishingDatetimeUtc") var endOfFishingDateTime: ZonedDateTime? = null } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/messages/FAR.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/messages/FAR.kt index bbfb8aee65..6ae7f3c10f 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/messages/FAR.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/messages/FAR.kt @@ -2,6 +2,6 @@ package fr.gouv.cnsp.monitorfish.domain.entities.logbook.messages import fr.gouv.cnsp.monitorfish.domain.entities.logbook.Haul -class FAR() : LogbookMessageValue { +class FAR : LogbookMessageValue { var hauls: List = listOf() } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/messages/LAN.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/messages/LAN.kt index e4f048315c..26e7b0417e 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/messages/LAN.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/messages/LAN.kt @@ -4,7 +4,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import fr.gouv.cnsp.monitorfish.domain.entities.logbook.LogbookFishingCatch import java.time.ZonedDateTime -class LAN() : LogbookMessageValue { +class LAN : LogbookMessageValue { var port: String? = null var portName: String? = null var catchLanded: List = listOf() diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/messages/NotImplemented.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/messages/NotImplemented.kt index 4187a5d45a..01c8641d96 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/messages/NotImplemented.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/messages/NotImplemented.kt @@ -1,3 +1,3 @@ package fr.gouv.cnsp.monitorfish.domain.entities.logbook.messages -class NotImplemented() : LogbookMessageValue +class NotImplemented : LogbookMessageValue diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/messages/PNO.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/messages/PNO.kt index 43f7974658..9fa7065156 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/messages/PNO.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/messages/PNO.kt @@ -10,7 +10,7 @@ import fr.gouv.cnsp.monitorfish.utils.ZonedDateTimeSerializer import java.time.ZonedDateTime // TODO Rename to `LogbookMessageValueForPno`. -class PNO() : LogbookMessageValue { +class PNO : LogbookMessageValue { var hasPortEntranceAuthorization: Boolean? = null var hasPortLandingAuthorization: Boolean? = null diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/messages/RTP.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/messages/RTP.kt index 9f9cc4639d..f3e6730333 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/messages/RTP.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/messages/RTP.kt @@ -4,7 +4,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import fr.gouv.cnsp.monitorfish.domain.entities.logbook.LogbookTripGear import java.time.ZonedDateTime -class RTP() : LogbookMessageValue { +class RTP : LogbookMessageValue { var reasonOfReturn: String? = null var port: String? = null var portName: String? = null diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/env_mission_action/EnvMissionActionType.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/env_mission_action/EnvMissionActionType.kt index b54f23627f..6046953909 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/env_mission_action/EnvMissionActionType.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/env_mission_action/EnvMissionActionType.kt @@ -1,6 +1,8 @@ package fr.gouv.cnsp.monitorfish.domain.entities.mission.env_mission_action -enum class EnvMissionActionType(val value: String) { +enum class EnvMissionActionType( + val value: String, +) { CONTROL("CONTROL"), NOTE("NOTE"), SURVEILLANCE("SURVEILLANCE"), diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/mission_actions/Completion.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/mission_actions/Completion.kt index 3fd7b12618..38b0d1a3bb 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/mission_actions/Completion.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/mission_actions/Completion.kt @@ -1,6 +1,8 @@ package fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions -enum class Completion(val value: String) { +enum class Completion( + val value: String, +) { COMPLETED("COMPLETED"), TO_COMPLETE("TO_COMPLETE"), } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/mission_actions/ControlCheck.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/mission_actions/ControlCheck.kt index 881156e38f..9cbc103352 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/mission_actions/ControlCheck.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/mission_actions/ControlCheck.kt @@ -1,6 +1,8 @@ package fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions -enum class ControlCheck(val value: String) { +enum class ControlCheck( + val value: String, +) { YES("YES"), NO("NO"), NOT_APPLICABLE("NOT_APPLICABLE"), diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/mission_actions/ControlOrigin.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/mission_actions/ControlOrigin.kt index 3918218ee5..099ff2131c 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/mission_actions/ControlOrigin.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/mission_actions/ControlOrigin.kt @@ -1,6 +1,8 @@ package fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions -enum class ControlOrigin(val value: String) { +enum class ControlOrigin( + val value: String, +) { POSEIDON_ENV("POSEIDON_ENV"), POSEIDON_FISH("POSEIDON_FISH"), MONITORENV("MONITORENV"), diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/mission_actions/FlightGoal.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/mission_actions/FlightGoal.kt index 894d8ff48a..7a19441b90 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/mission_actions/FlightGoal.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/mission_actions/FlightGoal.kt @@ -1,6 +1,8 @@ package fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions -enum class FlightGoal(val value: String) { +enum class FlightGoal( + val value: String, +) { VMS_AIS_CHECK("VMS_AIS_CHECK"), UNAUTHORIZED_FISHING("UNAUTHORIZED_FISHING"), CLOSED_AREA("CLOSED_AREA"), diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/mission_actions/InfractionCategory.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/mission_actions/InfractionCategory.kt index 5304d037ec..d599ab48ed 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/mission_actions/InfractionCategory.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/mission_actions/InfractionCategory.kt @@ -1,6 +1,8 @@ package fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions -enum class InfractionCategory(val value: String) { +enum class InfractionCategory( + val value: String, +) { FISHING("Pêche"), SECURITY("Sécurité / Rôle"), } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/mission_actions/InfractionType.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/mission_actions/InfractionType.kt index 3dd67aa1ce..06791b6fab 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/mission_actions/InfractionType.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/mission_actions/InfractionType.kt @@ -1,6 +1,8 @@ package fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions -enum class InfractionType(val value: String) { +enum class InfractionType( + val value: String, +) { WITH_RECORD("WITH_RECORD"), WITHOUT_RECORD("WITHOUT_RECORD"), PENDING("PENDING"), diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/mission_actions/MissionActionType.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/mission_actions/MissionActionType.kt index fb4b53fc8a..317042bce2 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/mission_actions/MissionActionType.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/mission_actions/MissionActionType.kt @@ -1,6 +1,8 @@ package fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions -enum class MissionActionType(val value: String) { +enum class MissionActionType( + val value: String, +) { SEA_CONTROL("SEA_CONTROL"), LAND_CONTROL("LAND_CONTROL"), AIR_CONTROL("AIR_CONTROL"), diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/mission_actions/actrep/Constants.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/mission_actions/actrep/Constants.kt index 68b865fcd1..dd91bab4ac 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/mission_actions/actrep/Constants.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/mission_actions/actrep/Constants.kt @@ -213,6 +213,4 @@ val EU_QUOTAS_SPECIES = fun generateSpeciesWithFaoCode( faoZones: FaoZones, species: List, -): List { - return species.map { Pair(faoZones, it) } -} +): List = species.map { Pair(faoZones, it) } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/mission_actions/actrep/JointDeploymentPlan.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/mission_actions/actrep/JointDeploymentPlan.kt index eabfac7274..d461e30371 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/mission_actions/actrep/JointDeploymentPlan.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/mission_actions/actrep/JointDeploymentPlan.kt @@ -40,13 +40,9 @@ enum class JointDeploymentPlan( WESTERN_WATERS(WESTERN_WATERS_SPECIES, WESTERN_WATERS_OPERATIONAL_ZONES), ; - fun getSpeciesCodes(): List { - return this.species.map { it.second }.distinct() - } + fun getSpeciesCodes(): List = this.species.map { it.second }.distinct() - private fun getOperationalZones(): List { - return this.operationalZones - } + private fun getOperationalZones(): List = this.operationalZones /** * See "DÉCISION D’EXÉCUTION (UE) 2023/2376 DE LA COMMISSION": diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/oidc/UserInfo.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/oidc/UserInfo.kt index 3faad573cb..1db1f4ae3f 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/oidc/UserInfo.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/oidc/UserInfo.kt @@ -3,4 +3,6 @@ package fr.gouv.cnsp.monitorfish.domain.entities.oidc import kotlinx.serialization.Serializable @Serializable -data class UserInfo(val email: String) +data class UserInfo( + val email: String, +) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/port/Port.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/port/Port.kt index 99dc92888d..912e4ec177 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/port/Port.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/port/Port.kt @@ -13,7 +13,5 @@ data class Port( val longitude: Double?, val region: String?, ) { - fun isFrenchOrUnknown(): Boolean { - return this.countryCode === null || FRENCH_COUNTRY_CODES.contains(countryCode) - } + fun isFrenchOrUnknown(): Boolean = this.countryCode === null || FRENCH_COUNTRY_CODES.contains(countryCode) } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/position/NetworkType.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/position/NetworkType.kt index feb65f871c..d95eb8c69d 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/position/NetworkType.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/position/NetworkType.kt @@ -3,7 +3,9 @@ package fr.gouv.cnsp.monitorfish.domain.entities.position import org.slf4j.Logger import org.slf4j.LoggerFactory -enum class NetworkType(val codes: List) { +enum class NetworkType( + val codes: List, +) { CELLULAR(listOf("CEL", "GSM")), SATELLITE(listOf("SAT")), ; @@ -11,14 +13,13 @@ enum class NetworkType(val codes: List) { companion object { private val logger: Logger = LoggerFactory.getLogger(NetworkType::class.java) - infix fun from(code: String): NetworkType? { - return try { + infix fun from(code: String): NetworkType? = + try { NetworkType.entries.first { it.codes.contains(code) } } catch (e: NoSuchElementException) { logger.error("NAF Message parsing : NetworkType $code not found.", e) null } - } } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/prior_notification/PnoType.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/prior_notification/PnoType.kt index 10d39ccaae..a1e3fc72a7 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/prior_notification/PnoType.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/prior_notification/PnoType.kt @@ -7,11 +7,10 @@ data class PnoType( val hasDesignatedPorts: Boolean, val pnoTypeRules: List, ) { - fun toPriorNotificationType(): PriorNotificationType { - return PriorNotificationType( + fun toPriorNotificationType(): PriorNotificationType = + PriorNotificationType( hasDesignatedPorts, minimumNotificationPeriod, name, ) - } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/prior_notification/PriorNotification.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/prior_notification/PriorNotification.kt index 14384c6de5..0bd6f6b481 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/prior_notification/PriorNotification.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/prior_notification/PriorNotification.kt @@ -103,7 +103,9 @@ data class PriorNotification( } } else { logbookMessage.internalReferenceNumber?.let { vesselInternalReferenceNumber -> - allRiskFactors.find { it.internalReferenceNumber == vesselInternalReferenceNumber }?.lastControlDatetime + allRiskFactors + .find { it.internalReferenceNumber == vesselInternalReferenceNumber } + ?.lastControlDatetime } } } @@ -209,12 +211,11 @@ data class PriorNotification( fun getNextState( isInVerificationScope: Boolean, isPartOfControlUnitSubscriptions: Boolean, - ): PriorNotificationState { - return when { + ): PriorNotificationState = + when { isInVerificationScope -> PriorNotificationState.PENDING_VERIFICATION isPartOfControlUnitSubscriptions -> PriorNotificationState.AUTO_SEND_REQUESTED else -> PriorNotificationState.OUT_OF_VERIFICATION_SCOPE } - } } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/prior_notification/PriorNotificationCheck.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/prior_notification/PriorNotificationCheck.kt index 38dc52708c..906979d91b 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/prior_notification/PriorNotificationCheck.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/prior_notification/PriorNotificationCheck.kt @@ -31,8 +31,8 @@ data class PriorNotificationCheck( isVerified: Boolean = false, isBeingSent: Boolean = false, isSent: Boolean = false, - ): PriorNotificationCheck { - return PriorNotificationCheck( + ): PriorNotificationCheck = + PriorNotificationCheck( reportId = reportId, createdAt = CustomZonedDateTime.now().toString(), isInVerificationScope = isInVerificationScope, @@ -41,6 +41,5 @@ data class PriorNotificationCheck( isSent = isSent, updatedAt = CustomZonedDateTime.now().toString(), ) - } } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/reporting/ReportingTypeMapping.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/reporting/ReportingTypeMapping.kt index 6ef28da2a3..95102540f6 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/reporting/ReportingTypeMapping.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/reporting/ReportingTypeMapping.kt @@ -1,12 +1,12 @@ package fr.gouv.cnsp.monitorfish.domain.entities.reporting -enum class ReportingTypeMapping(private val clazz: Class) : IHasImplementation { +enum class ReportingTypeMapping( + private val clazz: Class, +) : IHasImplementation { OBSERVATION(Observation::class.java), INFRACTION_SUSPICION(InfractionSuspicion::class.java), ; - override fun getImplementation(): Class { - return clazz - } + override fun getImplementation(): Class = clazz } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/reporting/ReportingValue.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/reporting/ReportingValue.kt index 889aa238e3..0877ef8b22 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/reporting/ReportingValue.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/reporting/ReportingValue.kt @@ -1,3 +1,5 @@ package fr.gouv.cnsp.monitorfish.domain.entities.reporting -abstract class ReportingValue(open val natinfCode: Int? = null) +abstract class ReportingValue( + open val natinfCode: Int? = null, +) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/species/SpeciesAndSpeciesGroups.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/species/SpeciesAndSpeciesGroups.kt index 7f563f0a5d..8acae06024 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/species/SpeciesAndSpeciesGroups.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/species/SpeciesAndSpeciesGroups.kt @@ -1,3 +1,6 @@ package fr.gouv.cnsp.monitorfish.domain.entities.species -data class SpeciesAndSpeciesGroups(val species: List, val groups: List) +data class SpeciesAndSpeciesGroups( + val species: List, + val groups: List, +) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/species/SpeciesGroup.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/species/SpeciesGroup.kt index e76dc55a22..f3d639e471 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/species/SpeciesGroup.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/species/SpeciesGroup.kt @@ -1,3 +1,6 @@ package fr.gouv.cnsp.monitorfish.domain.entities.species -data class SpeciesGroup(val group: String, val comment: String) +data class SpeciesGroup( + val group: String, + val comment: String, +) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/vessel/Vessel.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/vessel/Vessel.kt index fbd6b9b733..a319652208 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/vessel/Vessel.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/vessel/Vessel.kt @@ -67,13 +67,9 @@ data class Vessel( return "$districtCode$identifier" } - fun isFrench(): Boolean { - return FRENCH_COUNTRY_CODES.contains(flagState.alpha2) - } + fun isFrench(): Boolean = FRENCH_COUNTRY_CODES.contains(flagState.alpha2) - fun isLessThanTwelveMetersVessel(): Boolean { - return length?.let { it < 12.0 } == true - } + fun isLessThanTwelveMetersVessel(): Boolean = length?.let { it < 12.0 } == true } val LIKELY_CONTROLLED_COUNTRY_CODES = diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/exceptions/CodeNotFoundException.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/exceptions/CodeNotFoundException.kt index 9cf100fbf6..20ff8bb07a 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/exceptions/CodeNotFoundException.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/exceptions/CodeNotFoundException.kt @@ -1,4 +1,6 @@ package fr.gouv.cnsp.monitorfish.domain.exceptions -class CodeNotFoundException(message: String, cause: Throwable? = null) : - Throwable(message, cause) +class CodeNotFoundException( + message: String, + cause: Throwable? = null, +) : Throwable(message, cause) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/exceptions/CouldNotDeleteException.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/exceptions/CouldNotDeleteException.kt index fc5336d33f..aefee51a36 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/exceptions/CouldNotDeleteException.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/exceptions/CouldNotDeleteException.kt @@ -1,4 +1,6 @@ package fr.gouv.cnsp.monitorfish.domain.exceptions -class CouldNotDeleteException(message: String, cause: Throwable? = null) : - Throwable(message, cause) +class CouldNotDeleteException( + message: String, + cause: Throwable? = null, +) : Throwable(message, cause) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/exceptions/CouldNotFindException.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/exceptions/CouldNotFindException.kt index 55b5544bcc..d70c059677 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/exceptions/CouldNotFindException.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/exceptions/CouldNotFindException.kt @@ -1,4 +1,6 @@ package fr.gouv.cnsp.monitorfish.domain.exceptions -class CouldNotFindException(message: String, cause: Throwable? = null) : - Throwable(message, cause) +class CouldNotFindException( + message: String, + cause: Throwable? = null, +) : Throwable(message, cause) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/exceptions/CouldNotUpdateBeaconMalfunctionException.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/exceptions/CouldNotUpdateBeaconMalfunctionException.kt index a6f79f5f5d..cec7061055 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/exceptions/CouldNotUpdateBeaconMalfunctionException.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/exceptions/CouldNotUpdateBeaconMalfunctionException.kt @@ -1,4 +1,6 @@ package fr.gouv.cnsp.monitorfish.domain.exceptions -class CouldNotUpdateBeaconMalfunctionException(message: String, cause: Throwable? = null) : - Throwable(message, cause) +class CouldNotUpdateBeaconMalfunctionException( + message: String, + cause: Throwable? = null, +) : Throwable(message, cause) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/exceptions/CouldNotUpdateControlObjectiveException.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/exceptions/CouldNotUpdateControlObjectiveException.kt index 7b1dafe409..b255e338a7 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/exceptions/CouldNotUpdateControlObjectiveException.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/exceptions/CouldNotUpdateControlObjectiveException.kt @@ -1,4 +1,6 @@ package fr.gouv.cnsp.monitorfish.domain.exceptions -class CouldNotUpdateControlObjectiveException(message: String, cause: Throwable? = null) : - Throwable(message, cause) +class CouldNotUpdateControlObjectiveException( + message: String, + cause: Throwable? = null, +) : Throwable(message, cause) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/exceptions/CouldNotUpdateFleetSegmentException.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/exceptions/CouldNotUpdateFleetSegmentException.kt index 8eb5981d1f..190cc2e9ca 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/exceptions/CouldNotUpdateFleetSegmentException.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/exceptions/CouldNotUpdateFleetSegmentException.kt @@ -1,4 +1,6 @@ package fr.gouv.cnsp.monitorfish.domain.exceptions -class CouldNotUpdateFleetSegmentException(message: String, cause: Throwable? = null) : - Throwable(message, cause) +class CouldNotUpdateFleetSegmentException( + message: String, + cause: Throwable? = null, +) : Throwable(message, cause) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/exceptions/EntityConversionException.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/exceptions/EntityConversionException.kt index dabb510cf7..f0944d26a8 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/exceptions/EntityConversionException.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/exceptions/EntityConversionException.kt @@ -1,4 +1,6 @@ package fr.gouv.cnsp.monitorfish.domain.exceptions -class EntityConversionException(message: String, cause: Throwable? = null) : - Throwable(message, cause) +class EntityConversionException( + message: String, + cause: Throwable? = null, +) : Throwable(message, cause) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/exceptions/LogbookReportNotEnrichedException.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/exceptions/LogbookReportNotEnrichedException.kt index f68eea3bc7..b5705a1f12 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/exceptions/LogbookReportNotEnrichedException.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/exceptions/LogbookReportNotEnrichedException.kt @@ -1,4 +1,6 @@ package fr.gouv.cnsp.monitorfish.domain.exceptions /** Thrown when a logbook report is not enriched. */ -class LogbookReportNotEnrichedException(message: String) : RuntimeException(message) +class LogbookReportNotEnrichedException( + message: String, +) : RuntimeException(message) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/exceptions/NAFMessageParsingException.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/exceptions/NAFMessageParsingException.kt index 45dbb9e041..228da78fcf 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/exceptions/NAFMessageParsingException.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/exceptions/NAFMessageParsingException.kt @@ -1,4 +1,7 @@ package fr.gouv.cnsp.monitorfish.domain.exceptions -class NAFMessageParsingException(message: String, nafMessage: String, cause: Throwable? = null) : - Throwable("$message for NAF message \"$nafMessage\"", cause) +class NAFMessageParsingException( + message: String, + nafMessage: String, + cause: Throwable? = null, +) : Throwable("$message for NAF message \"$nafMessage\"", cause) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/exceptions/NatinfCodeNotFoundException.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/exceptions/NatinfCodeNotFoundException.kt index d18637774d..d28ce33648 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/exceptions/NatinfCodeNotFoundException.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/exceptions/NatinfCodeNotFoundException.kt @@ -1,4 +1,6 @@ package fr.gouv.cnsp.monitorfish.domain.exceptions -class NatinfCodeNotFoundException(message: String, cause: Throwable? = null) : - Throwable(message, cause) +class NatinfCodeNotFoundException( + message: String, + cause: Throwable? = null, +) : Throwable(message, cause) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/exceptions/NoERSMessagesFound.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/exceptions/NoERSMessagesFound.kt index 1112c0df60..735a20b2b2 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/exceptions/NoERSMessagesFound.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/exceptions/NoERSMessagesFound.kt @@ -1,4 +1,6 @@ package fr.gouv.cnsp.monitorfish.domain.exceptions -class NoERSMessagesFound(message: String, cause: Throwable? = null) : - Throwable(message, cause) +class NoERSMessagesFound( + message: String, + cause: Throwable? = null, +) : Throwable(message, cause) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/exceptions/NoLogbookFishingTripFound.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/exceptions/NoLogbookFishingTripFound.kt index 0584aeb9f9..c7d6a524a1 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/exceptions/NoLogbookFishingTripFound.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/exceptions/NoLogbookFishingTripFound.kt @@ -1,4 +1,6 @@ package fr.gouv.cnsp.monitorfish.domain.exceptions -class NoLogbookFishingTripFound(message: String, cause: Throwable? = null) : - Throwable(message, cause) +class NoLogbookFishingTripFound( + message: String, + cause: Throwable? = null, +) : Throwable(message, cause) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/exceptions/WrongTypeException.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/exceptions/WrongTypeException.kt index b6f26339be..4e429944ed 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/exceptions/WrongTypeException.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/exceptions/WrongTypeException.kt @@ -1,4 +1,6 @@ package fr.gouv.cnsp.monitorfish.domain.exceptions /** Thrown when a database row data is not of the expected category or type. */ -class WrongTypeException(message: String) : RuntimeException(message) +class WrongTypeException( + message: String, +) : RuntimeException(message) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/helpers/GeoHelpers.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/helpers/GeoHelpers.kt index a1110dd8cd..dfe9623485 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/helpers/GeoHelpers.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/helpers/GeoHelpers.kt @@ -1,6 +1,8 @@ package fr.gouv.cnsp.monitorfish.domain.helpers -enum class Direction(val direction: String) { +enum class Direction( + val direction: String, +) { N("N"), S("S"), E("E"), diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/mappers/ERSMapper.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/mappers/ERSMapper.kt index 6c41a4ddb3..ae16174384 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/mappers/ERSMapper.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/mappers/ERSMapper.kt @@ -17,8 +17,8 @@ object ERSMapper { message: String?, messageType: String?, operationType: LogbookOperationType, - ): LogbookMessageValue? { - return try { + ): LogbookMessageValue? = + try { if (operationType == LogbookOperationType.RET && !message.isNullOrEmpty() && message != JSONB_NULL_STRING) { val classType = LogbookOperationTypeMapping.getClassFromName(operationType.name) @@ -33,5 +33,4 @@ object ERSMapper { } catch (e: Exception) { throw EntityConversionException("Error while converting 'LogbookMessage'. $message", e) } - } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/mappers/NAFCode.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/mappers/NAFCode.kt index e7fa563e57..bab29d3992 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/mappers/NAFCode.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/mappers/NAFCode.kt @@ -2,7 +2,9 @@ package fr.gouv.cnsp.monitorfish.domain.mappers import java.util.regex.Pattern -enum class NAFCode(val code: String) { +enum class NAFCode( + val code: String, +) { START_RECORD("SR"), END_RECORD("ER"), FROM("FR"), diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/mappers/NAFMessageMapper.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/mappers/NAFMessageMapper.kt index 49bfd81969..003ed79d9c 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/mappers/NAFMessageMapper.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/mappers/NAFMessageMapper.kt @@ -14,7 +14,9 @@ import java.time.ZonedDateTime import java.time.format.DateTimeFormatter import kotlin.properties.Delegates -class NAFMessageMapper(private val naf: String) { +class NAFMessageMapper( + private val naf: String, +) { private val logger: Logger = LoggerFactory.getLogger(NAFMessageMapper::class.java) private lateinit var dateTime: ZonedDateTime @@ -45,7 +47,8 @@ class NAFMessageMapper(private val naf: String) { throw NAFMessageParsingException("Invalid NAF format", naf) } - NAFCode.values() + NAFCode + .values() .filter { it.matches(naf) } .forEach { val value: String = it.getValue(naf)!! @@ -109,13 +112,12 @@ class NAFMessageMapper(private val naf: String) { return message.startsWith(startRecord) && message.endsWith(endRecord) } - private fun getCountryOrThrowIfCountryNotFound(value: String): CountryCode? { - return if (value.isNotEmpty() && value != noCountry) { + private fun getCountryOrThrowIfCountryNotFound(value: String): CountryCode? = + if (value.isNotEmpty() && value != noCountry) { CountryCode.getByAlpha3Code(value) ?: throw NAFMessageParsingException("Country \"$value\" not found", naf) } else { null } - } private fun setZoneDateTimeFromString() { if (date != null && time != null) { @@ -133,7 +135,8 @@ class NAFMessageMapper(private val naf: String) { val regex = "([NSEW]{1})([0-9]{2,3})([0-9]{2})".toRegex() return try { - regex.matchEntire(value) + regex + .matchEntire(value) ?.destructured ?.let { (direction, degrees, minutes) -> degreeMinuteToDecimal(direction, degrees.toInt(), minutes.toInt()) @@ -144,8 +147,8 @@ class NAFMessageMapper(private val naf: String) { } } - fun toPosition(): Position { - return Position( + fun toPosition(): Position = + Position( internalReferenceNumber = internalReferenceNumber, ircs = ircs, externalReferenceNumber = externalReferenceNumber, @@ -163,5 +166,4 @@ class NAFMessageMapper(private val naf: String) { networkType = networkType, isManual = isManual, ) - } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/mappers/PatchEntity.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/mappers/PatchEntity.kt index 7c4066836c..3561bddead 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/mappers/PatchEntity.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/mappers/PatchEntity.kt @@ -50,11 +50,10 @@ class PatchEntity { private fun getValueFromOptional( existingValue: Any?, optional: Optional<*>?, - ): Any? { - return when { + ): Any? = + when { optional == null -> existingValue optional.isPresent -> optional.get() else -> null } - } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/mappers/ReportingMapper.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/mappers/ReportingMapper.kt index 18b04f1711..743df0e3de 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/mappers/ReportingMapper.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/mappers/ReportingMapper.kt @@ -17,8 +17,8 @@ object ReportingMapper { mapper: ObjectMapper, message: String?, reportingType: ReportingType, - ): ReportingValue { - return try { + ): ReportingValue = + try { if (!message.isNullOrEmpty() && message != jsonbNullString) { when (reportingType) { ReportingType.ALERT -> mapper.readValue(message, AlertType::class.java) @@ -31,5 +31,4 @@ object ReportingMapper { } catch (e: Exception) { throw EntityConversionException("Error while converting 'Reporting'. $message", e) } - } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/alert/DeleteSilencedAlert.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/alert/DeleteSilencedAlert.kt index 9a6bf3ef3d..df04ffd0fb 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/alert/DeleteSilencedAlert.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/alert/DeleteSilencedAlert.kt @@ -5,7 +5,9 @@ import fr.gouv.cnsp.monitorfish.domain.repositories.SilencedAlertRepository import org.slf4j.LoggerFactory @UseCase -class DeleteSilencedAlert(private val silencedAlertRepository: SilencedAlertRepository) { +class DeleteSilencedAlert( + private val silencedAlertRepository: SilencedAlertRepository, +) { private val logger = LoggerFactory.getLogger(DeleteSilencedAlert::class.java) fun execute(silencedAlertId: Int) { diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/alert/GetPendingAlerts.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/alert/GetPendingAlerts.kt index 5bd37fbec8..a7c615e012 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/alert/GetPendingAlerts.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/alert/GetPendingAlerts.kt @@ -15,27 +15,27 @@ class GetPendingAlerts( ) { private val logger = LoggerFactory.getLogger(GetPendingAlerts::class.java) - fun execute(): List { - return pendingAlertRepository.findAlertsOfTypes( - listOf( - AlertTypeMapping.THREE_MILES_TRAWLING_ALERT, - AlertTypeMapping.FRENCH_EEZ_FISHING_ALERT, - AlertTypeMapping.TWELVE_MILES_FISHING_ALERT, - AlertTypeMapping.RTC_FISHING_ALERT, - AlertTypeMapping.MISSING_DEP_ALERT, - AlertTypeMapping.MISSING_FAR_48_HOURS_ALERT, - AlertTypeMapping.SUSPICION_OF_UNDER_DECLARATION_ALERT, - ), - ).map { pendingAlert -> - pendingAlert.value.natinfCode?.let { - try { - pendingAlert.infraction = infractionRepository.findInfractionByNatinfCode(it) - } catch (e: NatinfCodeNotFoundException) { - logger.warn(e.message) + fun execute(): List = + pendingAlertRepository + .findAlertsOfTypes( + listOf( + AlertTypeMapping.THREE_MILES_TRAWLING_ALERT, + AlertTypeMapping.FRENCH_EEZ_FISHING_ALERT, + AlertTypeMapping.TWELVE_MILES_FISHING_ALERT, + AlertTypeMapping.RTC_FISHING_ALERT, + AlertTypeMapping.MISSING_DEP_ALERT, + AlertTypeMapping.MISSING_FAR_48_HOURS_ALERT, + AlertTypeMapping.SUSPICION_OF_UNDER_DECLARATION_ALERT, + ), + ).map { pendingAlert -> + pendingAlert.value.natinfCode?.let { + try { + pendingAlert.infraction = infractionRepository.findInfractionByNatinfCode(it) + } catch (e: NatinfCodeNotFoundException) { + logger.warn(e.message) + } } - } - pendingAlert - } - } + pendingAlert + } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/alert/GetSilencedAlerts.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/alert/GetSilencedAlerts.kt index dd2a01ee66..5f4c6950c2 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/alert/GetSilencedAlerts.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/alert/GetSilencedAlerts.kt @@ -6,13 +6,15 @@ import fr.gouv.cnsp.monitorfish.domain.repositories.SilencedAlertRepository import org.slf4j.LoggerFactory @UseCase -class GetSilencedAlerts(private val silencedAlertRepository: SilencedAlertRepository) { +class GetSilencedAlerts( + private val silencedAlertRepository: SilencedAlertRepository, +) { private val logger = LoggerFactory.getLogger(GetSilencedAlerts::class.java) - fun execute(): List { - return silencedAlertRepository.findAllCurrentSilencedAlerts() + fun execute(): List = + silencedAlertRepository + .findAllCurrentSilencedAlerts() .filter { it.wasValidated == null || it.wasValidated.let { wasValidated -> !wasValidated } } - } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/beacon_malfunction/GetAllForeignFMCs.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/beacon_malfunction/GetAllForeignFMCs.kt index a1f10a3bfc..53f75257a2 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/beacon_malfunction/GetAllForeignFMCs.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/beacon_malfunction/GetAllForeignFMCs.kt @@ -5,8 +5,8 @@ import fr.gouv.cnsp.monitorfish.domain.entities.beacon_malfunctions.ForeignFMC import fr.gouv.cnsp.monitorfish.domain.repositories.ForeignFMCRepository @UseCase -class GetAllForeignFMCs(private val foreignFMCRepository: ForeignFMCRepository) { - fun execute(): List { - return foreignFMCRepository.findAll() - } +class GetAllForeignFMCs( + private val foreignFMCRepository: ForeignFMCRepository, +) { + fun execute(): List = foreignFMCRepository.findAll() } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/beacon_malfunction/GetBeaconMalfunction.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/beacon_malfunction/GetBeaconMalfunction.kt index 3d1fe929ef..f24644240c 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/beacon_malfunction/GetBeaconMalfunction.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/beacon_malfunction/GetBeaconMalfunction.kt @@ -33,9 +33,10 @@ class GetBeaconMalfunction( ) val riskFactor = - lastPositions.find( - BeaconMalfunction.getVesselFromBeaconMalfunction(beaconMalfunction), - )?.riskFactor + lastPositions + .find( + BeaconMalfunction.getVesselFromBeaconMalfunction(beaconMalfunction), + )?.riskFactor beaconMalfunction.riskFactor = riskFactor if (riskFactor == null) { diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/beacon_malfunction/RequestNotification.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/beacon_malfunction/RequestNotification.kt index 659d9c2baf..429686f71b 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/beacon_malfunction/RequestNotification.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/beacon_malfunction/RequestNotification.kt @@ -5,7 +5,9 @@ import fr.gouv.cnsp.monitorfish.domain.entities.beacon_malfunctions.BeaconMalfun import fr.gouv.cnsp.monitorfish.domain.repositories.BeaconMalfunctionsRepository @UseCase -class RequestNotification(private val beaconMalfunctionsRepository: BeaconMalfunctionsRepository) { +class RequestNotification( + private val beaconMalfunctionsRepository: BeaconMalfunctionsRepository, +) { fun execute( id: Int, notificationRequested: BeaconMalfunctionNotificationType, diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_objective/AddControlObjective.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_objective/AddControlObjective.kt index 7e1a1df075..af67fdcbeb 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_objective/AddControlObjective.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_objective/AddControlObjective.kt @@ -5,13 +5,15 @@ import fr.gouv.cnsp.monitorfish.domain.entities.control_objective.ControlObjecti import fr.gouv.cnsp.monitorfish.domain.repositories.ControlObjectivesRepository @UseCase -class AddControlObjective(private val controlObjectivesRepository: ControlObjectivesRepository) { +class AddControlObjective( + private val controlObjectivesRepository: ControlObjectivesRepository, +) { fun execute( segment: String, facade: String, year: Int, - ): Int { - return controlObjectivesRepository.add( + ): Int = + controlObjectivesRepository.add( ControlObjective( segment = segment, facade = facade, @@ -21,5 +23,4 @@ class AddControlObjective(private val controlObjectivesRepository: ControlObject controlPriorityLevel = 1.0, ), ) - } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_objective/DeleteControlObjective.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_objective/DeleteControlObjective.kt index 15688ae641..02e4d73c36 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_objective/DeleteControlObjective.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_objective/DeleteControlObjective.kt @@ -5,7 +5,9 @@ import fr.gouv.cnsp.monitorfish.domain.exceptions.CouldNotDeleteException import fr.gouv.cnsp.monitorfish.domain.repositories.ControlObjectivesRepository @UseCase -class DeleteControlObjective(private val controlObjectivesRepository: ControlObjectivesRepository) { +class DeleteControlObjective( + private val controlObjectivesRepository: ControlObjectivesRepository, +) { @Throws(CouldNotDeleteException::class, IllegalArgumentException::class) fun execute(id: Int) { controlObjectivesRepository.delete(id) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_objective/GetControlObjectiveYearEntries.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_objective/GetControlObjectiveYearEntries.kt index 1da4c021ab..f5e81f5148 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_objective/GetControlObjectiveYearEntries.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_objective/GetControlObjectiveYearEntries.kt @@ -4,8 +4,8 @@ import fr.gouv.cnsp.monitorfish.config.UseCase import fr.gouv.cnsp.monitorfish.domain.repositories.ControlObjectivesRepository @UseCase -class GetControlObjectiveYearEntries(private val controlObjectivesRepository: ControlObjectivesRepository) { - fun execute(): List { - return controlObjectivesRepository.findYearEntries() - } +class GetControlObjectiveYearEntries( + private val controlObjectivesRepository: ControlObjectivesRepository, +) { + fun execute(): List = controlObjectivesRepository.findYearEntries() } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_objective/GetControlObjectivesOfYear.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_objective/GetControlObjectivesOfYear.kt index cf2300bf4d..5e56fc0456 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_objective/GetControlObjectivesOfYear.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_objective/GetControlObjectivesOfYear.kt @@ -5,8 +5,8 @@ import fr.gouv.cnsp.monitorfish.domain.entities.control_objective.ControlObjecti import fr.gouv.cnsp.monitorfish.domain.repositories.ControlObjectivesRepository @UseCase -class GetControlObjectivesOfYear(private val controlObjectivesRepository: ControlObjectivesRepository) { - fun execute(year: Int): List { - return controlObjectivesRepository.findAllByYear(year) - } +class GetControlObjectivesOfYear( + private val controlObjectivesRepository: ControlObjectivesRepository, +) { + fun execute(year: Int): List = controlObjectivesRepository.findAllByYear(year) } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_objective/UpdateControlObjective.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_objective/UpdateControlObjective.kt index d95cac0843..ef2d810bcc 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_objective/UpdateControlObjective.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_objective/UpdateControlObjective.kt @@ -5,7 +5,9 @@ import fr.gouv.cnsp.monitorfish.domain.exceptions.CouldNotUpdateControlObjective import fr.gouv.cnsp.monitorfish.domain.repositories.ControlObjectivesRepository @UseCase -class UpdateControlObjective(private val controlObjectivesRepository: ControlObjectivesRepository) { +class UpdateControlObjective( + private val controlObjectivesRepository: ControlObjectivesRepository, +) { @Throws(CouldNotUpdateControlObjectiveException::class, IllegalArgumentException::class) fun execute( id: Int, diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_units/GetAllControlUnits.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_units/GetAllControlUnits.kt index 2ab16c62da..9cccde7259 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_units/GetAllControlUnits.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_units/GetAllControlUnits.kt @@ -8,7 +8,5 @@ import fr.gouv.cnsp.monitorfish.domain.use_cases.control_units.dtos.FullControlU class GetAllControlUnits( private val controlUnitsRepository: ControlUnitRepository, ) { - fun execute(): List { - return controlUnitsRepository.findAll() - } + fun execute(): List = controlUnitsRepository.findAll() } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_units/GetAllLegacyControlUnits.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_units/GetAllLegacyControlUnits.kt index d65ee9cc32..f848608a24 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_units/GetAllLegacyControlUnits.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_units/GetAllLegacyControlUnits.kt @@ -8,7 +8,5 @@ import fr.gouv.cnsp.monitorfish.domain.repositories.LegacyControlUnitRepository class GetAllLegacyControlUnits( private val legacyControlUnitsRepository: LegacyControlUnitRepository, ) { - fun execute(): List { - return legacyControlUnitsRepository.findAll() - } + fun execute(): List = legacyControlUnitsRepository.findAll() } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/fao_areas/ComputeFaoAreasFromCoordinates.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/fao_areas/ComputeFaoAreasFromCoordinates.kt index 8c253eb128..20d5ae4b5e 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/fao_areas/ComputeFaoAreasFromCoordinates.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/fao_areas/ComputeFaoAreasFromCoordinates.kt @@ -8,7 +8,9 @@ import org.locationtech.jts.geom.Coordinate import org.locationtech.jts.geom.GeometryFactory @UseCase -class ComputeFaoAreasFromCoordinates(private val faoAreaRepository: FaoAreaRepository) { +class ComputeFaoAreasFromCoordinates( + private val faoAreaRepository: FaoAreaRepository, +) { fun execute( longitude: Double, latitude: Double, diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/fao_areas/GetFaoAreas.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/fao_areas/GetFaoAreas.kt index a4f79d4727..2a9f4c20ab 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/fao_areas/GetFaoAreas.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/fao_areas/GetFaoAreas.kt @@ -4,7 +4,9 @@ import fr.gouv.cnsp.monitorfish.config.UseCase import fr.gouv.cnsp.monitorfish.domain.repositories.FaoAreaRepository @UseCase -class GetFaoAreas(private val faoAreaRepository: FaoAreaRepository) { +class GetFaoAreas( + private val faoAreaRepository: FaoAreaRepository, +) { fun execute(): List { val faoAreas = faoAreaRepository.findAllSortedByUsage() diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/fleet_segment/ComputeFleetSegments.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/fleet_segment/ComputeFleetSegments.kt index a99992030a..01978f6de4 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/fleet_segment/ComputeFleetSegments.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/fleet_segment/ComputeFleetSegments.kt @@ -54,71 +54,75 @@ class ComputeFleetSegments( val speciesToSegments = speciesCatches.map { specyCatch -> val computedSegment = - fleetSegments.filter { fleetSegment -> - /** - * minShareOfTargetSpecies - */ - val containsTargetSpecies = - speciesCatches.any { summedSpecyCatch -> - fleetSegment.targetSpecies.any { it == summedSpecyCatch.species } - } - val sumOfTargetSpeciesWeight = - speciesCatches - .filter { summedSpecyCatch -> + fleetSegments + .filter { fleetSegment -> + /** + * minShareOfTargetSpecies + */ + val containsTargetSpecies = + speciesCatches.any { summedSpecyCatch -> fleetSegment.targetSpecies.any { it == summedSpecyCatch.species } - }.sumOf { it.weight } - val shareOfTargetSpecies = sumOfTargetSpeciesWeight / totalSumOfSpeciesWeight - - // This condition is used to add "by hand" a fleet segment to a PNO or a control, - // by adding a species with a 0.0 weight - val hasZeroWeightTargetSpecies = - containsTargetSpecies && - sumOfTargetSpeciesWeight == 0.0 && - fleetSegment.minShareOfTargetSpecies == 0.0 - - val hasMinShareOfTargetSpecies = - fleetSegment.minShareOfTargetSpecies == null || - fleetSegment.targetSpecies.isEmpty() || - shareOfTargetSpecies > fleetSegment.minShareOfTargetSpecies || - hasZeroWeightTargetSpecies - - /** - * gears - */ - val isContainingGearFromList = - fleetSegment.gears.isEmpty() || fleetSegment.gears.any { gear -> gear == specyCatch.gear } - - /** - * faoAreas - */ - val isContainingFaoAreaFromList = - fleetSegment.faoAreas.isEmpty() || - fleetSegment.faoAreas.any { faoArea -> - FaoArea(specyCatch.faoArea).hasFaoCodeIncludedIn(faoArea) } - - /** - * mesh - */ - val isMeshAboveMinMesh = - fleetSegment.minMesh == null || (specyCatch.mesh != null && specyCatch.mesh >= fleetSegment.minMesh) - val isMeshBelowMaxMesh = - fleetSegment.maxMesh == null || (specyCatch.mesh != null && specyCatch.mesh < fleetSegment.maxMesh) - val hasRightVesselType = - fleetSegment.vesselTypes.isEmpty() || fleetSegment.vesselTypes.any { it == vesselType } - - val hasMainScipSpeciesType = - fleetSegment.mainScipSpeciesType == null || - fleetSegment.mainScipSpeciesType == mainScipSpeciesType - - return@filter isContainingGearFromList && - isContainingFaoAreaFromList && - isMeshAboveMinMesh && - isMeshBelowMaxMesh && - hasRightVesselType && - hasMainScipSpeciesType && - hasMinShareOfTargetSpecies - }.maxByOrNull { it.priority } + val sumOfTargetSpeciesWeight = + speciesCatches + .filter { summedSpecyCatch -> + fleetSegment.targetSpecies.any { it == summedSpecyCatch.species } + }.sumOf { it.weight } + val shareOfTargetSpecies = sumOfTargetSpeciesWeight / totalSumOfSpeciesWeight + + // This condition is used to add "by hand" a fleet segment to a PNO or a control, + // by adding a species with a 0.0 weight + val hasZeroWeightTargetSpecies = + containsTargetSpecies && + sumOfTargetSpeciesWeight == 0.0 && + fleetSegment.minShareOfTargetSpecies == 0.0 + + val hasMinShareOfTargetSpecies = + fleetSegment.minShareOfTargetSpecies == null || + fleetSegment.targetSpecies.isEmpty() || + shareOfTargetSpecies > fleetSegment.minShareOfTargetSpecies || + hasZeroWeightTargetSpecies + + /** + * gears + */ + val isContainingGearFromList = + fleetSegment.gears.isEmpty() || + fleetSegment.gears.any { gear -> gear == specyCatch.gear } + + /** + * faoAreas + */ + val isContainingFaoAreaFromList = + fleetSegment.faoAreas.isEmpty() || + fleetSegment.faoAreas.any { faoArea -> + FaoArea(specyCatch.faoArea).hasFaoCodeIncludedIn(faoArea) + } + + /** + * mesh + */ + val isMeshAboveMinMesh = + fleetSegment.minMesh == null || + (specyCatch.mesh != null && specyCatch.mesh >= fleetSegment.minMesh) + val isMeshBelowMaxMesh = + fleetSegment.maxMesh == null || + (specyCatch.mesh != null && specyCatch.mesh < fleetSegment.maxMesh) + val hasRightVesselType = + fleetSegment.vesselTypes.isEmpty() || fleetSegment.vesselTypes.any { it == vesselType } + + val hasMainScipSpeciesType = + fleetSegment.mainScipSpeciesType == null || + fleetSegment.mainScipSpeciesType == mainScipSpeciesType + + return@filter isContainingGearFromList && + isContainingFaoAreaFromList && + isMeshAboveMinMesh && + isMeshBelowMaxMesh && + hasRightVesselType && + hasMainScipSpeciesType && + hasMinShareOfTargetSpecies + }.maxByOrNull { it.priority } return@map Pair(specyCatch, computedSegment) } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/fleet_segment/CreateFleetSegment.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/fleet_segment/CreateFleetSegment.kt index 1c3ec81155..237959e8f0 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/fleet_segment/CreateFleetSegment.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/fleet_segment/CreateFleetSegment.kt @@ -6,7 +6,9 @@ import fr.gouv.cnsp.monitorfish.domain.repositories.FleetSegmentRepository import fr.gouv.cnsp.monitorfish.domain.use_cases.dtos.CreateOrUpdateFleetSegmentFields @UseCase -class CreateFleetSegment(private val fleetSegmentRepository: FleetSegmentRepository) { +class CreateFleetSegment( + private val fleetSegmentRepository: FleetSegmentRepository, +) { fun execute(fields: CreateOrUpdateFleetSegmentFields): FleetSegment { require(fields.segment != null) { "`segment` must be provided" diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/fleet_segment/DeleteFleetSegment.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/fleet_segment/DeleteFleetSegment.kt index 7c56344fde..0bd84b1217 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/fleet_segment/DeleteFleetSegment.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/fleet_segment/DeleteFleetSegment.kt @@ -6,12 +6,12 @@ import fr.gouv.cnsp.monitorfish.domain.exceptions.CouldNotDeleteException import fr.gouv.cnsp.monitorfish.domain.repositories.FleetSegmentRepository @UseCase -class DeleteFleetSegment(private val fleetSegmentRepository: FleetSegmentRepository) { +class DeleteFleetSegment( + private val fleetSegmentRepository: FleetSegmentRepository, +) { @Throws(CouldNotDeleteException::class, IllegalArgumentException::class) fun execute( segment: String, year: Int, - ): List { - return fleetSegmentRepository.delete(segment, year) - } + ): List = fleetSegmentRepository.delete(segment, year) } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/fleet_segment/GetAllFleetSegmentsByYear.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/fleet_segment/GetAllFleetSegmentsByYear.kt index 1d3029a5e2..a1397bd098 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/fleet_segment/GetAllFleetSegmentsByYear.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/fleet_segment/GetAllFleetSegmentsByYear.kt @@ -5,8 +5,8 @@ import fr.gouv.cnsp.monitorfish.domain.entities.fleet_segment.FleetSegment import fr.gouv.cnsp.monitorfish.domain.repositories.FleetSegmentRepository @UseCase -class GetAllFleetSegmentsByYear(private val fleetSegmentRepository: FleetSegmentRepository) { - fun execute(year: Int): List { - return fleetSegmentRepository.findAllByYear(year) - } +class GetAllFleetSegmentsByYear( + private val fleetSegmentRepository: FleetSegmentRepository, +) { + fun execute(year: Int): List = fleetSegmentRepository.findAllByYear(year) } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/fleet_segment/GetFleetSegmentYearEntries.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/fleet_segment/GetFleetSegmentYearEntries.kt index fb8d79c49c..715576aa5f 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/fleet_segment/GetFleetSegmentYearEntries.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/fleet_segment/GetFleetSegmentYearEntries.kt @@ -4,8 +4,8 @@ import fr.gouv.cnsp.monitorfish.config.UseCase import fr.gouv.cnsp.monitorfish.domain.repositories.FleetSegmentRepository @UseCase -class GetFleetSegmentYearEntries(private val fleetSegmentRepository: FleetSegmentRepository) { - fun execute(): List { - return fleetSegmentRepository.findYearEntries() - } +class GetFleetSegmentYearEntries( + private val fleetSegmentRepository: FleetSegmentRepository, +) { + fun execute(): List = fleetSegmentRepository.findYearEntries() } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/fleet_segment/UpdateFleetSegment.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/fleet_segment/UpdateFleetSegment.kt index 11b4ec70f9..b968240336 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/fleet_segment/UpdateFleetSegment.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/fleet_segment/UpdateFleetSegment.kt @@ -7,7 +7,9 @@ import fr.gouv.cnsp.monitorfish.domain.repositories.FleetSegmentRepository import fr.gouv.cnsp.monitorfish.domain.use_cases.dtos.CreateOrUpdateFleetSegmentFields @UseCase -class UpdateFleetSegment(private val fleetSegmentRepository: FleetSegmentRepository) { +class UpdateFleetSegment( + private val fleetSegmentRepository: FleetSegmentRepository, +) { @Throws(CouldNotUpdateFleetSegmentException::class, IllegalArgumentException::class) fun execute( segment: String, diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/fleet_segment/Utils.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/fleet_segment/Utils.kt index 9608c61da0..a002b6aae7 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/fleet_segment/Utils.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/fleet_segment/Utils.kt @@ -60,8 +60,8 @@ fun getSpeciesCatchesForSegmentCalculation( gears: List, species: List, allSpecies: List, -): List { - return faoAreas.flatMap { faoArea -> +): List = + faoAreas.flatMap { faoArea -> gears.flatMap { gear -> species.map { specy -> val scipSpeciesType = allSpecies.find { it.code == specy.speciesCode }?.scipSpeciesType @@ -79,14 +79,13 @@ fun getSpeciesCatchesForSegmentCalculation( } } } -} fun getSpeciesCatchesForSegmentCalculation( gearCodes: List, catches: List, allSpecies: List, -): List { - return gearCodes.flatMap { gearCode -> +): List = + gearCodes.flatMap { gearCode -> catches.map { specy -> val scipSpeciesType = allSpecies.find { it.code == specy.species }?.scipSpeciesType val weight = specy.weight ?: 0.0 @@ -102,4 +101,3 @@ fun getSpeciesCatchesForSegmentCalculation( ) } } -} diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/infraction/GetAllInfractions.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/infraction/GetAllInfractions.kt index d90d4e78b2..bad6aadc35 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/infraction/GetAllInfractions.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/infraction/GetAllInfractions.kt @@ -5,8 +5,8 @@ import fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions.Infracti import fr.gouv.cnsp.monitorfish.domain.repositories.InfractionRepository @UseCase -class GetAllInfractions(private val infractionRepository: InfractionRepository) { - fun execute(): List { - return infractionRepository.findAll() - } +class GetAllInfractions( + private val infractionRepository: InfractionRepository, +) { + fun execute(): List = infractionRepository.findAll() } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/GetAllMissions.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/GetAllMissions.kt index 0b76cd812c..50e1c0d321 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/GetAllMissions.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/GetAllMissions.kt @@ -48,8 +48,7 @@ class GetAllMissions( .map { chunkedMissions -> val ids = chunkedMissions.map { it.id } return@map missionActionsRepository.findMissionActionsIn(ids) - } - .flatten() + }.flatten() logger.info("Got ${allMissionsActions.size} mission actions associated to fetched missions.") return missions.map { mission -> diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/DeleteMissionAction.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/DeleteMissionAction.kt index b0ce47c778..1d88a1f596 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/DeleteMissionAction.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/DeleteMissionAction.kt @@ -5,7 +5,9 @@ import fr.gouv.cnsp.monitorfish.domain.exceptions.CouldNotDeleteException import fr.gouv.cnsp.monitorfish.domain.repositories.MissionActionsRepository @UseCase -class DeleteMissionAction(private val missionActionsRepository: MissionActionsRepository) { +class DeleteMissionAction( + private val missionActionsRepository: MissionActionsRepository, +) { @Throws(CouldNotDeleteException::class) fun execute(actionId: Int) { try { diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetActivityReports.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetActivityReports.kt index aa941e6740..66b284a538 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetActivityReports.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetActivityReports.kt @@ -46,93 +46,95 @@ class GetActivityReports( logger.info("Found ${missions.size} missions.") val filteredControls = - controls.filter { control -> - when (control.actionType) { - MissionActionType.LAND_CONTROL -> { - return@filter jdp.isLandControlApplicable(control) - } - - MissionActionType.SEA_CONTROL -> { - val controlMission = missions.firstOrNull { mission -> mission.id == control.missionId } - val isUnderJdp = controlMission?.isUnderJdp == true - if (controlMission == null) { - logger.error( - "Mission id '${control.missionId}' linked to SEA control id '${control.id}' could not be found. Is this mission deleted ?", - ) + controls + .filter { control -> + when (control.actionType) { + MissionActionType.LAND_CONTROL -> { + return@filter jdp.isLandControlApplicable(control) } - if (control.faoAreas.isNotEmpty()) { - return@filter isUnderJdp && jdp.isAttributedJdp(control) + MissionActionType.SEA_CONTROL -> { + val controlMission = missions.firstOrNull { mission -> mission.id == control.missionId } + val isUnderJdp = controlMission?.isUnderJdp == true + if (controlMission == null) { + logger.error( + "Mission id '${control.missionId}' linked to SEA control id '${control.id}' could not be found. Is this mission deleted ?", + ) + } + + if (control.faoAreas.isNotEmpty()) { + return@filter isUnderJdp && jdp.isAttributedJdp(control) + } + + // The mission must be under JDP + return@filter isUnderJdp } - // The mission must be under JDP - return@filter isUnderJdp + else -> throw IllegalArgumentException("Bad control type: ${control.actionType}") } - - else -> throw IllegalArgumentException("Bad control type: ${control.actionType}") + }.filter { control -> + val controlMission = missions.firstOrNull { mission -> mission.id == control.missionId } + // All AECP reports are excluded from the response + // see: https://github.com/MTES-MCT/monitorfish/issues/3194 + return@filter controlMission?.controlUnits?.any { controlUnit -> + controlUnit.administration == "AECP" + } != true } - }.filter { control -> - val controlMission = missions.firstOrNull { mission -> mission.id == control.missionId } - // All AECP reports are excluded from the response - // see: https://github.com/MTES-MCT/monitorfish/issues/3194 - return@filter controlMission?.controlUnits?.any { controlUnit -> - controlUnit.administration == "AECP" - } != true - } logger.info("Found ${filteredControls.size} controls to report.") val activityReports = - filteredControls.map { control -> - val activityCode = - when (control.actionType) { - MissionActionType.LAND_CONTROL -> ActivityCode.LAN - MissionActionType.SEA_CONTROL -> ActivityCode.FIS - else -> throw IllegalArgumentException("Bad control type: ${control.actionType}") - } + filteredControls + .map { control -> + val activityCode = + when (control.actionType) { + MissionActionType.LAND_CONTROL -> ActivityCode.LAN + MissionActionType.SEA_CONTROL -> ActivityCode.FIS + else -> throw IllegalArgumentException("Bad control type: ${control.actionType}") + } - val controlledVessel = - try { - vessels.first { vessel -> vessel.id == control.vesselId } - } catch (e: NoSuchElementException) { - logger.error("The vessel id ${control.vesselId} could not be found.", e) + val controlledVessel = + try { + vessels.first { vessel -> vessel.id == control.vesselId } + } catch (e: NoSuchElementException) { + logger.error("The vessel id ${control.vesselId} could not be found.", e) - return@map null - } - val controlMission = - try { - missions.first { mission -> mission.id == control.missionId } - } catch (e: NoSuchElementException) { - logger.error( - "Mission id '${control.missionId}' linked to ${control.actionType} control id '${control.id}' could not be found. Is this mission deleted ?", - e, - ) - - return@map null - } + return@map null + } + val controlMission = + try { + missions.first { mission -> mission.id == control.missionId } + } catch (e: NoSuchElementException) { + logger.error( + "Mission id '${control.missionId}' linked to ${control.actionType} control id '${control.id}' could not be found. Is this mission deleted ?", + e, + ) + + return@map null + } - control.portLocode?.let { port -> - try { - control.portName = portRepository.findByLocode(port).name - } catch (e: CodeNotFoundException) { - logger.warn(e.message) + control.portLocode?.let { port -> + try { + control.portName = portRepository.findByLocode(port).name + } catch (e: CodeNotFoundException) { + logger.warn(e.message) + } } - } - val faoArea = jdp.getFirstFaoAreaIncludedInJdp(control) - - ActivityReport( - action = control, - activityCode = activityCode, - controlUnits = controlMission.controlUnits, - faoArea = faoArea?.faoCode, - /** - * The fleet segment is set as null, as we need to integrate the EFCA segments referential - * see: https://github.com/MTES-MCT/monitorfish/issues/3157#issuecomment-2093036583 - */ - segment = null, - vesselNationalIdentifier = controlledVessel.getNationalIdentifier(), - vessel = controlledVessel, - ) - }.filterNotNull() + val faoArea = jdp.getFirstFaoAreaIncludedInJdp(control) + + ActivityReport( + action = control, + activityCode = activityCode, + controlUnits = controlMission.controlUnits, + faoArea = faoArea?.faoCode, + /** + * The fleet segment is set as null, as we need to integrate the EFCA segments referential + * see: https://github.com/MTES-MCT/monitorfish/issues/3157#issuecomment-2093036583 + */ + segment = null, + vesselNationalIdentifier = controlledVessel.getNationalIdentifier(), + vessel = controlledVessel, + ) + }.filterNotNull() return ActivityReports( activityReports = activityReports, diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetMissionAction.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetMissionAction.kt index f12933d8c9..4068463703 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetMissionAction.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetMissionAction.kt @@ -6,7 +6,9 @@ import fr.gouv.cnsp.monitorfish.domain.exceptions.CouldNotFindException import fr.gouv.cnsp.monitorfish.domain.repositories.MissionActionsRepository @UseCase -class GetMissionAction(private val missionActionsRepository: MissionActionsRepository) { +class GetMissionAction( + private val missionActionsRepository: MissionActionsRepository, +) { @Throws(CouldNotFindException::class) fun execute(actionId: Int): MissionAction { try { diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetMissionActionFacade.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetMissionActionFacade.kt index 835e333c50..666e7b1ae3 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetMissionActionFacade.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetMissionActionFacade.kt @@ -14,15 +14,14 @@ class GetMissionActionFacade( private val portsRepository: PortRepository, private val facadeAreasRepository: FacadeAreasRepository, ) { - fun execute(action: MissionAction): Seafront? { - return when (action.actionType) { + fun execute(action: MissionAction): Seafront? = + when (action.actionType) { MissionActionType.SEA_CONTROL -> getFacadeFromCoordinates(action) MissionActionType.LAND_CONTROL -> getFacadeFromPort(action) MissionActionType.AIR_CONTROL -> getFacadeFromCoordinates(action) MissionActionType.AIR_SURVEILLANCE -> null MissionActionType.OBSERVATION -> null } - } private fun getFacadeFromCoordinates(action: MissionAction): Seafront? { if (action.latitude == null || action.longitude == null) { diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetMissionActions.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetMissionActions.kt index 90bf102c81..7fd0aaccfc 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetMissionActions.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetMissionActions.kt @@ -14,7 +14,8 @@ class GetMissionActions( fun execute(missionId: Int): List { logger.debug("Searching undeleted actions for mission $missionId") val actions = - missionActionsRepository.findByMissionId(missionId) + missionActionsRepository + .findByMissionId(missionId) .sortedByDescending { it.actionDatetimeUtc } logger.debug("Found ${actions.size} undeleted actions for mission $missionId") diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetVesselControls.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetVesselControls.kt index 3668760adf..7ed06d13d5 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetVesselControls.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetVesselControls.kt @@ -28,7 +28,8 @@ class GetVesselControls( coroutineScope { logger.debug("Searching controls for vessel {} after {}", vesselId, afterDateTime) val controls = - missionActionsRepository.findVesselMissionActionsAfterDateTime(vesselId, afterDateTime) + missionActionsRepository + .findVesselMissionActionsAfterDateTime(vesselId, afterDateTime) .filter { it.actionType in setOf( @@ -40,33 +41,34 @@ class GetVesselControls( logger.debug("Found ${controls.size} controls for vessel $vesselId") val controlsWithCodeValues = - controls.map { action -> - val controlUnits = missionRepository.findControlUnitsOfMission(this, action.missionId) + controls + .map { action -> + val controlUnits = missionRepository.findControlUnitsOfMission(this, action.missionId) - Pair(action, controlUnits) - }.map { (control, controlUnits) -> - control.controlUnits = controlUnits.await() + Pair(action, controlUnits) + }.map { (control, controlUnits) -> + control.controlUnits = controlUnits.await() - control.portLocode?.let { port -> - try { - control.portName = portRepository.findByLocode(port).name - } catch (e: CodeNotFoundException) { - logger.warn(e.message) - } - } - - control.gearOnboard.forEach { gearControl -> - gearControl.gearCode?.let { gear -> + control.portLocode?.let { port -> try { - gearControl.gearName = gearRepository.findByCode(gear).name + control.portName = portRepository.findByLocode(port).name } catch (e: CodeNotFoundException) { logger.warn(e.message) } } - } - control - } + control.gearOnboard.forEach { gearControl -> + gearControl.gearCode?.let { gear -> + try { + gearControl.gearName = gearRepository.findByCode(gear).name + } catch (e: CodeNotFoundException) { + logger.warn(e.message) + } + } + } + + control + } val numberOfDiversions = controlsWithCodeValues diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/PatchMissionAction.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/PatchMissionAction.kt index 116b8f9088..17e25d1cbf 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/PatchMissionAction.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/PatchMissionAction.kt @@ -16,8 +16,8 @@ class PatchMissionAction( fun execute( id: Int, patchableEnvActionEntity: PatchableMissionAction, - ): MissionAction { - return try { + ): MissionAction = + try { val previousMissionAction = missionActionsRepository.findById(id) val updatedMissionAction = patchMissionAction.execute(previousMissionAction, patchableEnvActionEntity) @@ -26,5 +26,4 @@ class PatchMissionAction( } catch (e: Exception) { throw BackendUsageException(BackendUsageErrorCode.NOT_FOUND, "Action $id not found", e) } - } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/port/GetActivePorts.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/port/GetActivePorts.kt index 16a9e92543..3f4e685309 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/port/GetActivePorts.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/port/GetActivePorts.kt @@ -5,8 +5,8 @@ import fr.gouv.cnsp.monitorfish.domain.entities.port.Port import fr.gouv.cnsp.monitorfish.domain.repositories.PortRepository @UseCase -class GetActivePorts(private val portRepository: PortRepository) { - fun execute(): List { - return portRepository.findAllActive() - } +class GetActivePorts( + private val portRepository: PortRepository, +) { + fun execute(): List = portRepository.findAllActive() } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/ComputePnoTypes.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/ComputePnoTypes.kt index a0b2ab0be4..3856a1d34b 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/ComputePnoTypes.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/ComputePnoTypes.kt @@ -41,15 +41,14 @@ class ComputePnoTypes( allPnoTypeRules.filter { (rule) -> val allCatchesOfRule = catchToPnoTypeRules - .filter { - (_, pnoTypeRules) -> + .filter { (_, pnoTypeRules) -> pnoTypeRules.any { pnoTypeRuleOfCatch -> pnoTypeRuleOfCatch.id == rule.id } - } - .map { (pnoCatch, _) -> pnoCatch } + }.map { (pnoCatch, _) -> pnoCatch } val hasEmptyGears = rule.gears.isEmpty() val hasEmptyFlagStates = rule.flagStates.isEmpty() - val hasEmptyRequiredCatches = rule.species.isEmpty() && rule.faoAreas.isEmpty() && rule.cgpmAreas.isEmpty() + val hasEmptyRequiredCatches = + rule.species.isEmpty() && rule.faoAreas.isEmpty() && rule.cgpmAreas.isEmpty() val numberOfEmptyRules = listOf(hasEmptyGears, hasEmptyFlagStates, hasEmptyRequiredCatches).count { it } @@ -67,7 +66,9 @@ class ComputePnoTypes( when { !hasEmptyGears && !hasEmptyFlagStates -> containsGear && containsFlagState !hasEmptyGears && !hasEmptyRequiredCatches -> containsGear && hasCatchesAndMinimumQuantity - !hasEmptyFlagStates && !hasEmptyRequiredCatches -> containsFlagState && hasCatchesAndMinimumQuantity + !hasEmptyFlagStates && !hasEmptyRequiredCatches -> + containsFlagState && + hasCatchesAndMinimumQuantity else -> false } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/ComputeRiskFactor.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/ComputeRiskFactor.kt index 6dac6b4a33..7d47568210 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/ComputeRiskFactor.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/ComputeRiskFactor.kt @@ -38,13 +38,13 @@ class ComputeRiskFactor( val probabilityRiskFactor = storedRiskFactor?.probabilityRiskFactor ?: defaultProbabilityRiskFactor val controlRateRiskFactor = storedRiskFactor?.controlRateRiskFactor ?: defaultControlRateRiskFactor val highestControlPriorityLevel = - controlObjectivesRepository.findAllByYear(currentYear) + controlObjectivesRepository + .findAllByYear(currentYear) .filter { controlObjective -> !facade.isNullOrEmpty() && controlObjective.facade == facade && fleetSegments.map { it.segment }.contains(controlObjective.segment) - } - .maxByOrNull { it.controlPriorityLevel } + }.maxByOrNull { it.controlPriorityLevel } ?.controlPriorityLevel ?: defaultControlPriorityLevel val computedRiskFactor = diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/CreateOrUpdateManualPriorNotification.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/CreateOrUpdateManualPriorNotification.kt index f0bd89a09e..4a043d98ed 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/CreateOrUpdateManualPriorNotification.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/CreateOrUpdateManualPriorNotification.kt @@ -53,7 +53,11 @@ class CreateOrUpdateManualPriorNotification( reportId?.let { manualPriorNotificationRepository.findByReportId(reportId) } - val existingMessageValue: PNO? = existingManualPriorNotification?.logbookMessageAndValue?.logbookMessage?.message as PNO? + val existingMessageValue: PNO? = + existingManualPriorNotification + ?.logbookMessageAndValue + ?.logbookMessage + ?.message as PNO? // /!\ Backend computed vessel risk factor is only used as a real time Frontend indicator. // The Backend should NEVER update `risk_factors` DB table, only the pipeline is allowed to update it. diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotification.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotification.kt index 5c57439071..6b03890c58 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotification.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotification.kt @@ -56,7 +56,9 @@ class GetPriorNotification( when (priorNotification.isManuallyCreated) { true -> if (priorNotification.logbookMessageAndValue.logbookMessage.vesselId != null) { - vesselRepository.findVesselById(priorNotification.logbookMessageAndValue.logbookMessage.vesselId!!) + vesselRepository.findVesselById( + priorNotification.logbookMessageAndValue.logbookMessage.vesselId!!, + ) } else { null } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSentMessages.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSentMessages.kt index c956026a09..ecc874c43e 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSentMessages.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSentMessages.kt @@ -8,7 +8,6 @@ import fr.gouv.cnsp.monitorfish.domain.repositories.* class GetPriorNotificationSentMessages( private val priorNotificationSentMessageRepository: PriorNotificationSentMessageRepository, ) { - fun execute(reportId: String): List { - return priorNotificationSentMessageRepository.findAllByReportId(reportId) - } + fun execute(reportId: String): List = + priorNotificationSentMessageRepository.findAllByReportId(reportId) } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscribers.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscribers.kt index 9c9b2ce456..b34991eb5b 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscribers.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscribers.kt @@ -73,8 +73,8 @@ class GetPriorNotificationSubscribers( private fun filterPriorNotificationSubscribers( subscribers: List, filter: PriorNotificationSubscribersFilter, - ): List { - return subscribers.filter { subscriber -> + ): List = + subscribers.filter { subscriber -> val administrationIdMatches = filter.administrationId?.let { subscriber.controlUnit.administration.id == it @@ -90,12 +90,14 @@ class GetPriorNotificationSubscribers( val normalizedQuery = StringUtils.removeAccents(query).lowercase() val controlUnitNameMatches = - StringUtils.removeAccents(subscriber.controlUnit.name) + StringUtils + .removeAccents(subscriber.controlUnit.name) .lowercase() .contains(normalizedQuery) val administrationNameMatches = - StringUtils.removeAccents(subscriber.controlUnit.administration.name) + StringUtils + .removeAccents(subscriber.controlUnit.administration.name) .lowercase() .contains(normalizedQuery) @@ -123,7 +125,6 @@ class GetPriorNotificationSubscribers( administrationIdMatches && portLocodeMatches && searchQueryMatches && withAtLeastOneSubscriptionMatches } - } private fun sortPriorNotificationSubscribers( subscribers: List, diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationTypes.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationTypes.kt index 5adfef1ea8..6d64d0a885 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationTypes.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationTypes.kt @@ -7,7 +7,5 @@ import fr.gouv.cnsp.monitorfish.domain.repositories.LogbookReportRepository class GetPriorNotificationTypes( private val logbookReportRepository: LogbookReportRepository, ) { - fun execute(): List { - return logbookReportRepository.findDistinctPriorNotificationTypes() - } + fun execute(): List = logbookReportRepository.findDistinctPriorNotificationTypes() } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationUpload.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationUpload.kt index c3b9c80dcc..146ee8609c 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationUpload.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationUpload.kt @@ -8,7 +8,6 @@ import fr.gouv.cnsp.monitorfish.domain.repositories.PriorNotificationUploadRepos class GetPriorNotificationUpload( private val priorNotificationUploadRepository: PriorNotificationUploadRepository, ) { - fun execute(priorNotificationUploadId: String): PriorNotificationDocument { - return priorNotificationUploadRepository.findById(priorNotificationUploadId) - } + fun execute(priorNotificationUploadId: String): PriorNotificationDocument = + priorNotificationUploadRepository.findById(priorNotificationUploadId) } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationUploads.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationUploads.kt index 988b3e71d5..61148a8326 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationUploads.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationUploads.kt @@ -8,7 +8,6 @@ import fr.gouv.cnsp.monitorfish.domain.repositories.PriorNotificationUploadRepos class GetPriorNotificationUploads( private val priorNotificationUploadRepository: PriorNotificationUploadRepository, ) { - fun execute(reportId: String): List { - return priorNotificationUploadRepository.findAllByReportId(reportId) - } + fun execute(reportId: String): List = + priorNotificationUploadRepository.findAllByReportId(reportId) } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotifications.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotifications.kt index cd8569d989..04563f85ed 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotifications.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotifications.kt @@ -223,33 +223,29 @@ class GetPriorNotifications( private fun filterBySeafrontGroup( seafrontGroup: SeafrontGroup, priorNotification: PriorNotification, - ): Boolean { - return seafrontGroup.hasSeafront(priorNotification.seafront) - } + ): Boolean = seafrontGroup.hasSeafront(priorNotification.seafront) private fun filterByStatuses( states: List?, isInvalidated: Boolean?, isPriorNotificationZero: Boolean?, priorNotification: PriorNotification, - ): Boolean { - return (states.isNullOrEmpty() && isInvalidated == null && isPriorNotificationZero == null) || + ): Boolean = + (states.isNullOrEmpty() && isInvalidated == null && isPriorNotificationZero == null) || (!states.isNullOrEmpty() && states.contains(priorNotification.state)) || (isInvalidated != null && priorNotification.logbookMessageAndValue.value.isInvalidated == isInvalidated) || (isPriorNotificationZero != null && priorNotification.isPriorNotificationZero == isPriorNotificationZero) - } private fun getSortKey( priorNotification: PriorNotification, sortColumn: PriorNotificationsSortColumn, - ): Comparable<*>? { - return when (sortColumn) { + ): Comparable<*>? = + when (sortColumn) { PriorNotificationsSortColumn.EXPECTED_ARRIVAL_DATE -> priorNotification.logbookMessageAndValue.value.predictedArrivalDatetimeUtc PriorNotificationsSortColumn.EXPECTED_LANDING_DATE -> priorNotification.logbookMessageAndValue.value.predictedLandingDatetimeUtc PriorNotificationsSortColumn.PORT_NAME -> priorNotification.port?.name PriorNotificationsSortColumn.VESSEL_NAME -> priorNotification.logbookMessageAndValue.logbookMessage.vesselName PriorNotificationsSortColumn.VESSEL_RISK_FACTOR -> priorNotification.logbookMessageAndValue.value.riskFactor } - } } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/producer_organization_membership/GetAllProducerOrganizationMemberships.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/producer_organization_membership/GetAllProducerOrganizationMemberships.kt index f4b511e2a5..182de19d94 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/producer_organization_membership/GetAllProducerOrganizationMemberships.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/producer_organization_membership/GetAllProducerOrganizationMemberships.kt @@ -8,7 +8,5 @@ import fr.gouv.cnsp.monitorfish.domain.repositories.ProducerOrganizationMembersh class GetAllProducerOrganizationMemberships( private val producerOrganizationMembershipRepository: ProducerOrganizationMembershipRepository, ) { - fun execute(): List { - return producerOrganizationMembershipRepository.findAll() - } + fun execute(): List = producerOrganizationMembershipRepository.findAll() } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/ArchiveOutdatedReportings.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/ArchiveOutdatedReportings.kt index 7f641b184a..9a53724cf6 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/ArchiveOutdatedReportings.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/ArchiveOutdatedReportings.kt @@ -8,7 +8,9 @@ import org.springframework.scheduling.annotation.Scheduled import org.springframework.transaction.annotation.Transactional @UseCase -class ArchiveOutdatedReportings(private val reportingRepository: ReportingRepository) { +class ArchiveOutdatedReportings( + private val reportingRepository: ReportingRepository, +) { private val logger = LoggerFactory.getLogger(ArchiveOutdatedReportings::class.java) // At every 5 minutes, after 1 minute of initial delay @@ -19,16 +21,20 @@ class ArchiveOutdatedReportings(private val reportingRepository: ReportingReposi val expiredReportingsToArchive = reportingRepository.findExpiredReportings() val filteredReportingIdsToArchive = - reportingCandidatesToArchive.filter { - it.second.type == AlertTypeMapping.MISSING_FAR_ALERT || - it.second.type == AlertTypeMapping.THREE_MILES_TRAWLING_ALERT || - it.second.type == AlertTypeMapping.MISSING_DEP_ALERT || - it.second.type == AlertTypeMapping.SUSPICION_OF_UNDER_DECLARATION_ALERT - }.map { it.first } + reportingCandidatesToArchive + .filter { + it.second.type == AlertTypeMapping.MISSING_FAR_ALERT || + it.second.type == AlertTypeMapping.THREE_MILES_TRAWLING_ALERT || + it.second.type == AlertTypeMapping.MISSING_DEP_ALERT || + it.second.type == AlertTypeMapping.SUSPICION_OF_UNDER_DECLARATION_ALERT + }.map { it.first } logger.info("Found ${filteredReportingIdsToArchive.size} reportings alerts to archive.") logger.info("Found ${expiredReportingsToArchive.size} expired reportings to archive.") - val numberOfArchivedReportings = reportingRepository.archiveReportings(filteredReportingIdsToArchive + expiredReportingsToArchive) + val numberOfArchivedReportings = + reportingRepository.archiveReportings( + filteredReportingIdsToArchive + expiredReportingsToArchive, + ) logger.info("Archived $numberOfArchivedReportings reportings") } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/ArchiveReporting.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/ArchiveReporting.kt index e558d42cec..6a37ffe302 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/ArchiveReporting.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/ArchiveReporting.kt @@ -6,7 +6,9 @@ import org.slf4j.Logger import org.slf4j.LoggerFactory @UseCase -class ArchiveReporting(private val reportingRepository: ReportingRepository) { +class ArchiveReporting( + private val reportingRepository: ReportingRepository, +) { private val logger: Logger = LoggerFactory.getLogger(ArchiveReporting::class.java) fun execute(id: Int) { diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/ArchiveReportings.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/ArchiveReportings.kt index 38f8e1b4fe..fdcb97ed72 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/ArchiveReportings.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/ArchiveReportings.kt @@ -3,7 +3,9 @@ package fr.gouv.cnsp.monitorfish.domain.use_cases.reporting import fr.gouv.cnsp.monitorfish.config.UseCase @UseCase -class ArchiveReportings(private val archiveReporting: ArchiveReporting) { +class ArchiveReportings( + private val archiveReporting: ArchiveReporting, +) { fun execute(ids: List) { ids.forEach { archiveReporting.execute(it) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/DeleteReporting.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/DeleteReporting.kt index 017f8dd78b..8242d98a0a 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/DeleteReporting.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/DeleteReporting.kt @@ -6,7 +6,9 @@ import org.slf4j.Logger import org.slf4j.LoggerFactory @UseCase -class DeleteReporting(private val reportingRepository: ReportingRepository) { +class DeleteReporting( + private val reportingRepository: ReportingRepository, +) { private val logger: Logger = LoggerFactory.getLogger(DeleteReporting::class.java) fun execute(id: Int) { diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/DeleteReportings.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/DeleteReportings.kt index 72490df831..750785357e 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/DeleteReportings.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/DeleteReportings.kt @@ -3,7 +3,9 @@ package fr.gouv.cnsp.monitorfish.domain.use_cases.reporting import fr.gouv.cnsp.monitorfish.config.UseCase @UseCase -class DeleteReportings(private val deleteReporting: DeleteReporting) { +class DeleteReportings( + private val deleteReporting: DeleteReporting, +) { fun execute(ids: List) { ids.forEach { deleteReporting.execute(it) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/GetVesselReportings.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/GetVesselReportings.kt index 2604fad88a..0027ae3b5b 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/GetVesselReportings.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/GetVesselReportings.kt @@ -237,9 +237,7 @@ class GetVesselReportings( private fun findReportingsByVesselId( vesselId: Int, fromDate: ZonedDateTime, - ): List { - return reportingRepository.findCurrentAndArchivedByVesselIdEquals(vesselId, fromDate) - } + ): List = reportingRepository.findCurrentAndArchivedByVesselIdEquals(vesselId, fromDate) private fun findReportingsByVesselIdentity( vesselIdentifier: VesselIdentifier?, @@ -247,8 +245,8 @@ class GetVesselReportings( fromDate: ZonedDateTime, ircs: String, externalReferenceNumber: String, - ): List { - return when (vesselIdentifier) { + ): List = + when (vesselIdentifier) { VesselIdentifier.INTERNAL_REFERENCE_NUMBER -> reportingRepository.findCurrentAndArchivedByVesselIdentifierEquals( vesselIdentifier, @@ -274,5 +272,4 @@ class GetVesselReportings( fromDate, ) } - } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/UpdateReporting.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/UpdateReporting.kt index 55dc22f62f..1a55c64882 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/UpdateReporting.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/UpdateReporting.kt @@ -58,11 +58,12 @@ class UpdateReporting( expirationDate = expirationDate, updatedInfractionSuspicion = nextReporting, ) - is Observation -> reportingRepository.update( - reportingId = reportingId, - expirationDate = expirationDate, - updatedObservation = nextReporting, - ) + is Observation -> + reportingRepository.update( + reportingId = reportingId, + expirationDate = expirationDate, + updatedObservation = nextReporting, + ) else -> throw IllegalArgumentException( "The new reporting type must be an INFRACTION_SUSPICION or an OBSERVATION", ) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/vessel/GetLastPositions.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/vessel/GetLastPositions.kt index e0716d8a89..98249a4d9c 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/vessel/GetLastPositions.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/vessel/GetLastPositions.kt @@ -5,8 +5,8 @@ import fr.gouv.cnsp.monitorfish.domain.entities.last_position.LastPosition import fr.gouv.cnsp.monitorfish.domain.repositories.LastPositionRepository @UseCase -class GetLastPositions(private val lastPositionRepository: LastPositionRepository) { - fun execute(): List { - return lastPositionRepository.findAllInLastMonthOrWithBeaconMalfunction() - } +class GetLastPositions( + private val lastPositionRepository: LastPositionRepository, +) { + fun execute(): List = lastPositionRepository.findAllInLastMonthOrWithBeaconMalfunction() } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/vessel/GetLogbookMessages.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/vessel/GetLogbookMessages.kt index 723436cb7c..7d97c26eb6 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/vessel/GetLogbookMessages.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/vessel/GetLogbookMessages.kt @@ -35,8 +35,7 @@ class GetLogbookMessages( afterDepartureDate, beforeDepartureDate, tripNumber, - ) - .sortedBy { it.reportDateTime } + ).sortedBy { it.reportDateTime } .map { logbookMessage -> logbookMessage.operationNumber?.let { operationNumber -> try { diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/vessel/GetVessel.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/vessel/GetVessel.kt index ca7caacb88..3d39e8e108 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/vessel/GetVessel.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/vessel/GetVessel.kt @@ -33,8 +33,8 @@ class GetVessel( vesselIdentifier: VesselIdentifier?, fromDateTime: ZonedDateTime? = null, toDateTime: ZonedDateTime? = null, - ): Pair { - return coroutineScope { + ): Pair = + coroutineScope { val (vesselTrackHasBeenModified, positions) = GetVesselPositions( positionRepository, @@ -74,7 +74,8 @@ class GetVessel( it, ) } - val hasVisioCaptures = logbookSoftware?.let { LogbookSoftware.isVisioCaptureInRealTime(logbookSoftware) } ?: false + val hasVisioCaptures = + logbookSoftware?.let { LogbookSoftware.isVisioCaptureInRealTime(logbookSoftware) } ?: false Pair( vesselTrackHasBeenModified, @@ -91,5 +92,4 @@ class GetVessel( ), ) } - } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/vessel/GetVesselById.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/vessel/GetVesselById.kt index 3dabc06198..50871a9709 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/vessel/GetVesselById.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/vessel/GetVesselById.kt @@ -10,7 +10,6 @@ import fr.gouv.cnsp.monitorfish.domain.repositories.VesselRepository class GetVesselById( private val vesselRepository: VesselRepository, ) { - fun execute(vesselId: Int): Vessel { - return vesselRepository.findVesselById(vesselId) ?: throw BackendUsageException(BackendUsageErrorCode.NOT_FOUND) - } + fun execute(vesselId: Int): Vessel = + vesselRepository.findVesselById(vesselId) ?: throw BackendUsageException(BackendUsageErrorCode.NOT_FOUND) } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/vessel/GetVesselLastTripNumbers.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/vessel/GetVesselLastTripNumbers.kt index ac6da40437..e641d24b8c 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/vessel/GetVesselLastTripNumbers.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/vessel/GetVesselLastTripNumbers.kt @@ -10,7 +10,6 @@ class GetVesselLastTripNumbers( ) { private val logger = LoggerFactory.getLogger(GetVesselLastTripNumbers::class.java) - fun execute(internalReferenceNumber: String): List { - return logbookReportRepository.findLastThreeYearsTripNumbers(internalReferenceNumber) - } + fun execute(internalReferenceNumber: String): List = + logbookReportRepository.findLastThreeYearsTripNumbers(internalReferenceNumber) } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/vessel/GetVesselPositions.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/vessel/GetVesselPositions.kt index 4e3069a3c0..e7eaa137d2 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/vessel/GetVesselPositions.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/vessel/GetVesselPositions.kt @@ -49,11 +49,11 @@ class GetVesselPositions( try { // We subtract 4h to this date to ensure the track starts at the port // (the departure message may be sent after the departure) - logbookReportRepository.findFirstAcknowledgedDateOfTripBeforeDateTime( - internalReferenceNumber, - ZonedDateTime.now(), - ) - .minusHours(4) + logbookReportRepository + .findFirstAcknowledgedDateOfTripBeforeDateTime( + internalReferenceNumber, + ZonedDateTime.now(), + ).minusHours(4) } catch (e: NoLogbookFishingTripFound) { logger.warn(e.message) isTrackDepthModified = true @@ -101,41 +101,42 @@ class GetVesselPositions( to: ZonedDateTime?, ircs: String, externalReferenceNumber: String, - ): Deferred> { - return when (vesselIdentifier) { + ): Deferred> = + when (vesselIdentifier) { VesselIdentifier.INTERNAL_REFERENCE_NUMBER -> async { - positionRepository.findVesselLastPositionsByInternalReferenceNumber( - internalReferenceNumber, - from!!, - to!!, - ) - .sortedBy { it.dateTime } + positionRepository + .findVesselLastPositionsByInternalReferenceNumber( + internalReferenceNumber, + from!!, + to!!, + ).sortedBy { it.dateTime } } VesselIdentifier.IRCS -> async { - positionRepository.findVesselLastPositionsByIrcs(ircs, from!!, to!!) + positionRepository + .findVesselLastPositionsByIrcs(ircs, from!!, to!!) .sortedBy { it.dateTime } } VesselIdentifier.EXTERNAL_REFERENCE_NUMBER -> async { - positionRepository.findVesselLastPositionsByExternalReferenceNumber( - externalReferenceNumber, - from!!, - to!!, - ) - .sortedBy { it.dateTime } + positionRepository + .findVesselLastPositionsByExternalReferenceNumber( + externalReferenceNumber, + from!!, + to!!, + ).sortedBy { it.dateTime } } else -> async { - positionRepository.findVesselLastPositionsWithoutSpecifiedIdentifier( - internalReferenceNumber = internalReferenceNumber, - externalReferenceNumber = externalReferenceNumber, - ircs = ircs, - from = from!!, - to = to!!, - ).sortedBy { it.dateTime } + positionRepository + .findVesselLastPositionsWithoutSpecifiedIdentifier( + internalReferenceNumber = internalReferenceNumber, + externalReferenceNumber = externalReferenceNumber, + ircs = ircs, + from = from!!, + to = to!!, + ).sortedBy { it.dateTime } } } - } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/vessel/GetVesselRiskFactor.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/vessel/GetVesselRiskFactor.kt index 10de170024..129ac460d1 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/vessel/GetVesselRiskFactor.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/vessel/GetVesselRiskFactor.kt @@ -7,7 +7,9 @@ import org.slf4j.Logger import org.slf4j.LoggerFactory @UseCase -class GetVesselRiskFactor(private val riskFactorRepository: RiskFactorRepository) { +class GetVesselRiskFactor( + private val riskFactorRepository: RiskFactorRepository, +) { private val logger: Logger = LoggerFactory.getLogger(GetVesselRiskFactor::class.java) fun execute(internalReferenceNumber: String): VesselRiskFactor { diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/vessel/GetVesselVoyage.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/vessel/GetVesselVoyage.kt index da818b1cc4..76fec2f64b 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/vessel/GetVesselVoyage.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/vessel/GetVesselVoyage.kt @@ -134,13 +134,12 @@ class GetVesselVoyage( private fun getIsFirstVoyage( internalReferenceNumber: String, tripNumber: String, - ): Boolean { - return try { + ): Boolean = + try { logbookReportRepository.findTripBeforeTripNumber(internalReferenceNumber, tripNumber) false } catch (e: NoLogbookFishingTripFound) { true } - } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/vessel/ParseAndSavePosition.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/vessel/ParseAndSavePosition.kt index 68944afd7e..825f447a1c 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/vessel/ParseAndSavePosition.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/vessel/ParseAndSavePosition.kt @@ -8,7 +8,9 @@ import org.slf4j.Logger import org.slf4j.LoggerFactory @UseCase -class ParseAndSavePosition(private val positionRepository: PositionRepository) { +class ParseAndSavePosition( + private val positionRepository: PositionRepository, +) { private val logger: Logger = LoggerFactory.getLogger(ParseAndSavePosition::class.java) @Throws(NAFMessageParsingException::class) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/vessel/SearchVessels.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/vessel/SearchVessels.kt index fef0f45aa0..4c811272a8 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/vessel/SearchVessels.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/vessel/SearchVessels.kt @@ -12,14 +12,16 @@ class SearchVessels( ) { fun execute(searched: String): List { val vessels = - vesselRepository.search(searched).filter { - !( - it.internalReferenceNumber.isNullOrEmpty() && - it.externalReferenceNumber.isNullOrEmpty() && - it.ircs.isNullOrEmpty() && - it.mmsi.isNullOrEmpty() - ) - }.map { VesselAndBeacon(vessel = it) } + vesselRepository + .search(searched) + .filter { + !( + it.internalReferenceNumber.isNullOrEmpty() && + it.externalReferenceNumber.isNullOrEmpty() && + it.ircs.isNullOrEmpty() && + it.mmsi.isNullOrEmpty() + ) + }.map { VesselAndBeacon(vessel = it) } val beacons = beaconRepository.search(searched) val beaconsVesselId = beacons.mapNotNull { it.vesselId } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/ControllersExceptionHandler.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/ControllersExceptionHandler.kt index 906e6ed703..c851dcfe62 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/ControllersExceptionHandler.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/ControllersExceptionHandler.kt @@ -18,20 +18,20 @@ import org.springframework.web.bind.annotation.RestControllerAdvice @RestControllerAdvice @Order(LOWEST_PRECEDENCE) -class ControllersExceptionHandler(val sentryConfig: SentryConfig) { +class ControllersExceptionHandler( + val sentryConfig: SentryConfig, +) { private val logger: Logger = LoggerFactory.getLogger(ControllersExceptionHandler::class.java) @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) @ExceptionHandler(BackendInternalException::class) - fun handleBackendInternalException(e: BackendInternalException): BackendInternalErrorDataOutput { - return BackendInternalErrorDataOutput(code = e.code, message = e.message) - } + fun handleBackendInternalException(e: BackendInternalException): BackendInternalErrorDataOutput = + BackendInternalErrorDataOutput(code = e.code, message = e.message) @ResponseStatus(HttpStatus.UNPROCESSABLE_ENTITY) @ExceptionHandler(BackendRequestException::class) - fun handleBackendRequestException(e: BackendRequestException): BackendRequestErrorDataOutput { - return BackendRequestErrorDataOutput(code = e.code, data = e.data, message = e.message) - } + fun handleBackendRequestException(e: BackendRequestException): BackendRequestErrorDataOutput = + BackendRequestErrorDataOutput(code = e.code, data = e.data, message = e.message) @ExceptionHandler(BackendUsageException::class) fun handleBackendUsageException(e: BackendUsageException): ResponseEntity { diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/BeaconMalfunctionController.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/BeaconMalfunctionController.kt index 71fc122a02..04567f594e 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/BeaconMalfunctionController.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/BeaconMalfunctionController.kt @@ -25,11 +25,10 @@ class BeaconMalfunctionController( ) { @GetMapping(value = [""]) @Operation(summary = "Get all beacon malfunctions") - fun getAllBeaconMalfunctions(): List { - return getAllBeaconMalfunctions.execute().map { + fun getAllBeaconMalfunctions(): List = + getAllBeaconMalfunctions.execute().map { BeaconMalfunctionDataOutput.fromBeaconMalfunction(it) } - } @PutMapping(value = ["/{beaconMalfunctionId}"], consumes = ["application/json"]) @Operation(summary = "Update a beacon malfunction") @@ -39,16 +38,16 @@ class BeaconMalfunctionController( beaconMalfunctionId: Int, @RequestBody updateBeaconMalfunctionData: UpdateBeaconMalfunctionDataInput, - ): BeaconMalfunctionResumeAndDetailsDataOutput { - return updateBeaconMalfunction.execute( - id = beaconMalfunctionId, - vesselStatus = updateBeaconMalfunctionData.vesselStatus, - stage = updateBeaconMalfunctionData.stage, - endOfBeaconMalfunctionReason = updateBeaconMalfunctionData.endOfBeaconMalfunctionReason, - ).let { - BeaconMalfunctionResumeAndDetailsDataOutput.fromBeaconMalfunctionResumeAndDetails(it) - } - } + ): BeaconMalfunctionResumeAndDetailsDataOutput = + updateBeaconMalfunction + .execute( + id = beaconMalfunctionId, + vesselStatus = updateBeaconMalfunctionData.vesselStatus, + stage = updateBeaconMalfunctionData.stage, + endOfBeaconMalfunctionReason = updateBeaconMalfunctionData.endOfBeaconMalfunctionReason, + ).let { + BeaconMalfunctionResumeAndDetailsDataOutput.fromBeaconMalfunctionResumeAndDetails(it) + } @ResponseStatus(HttpStatus.CREATED) @PostMapping(value = ["/{beaconMalfunctionId}/comments"], consumes = ["application/json"]) @@ -59,15 +58,15 @@ class BeaconMalfunctionController( beaconMalfunctionId: Int, @RequestBody saveBeaconMalfunctionCommentDataInput: SaveBeaconMalfunctionCommentDataInput, - ): BeaconMalfunctionResumeAndDetailsDataOutput { - return saveBeaconMalfunctionComment.execute( - beaconMalfunctionId = beaconMalfunctionId, - comment = saveBeaconMalfunctionCommentDataInput.comment, - userType = saveBeaconMalfunctionCommentDataInput.userType, - ).let { - BeaconMalfunctionResumeAndDetailsDataOutput.fromBeaconMalfunctionResumeAndDetails(it) - } - } + ): BeaconMalfunctionResumeAndDetailsDataOutput = + saveBeaconMalfunctionComment + .execute( + beaconMalfunctionId = beaconMalfunctionId, + comment = saveBeaconMalfunctionCommentDataInput.comment, + userType = saveBeaconMalfunctionCommentDataInput.userType, + ).let { + BeaconMalfunctionResumeAndDetailsDataOutput.fromBeaconMalfunctionResumeAndDetails(it) + } @GetMapping(value = ["/{beaconMalfunctionId}"]) @Operation(summary = "Get a beacon malfunction with the comments and history") @@ -75,11 +74,10 @@ class BeaconMalfunctionController( @PathParam("Beacon malfunction id") @PathVariable(name = "beaconMalfunctionId") beaconMalfunctionId: Int, - ): BeaconMalfunctionResumeAndDetailsDataOutput { - return BeaconMalfunctionResumeAndDetailsDataOutput.fromBeaconMalfunctionResumeAndDetails( + ): BeaconMalfunctionResumeAndDetailsDataOutput = + BeaconMalfunctionResumeAndDetailsDataOutput.fromBeaconMalfunctionResumeAndDetails( getBeaconMalfunction.execute(beaconMalfunctionId), ) - } @PutMapping(value = ["/{beaconMalfunctionId}/{notificationRequested}"]) @Operation(summary = "Request a notification") @@ -93,11 +91,9 @@ class BeaconMalfunctionController( @Parameter(name = "ISO3 country code of the FMC to notify") @RequestParam(name = "requestedNotificationForeignFmcCode") requestedNotificationForeignFmcCode: String? = null, - ) { - return requestNotification.execute( - id = beaconMalfunctionId, - notificationRequested = notificationRequested, - requestedNotificationForeignFmcCode = requestedNotificationForeignFmcCode, - ) - } + ) = requestNotification.execute( + id = beaconMalfunctionId, + notificationRequested = notificationRequested, + requestedNotificationForeignFmcCode = requestedNotificationForeignFmcCode, + ) } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/ControlObjectiveAdminController.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/ControlObjectiveAdminController.kt index 66b0d50476..0bd53aea35 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/ControlObjectiveAdminController.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/ControlObjectiveAdminController.kt @@ -27,24 +27,19 @@ class ControlObjectiveAdminController( @PathParam("Year") @PathVariable(name = "year") year: Int, - ): List { - return getControlObjectivesOfYear.execute(year).map { controlObjective -> + ): List = + getControlObjectivesOfYear.execute(year).map { controlObjective -> ControlObjectiveDataOutput.fromControlObjective(controlObjective) } - } @GetMapping("/years") @Operation(summary = "Get control objective year entries") - fun getControlObjectiveYearEntries(): List { - return getControlObjectiveYearEntries.execute() - } + fun getControlObjectiveYearEntries(): List = getControlObjectiveYearEntries.execute() @ResponseStatus(HttpStatus.CREATED) @PostMapping("/years") @Operation(summary = "Add a control objective year") - fun addControlObjectiveYear() { - return addControlObjectiveYear.execute() - } + fun addControlObjectiveYear() = addControlObjectiveYear.execute() @PutMapping(value = ["/{controlObjectiveId}"], consumes = ["application/json"]) @Operation(summary = "Update a control objective") @@ -78,11 +73,10 @@ class ControlObjectiveAdminController( fun addControlObjective( @RequestBody addControlObjectiveData: AddControlObjectiveDataInput, - ): Int { - return addControlObjective.execute( + ): Int = + addControlObjective.execute( segment = addControlObjectiveData.segment, facade = addControlObjectiveData.facade, year = addControlObjectiveData.year, ) - } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/DataReferentialController.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/DataReferentialController.kt index 6d258b092b..e45f57b3c3 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/DataReferentialController.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/DataReferentialController.kt @@ -19,15 +19,13 @@ class DataReferentialController( ) { @GetMapping("/v1/gears") @Operation(summary = "Get FAO fishing gear codes") - fun getGears(): List { - return getAllGears.execute().map { gear -> + fun getGears(): List = + getAllGears.execute().map { gear -> GearDataOutput.fromGear(gear) } - } @GetMapping("/v1/species") @Operation(summary = "Get FAO species codes and groups") - fun getSpecies(): SpeciesAndSpeciesGroupsDataOutput { - return SpeciesAndSpeciesGroupsDataOutput.fromSpeciesAndSpeciesGroups(getAllSpeciesAndSpeciesGroups.execute()) - } + fun getSpecies(): SpeciesAndSpeciesGroupsDataOutput = + SpeciesAndSpeciesGroupsDataOutput.fromSpeciesAndSpeciesGroups(getAllSpeciesAndSpeciesGroups.execute()) } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/FaoAreaController.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/FaoAreaController.kt index f324142d65..baee94182e 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/FaoAreaController.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/FaoAreaController.kt @@ -19,9 +19,7 @@ class FaoAreaController( ) { @GetMapping("/v1/fao_areas") @Operation(summary = "Get FAO areas") - fun getFAOAreas(): List { - return getFAOAreas.execute() - } + fun getFAOAreas(): List = getFAOAreas.execute() @GetMapping("/v1/fao_areas/compute") @Operation(summary = "Get FAO areas") @@ -38,7 +36,5 @@ class FaoAreaController( @Parameter(description = "Port Locode") @RequestParam(name = "portLocode") portLocode: String?, - ): List { - return computeVesselFAOAreas.execute(internalReferenceNumber, latitude, longitude, portLocode) - } + ): List = computeVesselFAOAreas.execute(internalReferenceNumber, latitude, longitude, portLocode) } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/FleetSegmentAdminController.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/FleetSegmentAdminController.kt index 56fa549f37..78a7114904 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/FleetSegmentAdminController.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/FleetSegmentAdminController.kt @@ -51,11 +51,10 @@ class FleetSegmentAdminController( @Parameter(description = "Segment") @RequestParam(name = "segment") segment: String, - ): List { - return deleteFleetSegment.execute(segment, year).map { + ): List = + deleteFleetSegment.execute(segment, year).map { FleetSegmentDataOutput.fromFleetSegment(it) } - } @ResponseStatus(HttpStatus.CREATED) @PostMapping(value = [""]) @@ -71,9 +70,7 @@ class FleetSegmentAdminController( @GetMapping("/years") @Operation(summary = "Get fleet segment year entries") - fun getFleetSegmentYearEntries(): List { - return getFleetSegmentYearEntries.execute() - } + fun getFleetSegmentYearEntries(): List = getFleetSegmentYearEntries.execute() @ResponseStatus(HttpStatus.CREATED) @PostMapping("/{year}") @@ -82,7 +79,5 @@ class FleetSegmentAdminController( @PathParam("Year") @PathVariable(name = "year") year: Int, - ) { - return addFleetSegmentYear.execute(year) - } + ) = addFleetSegmentYear.execute(year) } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/FleetSegmentController.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/FleetSegmentController.kt index 4854e3301b..58137b9f65 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/FleetSegmentController.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/FleetSegmentController.kt @@ -22,11 +22,10 @@ class FleetSegmentController( @PathParam("Year") @PathVariable(name = "year") year: Int, - ): List { - return getAllFleetSegmentsByYearByYear.execute(year).map { fleetSegment -> + ): List = + getAllFleetSegmentsByYearByYear.execute(year).map { fleetSegment -> FleetSegmentDataOutput.fromFleetSegment(fleetSegment) } - } @PostMapping("/compute") @Operation(summary = "compute fleet segments for the current year") diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/ForeignFMCsController.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/ForeignFMCsController.kt index e27610041d..f4083c03fa 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/ForeignFMCsController.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/ForeignFMCsController.kt @@ -11,12 +11,13 @@ import org.springframework.web.bind.annotation.RestController @RestController @RequestMapping("/bff/v1/foreign_fmcs") @Tag(name = "APIs for foreign FMCs") -class ForeignFMCsController(private val getAllForeignFMCs: GetAllForeignFMCs) { +class ForeignFMCsController( + private val getAllForeignFMCs: GetAllForeignFMCs, +) { @GetMapping("") @Operation(summary = "Get all foreign FMCs") - fun getAllForeignFMCs(): List { - return getAllForeignFMCs.execute().map { foreignFMC -> + fun getAllForeignFMCs(): List = + getAllForeignFMCs.execute().map { foreignFMC -> ForeignFMCDataOutput.fromForeignFMC(foreignFMC) } - } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/MissionActionsController.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/MissionActionsController.kt index 868ce696ae..c7b732f613 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/MissionActionsController.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/MissionActionsController.kt @@ -38,13 +38,12 @@ class MissionActionsController( @RequestParam(name = "afterDateTime") @DateTimeFormat(pattern = VesselController.zoneDateTimePattern) afterDateTime: ZonedDateTime, - ): ControlsSummaryDataOutput { - return runBlocking { + ): ControlsSummaryDataOutput = + runBlocking { val actionsSummary = getVesselControls.execute(vesselId, afterDateTime) ControlsSummaryDataOutput.fromControlsSummary(actionsSummary) } - } @GetMapping("/controls/activity_reports") @Operation(summary = "Get vessels activity reports (ACT-REP)") @@ -72,9 +71,10 @@ class MissionActionsController( @Parameter(description = "Mission id") @RequestParam(name = "missionId") missionId: Int, - ): List { - return getMissionActions.execute(missionId).map { MissionActionDataOutput.fromMissionAction(it) } - } + ): List = + getMissionActions.execute(missionId).map { + MissionActionDataOutput.fromMissionAction(it) + } @PostMapping(value = [""], consumes = ["application/json"]) @Operation(summary = "Create a mission action") @@ -82,9 +82,8 @@ class MissionActionsController( fun createMissionAction( @RequestBody actionInput: AddMissionActionDataInput, - ): MissionActionDataOutput { - return MissionActionDataOutput.fromMissionAction(addMissionAction.execute(actionInput.toMissionAction())) - } + ): MissionActionDataOutput = + MissionActionDataOutput.fromMissionAction(addMissionAction.execute(actionInput.toMissionAction())) @PutMapping(value = ["/{actionId}"], consumes = ["application/json"]) @Operation(summary = "Update a mission action") @@ -119,7 +118,5 @@ class MissionActionsController( @PathParam("Action id") @PathVariable(name = "actionId") actionId: Int, - ) { - return deleteMissionAction.execute(actionId) - } + ) = deleteMissionAction.execute(actionId) } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/PendingAlertController.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/PendingAlertController.kt index f8d587450f..c805cb1084 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/PendingAlertController.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/PendingAlertController.kt @@ -25,11 +25,10 @@ class PendingAlertController( ) { @GetMapping("") @Operation(summary = "Get pending operational alerts") - fun getOperationalAlerts(): List { - return getPendingAlerts.execute().map { + fun getOperationalAlerts(): List = + getPendingAlerts.execute().map { PendingAlertDataOutput.fromPendingAlert(it) } - } @PutMapping(value = ["/{id}/validate"]) @Operation(summary = "Validate a pending operational alert") @@ -37,9 +36,7 @@ class PendingAlertController( @PathParam("Alert id") @PathVariable(name = "id") id: Int, - ) { - return validatePendingAlert.execute(id) - } + ) = validatePendingAlert.execute(id) @PutMapping(value = ["/{id}/silence"], consumes = ["application/json"]) @Operation(summary = "Silence a pending operational alert") @@ -62,11 +59,10 @@ class PendingAlertController( @GetMapping(value = ["/silenced"]) @Operation(summary = "Get all silenced operational alert") - fun getSilencedAlerts(): List { - return getSilencedAlerts.execute().map { + fun getSilencedAlerts(): List = + getSilencedAlerts.execute().map { SilencedAlertDataOutput.fromSilencedAlert(it) } - } @DeleteMapping(value = ["/silenced/{id}"]) @Operation(summary = "Delete a silenced operational alert") @@ -74,9 +70,7 @@ class PendingAlertController( @PathParam("Alert id") @PathVariable(name = "id") id: Int, - ) { - return deleteSilencedAlert.execute(id) - } + ) = deleteSilencedAlert.execute(id) @PostMapping(value = ["/silenced"], consumes = ["application/json"]) @Operation(summary = "Silence an operational alert") diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/PortController.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/PortController.kt index 4ca1cc09bd..f0542bc17b 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/PortController.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/PortController.kt @@ -11,12 +11,13 @@ import org.springframework.web.bind.annotation.RestController @RestController @RequestMapping("/bff/v1/ports") @Tag(name = "APIs for Ports") -class PortController(private val getActivePorts: GetActivePorts) { +class PortController( + private val getActivePorts: GetActivePorts, +) { @GetMapping("") @Operation(summary = "Get all active ports") - fun getActivePorts(): List { - return getActivePorts.execute().map { port -> + fun getActivePorts(): List = + getActivePorts.execute().map { port -> PortDataOutput.fromPort(port) } - } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/PriorNotificationController.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/PriorNotificationController.kt index 0ae83a7742..f44e5250da 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/PriorNotificationController.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/PriorNotificationController.kt @@ -48,7 +48,9 @@ class PriorNotificationController( private val updateLogbookPriorNotification: UpdateLogbookPriorNotification, private val verifyAndSendPriorNotification: VerifyAndSendPriorNotification, ) { - data class Status(val status: String) + data class Status( + val status: String, + ) @GetMapping("") @Operation(summary = "Get all prior notifications") @@ -282,9 +284,7 @@ class PriorNotificationController( @GetMapping("/types") @Operation(summary = "Get all prior notification types") - fun getAllTypes(): List { - return getPriorNotificationTypes.execute() - } + fun getAllTypes(): List = getPriorNotificationTypes.execute() @GetMapping("/{reportId}") @Operation(summary = "Get a prior notification by its `reportId`") @@ -298,10 +298,9 @@ class PriorNotificationController( @Parameter(description = "Operation date (to optimize SQL query via Timescale).") @RequestParam(name = "operationDate") operationDate: ZonedDateTime, - ): PriorNotificationDataOutput { - return PriorNotificationDataOutput + ): PriorNotificationDataOutput = + PriorNotificationDataOutput .fromPriorNotification(getPriorNotification.execute(reportId, operationDate, isManuallyCreated)) - } @GetMapping("/{reportId}/pdf") @Operation(summary = "Get the PNO PDF document") @@ -352,10 +351,9 @@ class PriorNotificationController( @Parameter(description = "Is the prior notification manually created?") @RequestParam(name = "isManuallyCreated") isManuallyCreated: Boolean, - ): PriorNotificationDataOutput { - return PriorNotificationDataOutput + ): PriorNotificationDataOutput = + PriorNotificationDataOutput .fromPriorNotification(verifyAndSendPriorNotification.execute(reportId, operationDate, isManuallyCreated)) - } @PutMapping("/{reportId}/invalidate") @Operation(summary = "Invalidate a prior notification by its `reportId`") @@ -386,10 +384,10 @@ class PriorNotificationController( @PathParam("Logbook message `reportId`") @PathVariable(name = "reportId") reportId: String, - ): List { - return getPriorNotificationSentMessages.execute(reportId) + ): List = + getPriorNotificationSentMessages + .execute(reportId) .map { PriorNotificationSentMessageDataOutput.fromPriorNotificationSentMessage(it) } - } @GetMapping("/{reportId}/uploads/{priorNotificationUploadId}") @Operation(summary = "Download a prior notification attachment") @@ -418,10 +416,10 @@ class PriorNotificationController( @PathParam("Logbook message `reportId`") @PathVariable(name = "reportId") reportId: String, - ): List { - return getPriorNotificationUploads.execute(reportId) + ): List = + getPriorNotificationUploads + .execute(reportId) .map { PriorNotificationUploadDataOutput.fromPriorNotificationDocument(it) } - } @PostMapping("/{reportId}/uploads") @Operation(summary = "Attach a document to a prior notification") diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/ProducerOrganizationMembershipController.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/ProducerOrganizationMembershipController.kt index 3bdfd6efb4..18b26ad147 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/ProducerOrganizationMembershipController.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/ProducerOrganizationMembershipController.kt @@ -18,10 +18,10 @@ class ProducerOrganizationMembershipController( ) { @GetMapping("") @Operation(summary = "Get all Producer Organization memberships") - fun getAll(): List { - return getAllProducerOrganizationMemberships.execute() + fun getAll(): List = + getAllProducerOrganizationMemberships + .execute() .map { ProducerOrganizationMembershipDataOutput.fromProducerOrganizationMembership(it) } - } @ResponseStatus(HttpStatus.CREATED) @PostMapping(value = [""], consumes = ["application/json"]) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/ReportingController.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/ReportingController.kt index f8bccb19cc..1465e769c0 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/ReportingController.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/ReportingController.kt @@ -36,11 +36,10 @@ class ReportingController( @GetMapping(value = [""]) @Operation(summary = "Get all current reportings") - fun getAllReportings(): List { - return getAllCurrentReportings.execute().map { + fun getAllReportings(): List = + getAllCurrentReportings.execute().map { ReportingDataOutput.fromReporting(it.first, it.second) } - } @PutMapping(value = ["/{reportingId}/archive"]) @Operation(summary = "Archive a reporting") diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/VesselController.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/VesselController.kt index ce625dc82b..3f4a7a62d0 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/VesselController.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/VesselController.kt @@ -50,9 +50,7 @@ class VesselController( @PathParam("Vessel ID") @PathVariable(name = "vesselId") vesselId: Int, - ): VesselDataOutput { - return VesselDataOutput.fromVessel(getVesselById.execute(vesselId)) - } + ): VesselDataOutput = VesselDataOutput.fromVessel(getVesselById.execute(vesselId)) @GetMapping("/find") @Operation(summary = "Get vessel information and positions") @@ -83,8 +81,8 @@ class VesselController( @RequestParam(name = "beforeDateTime", required = false) @DateTimeFormat(pattern = zoneDateTimePattern) beforeDateTime: ZonedDateTime?, - ): ResponseEntity { - return runBlocking { + ): ResponseEntity = + runBlocking { val (vesselTrackHasBeenModified, vesselWithData) = getVessel.execute( vesselId, @@ -101,7 +99,6 @@ class VesselController( ResponseEntity.status(returnCode).body(VesselAndPositionsDataOutput.fromVesselInformation(vesselWithData)) } - } @GetMapping("/beacon_malfunctions") @Operation(summary = "Get vessel's beacon malfunctions history") @@ -225,11 +222,10 @@ class VesselController( ) @RequestParam(name = "searched") searched: String, - ): List { - return searchVessels.execute(searched).map { + ): List = + searchVessels.execute(searched).map { VesselIdentityDataOutput.fromVesselAndBeacon(it) } - } @GetMapping("/logbook/find") @Operation(summary = "Get vessel's Logbook messages") @@ -258,9 +254,7 @@ class VesselController( @Parameter(description = "Vessel internal reference number (CFR)", required = true) @RequestParam(name = "internalReferenceNumber") internalReferenceNumber: String, - ): List { - return getVesselLastTripNumbers.execute(internalReferenceNumber) - } + ): List = getVesselLastTripNumbers.execute(internalReferenceNumber) @GetMapping("/risk_factor") @Operation(summary = "Get vessel risk factor") diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/input/ManualPriorNotificationFishingCatchDataInput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/input/ManualPriorNotificationFishingCatchDataInput.kt index 2f05e44a10..d0b3c3ba26 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/input/ManualPriorNotificationFishingCatchDataInput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/input/ManualPriorNotificationFishingCatchDataInput.kt @@ -9,8 +9,8 @@ data class ManualPriorNotificationFishingCatchDataInput( val specyName: String, val weight: Double, ) { - fun toLogbookFishingCatch(): LogbookFishingCatch { - return LogbookFishingCatch( + fun toLogbookFishingCatch(): LogbookFishingCatch = + LogbookFishingCatch( conversionFactor = null, economicZone = null, effortZone = null, @@ -25,5 +25,4 @@ data class ManualPriorNotificationFishingCatchDataInput( statisticalRectangle = null, weight = weight, ) - } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/light/VesselLightController.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/light/VesselLightController.kt index ef4b9e93dd..adeda25cbd 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/light/VesselLightController.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/light/VesselLightController.kt @@ -75,8 +75,8 @@ class VesselLightController( @RequestParam(name = "beforeDateTime", required = false) @DateTimeFormat(pattern = zoneDateTimePattern) beforeDateTime: ZonedDateTime?, - ): ResponseEntity { - return runBlocking { + ): ResponseEntity = + runBlocking { val (vesselTrackHasBeenModified, vesselWithData) = getVessel.execute( vesselId, @@ -93,7 +93,6 @@ class VesselLightController( ResponseEntity.status(returnCode).body(VesselAndPositionsDataOutput.fromVesselWithData(vesselWithData)) } - } @GetMapping("/logbook/find") @Operation(summary = "Get vessel's Logbook messages") diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/light/outputs/LastPositionDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/light/outputs/LastPositionDataOutput.kt index 5a526a272f..61c93a272f 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/light/outputs/LastPositionDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/light/outputs/LastPositionDataOutput.kt @@ -46,8 +46,8 @@ data class LastPositionDataOutput( val beaconMalfunctionId: Int? = null, ) { companion object { - fun fromLastPosition(position: LastPosition): LastPositionDataOutput { - return LastPositionDataOutput( + fun fromLastPosition(position: LastPosition): LastPositionDataOutput = + LastPositionDataOutput( vesselId = position.vesselId, internalReferenceNumber = position.internalReferenceNumber, ircs = position.ircs, @@ -88,6 +88,5 @@ data class LastPositionDataOutput( isAtPort = position.isAtPort, beaconMalfunctionId = position.beaconMalfunctionId, ) - } } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/light/outputs/VesselAndPositionsDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/light/outputs/VesselAndPositionsDataOutput.kt index e0d711c5f0..48cf333673 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/light/outputs/VesselAndPositionsDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/light/outputs/VesselAndPositionsDataOutput.kt @@ -8,8 +8,8 @@ data class VesselAndPositionsDataOutput( val vessel: VesselDataOutput?, ) { companion object { - fun fromVesselWithData(vesselInformation: VesselInformation): VesselAndPositionsDataOutput { - return VesselAndPositionsDataOutput( + fun fromVesselWithData(vesselInformation: VesselInformation): VesselAndPositionsDataOutput = + VesselAndPositionsDataOutput( vessel = VesselDataOutput.fromVessel( vesselInformation.vessel, @@ -20,6 +20,5 @@ data class VesselAndPositionsDataOutput( PositionDataOutput.fromPosition(it) }, ) - } } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/light/outputs/VoyageDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/light/outputs/VoyageDataOutput.kt index 2975587325..cbb1eb3de0 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/light/outputs/VoyageDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/light/outputs/VoyageDataOutput.kt @@ -12,8 +12,8 @@ data class VoyageDataOutput( val logbookMessagesAndAlerts: LogbookMessagesAndAlertsDataOutput, ) { companion object { - fun fromVoyage(voyage: Voyage): VoyageDataOutput { - return VoyageDataOutput( + fun fromVoyage(voyage: Voyage): VoyageDataOutput = + VoyageDataOutput( isLastVoyage = voyage.isLastVoyage, isFirstVoyage = voyage.isFirstVoyage, startDate = voyage.startDate, @@ -23,6 +23,5 @@ data class VoyageDataOutput( LogbookMessagesAndAlertsDataOutput .fromLogbookMessagesAndAlerts(voyage.logbookMessagesAndAlerts), ) - } } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/log/CorrelationInterceptor.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/log/CorrelationInterceptor.kt index e82be7cb68..e07440cf07 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/log/CorrelationInterceptor.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/log/CorrelationInterceptor.kt @@ -45,7 +45,5 @@ class CorrelationInterceptor : HandlerInterceptor { return correlationId } - private fun generateUniqueCorrelationId(): String { - return UUID.randomUUID().toString() - } + private fun generateUniqueCorrelationId(): String = UUID.randomUUID().toString() } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/log/LogGETRequests.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/log/LogGETRequests.kt index f1de805b8f..908d24ad7f 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/log/LogGETRequests.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/log/LogGETRequests.kt @@ -7,7 +7,9 @@ import org.slf4j.LoggerFactory import org.springframework.http.HttpMethod.GET import org.springframework.web.servlet.HandlerInterceptor -class LogGETRequests(val mapper: ObjectMapper) : HandlerInterceptor { +class LogGETRequests( + val mapper: ObjectMapper, +) : HandlerInterceptor { private val logger = LoggerFactory.getLogger(LogGETRequests::class.java) override fun preHandle( diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/log/LogRequestsWithBody.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/log/LogRequestsWithBody.kt index 82d43137bf..8577de77b4 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/log/LogRequestsWithBody.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/log/LogRequestsWithBody.kt @@ -13,7 +13,10 @@ import org.springframework.web.servlet.mvc.method.annotation.RequestBodyAdviceAd import java.lang.reflect.Type @ControllerAdvice -class LogRequestsWithBody(val request: HttpServletRequest, val mapper: ObjectMapper) : RequestBodyAdviceAdapter() { +class LogRequestsWithBody( + val request: HttpServletRequest, + val mapper: ObjectMapper, +) : RequestBodyAdviceAdapter() { private val logger = LoggerFactory.getLogger(LogGETRequests::class.java) override fun afterBodyRead( @@ -35,7 +38,5 @@ class LogRequestsWithBody(val request: HttpServletRequest, val mapper: ObjectMap methodParameter: MethodParameter, targetType: Type, converterType: Class>, - ): Boolean { - return true - } + ): Boolean = true } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/log/LogResponseWithBody.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/log/LogResponseWithBody.kt index f9f569b3ca..72de15f11a 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/log/LogResponseWithBody.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/log/LogResponseWithBody.kt @@ -15,15 +15,15 @@ import org.springframework.web.bind.annotation.ControllerAdvice import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice @ControllerAdvice -class LogResponseWithBody(val mapper: ObjectMapper) : ResponseBodyAdvice { +class LogResponseWithBody( + val mapper: ObjectMapper, +) : ResponseBodyAdvice { private val logger = LoggerFactory.getLogger(LogGETRequests::class.java) override fun supports( returnType: MethodParameter, converterType: Class>, - ): Boolean { - return true - } + ): Boolean = true override fun beforeBodyWrite( body: Any?, diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/AcknowledgmentDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/AcknowledgmentDataOutput.kt index 3665cc0f77..9928216d81 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/AcknowledgmentDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/AcknowledgmentDataOutput.kt @@ -9,13 +9,12 @@ class AcknowledgmentDataOutput( var returnStatus: String?, ) { companion object { - fun fromAcknowledgment(acknowledgment: Acknowledgment): AcknowledgmentDataOutput { - return AcknowledgmentDataOutput( + fun fromAcknowledgment(acknowledgment: Acknowledgment): AcknowledgmentDataOutput = + AcknowledgmentDataOutput( dateTime = acknowledgment.dateTime?.toString(), isSuccess = acknowledgment.isSuccess ?: false, rejectionCause = acknowledgment.rejectionCause, returnStatus = acknowledgment.returnStatus, ) - } } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/AdministrationDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/AdministrationDataOutput.kt index 30d4685d40..b731a12c58 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/AdministrationDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/AdministrationDataOutput.kt @@ -7,11 +7,10 @@ data class AdministrationDataOutput( val name: String, ) { companion object { - fun fromAdministration(administration: Administration): AdministrationDataOutput { - return AdministrationDataOutput( + fun fromAdministration(administration: Administration): AdministrationDataOutput = + AdministrationDataOutput( id = administration.id, name = administration.name, ) - } } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ApiError.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ApiError.kt index a0f9e04208..10849a3029 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ApiError.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ApiError.kt @@ -1,9 +1,15 @@ package fr.gouv.cnsp.monitorfish.infrastructure.api.outputs -class ApiError(val error: String, val type: String) { +class ApiError( + val error: String, + val type: String, +) { constructor(exception: Throwable) : this( exception.cause?.message ?: "", - exception.cause?.javaClass?.simpleName.toString(), + exception.cause + ?.javaClass + ?.simpleName + .toString(), ) } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/BeaconDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/BeaconDataOutput.kt index 8d55957f03..94e9e468f4 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/BeaconDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/BeaconDataOutput.kt @@ -9,12 +9,11 @@ data class BeaconDataOutput( val loggingDatetimeUtc: ZonedDateTime? = null, ) { companion object { - fun fromBeacon(beacon: Beacon): BeaconDataOutput { - return BeaconDataOutput( + fun fromBeacon(beacon: Beacon): BeaconDataOutput = + BeaconDataOutput( beaconNumber = beacon.beaconNumber, isCoastal = beacon.isCoastal, loggingDatetimeUtc = beacon.loggingDatetimeUtc, ) - } } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/BeaconMalfunctionActionDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/BeaconMalfunctionActionDataOutput.kt index 0886931ada..64d9f4fe09 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/BeaconMalfunctionActionDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/BeaconMalfunctionActionDataOutput.kt @@ -14,14 +14,13 @@ data class BeaconMalfunctionActionDataOutput( companion object { fun fromBeaconMalfunctionAction( beaconMalfunctionAction: BeaconMalfunctionAction, - ): BeaconMalfunctionActionDataOutput { - return BeaconMalfunctionActionDataOutput( + ): BeaconMalfunctionActionDataOutput = + BeaconMalfunctionActionDataOutput( beaconMalfunctionId = beaconMalfunctionAction.beaconMalfunctionId, propertyName = beaconMalfunctionAction.propertyName, previousValue = beaconMalfunctionAction.previousValue, nextValue = beaconMalfunctionAction.nextValue, dateTime = beaconMalfunctionAction.dateTime, ) - } } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/BeaconMalfunctionCommentDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/BeaconMalfunctionCommentDataOutput.kt index df9668c9e6..0d6b310452 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/BeaconMalfunctionCommentDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/BeaconMalfunctionCommentDataOutput.kt @@ -13,13 +13,12 @@ data class BeaconMalfunctionCommentDataOutput( companion object { fun fromBeaconMalfunctionComment( beaconMalfunctionComment: BeaconMalfunctionComment, - ): BeaconMalfunctionCommentDataOutput { - return BeaconMalfunctionCommentDataOutput( + ): BeaconMalfunctionCommentDataOutput = + BeaconMalfunctionCommentDataOutput( beaconMalfunctionId = beaconMalfunctionComment.beaconMalfunctionId, comment = beaconMalfunctionComment.comment, userType = beaconMalfunctionComment.userType, dateTime = beaconMalfunctionComment.dateTime, ) - } } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/BeaconMalfunctionDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/BeaconMalfunctionDataOutput.kt index 8cb620e1b9..9ad680f990 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/BeaconMalfunctionDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/BeaconMalfunctionDataOutput.kt @@ -24,8 +24,8 @@ data class BeaconMalfunctionDataOutput( val beaconNumber: String? = null, ) { companion object { - fun fromBeaconMalfunction(beaconMalfunction: BeaconMalfunction): BeaconMalfunctionDataOutput { - return BeaconMalfunctionDataOutput( + fun fromBeaconMalfunction(beaconMalfunction: BeaconMalfunction): BeaconMalfunctionDataOutput = + BeaconMalfunctionDataOutput( id = beaconMalfunction.id, internalReferenceNumber = beaconMalfunction.internalReferenceNumber, ircs = beaconMalfunction.ircs, @@ -44,6 +44,5 @@ data class BeaconMalfunctionDataOutput( beaconNumber = beaconMalfunction.beaconNumber, vesselId = beaconMalfunction.vesselId, ) - } } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/BeaconMalfunctionNotificationDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/BeaconMalfunctionNotificationDataOutput.kt index d6a2ddf88a..573a203d1b 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/BeaconMalfunctionNotificationDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/BeaconMalfunctionNotificationDataOutput.kt @@ -20,8 +20,8 @@ data class BeaconMalfunctionNotificationDataOutput( companion object { fun fromBeaconMalfunctionNotification( beaconMalfunctionNotification: BeaconMalfunctionNotification, - ): BeaconMalfunctionNotificationDataOutput { - return BeaconMalfunctionNotificationDataOutput( + ): BeaconMalfunctionNotificationDataOutput = + BeaconMalfunctionNotificationDataOutput( beaconMalfunctionId = beaconMalfunctionNotification.beaconMalfunctionId, dateTime = beaconMalfunctionNotification.dateTimeUtc, notificationType = beaconMalfunctionNotification.notificationType, @@ -32,6 +32,5 @@ data class BeaconMalfunctionNotificationDataOutput( success = beaconMalfunctionNotification.success, errorMessage = beaconMalfunctionNotification.errorMessage, ) - } } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/BeaconMalfunctionResumeAndDetailsDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/BeaconMalfunctionResumeAndDetailsDataOutput.kt index 66cc3511db..39430e62d3 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/BeaconMalfunctionResumeAndDetailsDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/BeaconMalfunctionResumeAndDetailsDataOutput.kt @@ -12,8 +12,8 @@ data class BeaconMalfunctionResumeAndDetailsDataOutput( companion object { fun fromBeaconMalfunctionResumeAndDetails( beaconMalfunctionResumeAndDetails: BeaconMalfunctionResumeAndDetails, - ): BeaconMalfunctionResumeAndDetailsDataOutput { - return BeaconMalfunctionResumeAndDetailsDataOutput( + ): BeaconMalfunctionResumeAndDetailsDataOutput = + BeaconMalfunctionResumeAndDetailsDataOutput( beaconMalfunction = BeaconMalfunctionDataOutput.fromBeaconMalfunction( beaconMalfunctionResumeAndDetails.beaconMalfunction, @@ -43,6 +43,5 @@ data class BeaconMalfunctionResumeAndDetailsDataOutput( ) }, ) - } } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/BeaconMalfunctionWithDetailsDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/BeaconMalfunctionWithDetailsDataOutput.kt index 2deeed4740..d44119e77d 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/BeaconMalfunctionWithDetailsDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/BeaconMalfunctionWithDetailsDataOutput.kt @@ -10,8 +10,8 @@ data class BeaconMalfunctionWithDetailsDataOutput( companion object { fun fromBeaconMalfunctionWithDetails( beaconMalfunctionWithDetails: BeaconMalfunctionWithDetails, - ): BeaconMalfunctionWithDetailsDataOutput { - return BeaconMalfunctionWithDetailsDataOutput( + ): BeaconMalfunctionWithDetailsDataOutput = + BeaconMalfunctionWithDetailsDataOutput( beaconMalfunction = BeaconMalfunctionDataOutput.fromBeaconMalfunction( beaconMalfunctionWithDetails.beaconMalfunction, @@ -29,6 +29,5 @@ data class BeaconMalfunctionWithDetailsDataOutput( ) }, ) - } } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/FleetSegmentDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/FleetSegmentDataOutput.kt index 26a600760f..6e400dca51 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/FleetSegmentDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/FleetSegmentDataOutput.kt @@ -19,8 +19,8 @@ data class FleetSegmentDataOutput( val year: Int, ) { companion object { - fun fromFleetSegment(fleetSegment: FleetSegment): FleetSegmentDataOutput { - return FleetSegmentDataOutput( + fun fromFleetSegment(fleetSegment: FleetSegment): FleetSegmentDataOutput = + FleetSegmentDataOutput( segment = fleetSegment.segment, segmentName = fleetSegment.segmentName, mainScipSpeciesType = fleetSegment.mainScipSpeciesType, @@ -35,6 +35,5 @@ data class FleetSegmentDataOutput( impactRiskFactor = fleetSegment.impactRiskFactor, year = fleetSegment.year, ) - } } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/GearDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/GearDataOutput.kt index 5ee6e428df..cc61d7bc74 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/GearDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/GearDataOutput.kt @@ -10,14 +10,13 @@ data class GearDataOutput( val isMeshRequiredForSegment: Boolean, ) { companion object { - fun fromGear(gear: Gear): GearDataOutput { - return GearDataOutput( + fun fromGear(gear: Gear): GearDataOutput = + GearDataOutput( code = gear.code, name = gear.name, category = gear.category, groupId = gear.groupId, isMeshRequiredForSegment = gear.isMeshRequiredForSegment ?: false, ) - } } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/InfractionSuspicionDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/InfractionSuspicionDataOutput.kt index 4c691c8b30..871578b4e6 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/InfractionSuspicionDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/InfractionSuspicionDataOutput.kt @@ -20,8 +20,8 @@ data class InfractionSuspicionDataOutput( fun fromInfractionSuspicion( infractionSuspicion: InfractionSuspicion, controlUnit: LegacyControlUnit? = null, - ): InfractionSuspicionDataOutput { - return InfractionSuspicionDataOutput( + ): InfractionSuspicionDataOutput = + InfractionSuspicionDataOutput( reportingActor = infractionSuspicion.reportingActor, controlUnitId = infractionSuspicion.controlUnitId, controlUnit = controlUnit, @@ -33,6 +33,5 @@ data class InfractionSuspicionDataOutput( dml = infractionSuspicion.dml, seaFront = infractionSuspicion.seaFront, ) - } } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/LastPositionDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/LastPositionDataOutput.kt index 52e56145fa..3155262652 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/LastPositionDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/LastPositionDataOutput.kt @@ -51,8 +51,8 @@ data class LastPositionDataOutput( val reportings: List = listOf(), ) { companion object { - fun fromLastPosition(position: LastPosition): LastPositionDataOutput { - return LastPositionDataOutput( + fun fromLastPosition(position: LastPosition): LastPositionDataOutput = + LastPositionDataOutput( vesselId = position.vesselId, internalReferenceNumber = position.internalReferenceNumber, ircs = position.ircs, @@ -100,6 +100,5 @@ data class LastPositionDataOutput( beaconMalfunctionId = position.beaconMalfunctionId, reportings = position.reportings, ) - } } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/LogbookMessageFishingCatchDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/LogbookMessageFishingCatchDataOutput.kt index 361bd64212..0ed7b66999 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/LogbookMessageFishingCatchDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/LogbookMessageFishingCatchDataOutput.kt @@ -18,8 +18,8 @@ class LogbookMessageFishingCatchDataOutput( var weight: Double?, ) { companion object { - fun fromLogbookFishingCatch(logbookFishingCatch: LogbookFishingCatch): LogbookMessageFishingCatchDataOutput { - return LogbookMessageFishingCatchDataOutput( + fun fromLogbookFishingCatch(logbookFishingCatch: LogbookFishingCatch): LogbookMessageFishingCatchDataOutput = + LogbookMessageFishingCatchDataOutput( conversionFactor = logbookFishingCatch.conversionFactor, economicZone = logbookFishingCatch.economicZone, effortZone = logbookFishingCatch.effortZone, @@ -34,6 +34,5 @@ class LogbookMessageFishingCatchDataOutput( statisticalRectangle = logbookFishingCatch.statisticalRectangle, weight = logbookFishingCatch.weight, ) - } } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/LogbookMessageGearDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/LogbookMessageGearDataOutput.kt index 56a9e4fa9d..98ae7fdf22 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/LogbookMessageGearDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/LogbookMessageGearDataOutput.kt @@ -9,8 +9,8 @@ class LogbookMessageGearDataOutput( val dimensions: String?, ) { companion object { - fun fromGear(gear: LogbookTripGear): LogbookMessageGearDataOutput? { - return gear.gear?.let { gearCode -> + fun fromGear(gear: LogbookTripGear): LogbookMessageGearDataOutput? = + gear.gear?.let { gearCode -> LogbookMessageGearDataOutput( gear = gearCode, gearName = gear.gearName, @@ -18,6 +18,5 @@ class LogbookMessageGearDataOutput( dimensions = gear.dimensions, ) } - } } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/LogbookMessageTripSegmentDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/LogbookMessageTripSegmentDataOutput.kt index 9a2a88e064..98af965b64 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/LogbookMessageTripSegmentDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/LogbookMessageTripSegmentDataOutput.kt @@ -8,12 +8,11 @@ class LogbookMessageTripSegmentDataOutput( val name: String, ) { companion object { - fun fromFleetSegment(fleetSegment: FleetSegment): LogbookMessageTripSegmentDataOutput { - return LogbookMessageTripSegmentDataOutput( + fun fromFleetSegment(fleetSegment: FleetSegment): LogbookMessageTripSegmentDataOutput = + LogbookMessageTripSegmentDataOutput( code = fleetSegment.segment, name = fleetSegment.segmentName, ) - } fun fromLogbookTripSegment(logbookTripSegment: LogbookTripSegment) = LogbookMessageTripSegmentDataOutput( diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/LogbookPriorNotificationFormDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/LogbookPriorNotificationFormDataOutput.kt index ede6a53501..bab526c143 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/LogbookPriorNotificationFormDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/LogbookPriorNotificationFormDataOutput.kt @@ -6,10 +6,9 @@ data class LogbookPriorNotificationFormDataOutput( val note: String?, ) { companion object { - fun fromPriorNotification(priorNotification: PriorNotification): LogbookPriorNotificationFormDataOutput { - return LogbookPriorNotificationFormDataOutput( + fun fromPriorNotification(priorNotification: PriorNotification): LogbookPriorNotificationFormDataOutput = + LogbookPriorNotificationFormDataOutput( note = priorNotification.logbookMessageAndValue.value.note, ) - } } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ManualPriorNotificationDraftDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ManualPriorNotificationDraftDataOutput.kt index c232acd2cc..63104f7537 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ManualPriorNotificationDraftDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ManualPriorNotificationDraftDataOutput.kt @@ -49,7 +49,11 @@ data class ManualPriorNotificationDraftDataOutput( // - or have an FAO area field per fishing catch // while in Backend, we always have an FAO area field per fishing catch. // So we need to check if all fishing catches have the same FAO area to know which case we are in. - val hasGlobalFaoArea = pnoValue.catchOnboard.mapNotNull { it.faoZone }.distinct().size == 1 + val hasGlobalFaoArea = + pnoValue.catchOnboard + .mapNotNull { it.faoZone } + .distinct() + .size == 1 val globalFaoArea = if (hasGlobalFaoArea) { pnoValue.catchOnboard.first().faoZone diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ManualPriorNotificationFormDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ManualPriorNotificationFormDataOutput.kt index 416074c031..6034a877df 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ManualPriorNotificationFormDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ManualPriorNotificationFormDataOutput.kt @@ -30,17 +30,19 @@ data class ManualPriorNotificationFormDataOutput( val pnoValue = priorNotification.logbookMessageAndValue.value val expectedArrivalDate = - CustomZonedDateTime.fromZonedDateTime( - requireNotNull(pnoValue.predictedArrivalDatetimeUtc) { - "`message.predictedArrivalDatetimeUtc` is null." - }, - ).toString() + CustomZonedDateTime + .fromZonedDateTime( + requireNotNull(pnoValue.predictedArrivalDatetimeUtc) { + "`message.predictedArrivalDatetimeUtc` is null." + }, + ).toString() val expectedLandingDate = - CustomZonedDateTime.fromZonedDateTime( - requireNotNull(pnoValue.predictedLandingDatetimeUtc) { - "`message.predictedLandingDatetimeUtc` is null." - }, - ).toString() + CustomZonedDateTime + .fromZonedDateTime( + requireNotNull(pnoValue.predictedLandingDatetimeUtc) { + "`message.predictedLandingDatetimeUtc` is null." + }, + ).toString() val portLocode = requireNotNull(pnoValue.port) { "`pnoValue.port` is null." } val purpose = requireNotNull(pnoValue.purpose) { "`pnoValue.purpose` is null." } val reportId = requireNotNull(priorNotification.reportId) { "`priorNotification.reportId` is null." } @@ -52,9 +54,10 @@ data class ManualPriorNotificationFormDataOutput( val updatedAt = requireNotNull( priorNotification.updatedAt, - ) { "`priorNotification.updatedAt` is null." }.withZoneSameInstant( - ZoneOffset.UTC, - ).toString() + ) { "`priorNotification.updatedAt` is null." } + .withZoneSameInstant( + ZoneOffset.UTC, + ).toString() requireNotNull(priorNotification.vessel) { "`priorNotification.vessel` is null." }.id @@ -66,7 +69,11 @@ data class ManualPriorNotificationFormDataOutput( // - or have an FAO area field per fishing catch // while in Backend, we always have an FAO area field per fishing catch. // So we need to check if all fishing catches have the same FAO area to know which case we are in. - val hasGlobalFaoArea = pnoValue.catchOnboard.mapNotNull { it.faoZone }.distinct().size == 1 + val hasGlobalFaoArea = + pnoValue.catchOnboard + .mapNotNull { it.faoZone } + .distinct() + .size == 1 val globalFaoArea = if (hasGlobalFaoArea) { pnoValue.catchOnboard.first().faoZone diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/MissingParameterApiError.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/MissingParameterApiError.kt index 437fec9862..1ba6a5b206 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/MissingParameterApiError.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/MissingParameterApiError.kt @@ -1,3 +1,5 @@ package fr.gouv.cnsp.monitorfish.infrastructure.api.outputs -data class MissingParameterApiError(val error: String) +data class MissingParameterApiError( + val error: String, +) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ObservationDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ObservationDataOutput.kt index f0e7bdda47..3b3159f62a 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ObservationDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ObservationDataOutput.kt @@ -19,8 +19,8 @@ class ObservationDataOutput( fun fromObservation( observation: Observation, controlUnit: LegacyControlUnit? = null, - ): ObservationDataOutput { - return ObservationDataOutput( + ): ObservationDataOutput = + ObservationDataOutput( reportingActor = observation.reportingActor, controlUnitId = observation.controlUnitId, controlUnit = controlUnit, @@ -31,6 +31,5 @@ class ObservationDataOutput( seaFront = observation.seaFront, dml = observation.dml, ) - } } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PositionDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PositionDataOutput.kt index 102911b30b..d30ceb4ee2 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PositionDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PositionDataOutput.kt @@ -28,8 +28,8 @@ data class PositionDataOutput( val networkType: NetworkType? = null, ) { companion object { - fun fromPosition(position: Position): PositionDataOutput { - return PositionDataOutput( + fun fromPosition(position: Position): PositionDataOutput = + PositionDataOutput( internalReferenceNumber = position.internalReferenceNumber, ircs = position.ircs, mmsi = position.mmsi, @@ -50,6 +50,5 @@ data class PositionDataOutput( isAtPort = position.isAtPort, networkType = position.networkType, ) - } } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PriorNotificationFleetSegmentSubscriptionDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PriorNotificationFleetSegmentSubscriptionDataOutput.kt index 8405741707..67ded87ecb 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PriorNotificationFleetSegmentSubscriptionDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PriorNotificationFleetSegmentSubscriptionDataOutput.kt @@ -10,12 +10,11 @@ data class PriorNotificationFleetSegmentSubscriptionDataOutput( companion object { fun fromPriorNotificationSegmentSubscription( priorNotificationFleetSegmentSubscription: PriorNotificationFleetSegmentSubscription, - ): PriorNotificationFleetSegmentSubscriptionDataOutput { - return PriorNotificationFleetSegmentSubscriptionDataOutput( + ): PriorNotificationFleetSegmentSubscriptionDataOutput = + PriorNotificationFleetSegmentSubscriptionDataOutput( controlUnitId = priorNotificationFleetSegmentSubscription.controlUnitId, segmentCode = priorNotificationFleetSegmentSubscription.segmentCode, segmentName = priorNotificationFleetSegmentSubscription.segmentName, ) - } } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PriorNotificationPortSubscriptionDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PriorNotificationPortSubscriptionDataOutput.kt index ec0050f226..66d55426c2 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PriorNotificationPortSubscriptionDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PriorNotificationPortSubscriptionDataOutput.kt @@ -11,13 +11,12 @@ data class PriorNotificationPortSubscriptionDataOutput( companion object { fun fromPriorNotificationPortSubscription( priorNotificationPortSubscription: PriorNotificationPortSubscription, - ): PriorNotificationPortSubscriptionDataOutput { - return PriorNotificationPortSubscriptionDataOutput( + ): PriorNotificationPortSubscriptionDataOutput = + PriorNotificationPortSubscriptionDataOutput( controlUnitId = priorNotificationPortSubscription.controlUnitId, hasSubscribedToAllPriorNotifications = priorNotificationPortSubscription.hasSubscribedToAllPriorNotifications, portLocode = priorNotificationPortSubscription.portLocode, portName = priorNotificationPortSubscription.portName, ) - } } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PriorNotificationSentMessageDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PriorNotificationSentMessageDataOutput.kt index 41a8158703..96f8a68a0c 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PriorNotificationSentMessageDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PriorNotificationSentMessageDataOutput.kt @@ -16,8 +16,8 @@ data class PriorNotificationSentMessageDataOutput( companion object { fun fromPriorNotificationSentMessage( priorNotificationSentMessage: PriorNotificationSentMessage, - ): PriorNotificationSentMessageDataOutput { - return PriorNotificationSentMessageDataOutput( + ): PriorNotificationSentMessageDataOutput = + PriorNotificationSentMessageDataOutput( id = priorNotificationSentMessage.id, communicationMeans = priorNotificationSentMessage.communicationMeans, dateTimeUtc = priorNotificationSentMessage.dateTimeUtc, @@ -27,6 +27,5 @@ data class PriorNotificationSentMessageDataOutput( recipientOrganization = priorNotificationSentMessage.recipientOrganization, success = priorNotificationSentMessage.success, ) - } } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PriorNotificationTypeDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PriorNotificationTypeDataOutput.kt index ce41096183..c602edfd90 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PriorNotificationTypeDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PriorNotificationTypeDataOutput.kt @@ -9,20 +9,18 @@ class PriorNotificationTypeDataOutput( val name: String, ) { companion object { - fun fromPriorNotificationType(priorNotificationType: PriorNotificationType): PriorNotificationTypeDataOutput { - return PriorNotificationTypeDataOutput( + fun fromPriorNotificationType(priorNotificationType: PriorNotificationType): PriorNotificationTypeDataOutput = + PriorNotificationTypeDataOutput( hasDesignatedPorts = priorNotificationType.hasDesignatedPorts, minimumNotificationPeriod = priorNotificationType.minimumNotificationPeriod, name = priorNotificationType.name ?: "Type de préavis inconnu", ) - } - fun fromPnoType(pnoType: PnoType): PriorNotificationTypeDataOutput { - return PriorNotificationTypeDataOutput( + fun fromPnoType(pnoType: PnoType): PriorNotificationTypeDataOutput = + PriorNotificationTypeDataOutput( hasDesignatedPorts = pnoType.hasDesignatedPorts, minimumNotificationPeriod = pnoType.minimumNotificationPeriod, name = pnoType.name, ) - } } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PriorNotificationVesselSubscriptionDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PriorNotificationVesselSubscriptionDataOutput.kt index 25bbc9b14f..92c7638371 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PriorNotificationVesselSubscriptionDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PriorNotificationVesselSubscriptionDataOutput.kt @@ -14,8 +14,8 @@ data class PriorNotificationVesselSubscriptionDataOutput( companion object { fun fromPriorNotificationVesselSubscription( priorNotificationFleetVesselSubscription: PriorNotificationVesselSubscription, - ): PriorNotificationVesselSubscriptionDataOutput { - return PriorNotificationVesselSubscriptionDataOutput( + ): PriorNotificationVesselSubscriptionDataOutput = + PriorNotificationVesselSubscriptionDataOutput( controlUnitId = priorNotificationFleetVesselSubscription.controlUnitId, vesselId = priorNotificationFleetVesselSubscription.vesselId, vesselCallSign = priorNotificationFleetVesselSubscription.vesselCallSign, @@ -24,6 +24,5 @@ data class PriorNotificationVesselSubscriptionDataOutput( vesselMmsi = priorNotificationFleetVesselSubscription.vesselMmsi, vesselName = priorNotificationFleetVesselSubscription.vesselName, ) - } } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PriorNotificationsExtraDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PriorNotificationsExtraDataOutput.kt index 0c55adb7de..1acd9456bd 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PriorNotificationsExtraDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PriorNotificationsExtraDataOutput.kt @@ -9,10 +9,9 @@ data class PriorNotificationsExtraDataOutput( companion object { fun fromPriorNotificationStats( priorNotificationStats: PriorNotificationStats, - ): PriorNotificationsExtraDataOutput { - return PriorNotificationsExtraDataOutput( + ): PriorNotificationsExtraDataOutput = + PriorNotificationsExtraDataOutput( perSeafrontGroupCount = priorNotificationStats.perSeafrontGroupCount, ) - } } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ProducerOrganizationMembershipDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ProducerOrganizationMembershipDataOutput.kt index ed88793851..672227bb65 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ProducerOrganizationMembershipDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ProducerOrganizationMembershipDataOutput.kt @@ -11,12 +11,11 @@ data class ProducerOrganizationMembershipDataOutput( companion object { fun fromProducerOrganizationMembership( producerOrganizationMembership: ProducerOrganizationMembership, - ): ProducerOrganizationMembershipDataOutput { - return ProducerOrganizationMembershipDataOutput( + ): ProducerOrganizationMembershipDataOutput = + ProducerOrganizationMembershipDataOutput( internalReferenceNumber = producerOrganizationMembership.internalReferenceNumber, joiningDate = producerOrganizationMembership.joiningDate, organizationName = producerOrganizationMembership.organizationName, ) - } } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ReportingAndOccurrencesDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ReportingAndOccurrencesDataOutput.kt index 2f4723de9c..d4c46ad61d 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ReportingAndOccurrencesDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ReportingAndOccurrencesDataOutput.kt @@ -9,8 +9,8 @@ data class ReportingAndOccurrencesDataOutput( companion object { fun fromReportingAndOccurrences( reportingAndOccurrences: ReportingAndOccurrences, - ): ReportingAndOccurrencesDataOutput { - return ReportingAndOccurrencesDataOutput( + ): ReportingAndOccurrencesDataOutput = + ReportingAndOccurrencesDataOutput( otherOccurrencesOfSameAlert = reportingAndOccurrences.otherOccurrencesOfSameAlert.map { reporting -> ReportingDataOutput.fromReporting(reporting, reportingAndOccurrences.controlUnit) @@ -21,6 +21,5 @@ data class ReportingAndOccurrencesDataOutput( reportingAndOccurrences.controlUnit, ), ) - } } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/SpeciesAndSpeciesGroupsDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/SpeciesAndSpeciesGroupsDataOutput.kt index 94ef340f99..943168fa2e 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/SpeciesAndSpeciesGroupsDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/SpeciesAndSpeciesGroupsDataOutput.kt @@ -9,11 +9,10 @@ data class SpeciesAndSpeciesGroupsDataOutput( companion object { fun fromSpeciesAndSpeciesGroups( speciesAndSpeciesGroups: SpeciesAndSpeciesGroups, - ): SpeciesAndSpeciesGroupsDataOutput { - return SpeciesAndSpeciesGroupsDataOutput( + ): SpeciesAndSpeciesGroupsDataOutput = + SpeciesAndSpeciesGroupsDataOutput( speciesAndSpeciesGroups.species.map { SpeciesDataOutput.fromSpecies(it) }, speciesAndSpeciesGroups.groups.map { SpeciesGroupDataOutput.fromSpeciesGroup(it) }, ) - } } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/SpeciesDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/SpeciesDataOutput.kt index 18a300cc09..c864fd2e69 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/SpeciesDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/SpeciesDataOutput.kt @@ -7,11 +7,10 @@ data class SpeciesDataOutput( val name: String, ) { companion object { - fun fromSpecies(species: Species): SpeciesDataOutput { - return SpeciesDataOutput( + fun fromSpecies(species: Species): SpeciesDataOutput = + SpeciesDataOutput( code = species.code, name = species.name, ) - } } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/SpeciesGroupDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/SpeciesGroupDataOutput.kt index 1ddeee5d54..21799e5a24 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/SpeciesGroupDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/SpeciesGroupDataOutput.kt @@ -7,11 +7,10 @@ data class SpeciesGroupDataOutput( val comment: String, ) { companion object { - fun fromSpeciesGroup(speciesGroup: SpeciesGroup): SpeciesGroupDataOutput { - return SpeciesGroupDataOutput( + fun fromSpeciesGroup(speciesGroup: SpeciesGroup): SpeciesGroupDataOutput = + SpeciesGroupDataOutput( group = speciesGroup.group, comment = speciesGroup.comment, ) - } } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/UserAuthorizationDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/UserAuthorizationDataOutput.kt index b5ff729771..7eafacd45b 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/UserAuthorizationDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/UserAuthorizationDataOutput.kt @@ -6,10 +6,9 @@ data class UserAuthorizationDataOutput( val isSuperUser: Boolean, ) { companion object { - fun fromUserAuthorization(userAuthorization: UserAuthorization): UserAuthorizationDataOutput { - return UserAuthorizationDataOutput( + fun fromUserAuthorization(userAuthorization: UserAuthorization): UserAuthorizationDataOutput = + UserAuthorizationDataOutput( isSuperUser = userAuthorization.isSuperUser, ) - } } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/VesselAndPositionsDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/VesselAndPositionsDataOutput.kt index 0715cd14ed..fe4fbbbf7d 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/VesselAndPositionsDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/VesselAndPositionsDataOutput.kt @@ -7,8 +7,8 @@ data class VesselAndPositionsDataOutput( val vessel: VesselDataOutput?, ) { companion object { - fun fromVesselInformation(vesselInformation: VesselInformation): VesselAndPositionsDataOutput { - return VesselAndPositionsDataOutput( + fun fromVesselInformation(vesselInformation: VesselInformation): VesselAndPositionsDataOutput = + VesselAndPositionsDataOutput( vessel = VesselDataOutput.fromVesselAndRelatedDatas( vessel = vesselInformation.vessel, @@ -21,6 +21,5 @@ data class VesselAndPositionsDataOutput( PositionDataOutput.fromPosition(it) }, ) - } } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/VesselBeaconMalfunctionResumeDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/VesselBeaconMalfunctionResumeDataOutput.kt index 3e44fc87e4..f07b4ca1ef 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/VesselBeaconMalfunctionResumeDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/VesselBeaconMalfunctionResumeDataOutput.kt @@ -13,13 +13,12 @@ data class VesselBeaconMalfunctionResumeDataOutput( companion object { fun fromVesselBeaconMalfunctionResume( vesselBeaconMalfunctionsResume: VesselBeaconMalfunctionsResume, - ): VesselBeaconMalfunctionResumeDataOutput { - return VesselBeaconMalfunctionResumeDataOutput( + ): VesselBeaconMalfunctionResumeDataOutput = + VesselBeaconMalfunctionResumeDataOutput( numberOfBeaconsAtSea = vesselBeaconMalfunctionsResume.numberOfBeaconsAtSea, numberOfBeaconsAtPort = vesselBeaconMalfunctionsResume.numberOfBeaconsAtPort, lastBeaconMalfunctionDateTime = vesselBeaconMalfunctionsResume.lastBeaconMalfunctionDateTime, lastBeaconMalfunctionVesselStatus = vesselBeaconMalfunctionsResume.lastBeaconMalfunctionVesselStatus, ) - } } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/VesselDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/VesselDataOutput.kt index 8598401846..74429aa0dd 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/VesselDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/VesselDataOutput.kt @@ -105,8 +105,8 @@ data class VesselDataOutput( ) } - fun fromVessel(vessel: Vessel): VesselDataOutput { - return VesselDataOutput( + fun fromVessel(vessel: Vessel): VesselDataOutput = + VesselDataOutput( vesselId = vessel.id, internalReferenceNumber = vessel.internalReferenceNumber, IMO = vessel.imo, @@ -141,6 +141,5 @@ data class VesselDataOutput( hasLogbookEsacapt = vessel.hasLogbookEsacapt, hasVisioCaptures = vessel.hasVisioCaptures, ) - } } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/VesselIdentityDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/VesselIdentityDataOutput.kt index 33ee935e15..58c2156ae8 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/VesselIdentityDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/VesselIdentityDataOutput.kt @@ -18,8 +18,8 @@ data class VesselIdentityDataOutput( val vesselName: String? = null, ) { companion object { - fun fromVessel(vessel: Vessel): VesselIdentityDataOutput { - return VesselIdentityDataOutput( + fun fromVessel(vessel: Vessel): VesselIdentityDataOutput = + VesselIdentityDataOutput( districtCode = vessel.districtCode, externalReferenceNumber = vessel.externalReferenceNumber, flagState = vessel.flagState, @@ -31,10 +31,9 @@ data class VesselIdentityDataOutput( vesselLength = vessel.length, vesselName = vessel.vesselName, ) - } - fun fromVesselAndBeacon(vesselAndBeacon: VesselAndBeacon): VesselIdentityDataOutput { - return VesselIdentityDataOutput( + fun fromVesselAndBeacon(vesselAndBeacon: VesselAndBeacon): VesselIdentityDataOutput = + VesselIdentityDataOutput( beaconNumber = vesselAndBeacon.beacon?.beaconNumber, districtCode = vesselAndBeacon.vessel.districtCode, externalReferenceNumber = vesselAndBeacon.vessel.externalReferenceNumber, @@ -47,6 +46,5 @@ data class VesselIdentityDataOutput( vesselLength = vesselAndBeacon.vessel.length, vesselName = vesselAndBeacon.vessel.vesselName, ) - } } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/VoyageDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/VoyageDataOutput.kt index 6d5b16ae77..e71f46af4d 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/VoyageDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/VoyageDataOutput.kt @@ -12,8 +12,8 @@ data class VoyageDataOutput( val logbookMessagesAndAlerts: LogbookMessagesAndAlertsDataOutput, ) { companion object { - fun fromVoyage(voyage: Voyage): VoyageDataOutput { - return VoyageDataOutput( + fun fromVoyage(voyage: Voyage): VoyageDataOutput = + VoyageDataOutput( isLastVoyage = voyage.isLastVoyage, isFirstVoyage = voyage.isFirstVoyage, startDate = voyage.startDate, @@ -23,6 +23,5 @@ data class VoyageDataOutput( LogbookMessagesAndAlertsDataOutput .fromLogbookMessagesAndAlerts(voyage.logbookMessagesAndAlerts), ) - } } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/proxy/KeycloakProxyController.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/proxy/KeycloakProxyController.kt index d4bface2a8..26fecbc683 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/proxy/KeycloakProxyController.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/proxy/KeycloakProxyController.kt @@ -92,15 +92,17 @@ class KeycloakProxyController( // @see spring.cloud.gateway.mvc.form-filter.enabled=false val formData = StringBuilder() if (params.isNotEmpty()) { - params.entries.joinToString("&") { (key, values) -> - "$key=${values.joinToString(",")}" - }.let { formData.append(it) } + params.entries + .joinToString("&") { (key, values) -> + "$key=${values.joinToString(",")}" + }.let { formData.append(it) } } val formDataBytes = formData.toString().toByteArray(StandardCharsets.UTF_8) // Ensure the content length matches the size of the byte array - proxy.header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED_VALUE) + proxy + .header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED_VALUE) .header("Content-Length", formDataBytes.size.toString()) return proxy.uri(targetUri.toString()).body(formDataBytes).post() } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/proxy/ScriptProxyController.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/proxy/ScriptProxyController.kt index b8a70f43f6..bf9f41f4f8 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/proxy/ScriptProxyController.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/proxy/ScriptProxyController.kt @@ -18,7 +18,8 @@ class ScriptProxyController( val scriptResponse = restTemplate.getForEntity(smallChatUrl, String::class.java) - return ResponseEntity.ok() + return ResponseEntity + .ok() .header(HttpHeaders.CONTENT_TYPE, "application/javascript") .body(scriptResponse.body) } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/HealthcheckController.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/HealthcheckController.kt index 0cfc8eb114..4ec47ccba7 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/HealthcheckController.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/HealthcheckController.kt @@ -16,7 +16,5 @@ class HealthcheckController( ) { @GetMapping("") @Operation(summary = "Get healthcheck of positions and logbook") - fun getHealthcheck(): HealthDataOutput { - return HealthDataOutput.fromHealth(getHealthcheck.execute()) - } + fun getHealthcheck(): HealthDataOutput = HealthDataOutput.fromHealth(getHealthcheck.execute()) } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/InfractionController.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/InfractionController.kt index 7954b4214a..3869e89d8d 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/InfractionController.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/InfractionController.kt @@ -11,12 +11,13 @@ import org.springframework.web.bind.annotation.RestController @RestController @RequestMapping("/api/v1/infractions") @Tag(name = "APIs for Infractions") -class InfractionController(private val getAllInfractions: GetAllInfractions) { +class InfractionController( + private val getAllInfractions: GetAllInfractions, +) { @GetMapping("") @Operation(summary = "Get all infractions") - fun getAllInfractionsController(): List { - return getAllInfractions.execute().map { infraction -> + fun getAllInfractionsController(): List = + getAllInfractions.execute().map { infraction -> InfractionDataOutput.fromInfraction(infraction) } - } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/PublicBeaconMalfunctionController.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/PublicBeaconMalfunctionController.kt index 9e9de6a4c2..24e56e23a3 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/PublicBeaconMalfunctionController.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/PublicBeaconMalfunctionController.kt @@ -25,16 +25,16 @@ class PublicBeaconMalfunctionController( beaconMalfunctionId: Int, @RequestBody updateBeaconMalfunctionData: UpdateBeaconMalfunctionDataInput, - ): BeaconMalfunctionResumeAndDetailsDataOutput { - return updateBeaconMalfunction.execute( - id = beaconMalfunctionId, - vesselStatus = updateBeaconMalfunctionData.vesselStatus, - stage = updateBeaconMalfunctionData.stage, - endOfBeaconMalfunctionReason = updateBeaconMalfunctionData.endOfBeaconMalfunctionReason, - ).let { - BeaconMalfunctionResumeAndDetailsDataOutput.fromBeaconMalfunctionResumeAndDetails(it) - } - } + ): BeaconMalfunctionResumeAndDetailsDataOutput = + updateBeaconMalfunction + .execute( + id = beaconMalfunctionId, + vesselStatus = updateBeaconMalfunctionData.vesselStatus, + stage = updateBeaconMalfunctionData.stage, + endOfBeaconMalfunctionReason = updateBeaconMalfunctionData.endOfBeaconMalfunctionReason, + ).let { + BeaconMalfunctionResumeAndDetailsDataOutput.fromBeaconMalfunctionResumeAndDetails(it) + } @PutMapping(value = ["/{beaconMalfunctionId}/{notificationRequested}"]) @Operation(summary = "Request a notification") @@ -48,11 +48,9 @@ class PublicBeaconMalfunctionController( @Parameter(name = "ISO3 country code of the FMC to notify") @RequestParam(name = "requestedNotificationForeignFmcCode") requestedNotificationForeignFmcCode: String? = null, - ) { - return requestNotification.execute( - id = beaconMalfunctionId, - notificationRequested = notificationRequested, - requestedNotificationForeignFmcCode = requestedNotificationForeignFmcCode, - ) - } + ) = requestNotification.execute( + id = beaconMalfunctionId, + notificationRequested = notificationRequested, + requestedNotificationForeignFmcCode = requestedNotificationForeignFmcCode, + ) } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/PublicMissionActionsController.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/PublicMissionActionsController.kt index 8b0608559a..135b6bb92f 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/PublicMissionActionsController.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/PublicMissionActionsController.kt @@ -24,9 +24,10 @@ class PublicMissionActionsController( @Parameter(description = "Mission id") @RequestParam(name = "missionId") missionId: Int, - ): List { - return getMissionActions.execute(missionId).map { MissionActionDataOutput.fromMissionAction(it) } - } + ): List = + getMissionActions.execute(missionId).map { + MissionActionDataOutput.fromMissionAction(it) + } @PatchMapping(value = ["/{actionId}"], consumes = ["application/json"]) @Operation(summary = "Update a mission action") diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/PublicOperationalAlertController.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/PublicOperationalAlertController.kt index 99e4e07dc4..fcabbef4ad 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/PublicOperationalAlertController.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/PublicOperationalAlertController.kt @@ -21,7 +21,5 @@ class PublicOperationalAlertController( @PathParam("Alert id") @PathVariable(name = "id") id: Int, - ) { - return validatePendingAlert.execute(id) - } + ) = validatePendingAlert.execute(id) } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/PublicPortController.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/PublicPortController.kt index 083f0e4f89..dff0da1679 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/PublicPortController.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/PublicPortController.kt @@ -1,5 +1,7 @@ package fr.gouv.cnsp.monitorfish.infrastructure.api.public_api +import fr.gouv.cnsp.monitorfish.domain.use_cases.port.GetActivePorts +import fr.gouv.cnsp.monitorfish.infrastructure.api.outputs.PortDataOutput import io.swagger.v3.oas.annotations.Operation import io.swagger.v3.oas.annotations.tags.Tag import org.springframework.cache.CacheManager @@ -7,8 +9,6 @@ import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.PutMapping import org.springframework.web.bind.annotation.RequestMapping import org.springframework.web.bind.annotation.RestController -import fr.gouv.cnsp.monitorfish.domain.use_cases.port.GetActivePorts -import fr.gouv.cnsp.monitorfish.infrastructure.api.outputs.PortDataOutput @RestController @RequestMapping("/api/v1/ports") @@ -19,11 +19,10 @@ class PublicPortController( ) { @GetMapping("") @Operation(summary = "Get all active ports") - fun getActivePorts(): List { - return getActivePorts.execute().map { port -> + fun getActivePorts(): List = + getActivePorts.execute().map { port -> PortDataOutput.fromPort(port) } - } @PutMapping(value = ["/invalidate"]) @Operation(summary = "Invalidate ports cache") diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/SentryController.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/SentryController.kt index 9926bbfb55..8208b909ef 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/SentryController.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/SentryController.kt @@ -8,7 +8,9 @@ import org.springframework.web.bind.annotation.RestController @RestController @RequestMapping("/api/v1/test") -class SentryController(val sentryConfig: SentryConfig) { +class SentryController( + val sentryConfig: SentryConfig, +) { private val logger = LoggerFactory.getLogger(SentryController::class.java) // This route is for testing purpose only diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/UserManagementController.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/UserManagementController.kt index dabfd2c677..4a235b0565 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/UserManagementController.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/UserManagementController.kt @@ -22,9 +22,7 @@ class UserManagementController( fun saveUser( @RequestBody user: AddUserDataInput, - ) { - return saveUser.execute(user.email, user.isSuperUser) - } + ) = saveUser.execute(user.email, user.isSuperUser) @DeleteMapping(value = ["/{email}"]) @Operation(summary = "Delete a given user") @@ -32,7 +30,5 @@ class UserManagementController( @PathParam("User email") @PathVariable(name = "email") email: String, - ) { - return deleteUser.execute(email) - } + ) = deleteUser.execute(email) } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/VersionController.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/VersionController.kt index 92fe3f5283..c85cdb392d 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/VersionController.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/VersionController.kt @@ -5,12 +5,13 @@ import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.RestController @RestController -class VersionController(val buildProperties: BuildProperties) { +class VersionController( + val buildProperties: BuildProperties, +) { @GetMapping("/version") - fun version(): Map { - return mapOf( + fun version(): Map = + mapOf( "version" to buildProperties.version, "commit" to buildProperties.get("commit.hash"), ) - } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/VesselController.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/VesselController.kt index fd74d49a3d..e3fbd7a3b4 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/VesselController.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/VesselController.kt @@ -16,7 +16,6 @@ import org.springframework.web.bind.annotation.RestController class PublicVesselController( private val searchVessels: SearchVessels, ) { - @GetMapping("/search") @Operation(summary = "Search vessels") fun searchVessel( @@ -27,9 +26,8 @@ class PublicVesselController( ) @RequestParam(name = "searched") searched: String, - ): List { - return searchVessels.execute(searched).map { + ): List = + searchVessels.execute(searched).map { VesselIdentityDataOutput.fromVesselAndBeacon(it) } - } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/input/PatchableMissionActionDataInput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/input/PatchableMissionActionDataInput.kt index d611b9a1c0..2f8ea7ea26 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/input/PatchableMissionActionDataInput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/input/PatchableMissionActionDataInput.kt @@ -9,11 +9,10 @@ data class PatchableMissionActionDataInput( val actionEndDatetimeUtc: Optional?, val observationsByUnit: Optional?, ) { - fun toPatchableMissionAction(): PatchableMissionAction { - return PatchableMissionAction( + fun toPatchableMissionAction(): PatchableMissionAction = + PatchableMissionAction( actionDatetimeUtc = actionDatetimeUtc, actionEndDatetimeUtc = actionEndDatetimeUtc, observationsByUnit = observationsByUnit, ) - } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/security/LoggedMessage.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/security/LoggedMessage.kt index 2122408c29..6113f007a2 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/security/LoggedMessage.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/security/LoggedMessage.kt @@ -1,11 +1,14 @@ package fr.gouv.cnsp.monitorfish.infrastructure.api.security -class LoggedMessage(private val message: String, private val email: String, val url: String) { - override fun toString(): String { - return "{" + +class LoggedMessage( + private val message: String, + private val email: String, + val url: String, +) { + override fun toString(): String = + "{" + "\"message\": \"" + message + "\", " + "\"email\": \"" + email + "\", " + "\"URL\": \"" + url + "\"" + '}' - } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/cache/CaffeineConfiguration.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/cache/CaffeineConfiguration.kt index e5c4068998..1c05283e24 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/cache/CaffeineConfiguration.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/cache/CaffeineConfiguration.kt @@ -237,45 +237,41 @@ class CaffeineConfiguration { name: String, ticker: Ticker, minutesToExpire: Int, - ): CaffeineCache { - return CaffeineCache( + ): CaffeineCache = + CaffeineCache( name, - Caffeine.newBuilder() + Caffeine + .newBuilder() .expireAfterWrite(minutesToExpire.toLong(), TimeUnit.MINUTES) .recordStats() .ticker(ticker) .build(), ) - } - private fun buildPermanentCache( - name: String, - ): CaffeineCache { - return CaffeineCache( + private fun buildPermanentCache(name: String): CaffeineCache = + CaffeineCache( name, - Caffeine.newBuilder() + Caffeine + .newBuilder() .recordStats() .build(), ) - } private fun buildSecondsCache( name: String, ticker: Ticker, secondsToExpire: Int, - ): CaffeineCache { - return CaffeineCache( + ): CaffeineCache = + CaffeineCache( name, - Caffeine.newBuilder() + Caffeine + .newBuilder() .expireAfterWrite(secondsToExpire.toLong(), TimeUnit.SECONDS) .recordStats() .ticker(ticker) .build(), ) - } @Bean - fun ticker(): Ticker? { - return Ticker.systemTicker() - } + fun ticker(): Ticker? = Ticker.systemTicker() } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/ControlObjectivesEntity.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/ControlObjectivesEntity.kt index 9fd734c34e..6e37c8145d 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/ControlObjectivesEntity.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/ControlObjectivesEntity.kt @@ -37,8 +37,8 @@ data class ControlObjectivesEntity( ) companion object { - fun fromControlObjective(controlObjective: ControlObjective): ControlObjectivesEntity { - return ControlObjectivesEntity( + fun fromControlObjective(controlObjective: ControlObjective): ControlObjectivesEntity = + ControlObjectivesEntity( facade = Seafront.from(controlObjective.facade).toString(), segment = controlObjective.segment, year = controlObjective.year, @@ -46,6 +46,5 @@ data class ControlObjectivesEntity( targetNumberOfControlsAtPort = controlObjective.targetNumberOfControlsAtPort, controlPriorityLevel = controlObjective.controlPriorityLevel, ) - } } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PendingAlertEntity.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PendingAlertEntity.kt index ee6bac5412..361a1b3427 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PendingAlertEntity.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PendingAlertEntity.kt @@ -50,8 +50,8 @@ data class PendingAlertEntity( @Column(name = "longitude") val longitude: Double? = null, ) { - fun toPendingAlert(mapper: ObjectMapper): PendingAlert { - return PendingAlert( + fun toPendingAlert(mapper: ObjectMapper): PendingAlert = + PendingAlert( id = id, vesselName = vesselName, internalReferenceNumber = internalReferenceNumber, @@ -66,7 +66,6 @@ data class PendingAlertEntity( latitude = latitude, longitude = longitude, ) - } companion object { fun fromPendingAlert( diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoAndLanAlertEntity.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoAndLanAlertEntity.kt index f8366631c0..25656ecec2 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoAndLanAlertEntity.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoAndLanAlertEntity.kt @@ -29,8 +29,8 @@ data class PnoAndLanAlertEntity( @Column(name = "value", nullable = false, columnDefinition = "jsonb") val value: String, ) { - fun toAlert(mapper: ObjectMapper): PNOAndLANAlert { - return PNOAndLANAlert( + fun toAlert(mapper: ObjectMapper): PNOAndLANAlert = + PNOAndLANAlert( id = id, internalReferenceNumber = internalReferenceNumber, externalReferenceNumber = externalReferenceNumber, @@ -39,7 +39,6 @@ data class PnoAndLanAlertEntity( tripNumber = tripNumber, value = mapper.readValue(value, AlertType::class.java), ) - } companion object { fun fromAlert( diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoFleetSegmentSubscriptionEntity.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoFleetSegmentSubscriptionEntity.kt index fbc59dc199..7b65fb6ddd 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoFleetSegmentSubscriptionEntity.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoFleetSegmentSubscriptionEntity.kt @@ -17,25 +17,23 @@ data class PnoFleetSegmentSubscriptionEntity( @EmbeddedId val id: PnoFleetSegmentSubscriptionId, ) { - fun toPriorNotificationFleetSegmentSubscription(): PriorNotificationFleetSegmentSubscription { - return PriorNotificationFleetSegmentSubscription( + fun toPriorNotificationFleetSegmentSubscription(): PriorNotificationFleetSegmentSubscription = + PriorNotificationFleetSegmentSubscription( controlUnitId = id.controlUnitId, segmentCode = id.segmentCode, segmentName = null, ) - } companion object { fun fromPriorNotificationFleetSegmentSubscription( priorNotificationFleetSegmentSubscription: PriorNotificationFleetSegmentSubscription, - ): PnoFleetSegmentSubscriptionEntity { - return PnoFleetSegmentSubscriptionEntity( + ): PnoFleetSegmentSubscriptionEntity = + PnoFleetSegmentSubscriptionEntity( id = PnoFleetSegmentSubscriptionId( controlUnitId = priorNotificationFleetSegmentSubscription.controlUnitId, segmentCode = priorNotificationFleetSegmentSubscription.segmentCode, ), ) - } } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoPortSubscriptionEntity.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoPortSubscriptionEntity.kt index c26c940195..fe4c093e30 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoPortSubscriptionEntity.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoPortSubscriptionEntity.kt @@ -5,7 +5,10 @@ import jakarta.persistence.* import java.io.Serializable @Embeddable -class PnoPortSubscriptionId(val controlUnitId: Int, val portLocode: String) : Serializable +class PnoPortSubscriptionId( + val controlUnitId: Int, + val portLocode: String, +) : Serializable @Entity @Table(name = "pno_ports_subscriptions") @@ -15,20 +18,19 @@ data class PnoPortSubscriptionEntity( @Column(name = "receive_all_pnos", updatable = false) val receiveAllPnos: Boolean, ) { - fun toPriorNotificationPortSubscription(): PriorNotificationPortSubscription { - return PriorNotificationPortSubscription( + fun toPriorNotificationPortSubscription(): PriorNotificationPortSubscription = + PriorNotificationPortSubscription( controlUnitId = id.controlUnitId, portLocode = id.portLocode, portName = null, hasSubscribedToAllPriorNotifications = receiveAllPnos, ) - } companion object { fun fromPriorNotificationPortSubscription( priorNotificationPortSubscription: PriorNotificationPortSubscription, - ): PnoPortSubscriptionEntity { - return PnoPortSubscriptionEntity( + ): PnoPortSubscriptionEntity = + PnoPortSubscriptionEntity( id = PnoPortSubscriptionId( controlUnitId = priorNotificationPortSubscription.controlUnitId, @@ -36,6 +38,5 @@ data class PnoPortSubscriptionEntity( ), receiveAllPnos = priorNotificationPortSubscription.hasSubscribedToAllPriorNotifications, ) - } } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoVesselSubscriptionEntity.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoVesselSubscriptionEntity.kt index 09d64783e4..3c8225dadb 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoVesselSubscriptionEntity.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoVesselSubscriptionEntity.kt @@ -8,7 +8,10 @@ import jakarta.persistence.Table import java.io.Serializable @Embeddable -class PnoVesselSubscriptionId(val controlUnitId: Int, val vesselId: Int) : Serializable +class PnoVesselSubscriptionId( + val controlUnitId: Int, + val vesselId: Int, +) : Serializable @Entity @Table(name = "pno_vessels_subscriptions") @@ -16,8 +19,8 @@ data class PnoVesselSubscriptionEntity( @EmbeddedId val id: PnoVesselSubscriptionId, ) { - fun toPriorNotificationVesselSubscription(): PriorNotificationVesselSubscription { - return PriorNotificationVesselSubscription( + fun toPriorNotificationVesselSubscription(): PriorNotificationVesselSubscription = + PriorNotificationVesselSubscription( controlUnitId = id.controlUnitId, vesselId = id.vesselId, vesselCallSign = null, @@ -26,19 +29,17 @@ data class PnoVesselSubscriptionEntity( vesselMmsi = null, vesselName = null, ) - } companion object { fun fromPriorNotificationVesselSubscription( priorNotificationVesselSubscription: PriorNotificationVesselSubscription, - ): PnoVesselSubscriptionEntity { - return PnoVesselSubscriptionEntity( + ): PnoVesselSubscriptionEntity = + PnoVesselSubscriptionEntity( id = PnoVesselSubscriptionId( controlUnitId = priorNotificationVesselSubscription.controlUnitId, vesselId = priorNotificationVesselSubscription.vesselId, ), ) - } } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PositionEntity.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PositionEntity.kt index b9c481164c..ff66e8bb4c 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PositionEntity.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PositionEntity.kt @@ -87,8 +87,8 @@ data class PositionEntity( ) companion object { - fun fromPosition(position: Position): PositionEntity { - return PositionEntity( + fun fromPosition(position: Position): PositionEntity = + PositionEntity( internalReferenceNumber = position.internalReferenceNumber, ircs = position.ircs, mmsi = position.mmsi, @@ -108,6 +108,5 @@ data class PositionEntity( isFishing = position.isFishing, networkType = position.networkType, ) - } } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PriorNotificationSentMessageEntity.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PriorNotificationSentMessageEntity.kt index 6a77741941..8b88a1ecd0 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PriorNotificationSentMessageEntity.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PriorNotificationSentMessageEntity.kt @@ -32,8 +32,8 @@ data class PriorNotificationSentMessageEntity( @Column(name = "success", nullable = false) val success: Boolean, ) { - fun toPriorNotificationSentMessage(): PriorNotificationSentMessage { - return PriorNotificationSentMessage( + fun toPriorNotificationSentMessage(): PriorNotificationSentMessage = + PriorNotificationSentMessage( id = id, communicationMeans = communicationMeans, dateTimeUtc = dateTimeUtc, @@ -45,5 +45,4 @@ data class PriorNotificationSentMessageEntity( recipientOrganization = recipientOrganization, success = success, ) - } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PriorNotificationUploadEntity.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PriorNotificationUploadEntity.kt index ed40090c50..ab8ce49d89 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PriorNotificationUploadEntity.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PriorNotificationUploadEntity.kt @@ -30,8 +30,8 @@ data class PriorNotificationUploadEntity( @Column(name = "updated_at", nullable = false) val updatedAt: ZonedDateTime, ) { - fun toDocument(): PriorNotificationDocument { - return PriorNotificationDocument( + fun toDocument(): PriorNotificationDocument = + PriorNotificationDocument( id = id!!, content = content, createdAt = CustomZonedDateTime.fromZonedDateTime(createdAt), @@ -41,7 +41,6 @@ data class PriorNotificationUploadEntity( reportId = reportId, updatedAt = CustomZonedDateTime.fromZonedDateTime(updatedAt), ) - } override fun equals(other: Any?): Boolean { if (this === other) return true @@ -74,8 +73,8 @@ data class PriorNotificationUploadEntity( } companion object { - fun fromDocument(priorNotificationDocument: PriorNotificationDocument): PriorNotificationUploadEntity { - return PriorNotificationUploadEntity( + fun fromDocument(priorNotificationDocument: PriorNotificationDocument): PriorNotificationUploadEntity = + PriorNotificationUploadEntity( id = priorNotificationDocument.id, content = priorNotificationDocument.content, createdAt = priorNotificationDocument.createdAt.toZonedDateTime(), @@ -85,6 +84,5 @@ data class PriorNotificationUploadEntity( reportId = priorNotificationDocument.reportId, updatedAt = priorNotificationDocument.updatedAt.toZonedDateTime(), ) - } } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/ProducerOrganizationMembershipEntity.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/ProducerOrganizationMembershipEntity.kt index 409e066e56..e6ee1b9dfe 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/ProducerOrganizationMembershipEntity.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/ProducerOrganizationMembershipEntity.kt @@ -17,13 +17,12 @@ data class ProducerOrganizationMembershipEntity( @Column(name = "organization_name", nullable = false) val organizationName: String, ) { - fun toProducerOrganizationMembership(): ProducerOrganizationMembership { - return ProducerOrganizationMembership( + fun toProducerOrganizationMembership(): ProducerOrganizationMembership = + ProducerOrganizationMembership( internalReferenceNumber = internalReferenceNumber, joiningDate = joiningDate, organizationName = organizationName, ) - } companion object { fun fromProducerOrganizationMembership(producerOrganizationMembership: ProducerOrganizationMembership) = diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/ReportingEntity.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/ReportingEntity.kt index d9fa1ee7d6..6fed68f9fb 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/ReportingEntity.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/ReportingEntity.kt @@ -62,8 +62,8 @@ data class ReportingEntity( @Column(name = "longitude") val longitude: Double? = null, ) { - fun toReporting(mapper: ObjectMapper): Reporting { - return Reporting( + fun toReporting(mapper: ObjectMapper): Reporting = + Reporting( id = id, vesselId = vesselId, type = type, @@ -82,7 +82,6 @@ data class ReportingEntity( latitude = latitude, longitude = longitude, ) - } companion object { fun fromPendingAlert( diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/SilencedAlertEntity.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/SilencedAlertEntity.kt index bcc56bca90..a69daab669 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/SilencedAlertEntity.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/SilencedAlertEntity.kt @@ -47,8 +47,8 @@ data class SilencedAlertEntity( @Column(name = "was_validated") val wasValidated: Boolean? = null, ) { - fun toSilencedAlert(mapper: ObjectMapper): SilencedAlert { - return SilencedAlert( + fun toSilencedAlert(mapper: ObjectMapper): SilencedAlert = + SilencedAlert( id = id, vesselName = vesselName, internalReferenceNumber = internalReferenceNumber, @@ -61,7 +61,6 @@ data class SilencedAlertEntity( vesselId = vesselId, wasValidated = wasValidated, ) - } companion object { fun fromPendingAlert( diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/converters/CountryCodeConverter.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/converters/CountryCodeConverter.kt index 2837229e71..355ad387c2 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/converters/CountryCodeConverter.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/converters/CountryCodeConverter.kt @@ -6,9 +6,7 @@ import jakarta.persistence.Converter @Converter(autoApply = true) class CountryCodeConverter : AttributeConverter { - override fun convertToDatabaseColumn(attribute: CountryCode?): String? { - return attribute?.name - } + override fun convertToDatabaseColumn(attribute: CountryCode?): String? = attribute?.name override fun convertToEntityAttribute(dbData: String?): CountryCode? { if (dbData == null) { diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/converters/CustomZonedDateTimeConverter.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/converters/CustomZonedDateTimeConverter.kt index cf9c22fed3..be0e018698 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/converters/CustomZonedDateTimeConverter.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/converters/CustomZonedDateTimeConverter.kt @@ -8,11 +8,11 @@ import java.time.ZoneOffset @Converter(autoApply = true) class CustomZonedDateTimeConverter : AttributeConverter { - override fun convertToDatabaseColumn(attribute: CustomZonedDateTime?): Timestamp? { - return attribute?.toZonedDateTime()?.let { Timestamp.valueOf(it.toLocalDateTime()) } - } + override fun convertToDatabaseColumn(attribute: CustomZonedDateTime?): Timestamp? = + attribute?.toZonedDateTime()?.let { Timestamp.valueOf(it.toLocalDateTime()) } - override fun convertToEntityAttribute(dbData: Timestamp?): CustomZonedDateTime? { - return dbData?.toLocalDateTime()?.atZone(ZoneOffset.UTC)?.let { CustomZonedDateTime.fromZonedDateTime(it) } - } + override fun convertToEntityAttribute(dbData: Timestamp?): CustomZonedDateTime? = + dbData?.toLocalDateTime()?.atZone(ZoneOffset.UTC)?.let { + CustomZonedDateTime.fromZonedDateTime(it) + } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaBeaconMalfunctionActionsRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaBeaconMalfunctionActionsRepository.kt index e3f7772c0d..f5de8e0440 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaBeaconMalfunctionActionsRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaBeaconMalfunctionActionsRepository.kt @@ -11,12 +11,12 @@ import org.springframework.transaction.annotation.Transactional class JpaBeaconMalfunctionActionsRepository( private val dbBeaconMalfunctionActionsRepository: DBBeaconMalfunctionActionsRepository, ) : BeaconMalfunctionActionsRepository { - override fun findAllByBeaconMalfunctionId(beaconMalfunctionId: Int): List { - return dbBeaconMalfunctionActionsRepository.findAllByBeaconMalfunctionId(beaconMalfunctionId) + override fun findAllByBeaconMalfunctionId(beaconMalfunctionId: Int): List = + dbBeaconMalfunctionActionsRepository + .findAllByBeaconMalfunctionId(beaconMalfunctionId) .map { it.toBeaconMalfunctionAction() } - } @Transactional override fun save(beaconMalfunctionAction: BeaconMalfunctionAction) { diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaBeaconMalfunctionCommentsRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaBeaconMalfunctionCommentsRepository.kt index 734758b1ae..5fa2ffdf02 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaBeaconMalfunctionCommentsRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaBeaconMalfunctionCommentsRepository.kt @@ -11,12 +11,12 @@ import org.springframework.transaction.annotation.Transactional class JpaBeaconMalfunctionCommentsRepository( private val dbBeaconMalfunctionCommentsRepository: DBBeaconMalfunctionCommentsRepository, ) : BeaconMalfunctionCommentsRepository { - override fun findAllByBeaconMalfunctionId(beaconMalfunctionId: Int): List { - return dbBeaconMalfunctionCommentsRepository.findAllByBeaconMalfunctionId(beaconMalfunctionId) + override fun findAllByBeaconMalfunctionId(beaconMalfunctionId: Int): List = + dbBeaconMalfunctionCommentsRepository + .findAllByBeaconMalfunctionId(beaconMalfunctionId) .map { it.toBeaconMalfunctionComment() } - } @Transactional override fun save(beaconMalfunctionComment: BeaconMalfunctionComment) { diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaBeaconMalfunctionNotificationsRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaBeaconMalfunctionNotificationsRepository.kt index 068c963494..ba1e866b17 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaBeaconMalfunctionNotificationsRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaBeaconMalfunctionNotificationsRepository.kt @@ -9,10 +9,10 @@ import org.springframework.stereotype.Repository class JpaBeaconMalfunctionNotificationsRepository( private val dbBeaconMalfunctionNotificationsRepository: DBBeaconMalfunctionNotificationsRepository, ) : BeaconMalfunctionNotificationsRepository { - override fun findAllByBeaconMalfunctionId(beaconMalfunctionId: Int): List { - return dbBeaconMalfunctionNotificationsRepository.findAllByBeaconMalfunctionId(beaconMalfunctionId) + override fun findAllByBeaconMalfunctionId(beaconMalfunctionId: Int): List = + dbBeaconMalfunctionNotificationsRepository + .findAllByBeaconMalfunctionId(beaconMalfunctionId) .map { it.toBeaconMalfunctionNotification() } - } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaBeaconMalfunctionsRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaBeaconMalfunctionsRepository.kt index a6ec967f84..8e1eea2c2b 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaBeaconMalfunctionsRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaBeaconMalfunctionsRepository.kt @@ -12,21 +12,23 @@ import java.time.ZonedDateTime class JpaBeaconMalfunctionsRepository( private val dbBeaconMalfunctionsRepository: DBBeaconMalfunctionsRepository, ) : BeaconMalfunctionsRepository { - override fun findAll(): List { - return dbBeaconMalfunctionsRepository.findAll().map { it.toBeaconMalfunction() } - } + override fun findAll(): List = + dbBeaconMalfunctionsRepository.findAll().map { + it.toBeaconMalfunction() + } - override fun findAllExceptArchived(): List { - return dbBeaconMalfunctionsRepository.findAllExceptArchived().map { it.toBeaconMalfunction() } - } + override fun findAllExceptArchived(): List = + dbBeaconMalfunctionsRepository.findAllExceptArchived().map { + it.toBeaconMalfunction() + } - override fun findLastSixtyArchived(): List { - return dbBeaconMalfunctionsRepository.findLastSixtyArchived().map { it.toBeaconMalfunction() } - } + override fun findLastSixtyArchived(): List = + dbBeaconMalfunctionsRepository.findLastSixtyArchived().map { + it.toBeaconMalfunction() + } - override fun find(beaconMalfunctionId: Int): BeaconMalfunction { - return dbBeaconMalfunctionsRepository.findById(beaconMalfunctionId).get().toBeaconMalfunction() - } + override fun find(beaconMalfunctionId: Int): BeaconMalfunction = + dbBeaconMalfunctionsRepository.findById(beaconMalfunctionId).get().toBeaconMalfunction() @Transactional override fun update( @@ -56,12 +58,12 @@ class JpaBeaconMalfunctionsRepository( override fun findAllByVesselId( vesselId: Int, afterDateTime: ZonedDateTime, - ): List { - return dbBeaconMalfunctionsRepository - .findAllByVesselIdEqualsAfterDateTime(vesselId, afterDateTime.toInstant()).map { + ): List = + dbBeaconMalfunctionsRepository + .findAllByVesselIdEqualsAfterDateTime(vesselId, afterDateTime.toInstant()) + .map { it.toBeaconMalfunction() } - } @Transactional override fun requestNotification( diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaBeaconRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaBeaconRepository.kt index e06ffa3c36..ce945bc315 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaBeaconRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaBeaconRepository.kt @@ -8,7 +8,9 @@ import org.springframework.dao.EmptyResultDataAccessException import org.springframework.stereotype.Repository @Repository -class JpaBeaconRepository(private val dbBeaconRepository: DBBeaconRepository) : BeaconRepository { +class JpaBeaconRepository( + private val dbBeaconRepository: DBBeaconRepository, +) : BeaconRepository { @Cacheable(value = ["search_beacons"]) override fun search(searched: String): List { if (searched.isEmpty()) { @@ -27,7 +29,5 @@ class JpaBeaconRepository(private val dbBeaconRepository: DBBeaconRepository) : } } - override fun findActivatedBeaconNumbers(): List { - return dbBeaconRepository.findActivatedBeaconNumbers() - } + override fun findActivatedBeaconNumbers(): List = dbBeaconRepository.findActivatedBeaconNumbers() } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaControlObjectivesRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaControlObjectivesRepository.kt index f9428a672f..7b040f33b6 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaControlObjectivesRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaControlObjectivesRepository.kt @@ -12,15 +12,12 @@ import org.springframework.transaction.annotation.Transactional class JpaControlObjectivesRepository( private val dbControlObjectivesRepository: DBControlObjectivesRepository, ) : ControlObjectivesRepository { - override fun findAllByYear(year: Int): List { - return dbControlObjectivesRepository.findAllByYearEquals(year).map { + override fun findAllByYear(year: Int): List = + dbControlObjectivesRepository.findAllByYearEquals(year).map { it.toControlObjective() } - } - override fun findYearEntries(): List { - return dbControlObjectivesRepository.findDistinctYears() - } + override fun findYearEntries(): List = dbControlObjectivesRepository.findDistinctYears() @Transactional override fun update( diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaDistrictRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaDistrictRepository.kt index 1a8c58ad6e..091cdf3fe0 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaDistrictRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaDistrictRepository.kt @@ -9,13 +9,14 @@ import org.springframework.dao.EmptyResultDataAccessException import org.springframework.stereotype.Repository @Repository -class JpaDistrictRepository(private val dbDistrictRepository: DBDistrictRepository) : DistrictRepository { +class JpaDistrictRepository( + private val dbDistrictRepository: DBDistrictRepository, +) : DistrictRepository { @Cacheable(value = ["district"]) - override fun find(districtCode: String): District { - return try { + override fun find(districtCode: String): District = + try { dbDistrictRepository.findByDistrictCodeEquals(districtCode).toDistrict() } catch (e: EmptyResultDataAccessException) { throw CodeNotFoundException("District: code $districtCode not found") } - } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaFacadeAreasRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaFacadeAreasRepository.kt index 5fb764e0c8..dc5e6d5ae8 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaFacadeAreasRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaFacadeAreasRepository.kt @@ -7,11 +7,12 @@ import org.locationtech.jts.geom.Point import org.springframework.stereotype.Repository @Repository -class JpaFacadeAreasRepository(private val dbFacadeAreasRepository: DBFacadeAreasRepository) : FacadeAreasRepository { +class JpaFacadeAreasRepository( + private val dbFacadeAreasRepository: DBFacadeAreasRepository, +) : FacadeAreasRepository { // TODO This could be cached via a `findAll()`. - override fun findByIncluding(point: Point): List { - return dbFacadeAreasRepository.findByIncluding(point).map { + override fun findByIncluding(point: Point): List = + dbFacadeAreasRepository.findByIncluding(point).map { it.toFacadeArea() } - } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaFaoAreaRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaFaoAreaRepository.kt index a920b7f0a4..797f47d00b 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaFaoAreaRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaFaoAreaRepository.kt @@ -8,24 +8,23 @@ import org.springframework.cache.annotation.Cacheable import org.springframework.stereotype.Repository @Repository -class JpaFaoAreaRepository(private val dbFAOAreaRepository: DBFaoAreaRepository) : FaoAreaRepository { +class JpaFaoAreaRepository( + private val dbFAOAreaRepository: DBFaoAreaRepository, +) : FaoAreaRepository { @Cacheable(value = ["fao_areas"]) - override fun findAll(): List { - return dbFAOAreaRepository.findAll().map { + override fun findAll(): List = + dbFAOAreaRepository.findAll().map { it.toFaoArea() } - } @Cacheable(value = ["fao_areas_sorted_by_usage"]) - override fun findAllSortedByUsage(): List { - return dbFAOAreaRepository.findAllSortedByUsage().map { + override fun findAllSortedByUsage(): List = + dbFAOAreaRepository.findAllSortedByUsage().map { it.toFaoArea() } - } - override fun findByIncluding(point: Point): List { - return dbFAOAreaRepository.findByIncluding(point).map { + override fun findByIncluding(point: Point): List = + dbFAOAreaRepository.findByIncluding(point).map { it.toFaoArea() } - } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaFleetSegmentRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaFleetSegmentRepository.kt index 4468c7b4c0..8f3b7bde47 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaFleetSegmentRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaFleetSegmentRepository.kt @@ -16,23 +16,20 @@ import org.springframework.stereotype.Repository class JpaFleetSegmentRepository( private val dbFleetSegmentRepository: DBFleetSegmentRepository, ) : FleetSegmentRepository { - override fun findAll(): List { - return dbFleetSegmentRepository.findAll().map { + override fun findAll(): List = + dbFleetSegmentRepository.findAll().map { it.toFleetSegment() } - } @Cacheable(value = ["segments_by_year"]) - override fun findAllByYear(year: Int): List { - return dbFleetSegmentRepository.findAllByYearEquals(year).map { + override fun findAllByYear(year: Int): List = + dbFleetSegmentRepository.findAllByYearEquals(year).map { it.toFleetSegment() } - } @Cacheable(value = ["segments_with_gears_mesh_condition"]) - override fun findAllSegmentsGearsWithRequiredMesh(year: Int): List { - return dbFleetSegmentRepository.findAllSegmentsGearsHavingMinOrMaxMesh(year) - } + override fun findAllSegmentsGearsWithRequiredMesh(year: Int): List = + dbFleetSegmentRepository.findAllSegmentsGearsHavingMinOrMaxMesh(year) @Transactional override fun update( @@ -107,7 +104,8 @@ class JpaFleetSegmentRepository( try { dbFleetSegmentRepository.deleteBySegmentAndYearEquals(segment, year) - return dbFleetSegmentRepository.findAllByYearEquals(year) + return dbFleetSegmentRepository + .findAllByYearEquals(year) .map { it.toFleetSegment() } } catch (e: Throwable) { throw CouldNotDeleteException("Could not delete fleet segment: ${e.message}") @@ -132,9 +130,7 @@ class JpaFleetSegmentRepository( return dbFleetSegmentRepository.findBySegmentAndYearEquals(segment.segment, segment.year).toFleetSegment() } - override fun findYearEntries(): List { - return dbFleetSegmentRepository.findDistinctYears() - } + override fun findYearEntries(): List = dbFleetSegmentRepository.findDistinctYears() @Transactional override fun addYear( diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaForeignFMCRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaForeignFMCRepository.kt index e72b3f37c1..ad1072efc7 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaForeignFMCRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaForeignFMCRepository.kt @@ -6,8 +6,8 @@ import fr.gouv.cnsp.monitorfish.infrastructure.database.repositories.interfaces. import org.springframework.stereotype.Repository @Repository -class JpaForeignFMCRepository(private val dbForeignFMCRepository: DBForeignFMCRepository) : ForeignFMCRepository { - override fun findAll(): List { - return dbForeignFMCRepository.findAll().map { it.toForeignFMC() } - } +class JpaForeignFMCRepository( + private val dbForeignFMCRepository: DBForeignFMCRepository, +) : ForeignFMCRepository { + override fun findAll(): List = dbForeignFMCRepository.findAll().map { it.toForeignFMC() } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaGearCodeGroupRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaGearCodeGroupRepository.kt index 30a36e00ea..6e4111b9c2 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaGearCodeGroupRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaGearCodeGroupRepository.kt @@ -13,18 +13,16 @@ class JpaGearCodeGroupRepository( private val dbGearCodeGroupRepository: DBGearCodeGroupRepository, ) : GearCodeGroupRepository { @Cacheable(value = ["gear_code_groups"]) - override fun findAll(): List { - return dbGearCodeGroupRepository.findAll().map { + override fun findAll(): List = + dbGearCodeGroupRepository.findAll().map { it.toGearCodeGroup() } - } @Cacheable(value = ["gear_code_group"]) - override fun find(code: String): GearCodeGroup { - return try { + override fun find(code: String): GearCodeGroup = + try { dbGearCodeGroupRepository.findByCodeEquals(code).toGearCodeGroup() } catch (e: EmptyResultDataAccessException) { throw CodeNotFoundException("GearCodeGroup: code $code not found") } - } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaGearRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaGearRepository.kt index 316c755ed7..646a4a4344 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaGearRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaGearRepository.kt @@ -9,20 +9,20 @@ import org.springframework.dao.EmptyResultDataAccessException import org.springframework.stereotype.Repository @Repository -class JpaGearRepository(private val dbGearRepository: DBGearRepository) : GearRepository { +class JpaGearRepository( + private val dbGearRepository: DBGearRepository, +) : GearRepository { @Cacheable(value = ["gears"]) - override fun findAll(): List { - return dbGearRepository.findAll().map { + override fun findAll(): List = + dbGearRepository.findAll().map { it.toGear() } - } @Cacheable(value = ["gear"]) - override fun findByCode(code: String): Gear { - return try { + override fun findByCode(code: String): Gear = + try { dbGearRepository.findByCodeEquals(code).toGear() } catch (e: EmptyResultDataAccessException) { throw CodeNotFoundException("Gear: code $code not found") } - } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaInfractionRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaInfractionRepository.kt index 345293a9b0..731b3e9e4c 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaInfractionRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaInfractionRepository.kt @@ -9,20 +9,20 @@ import org.springframework.dao.EmptyResultDataAccessException import org.springframework.stereotype.Repository @Repository -class JpaInfractionRepository(private val dbInfractionRepository: DBInfractionRepository) : InfractionRepository { +class JpaInfractionRepository( + private val dbInfractionRepository: DBInfractionRepository, +) : InfractionRepository { @Cacheable(value = ["infractions"]) - override fun findAll(): List { - return dbInfractionRepository.findAll().map { + override fun findAll(): List = + dbInfractionRepository.findAll().map { it.toInfraction() } - } @Cacheable(value = ["infraction"]) - override fun findInfractionByNatinfCode(natinfCode: Int): Infraction { - return try { + override fun findInfractionByNatinfCode(natinfCode: Int): Infraction = + try { dbInfractionRepository.findByNatinfCodeEquals(natinfCode).toInfraction() } catch (e: EmptyResultDataAccessException) { throw NatinfCodeNotFoundException("NATINF code $natinfCode not found") } - } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaLastPositionRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaLastPositionRepository.kt index 9ef52fd86b..15ec8e39f4 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaLastPositionRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaLastPositionRepository.kt @@ -19,19 +19,20 @@ class JpaLastPositionRepository( private val mapper: ObjectMapper, ) : LastPositionRepository { @Cacheable(value = ["vessels_all_position"]) - override fun findAll(): List { - return dbLastPositionRepository.findAll() + override fun findAll(): List = + dbLastPositionRepository + .findAll() // We NEED this non filterNotNull (even if the IDE say not so, as the SQL request may return null internalReferenceNumber) .filterNotNull() .map { it.toLastPosition(mapper) } - } @Cacheable(value = ["vessels_positions"]) override fun findAllInLastMonthOrWithBeaconMalfunction(): List { val nowMinusOneMonth = ZonedDateTime.now().minusMonths(1) - return dbLastPositionRepository.findAllByDateTimeGreaterThanEqualOrBeaconMalfunctionIdNotNull(nowMinusOneMonth) + return dbLastPositionRepository + .findAllByDateTimeGreaterThanEqualOrBeaconMalfunctionIdNotNull(nowMinusOneMonth) // We NEED this non filterNotNull (even if the IDE say not so, as the SQL request may return null internalReferenceNumber) .filterNotNull() .map { @@ -42,7 +43,8 @@ class JpaLastPositionRepository( @Cacheable(value = ["vessels_positions_with_beacon_malfunctions"]) override fun findAllWithBeaconMalfunctionBeforeLast48Hours(): List { val nowMinus48Hours = ZonedDateTime.now().minusHours(48) - return dbLastPositionRepository.findAllByDateTimeLessThanEqualAndBeaconMalfunctionIdNotNull(nowMinus48Hours) + return dbLastPositionRepository + .findAllByDateTimeLessThanEqualAndBeaconMalfunctionIdNotNull(nowMinus48Hours) // We NEED this non filterNotNull (even if the IDE say not so, as the SQL request may return null internalReferenceNumber) .filterNotNull() .map { @@ -50,14 +52,13 @@ class JpaLastPositionRepository( } } - override fun findLastPositionDate(): ZonedDateTime { - return try { + override fun findLastPositionDate(): ZonedDateTime = + try { dbLastPositionRepository.findLastPositionDateTime().atZone(UTC) } catch (e: EmptyResultDataAccessException) { // Date of birth of the CNSP ZonedDateTime.of(2012, 4, 17, 0, 0, 0, 1, UTC) } - } @Transactional override fun removeAlertToLastPositionByVesselIdentifierEquals( diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaLogbookRawMessageRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaLogbookRawMessageRepository.kt index 68dd73d815..554e8cc640 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaLogbookRawMessageRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaLogbookRawMessageRepository.kt @@ -14,14 +14,14 @@ class JpaLogbookRawMessageRepository( private val dbLogbookRawMessageRepository: DBLogbookRawMessageRepository, ) : LogbookRawMessageRepository { @Cacheable(value = ["logbook_raw_message"]) - override fun findRawMessage(operationNumber: String): String? { - return try { - dbLogbookRawMessageRepository.findByOperationNumberEquals(operationNumber) + override fun findRawMessage(operationNumber: String): String? = + try { + dbLogbookRawMessageRepository + .findByOperationNumberEquals(operationNumber) .rawMessage } catch (e: EmptyResultDataAccessException) { throw NoERSMessagesFound("Raw message of operation number $operationNumber not found") } - } // For test purpose override fun save(logbookRawMessage: LogbookRawMessage) { diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaLogbookReportRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaLogbookReportRepository.kt index 1a6d75f990..6f7f9efdc4 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaLogbookReportRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaLogbookReportRepository.kt @@ -118,7 +118,8 @@ class JpaLogbookReportRepository( ): PriorNotification? { val logbookReport = dbLogbookReportRepository - .findAcknowledgedNonDeletedPnoDatAndCorsByReportId(reportId, operationDate.toString()).firstOrNull() + .findAcknowledgedNonDeletedPnoDatAndCorsByReportId(reportId, operationDate.toString()) + .firstOrNull() return logbookReport?.let { val pno = PriorNotification.fromLogbookMessage(it.toLogbookMessage(objectMapper)) @@ -135,11 +136,12 @@ class JpaLogbookReportRepository( try { if (internalReferenceNumber.isNotEmpty()) { val lastTrip = - dbLogbookReportRepository.findTripsBeforeDatetime( - internalReferenceNumber, - beforeDateTime.toInstant(), - PageRequest.of(0, 1), - ).first() + dbLogbookReportRepository + .findTripsBeforeDatetime( + internalReferenceNumber, + beforeDateTime.toInstant(), + PageRequest.of(0, 1), + ).first() return VoyageDatesAndTripNumber( lastTrip.tripNumber, @@ -164,11 +166,13 @@ class JpaLogbookReportRepository( try { if (internalReferenceNumber.isNotEmpty()) { val previousTripNumber = - dbLogbookReportRepository.findPreviousTripNumber( - internalReferenceNumber, - tripNumber, - PageRequest.of(0, 1), - ).first().tripNumber + dbLogbookReportRepository + .findPreviousTripNumber( + internalReferenceNumber, + tripNumber, + PageRequest.of(0, 1), + ).first() + .tripNumber val previousTrip = dbLogbookReportRepository.findFirstAndLastOperationsDatesOfTrip( internalReferenceNumber, @@ -230,11 +234,13 @@ class JpaLogbookReportRepository( try { if (internalReferenceNumber.isNotEmpty()) { val nextTripNumber = - dbLogbookReportRepository.findNextTripNumber( - internalReferenceNumber, - tripNumber, - PageRequest.of(0, 1), - ).first().tripNumber + dbLogbookReportRepository + .findNextTripNumber( + internalReferenceNumber, + tripNumber, + PageRequest.of(0, 1), + ).first() + .tripNumber val nextTrip = dbLogbookReportRepository.findFirstAndLastOperationsDatesOfTrip( internalReferenceNumber, @@ -270,14 +276,15 @@ class JpaLogbookReportRepository( ): List { try { if (internalReferenceNumber.isNotEmpty()) { - return dbLogbookReportRepository.findAllMessagesByTripNumberBetweenDates( - internalReferenceNumber, - afterDate.toInstant().toString(), - beforeDate.toInstant().toString(), - tripNumber, - ).map { - it.toLogbookMessage(objectMapper) - } + return dbLogbookReportRepository + .findAllMessagesByTripNumberBetweenDates( + internalReferenceNumber, + afterDate.toInstant().toString(), + beforeDate.toInstant().toString(), + tripNumber, + ).map { + it.toLogbookMessage(objectMapper) + } } throw IllegalArgumentException("No CFR given to find the vessel.") @@ -289,13 +296,11 @@ class JpaLogbookReportRepository( } @Cacheable(value = ["logbook_pno_types"]) - override fun findDistinctPriorNotificationTypes(): List { - return dbLogbookReportRepository.findDistinctPriorNotificationType() ?: emptyList() - } + override fun findDistinctPriorNotificationTypes(): List = + dbLogbookReportRepository.findDistinctPriorNotificationType() ?: emptyList() - override fun findById(id: Long): LogbookMessage { - return dbLogbookReportRepository.findById(id).get().toLogbookMessage(objectMapper) - } + override fun findById(id: Long): LogbookMessage = + dbLogbookReportRepository.findById(id).get().toLogbookMessage(objectMapper) override fun findLastMessageDate(): ZonedDateTime { return try { @@ -313,20 +318,22 @@ class JpaLogbookReportRepository( try { if (internalReferenceNumber.isNotEmpty()) { val lastTrip = - dbLogbookReportRepository.findTripsBeforeDatetime( - internalReferenceNumber, - beforeDateTime.toInstant(), - PageRequest.of(0, 1), - ).first() - - return dbLogbookReportRepository.findFirstAcknowledgedDateOfTrip( - internalReferenceNumber = internalReferenceNumber, - tripNumber = lastTrip.tripNumber, - startDate = lastTrip.startDate, - endDate = lastTrip.endDate, - ).atZone( - UTC, - ) + dbLogbookReportRepository + .findTripsBeforeDatetime( + internalReferenceNumber, + beforeDateTime.toInstant(), + PageRequest.of(0, 1), + ).first() + + return dbLogbookReportRepository + .findFirstAcknowledgedDateOfTrip( + internalReferenceNumber = internalReferenceNumber, + tripNumber = lastTrip.tripNumber, + startDate = lastTrip.startDate, + endDate = lastTrip.endDate, + ).atZone( + UTC, + ) } throw IllegalArgumentException("No CFR given to find the vessel.") @@ -339,13 +346,11 @@ class JpaLogbookReportRepository( } } - override fun findLastThreeYearsTripNumbers(internalReferenceNumber: String): List { - return dbLogbookReportRepository.findLastThreeYearsTripNumbers(internalReferenceNumber) - } + override fun findLastThreeYearsTripNumbers(internalReferenceNumber: String): List = + dbLogbookReportRepository.findLastThreeYearsTripNumbers(internalReferenceNumber) - override fun findLastReportSoftware(internalReferenceNumber: String): String? { - return dbLogbookReportRepository.findLastReportSoftware(internalReferenceNumber) - } + override fun findLastReportSoftware(internalReferenceNumber: String): String? = + dbLogbookReportRepository.findLastReportSoftware(internalReferenceNumber) // For test purpose @Modifying @@ -362,13 +367,12 @@ class JpaLogbookReportRepository( @Modifying @Transactional - override fun savePriorNotification(logbookMessageAndValue: LogbookMessageAndValue): PriorNotification { - return PriorNotification.fromLogbookMessage( + override fun savePriorNotification(logbookMessageAndValue: LogbookMessageAndValue): PriorNotification = + PriorNotification.fromLogbookMessage( dbLogbookReportRepository .save(LogbookReportEntity.fromLogbookMessage(objectMapper, logbookMessageAndValue.logbookMessage)) .toLogbookMessage(objectMapper), ) - } @Transactional @CacheEvict(value = ["pno_to_verify"], allEntries = true) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaManualPriorNotificationRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaManualPriorNotificationRepository.kt index 14624ffeac..2b9251a28a 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaManualPriorNotificationRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaManualPriorNotificationRepository.kt @@ -21,8 +21,8 @@ import java.time.ZonedDateTime class JpaManualPriorNotificationRepository( private val dbManualPriorNotificationRepository: DBManualPriorNotificationRepository, ) : ManualPriorNotificationRepository { - override fun findAll(filter: PriorNotificationsFilter): List { - return dbManualPriorNotificationRepository + override fun findAll(filter: PriorNotificationsFilter): List = + dbManualPriorNotificationRepository .findAll( flagStates = filter.flagStates ?: emptyList(), hasOneOrMoreReportings = filter.hasOneOrMoreReportings, @@ -38,11 +38,10 @@ class JpaManualPriorNotificationRepository( willArriveAfter = filter.willArriveAfter, willArriveBefore = filter.willArriveBefore, ).map { it.toPriorNotification() } - } @Cacheable(value = ["manual_pno_to_verify"]) - override fun findAllToVerify(): List { - return dbManualPriorNotificationRepository + override fun findAllToVerify(): List = + dbManualPriorNotificationRepository .findAll( flagStates = emptyList(), hasOneOrMoreReportings = null, @@ -61,15 +60,12 @@ class JpaManualPriorNotificationRepository( it.value.isInVerificationScope == true && it.value.isVerified == false && it.value.isInvalidated != true - } - .map { + }.map { it.toPriorNotification() } - } - override fun findByReportId(reportId: String): PriorNotification? { - return dbManualPriorNotificationRepository.findByReportId(reportId)?.toPriorNotification() - } + override fun findByReportId(reportId: String): PriorNotification? = + dbManualPriorNotificationRepository.findByReportId(reportId)?.toPriorNotification() @Transactional @CacheEvict(value = ["manual_pno_to_verify"], allEntries = true) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaMissionActionsRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaMissionActionsRepository.kt index 4eecc1867b..5e0abbe0a6 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaMissionActionsRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaMissionActionsRepository.kt @@ -17,53 +17,50 @@ class JpaMissionActionsRepository( override fun findVesselMissionActionsAfterDateTime( vesselId: Int, afterDateTime: ZonedDateTime, - ): List { - return dbMissionActionsRepository.findAllByVesselIdEqualsAndActionDatetimeUtcAfterAndIsDeletedIsFalse( - vesselId, - afterDateTime.toInstant(), - ).map { control -> control.toMissionAction(mapper) } - } + ): List = + dbMissionActionsRepository + .findAllByVesselIdEqualsAndActionDatetimeUtcAfterAndIsDeletedIsFalse( + vesselId, + afterDateTime.toInstant(), + ).map { control -> control.toMissionAction(mapper) } - override fun findByMissionId(missionId: Int): List { - return dbMissionActionsRepository.findAllByMissionIdAndIsDeletedIsFalse(missionId).map { action -> + override fun findByMissionId(missionId: Int): List = + dbMissionActionsRepository.findAllByMissionIdAndIsDeletedIsFalse(missionId).map { action -> action.toMissionAction( mapper, ) } - } - override fun findMissionActionsIn(missionIds: List): List { - return dbMissionActionsRepository.findAllByMissionIdInAndIsDeletedIsFalse(missionIds).map { action -> + override fun findMissionActionsIn(missionIds: List): List = + dbMissionActionsRepository.findAllByMissionIdInAndIsDeletedIsFalse(missionIds).map { action -> action.toMissionAction( mapper, ) } - } - override fun save(missionAction: MissionAction): MissionAction { - return dbMissionActionsRepository.save(MissionActionEntity.fromMissionAction(mapper, missionAction)) + override fun save(missionAction: MissionAction): MissionAction = + dbMissionActionsRepository + .save(MissionActionEntity.fromMissionAction(mapper, missionAction)) .toMissionAction(mapper) - } - override fun findById(id: Int): MissionAction { - return dbMissionActionsRepository.findById(id).get().toMissionAction(mapper) - } + override fun findById(id: Int): MissionAction = + dbMissionActionsRepository.findById(id).get().toMissionAction(mapper) override fun findSeaAndLandControlBetweenDates( beforeDateTime: ZonedDateTime, afterDateTime: ZonedDateTime, - ): List { - return dbMissionActionsRepository.findAllByActionDatetimeUtcBeforeAndActionDatetimeUtcAfterAndIsDeletedIsFalseAndActionTypeIn( - beforeDateTime.toInstant(), - afterDateTime.toInstant(), - listOf( - MissionActionType.SEA_CONTROL, - MissionActionType.LAND_CONTROL, - ), - ).map { action -> - action.toMissionAction( - mapper, - ) - } - } + ): List = + dbMissionActionsRepository + .findAllByActionDatetimeUtcBeforeAndActionDatetimeUtcAfterAndIsDeletedIsFalseAndActionTypeIn( + beforeDateTime.toInstant(), + afterDateTime.toInstant(), + listOf( + MissionActionType.SEA_CONTROL, + MissionActionType.LAND_CONTROL, + ), + ).map { action -> + action.toMissionAction( + mapper, + ) + } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPNOAndLANAlertRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPNOAndLANAlertRepository.kt index 038f8f39aa..1d7100a092 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPNOAndLANAlertRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPNOAndLANAlertRepository.kt @@ -34,7 +34,8 @@ class JpaPNOAndLANAlertRepository( ): List { val rulesAsString = types.map { it.name } - return dbPNOAndLANAlertRepository.findAlertsOfRules(rulesAsString, internalReferenceNumber, tripNumber) + return dbPNOAndLANAlertRepository + .findAlertsOfRules(rulesAsString, internalReferenceNumber, tripNumber) .map { it.toAlert(mapper) } } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPendingAlertRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPendingAlertRepository.kt index 8f446ae603..474843b35b 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPendingAlertRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPendingAlertRepository.kt @@ -20,14 +20,16 @@ class JpaPendingAlertRepository( override fun findAlertsOfTypes(types: List): List { val rulesAsString = types.map { it.name } - return dbPendingAlertRepository.findAlertsOfRules(rulesAsString) + return dbPendingAlertRepository + .findAlertsOfRules(rulesAsString) .map { it.toPendingAlert(mapper) } } - override fun find(id: Int): PendingAlert { - return dbPendingAlertRepository.findById(id).get() + override fun find(id: Int): PendingAlert = + dbPendingAlertRepository + .findById(id) + .get() .toPendingAlert(mapper) - } override fun delete(id: Int) { dbPendingAlertRepository.deleteById(id) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoFleetSegmentSubscriptionRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoFleetSegmentSubscriptionRepository.kt index 3fb6c31429..5b9fc0f155 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoFleetSegmentSubscriptionRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoFleetSegmentSubscriptionRepository.kt @@ -16,34 +16,32 @@ class JpaPnoFleetSegmentSubscriptionRepository( dbPnoFleetSegmentsSubscriptionsRepository.deleteByControlUnitId(controlUnitId) } - override fun findAll(): List { - return dbPnoFleetSegmentsSubscriptionsRepository.findAll() + override fun findAll(): List = + dbPnoFleetSegmentsSubscriptionsRepository + .findAll() .map { it.toPriorNotificationFleetSegmentSubscription() } - } - override fun findByControlUnitId(controlUnitId: Int): List { - return dbPnoFleetSegmentsSubscriptionsRepository.findByControlUnitId(controlUnitId) + override fun findByControlUnitId(controlUnitId: Int): List = + dbPnoFleetSegmentsSubscriptionsRepository + .findByControlUnitId(controlUnitId) .map { it.toPriorNotificationFleetSegmentSubscription() } - } override fun has( portLocode: String, segmentCodes: List, - ): Boolean { - return dbPnoFleetSegmentsSubscriptionsRepository.countByPortLocodeAndSegmentCodes(portLocode, segmentCodes) > 0 - } + ): Boolean = + dbPnoFleetSegmentsSubscriptionsRepository.countByPortLocodeAndSegmentCodes(portLocode, segmentCodes) > 0 @Transactional override fun saveAll( priorNotificationFleetSegmentSubscriptions: List, - ): List { - return dbPnoFleetSegmentsSubscriptionsRepository.saveAll( - priorNotificationFleetSegmentSubscriptions.map { - PnoFleetSegmentSubscriptionEntity.fromPriorNotificationFleetSegmentSubscription( - it, - ) - }, - ) - .map { it.toPriorNotificationFleetSegmentSubscription() } - } + ): List = + dbPnoFleetSegmentsSubscriptionsRepository + .saveAll( + priorNotificationFleetSegmentSubscriptions.map { + PnoFleetSegmentSubscriptionEntity.fromPriorNotificationFleetSegmentSubscription( + it, + ) + }, + ).map { it.toPriorNotificationFleetSegmentSubscription() } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoPortSubscriptionRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoPortSubscriptionRepository.kt index c6daf99ed3..1d18961039 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoPortSubscriptionRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoPortSubscriptionRepository.kt @@ -16,31 +16,28 @@ class JpaPnoPortSubscriptionRepository( dbPnoPortsSubscriptionsRepository.deleteByControlUnitId(controlUnitId) } - override fun findAll(): List { - return dbPnoPortsSubscriptionsRepository.findAll() + override fun findAll(): List = + dbPnoPortsSubscriptionsRepository + .findAll() .map { it.toPriorNotificationPortSubscription() } - } - override fun findByControlUnitId(controlUnitId: Int): List { - return dbPnoPortsSubscriptionsRepository.findByControlUnitId(controlUnitId) + override fun findByControlUnitId(controlUnitId: Int): List = + dbPnoPortsSubscriptionsRepository + .findByControlUnitId(controlUnitId) .map { it.toPriorNotificationPortSubscription() } - } - override fun has(portLocode: String): Boolean { - return dbPnoPortsSubscriptionsRepository.countByPortLocode(portLocode) > 0 - } + override fun has(portLocode: String): Boolean = dbPnoPortsSubscriptionsRepository.countByPortLocode(portLocode) > 0 @Transactional override fun saveAll( priorNotificationPortSubscriptions: List, - ): List { - return dbPnoPortsSubscriptionsRepository.saveAll( - priorNotificationPortSubscriptions.map { - PnoPortSubscriptionEntity.fromPriorNotificationPortSubscription( - it, - ) - }, - ) - .map { it.toPriorNotificationPortSubscription() } - } + ): List = + dbPnoPortsSubscriptionsRepository + .saveAll( + priorNotificationPortSubscriptions.map { + PnoPortSubscriptionEntity.fromPriorNotificationPortSubscription( + it, + ) + }, + ).map { it.toPriorNotificationPortSubscription() } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoTypeRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoTypeRepository.kt index 53b849165c..d0ddced3e0 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoTypeRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoTypeRepository.kt @@ -7,9 +7,9 @@ import org.springframework.cache.annotation.Cacheable import org.springframework.stereotype.Repository @Repository -class JpaPnoTypeRepository(private val dbPnoTypeRepository: DBPnoTypeRepository) : PnoTypeRepository { +class JpaPnoTypeRepository( + private val dbPnoTypeRepository: DBPnoTypeRepository, +) : PnoTypeRepository { @Cacheable(value = ["pno_types"]) - override fun findAll(): List { - return dbPnoTypeRepository.findAll().map { it.toPnoType() } - } + override fun findAll(): List = dbPnoTypeRepository.findAll().map { it.toPnoType() } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoVesselSubscriptionRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoVesselSubscriptionRepository.kt index cff5ee3b1d..5a29ea8bd7 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoVesselSubscriptionRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoVesselSubscriptionRepository.kt @@ -16,31 +16,28 @@ class JpaPnoVesselSubscriptionRepository( dbPnoVesselsSubscriptionsRepository.deleteByControlUnitId(controlUnitId) } - override fun findAll(): List { - return dbPnoVesselsSubscriptionsRepository.findAll() + override fun findAll(): List = + dbPnoVesselsSubscriptionsRepository + .findAll() .map { it.toPriorNotificationVesselSubscription() } - } - override fun findByControlUnitId(controlUnitId: Int): List { - return dbPnoVesselsSubscriptionsRepository.findByControlUnitId(controlUnitId) + override fun findByControlUnitId(controlUnitId: Int): List = + dbPnoVesselsSubscriptionsRepository + .findByControlUnitId(controlUnitId) .map { it.toPriorNotificationVesselSubscription() } - } - override fun has(vesselId: Int): Boolean { - return dbPnoVesselsSubscriptionsRepository.countByVesselId(vesselId) > 0 - } + override fun has(vesselId: Int): Boolean = dbPnoVesselsSubscriptionsRepository.countByVesselId(vesselId) > 0 @Transactional override fun saveAll( priorNotificationVesselSubscriptions: List, - ): List { - return dbPnoVesselsSubscriptionsRepository.saveAll( - priorNotificationVesselSubscriptions.map { - PnoVesselSubscriptionEntity.fromPriorNotificationVesselSubscription( - it, - ) - }, - ) - .map { it.toPriorNotificationVesselSubscription() } - } + ): List = + dbPnoVesselsSubscriptionsRepository + .saveAll( + priorNotificationVesselSubscriptions.map { + PnoVesselSubscriptionEntity.fromPriorNotificationVesselSubscription( + it, + ) + }, + ).map { it.toPriorNotificationVesselSubscription() } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPortRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPortRepository.kt index 3d0d96606b..0ed493b5db 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPortRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPortRepository.kt @@ -9,27 +9,26 @@ import org.springframework.dao.EmptyResultDataAccessException import org.springframework.stereotype.Repository @Repository -class JpaPortRepository(private val dbPortRepository: DBPortRepository) : PortRepository { +class JpaPortRepository( + private val dbPortRepository: DBPortRepository, +) : PortRepository { @Cacheable(value = ["ports"]) - override fun findAll(): List { - return dbPortRepository.findAll().map { + override fun findAll(): List = + dbPortRepository.findAll().map { it.toPort() } - } @Cacheable(value = ["active_ports"]) - override fun findAllActive(): List { - return dbPortRepository.findAllByIsActiveIsTrue().map { + override fun findAllActive(): List = + dbPortRepository.findAllByIsActiveIsTrue().map { it.toPort() } - } @Cacheable(value = ["port"]) - override fun findByLocode(locode: String): Port { - return try { + override fun findByLocode(locode: String): Port = + try { dbPortRepository.findByLocodeEquals(locode).toPort() } catch (e: EmptyResultDataAccessException) { throw CodeNotFoundException("Port: code $locode not found") } - } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPositionRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPositionRepository.kt index a70cd6614b..34c3cba34d 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPositionRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPositionRepository.kt @@ -13,13 +13,15 @@ import java.time.ZoneOffset import java.time.ZonedDateTime @Repository -class JpaPositionRepository(private val dbPositionRepository: DBPositionRepository) : PositionRepository { +class JpaPositionRepository( + private val dbPositionRepository: DBPositionRepository, +) : PositionRepository { private val logger: Logger = LoggerFactory.getLogger(JpaPositionRepository::class.java) - override fun findAll(): List { - return dbPositionRepository.findAll() + override fun findAll(): List = + dbPositionRepository + .findAll() .map(PositionEntity::toPosition) - } override fun findVesselLastPositionsWithoutSpecifiedIdentifier( internalReferenceNumber: String, @@ -48,30 +50,30 @@ class JpaPositionRepository(private val dbPositionRepository: DBPositionReposito internalReferenceNumber: String, from: ZonedDateTime, to: ZonedDateTime, - ): List { - return dbPositionRepository.findLastByInternalReferenceNumber(internalReferenceNumber, from, to) + ): List = + dbPositionRepository + .findLastByInternalReferenceNumber(internalReferenceNumber, from, to) .map(PositionEntity::toPosition) - } @Cacheable(value = ["vessel_track"]) override fun findVesselLastPositionsByIrcs( ircs: String, from: ZonedDateTime, to: ZonedDateTime, - ): List { - return dbPositionRepository.findLastByIrcs(ircs, from, to) + ): List = + dbPositionRepository + .findLastByIrcs(ircs, from, to) .map(PositionEntity::toPosition) - } @Cacheable(value = ["vessel_track"]) override fun findVesselLastPositionsByExternalReferenceNumber( externalReferenceNumber: String, from: ZonedDateTime, to: ZonedDateTime, - ): List { - return dbPositionRepository.findLastByExternalReferenceNumber(externalReferenceNumber, from, to) + ): List = + dbPositionRepository + .findLastByExternalReferenceNumber(externalReferenceNumber, from, to) .map(PositionEntity::toPosition) - } @Transactional override fun save(position: Position) { @@ -79,12 +81,11 @@ class JpaPositionRepository(private val dbPositionRepository: DBPositionReposito dbPositionRepository.save(positionEntity) } - override fun findAllByMmsi(mmsi: String): List { - return dbPositionRepository.findAllByMmsi(mmsi) + override fun findAllByMmsi(mmsi: String): List = + dbPositionRepository + .findAllByMmsi(mmsi) .map(PositionEntity::toPosition) - } - override fun findLastPositionDate(): ZonedDateTime { - return dbPositionRepository.findLastPositionDateTime().atZone(ZoneOffset.UTC) - } + override fun findLastPositionDate(): ZonedDateTime = + dbPositionRepository.findLastPositionDateTime().atZone(ZoneOffset.UTC) } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPriorNotificationPdfDocumentRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPriorNotificationPdfDocumentRepository.kt index 8f5d44e27b..a5aed4eb67 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPriorNotificationPdfDocumentRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPriorNotificationPdfDocumentRepository.kt @@ -13,20 +13,18 @@ import org.springframework.stereotype.Repository class JpaPriorNotificationPdfDocumentRepository( private val dbPriorNotificationPdfDocumentRepository: DBPriorNotificationPdfDocumentRepository, ) : PriorNotificationPdfDocumentRepository { - override fun findByReportId(reportId: String): PdfDocument { - return try { + override fun findByReportId(reportId: String): PdfDocument = + try { dbPriorNotificationPdfDocumentRepository.findByReportId(reportId).toPdfDocument() } catch (e: EmptyResultDataAccessException) { throw BackendUsageException(BackendUsageErrorCode.NOT_FOUND) } - } @Modifying(clearAutomatically = true) - override fun deleteByReportId(reportId: String) { - return try { + override fun deleteByReportId(reportId: String) = + try { dbPriorNotificationPdfDocumentRepository.deleteById(reportId) } catch (e: EmptyResultDataAccessException) { throw BackendUsageException(BackendUsageErrorCode.NOT_FOUND) } - } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPriorNotificationSentMessageRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPriorNotificationSentMessageRepository.kt index ba15199311..3447013b41 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPriorNotificationSentMessageRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPriorNotificationSentMessageRepository.kt @@ -9,9 +9,8 @@ import org.springframework.stereotype.Repository class JpaPriorNotificationSentMessageRepository( private val dbPriorNotificationSentMessageRepository: DBPriorNotificationSentMessageRepository, ) : PriorNotificationSentMessageRepository { - override fun findAllByReportId(reportId: String): List { - return dbPriorNotificationSentMessageRepository + override fun findAllByReportId(reportId: String): List = + dbPriorNotificationSentMessageRepository .findAllByReportId(reportId) .map { it.toPriorNotificationSentMessage() } - } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPriorNotificationUploadRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPriorNotificationUploadRepository.kt index 93017484c4..69c0a31e55 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPriorNotificationUploadRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPriorNotificationUploadRepository.kt @@ -18,9 +18,10 @@ class JpaPriorNotificationUploadRepository( dbPriorNotificationUploadRepository.deleteById(id) } - override fun findAllByReportId(reportId: String): List { - return dbPriorNotificationUploadRepository.findByReportId(reportId).map { it.toDocument() } - } + override fun findAllByReportId(reportId: String): List = + dbPriorNotificationUploadRepository.findByReportId(reportId).map { + it.toDocument() + } override fun findById(id: String): PriorNotificationDocument { try { @@ -31,8 +32,8 @@ class JpaPriorNotificationUploadRepository( } @Transactional - override fun save(newPriorNotificationDocument: PriorNotificationDocument): PriorNotificationDocument { - return dbPriorNotificationUploadRepository - .save(PriorNotificationUploadEntity.fromDocument(newPriorNotificationDocument)).toDocument() - } + override fun save(newPriorNotificationDocument: PriorNotificationDocument): PriorNotificationDocument = + dbPriorNotificationUploadRepository + .save(PriorNotificationUploadEntity.fromDocument(newPriorNotificationDocument)) + .toDocument() } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaProducerOrganizationMembership.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaProducerOrganizationMembership.kt index c0ea30f28e..daaa3338d2 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaProducerOrganizationMembership.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaProducerOrganizationMembership.kt @@ -11,11 +11,10 @@ import kotlin.jvm.optionals.getOrNull class JpaProducerOrganizationMembership( private val dbProducerOrganizationMembership: DBProducerOrganizationMembership, ) : ProducerOrganizationMembershipRepository { - override fun findAll(): List { - return dbProducerOrganizationMembership.findAll().map { + override fun findAll(): List = + dbProducerOrganizationMembership.findAll().map { it.toProducerOrganizationMembership() } - } override fun saveAll(producerOrganizationMemberships: List) { dbProducerOrganizationMembership.saveAll( @@ -24,8 +23,9 @@ class JpaProducerOrganizationMembership( ) } - override fun findByInternalReferenceNumber(internalReferenceNumber: String): ProducerOrganizationMembership? { - return dbProducerOrganizationMembership.findById(internalReferenceNumber).getOrNull() + override fun findByInternalReferenceNumber(internalReferenceNumber: String): ProducerOrganizationMembership? = + dbProducerOrganizationMembership + .findById(internalReferenceNumber) + .getOrNull() ?.toProducerOrganizationMembership() - } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaRecentPositionsMetricsRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaRecentPositionsMetricsRepository.kt index 4b57c5ce25..43f3f5f61b 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaRecentPositionsMetricsRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaRecentPositionsMetricsRepository.kt @@ -10,7 +10,6 @@ class JpaRecentPositionsMetricsRepository( private val recentPositionsMetricsRepository: DBRecentPositionsMetricsRepository, ) : RecentPositionsMetricsRepository { @Cacheable(value = ["sudden_drop_of_positions_received"]) - override fun findSuddenDropOfPositionsReceived(): Boolean { - return recentPositionsMetricsRepository.findSuddenDropOfPositionsReceived() - } + override fun findSuddenDropOfPositionsReceived(): Boolean = + recentPositionsMetricsRepository.findSuddenDropOfPositionsReceived() } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaReportingRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaReportingRepository.kt index 604b3c7779..f1dc4cb37c 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaReportingRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaReportingRepository.kt @@ -35,9 +35,8 @@ class JpaReportingRepository( dbReportingRepository.save(ReportingEntity.fromPendingAlert(alert, validationDate, mapper)) } - override fun save(reporting: Reporting): Reporting { - return dbReportingRepository.save(ReportingEntity.fromReporting(reporting, mapper)).toReporting(mapper) - } + override fun save(reporting: Reporting): Reporting = + dbReportingRepository.save(ReportingEntity.fromReporting(reporting, mapper)).toReporting(mapper) @Transactional override fun update( @@ -100,30 +99,29 @@ class JpaReportingRepository( return entityManager.createQuery(criteriaQuery).resultList.map { it.toReporting(mapper) } } - override fun findById(reportingId: Int): Reporting { - return dbReportingRepository.findById(reportingId).get().toReporting(mapper) - } + override fun findById(reportingId: Int): Reporting = + dbReportingRepository.findById(reportingId).get().toReporting(mapper) override fun findCurrentAndArchivedByVesselIdentifierEquals( vesselIdentifier: VesselIdentifier, value: String, fromDate: ZonedDateTime, - ): List { - return dbReportingRepository - .findCurrentAndArchivedByVesselIdentifier(vesselIdentifier.toString(), value, fromDate.toInstant()).map { + ): List = + dbReportingRepository + .findCurrentAndArchivedByVesselIdentifier(vesselIdentifier.toString(), value, fromDate.toInstant()) + .map { it.toReporting(mapper) } - } override fun findCurrentAndArchivedByVesselIdEquals( vesselId: Int, fromDate: ZonedDateTime, - ): List { - return dbReportingRepository - .findCurrentAndArchivedByVesselId(vesselId, fromDate.toInstant()).map { + ): List = + dbReportingRepository + .findCurrentAndArchivedByVesselId(vesselId, fromDate.toInstant()) + .map { it.toReporting(mapper) } - } override fun findCurrentAndArchivedWithoutVesselIdentifier( internalReferenceNumber: String, @@ -172,8 +170,8 @@ class JpaReportingRepository( dbReportingRepository.archiveReporting(id) } - override fun findUnarchivedReportingsAfterNewVoyage(): List> { - return dbReportingRepository.findAllUnarchivedAfterDEPLogbookMessage().map { result -> + override fun findUnarchivedReportingsAfterNewVoyage(): List> = + dbReportingRepository.findAllUnarchivedAfterDEPLogbookMessage().map { result -> Pair( result[0] as Int, ReportingMapper.getReportingValueFromJSON( @@ -183,15 +181,10 @@ class JpaReportingRepository( ) as AlertType, ) } - } - override fun findExpiredReportings(): List { - return dbReportingRepository.findExpiredReportings() - } + override fun findExpiredReportings(): List = dbReportingRepository.findExpiredReportings() - override fun archiveReportings(ids: List): Int { - return dbReportingRepository.archiveReportings(ids) - } + override fun archiveReportings(ids: List): Int = dbReportingRepository.archiveReportings(ids) @Transactional override fun delete(id: Int) { @@ -202,31 +195,24 @@ class JpaReportingRepository( isArchived: Boolean, reportingEntity: Root, criteriaBuilder: CriteriaBuilder, - ): Predicate { - return criteriaBuilder.equal(reportingEntity.get("isArchived"), isArchived) - } + ): Predicate = criteriaBuilder.equal(reportingEntity.get("isArchived"), isArchived) private fun getIsDeletedPredicate( isDeleted: Boolean, reportingEntity: Root, criteriaBuilder: CriteriaBuilder, - ): Predicate { - return criteriaBuilder.equal(reportingEntity.get("isDeleted"), isDeleted) - } + ): Predicate = criteriaBuilder.equal(reportingEntity.get("isDeleted"), isDeleted) private fun getTypesPredicate( types: List, reportingEntity: Root, - ): Predicate { - return reportingEntity.get("type").`in`(*types.toTypedArray()) - } + ): Predicate = reportingEntity.get("type").`in`(*types.toTypedArray()) private fun getVesselInternalReferenceNumbersPredicate( vesselInternalReferenceNumbers: List, reportingEntity: Root, - ): Predicate { - return reportingEntity.get("internalReferenceNumber").`in`( + ): Predicate = + reportingEntity.get("internalReferenceNumber").`in`( *vesselInternalReferenceNumbers.toTypedArray(), ) - } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaSilencedAlertRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaSilencedAlertRepository.kt index 7b7ba29e23..c33461f6c8 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaSilencedAlertRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaSilencedAlertRepository.kt @@ -18,17 +18,17 @@ class JpaSilencedAlertRepository( alert: PendingAlert, silencedBeforeDate: ZonedDateTime, isValidated: Boolean, - ): SilencedAlert { - return dbSilencedAlertRepository.save( - SilencedAlertEntity.fromPendingAlert(mapper, alert, silencedBeforeDate, isValidated), - ).toSilencedAlert(mapper) - } + ): SilencedAlert = + dbSilencedAlertRepository + .save( + SilencedAlertEntity.fromPendingAlert(mapper, alert, silencedBeforeDate, isValidated), + ).toSilencedAlert(mapper) - override fun save(silencedAlert: SilencedAlert): SilencedAlert { - return dbSilencedAlertRepository.save( - SilencedAlertEntity.fromSilencedAlert(mapper, silencedAlert), - ).toSilencedAlert(mapper) - } + override fun save(silencedAlert: SilencedAlert): SilencedAlert = + dbSilencedAlertRepository + .save( + SilencedAlertEntity.fromSilencedAlert(mapper, silencedAlert), + ).toSilencedAlert(mapper) override fun findAllCurrentSilencedAlerts(): List { val now = ZonedDateTime.now() diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaSpeciesGroupRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaSpeciesGroupRepository.kt index 9e2be0a53e..9f999659a7 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaSpeciesGroupRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaSpeciesGroupRepository.kt @@ -11,9 +11,8 @@ class JpaSpeciesGroupRepository( private val dbSpeciesGroupRepository: DBSpeciesGroupRepository, ) : SpeciesGroupRepository { @Cacheable(value = ["all_species_groups"]) - override fun findAll(): List { - return dbSpeciesGroupRepository.findAll().map { + override fun findAll(): List = + dbSpeciesGroupRepository.findAll().map { it.toSpeciesGroup() } - } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaSpeciesRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaSpeciesRepository.kt index 2451364ff5..dc7079ff54 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaSpeciesRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaSpeciesRepository.kt @@ -9,20 +9,20 @@ import org.springframework.dao.EmptyResultDataAccessException import org.springframework.stereotype.Repository @Repository -class JpaSpeciesRepository(private val dbSpeciesRepository: DBSpeciesRepository) : SpeciesRepository { +class JpaSpeciesRepository( + private val dbSpeciesRepository: DBSpeciesRepository, +) : SpeciesRepository { @Cacheable(value = ["all_species"]) - override fun findAll(): List { - return dbSpeciesRepository.findAll().map { + override fun findAll(): List = + dbSpeciesRepository.findAll().map { it.toSpecies() } - } @Cacheable(value = ["species"]) - override fun findByCode(code: String): Species { - return try { + override fun findByCode(code: String): Species = + try { dbSpeciesRepository.findByCodeEquals(code).toSpecies() } catch (e: EmptyResultDataAccessException) { throw CodeNotFoundException("Species: code $code not found") } - } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaUserAuthorizationRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaUserAuthorizationRepository.kt index 38f9955100..14b14ada3f 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaUserAuthorizationRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaUserAuthorizationRepository.kt @@ -13,9 +13,8 @@ class JpaUserAuthorizationRepository( private val dbUserAuthorizationRepository: DBUserAuthorizationRepository, ) : UserAuthorizationRepository { @Cacheable(value = ["user_authorization"]) - override fun findByHashedEmail(hashedEmail: String): UserAuthorization { - return dbUserAuthorizationRepository.findByHashedEmail(hashedEmail).toUserAuthorization() - } + override fun findByHashedEmail(hashedEmail: String): UserAuthorization = + dbUserAuthorizationRepository.findByHashedEmail(hashedEmail).toUserAuthorization() @Modifying override fun save(user: UserAuthorization) { diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaVesselRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaVesselRepository.kt index 93f797a2cb..6b5d5f64ae 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaVesselRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaVesselRepository.kt @@ -12,13 +12,13 @@ import org.springframework.stereotype.Repository import kotlin.jvm.optionals.getOrNull @Repository -class JpaVesselRepository(private val dbVesselRepository: DBVesselRepository) : VesselRepository { +class JpaVesselRepository( + private val dbVesselRepository: DBVesselRepository, +) : VesselRepository { private val logger: Logger = LoggerFactory.getLogger(JpaVesselRepository::class.java) @Cacheable(value = ["vessels"]) - override fun findAll(): List { - return dbVesselRepository.findAll().map { it.toVessel() } - } + override fun findAll(): List = dbVesselRepository.findAll().map { it.toVessel() } @Cacheable(value = ["vessel"]) override fun findVessel( @@ -44,9 +44,10 @@ class JpaVesselRepository(private val dbVesselRepository: DBVesselRepository) : if (!externalReferenceNumber.isNullOrEmpty()) { try { - return dbVesselRepository.findByExternalReferenceNumberIgnoreCaseContaining( - externalReferenceNumber, - ).toVessel() + return dbVesselRepository + .findByExternalReferenceNumberIgnoreCaseContaining( + externalReferenceNumber, + ).toVessel() } catch (e: EmptyResultDataAccessException) { logger.warn("No vessel found for external marking $externalReferenceNumber", e) } @@ -56,23 +57,18 @@ class JpaVesselRepository(private val dbVesselRepository: DBVesselRepository) : } // Only used in tests - override fun findFirstByInternalReferenceNumber(internalReferenceNumber: String): Vessel? { - return dbVesselRepository.findFirstByCfr(internalReferenceNumber)?.toVessel() - } + override fun findFirstByInternalReferenceNumber(internalReferenceNumber: String): Vessel? = + dbVesselRepository.findFirstByCfr(internalReferenceNumber)?.toVessel() @Cacheable(value = ["vessels_by_ids"]) - override fun findVesselsByIds(ids: List): List { - return dbVesselRepository.findAllByIds(ids).map { it.toVessel() } - } + override fun findVesselsByIds(ids: List): List = + dbVesselRepository.findAllByIds(ids).map { it.toVessel() } @Cacheable(value = ["vessels_by_internal_reference_numbers"]) - override fun findVesselsByInternalReferenceNumbers(internalReferenceNumbers: List): List { - return dbVesselRepository.findAllByInternalReferenceNumbers(internalReferenceNumbers).map { it.toVessel() } - } + override fun findVesselsByInternalReferenceNumbers(internalReferenceNumbers: List): List = + dbVesselRepository.findAllByInternalReferenceNumbers(internalReferenceNumbers).map { it.toVessel() } - override fun findVesselById(vesselId: Int): Vessel? { - return dbVesselRepository.findById(vesselId).getOrNull()?.toVessel() - } + override fun findVesselById(vesselId: Int): Vessel? = dbVesselRepository.findById(vesselId).getOrNull()?.toVessel() @Cacheable(value = ["search_vessels"]) override fun search(searched: String): List { @@ -80,7 +76,8 @@ class JpaVesselRepository(private val dbVesselRepository: DBVesselRepository) : return listOf() } - return dbVesselRepository.searchBy(searched) + return dbVesselRepository + .searchBy(searched) .map { it.toVessel() } } @@ -88,7 +85,5 @@ class JpaVesselRepository(private val dbVesselRepository: DBVesselRepository) : override fun findUnderCharterForVessel( vesselIdentifier: VesselIdentifier, value: String, - ): Boolean { - return dbVesselRepository.findUnderCharterByVesselIdentifierEquals(vesselIdentifier.name, value) - } + ): Boolean = dbVesselRepository.findUnderCharterByVesselIdentifierEquals(vesselIdentifier.name, value) } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/interfaces/DBLogbookReportRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/interfaces/DBLogbookReportRepository.kt index b7ff920917..51cf1da64a 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/interfaces/DBLogbookReportRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/interfaces/DBLogbookReportRepository.kt @@ -10,7 +10,8 @@ import java.time.Instant @DynamicUpdate interface DBLogbookReportRepository : - CrudRepository, JpaSpecificationExecutor { + CrudRepository, + JpaSpecificationExecutor { @Query( """ WITH diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/interfaces/DBReportingRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/interfaces/DBReportingRepository.kt index 5f9b2696b9..bdefda1d51 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/interfaces/DBReportingRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/interfaces/DBReportingRepository.kt @@ -6,7 +6,6 @@ import org.springframework.data.jpa.repository.Modifying import org.springframework.data.jpa.repository.Query import org.springframework.data.repository.CrudRepository import java.time.Instant -import java.time.ZonedDateTime @DynamicUpdate interface DBReportingRepository : CrudRepository { diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/interfaces/VoyageTripNumberAndDates.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/interfaces/VoyageTripNumberAndDates.kt index b1cc36563d..4c014fcf7a 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/interfaces/VoyageTripNumberAndDates.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/interfaces/VoyageTripNumberAndDates.kt @@ -2,8 +2,18 @@ package fr.gouv.cnsp.monitorfish.infrastructure.database.repositories.interfaces import java.time.Instant -class VoyageTripNumberAndDate(var tripNumber: String, var startOrEndDate: Instant) +class VoyageTripNumberAndDate( + var tripNumber: String, + var startOrEndDate: Instant, +) -class VoyageTripNumberAndDates(var tripNumber: String, var startDate: Instant, var endDate: Instant) +class VoyageTripNumberAndDates( + var tripNumber: String, + var startDate: Instant, + var endDate: Instant, +) -class VoyageDates(var startDate: Instant, var endDate: Instant) +class VoyageDates( + var startDate: Instant, + var endDate: Instant, +) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/utils/ToSqlArrayString.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/utils/ToSqlArrayString.kt index 7e148ae262..d70e8ec74c 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/utils/ToSqlArrayString.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/utils/ToSqlArrayString.kt @@ -1,5 +1,3 @@ package fr.gouv.cnsp.monitorfish.infrastructure.database.repositories.utils -fun toSqlArrayString(list: List?): String? { - return list?.joinToString(",", prefix = "{", postfix = "}") -} +fun toSqlArrayString(list: List?): String? = list?.joinToString(",", prefix = "{", postfix = "}") diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/utils/ToSqlListString.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/utils/ToSqlListString.kt index 83ac29034f..ba13ee0ad5 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/utils/ToSqlListString.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/utils/ToSqlListString.kt @@ -1,5 +1,3 @@ package fr.gouv.cnsp.monitorfish.infrastructure.database.repositories.utils -fun toSqlListString(list: List?): String? { - return list?.joinToString(",", prefix = "(", postfix = ")") -} +fun toSqlListString(list: List?): String? = list?.joinToString(",", prefix = "(", postfix = ")") diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APIControlUnitRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APIControlUnitRepository.kt index 9de61f016a..8948fe34a9 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APIControlUnitRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APIControlUnitRepository.kt @@ -26,7 +26,9 @@ class APIControlUnitRepository( val controlUnitsUrl = "${monitorenvProperties.url}/api/v2/control_units" try { - apiClient.httpClient.get(controlUnitsUrl).body>() + apiClient.httpClient + .get(controlUnitsUrl) + .body>() .map { it.toFullControlUnit() } } catch (e: Exception) { logger.error("Could not fetch control units at $controlUnitsUrl", e) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APILegacyControlUnitRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APILegacyControlUnitRepository.kt index 6a0c093807..9bd175ce01 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APILegacyControlUnitRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APILegacyControlUnitRepository.kt @@ -26,7 +26,9 @@ class APILegacyControlUnitRepository( val legacyControlUnitsUrl = "${monitorenvProperties.url}/api/v1/control_units" try { - apiClient.httpClient.get(legacyControlUnitsUrl).body>() + apiClient.httpClient + .get(legacyControlUnitsUrl) + .body>() .map { it.toLegacyControlUnit() } } catch (e: Exception) { logger.error("Could not fetch legacy control units at $legacyControlUnitsUrl", e) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APIMissionRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APIMissionRepository.kt index c0719e21f9..2406210cde 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APIMissionRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APIMissionRepository.kt @@ -30,7 +30,8 @@ class APIMissionRepository( private val zoneDateTimeFormatter: DateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.000X") private val cache = - Caffeine.newBuilder() + Caffeine + .newBuilder() .maximumSize(500) .expireAfterWrite(1, TimeUnit.DAYS) .build>() @@ -49,8 +50,11 @@ class APIMissionRepository( try { val controlUnits = - apiClient.httpClient.get(missionsUrl) - .body().controlUnits.map { it.toLegacyControlUnit() } + apiClient.httpClient + .get(missionsUrl) + .body() + .controlUnits + .map { it.toLegacyControlUnit() } cache.put(cacheKey, controlUnits) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/responses/AdministrationDataResponse.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/responses/AdministrationDataResponse.kt index 2aea18a2d6..e413d93c97 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/responses/AdministrationDataResponse.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/responses/AdministrationDataResponse.kt @@ -9,11 +9,10 @@ data class AdministrationDataResponse( val isArchived: Boolean, val name: String, ) { - fun toAdministration(): Administration { - return Administration( + fun toAdministration(): Administration = + Administration( id = id, isArchived = isArchived, name = name, ) - } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/responses/ControlUnitContactDataResponse.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/responses/ControlUnitContactDataResponse.kt index 36c372bb29..80875781f4 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/responses/ControlUnitContactDataResponse.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/responses/ControlUnitContactDataResponse.kt @@ -13,8 +13,8 @@ data class ControlUnitContactDataResponse( val name: String, val phone: String?, ) { - fun toControlUnitContact(): ControlUnitContact { - return ControlUnitContact( + fun toControlUnitContact(): ControlUnitContact = + ControlUnitContact( id = id, controlUnitId = controlUnitId, email = email, @@ -23,5 +23,4 @@ data class ControlUnitContactDataResponse( name = name, phone = phone, ) - } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/responses/ControlUnitDataResponse.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/responses/ControlUnitDataResponse.kt index 146f084370..50c1fdf5e5 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/responses/ControlUnitDataResponse.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/responses/ControlUnitDataResponse.kt @@ -13,8 +13,8 @@ data class ControlUnitDataResponse( val name: String, val termsNote: String?, ) { - fun toControlUnit(): ControlUnit { - return ControlUnit( + fun toControlUnit(): ControlUnit = + ControlUnit( id = id, areaNote = areaNote, administrationId = administrationId, @@ -23,5 +23,4 @@ data class ControlUnitDataResponse( name = name, termsNote = termsNote, ) - } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/responses/ControlUnitDepartmentDataResponse.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/responses/ControlUnitDepartmentDataResponse.kt index 40cff967d7..9718985e6c 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/responses/ControlUnitDepartmentDataResponse.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/responses/ControlUnitDepartmentDataResponse.kt @@ -9,10 +9,9 @@ data class ControlUnitDepartmentDataResponse( val inseeCode: String, val name: String, ) { - fun toControlUnitDepartmentArea(): ControlUnitDepartmentArea { - return ControlUnitDepartmentArea( + fun toControlUnitDepartmentArea(): ControlUnitDepartmentArea = + ControlUnitDepartmentArea( inseeCode = inseeCode, name = name, ) - } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/responses/EnvMissionActionDataResponse.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/responses/EnvMissionActionDataResponse.kt index 0b150a8c29..310a832a44 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/responses/EnvMissionActionDataResponse.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/responses/EnvMissionActionDataResponse.kt @@ -31,9 +31,7 @@ data class EnvMissionActionDataResponse( object UUIDSerializer : KSerializer { override val descriptor = PrimitiveSerialDescriptor("UUID", PrimitiveKind.STRING) - override fun deserialize(decoder: Decoder): UUID { - return UUID.fromString(decoder.decodeString()) - } + override fun deserialize(decoder: Decoder): UUID = UUID.fromString(decoder.decodeString()) override fun serialize( encoder: Encoder, diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/responses/FullControlUnitDataResponse.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/responses/FullControlUnitDataResponse.kt index 3fb5fd6284..04ab492a82 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/responses/FullControlUnitDataResponse.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/responses/FullControlUnitDataResponse.kt @@ -19,8 +19,8 @@ data class FullControlUnitDataResponse( val name: String, val termsNote: String?, ) { - fun toFullControlUnit(): FullControlUnit { - return FullControlUnit( + fun toFullControlUnit(): FullControlUnit = + FullControlUnit( id = id, areaNote = areaNote, administration = administration.toAdministration(), @@ -35,5 +35,4 @@ data class FullControlUnitDataResponse( name = name, termsNote = termsNote, ) - } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/responses/FullControlUnitResourceDataResponse.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/responses/FullControlUnitResourceDataResponse.kt index 8cff51282e..9c158489a8 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/responses/FullControlUnitResourceDataResponse.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/responses/FullControlUnitResourceDataResponse.kt @@ -17,8 +17,8 @@ data class FullControlUnitResourceDataResponse( val stationId: Int, val type: ControlUnitResourceType, ) { - fun toFullControlUnitResource(): FullControlUnitResource { - return FullControlUnitResource( + fun toFullControlUnitResource(): FullControlUnitResource = + FullControlUnitResource( id = id, controlUnit = controlUnit.toControlUnit(), controlUnitId = controlUnitId, @@ -30,5 +30,4 @@ data class FullControlUnitResourceDataResponse( stationId = stationId, type = type, ) - } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/responses/LegacyControlUnitDataResponse.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/responses/LegacyControlUnitDataResponse.kt index 50131a9130..10d86ac5bf 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/responses/LegacyControlUnitDataResponse.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/responses/LegacyControlUnitDataResponse.kt @@ -13,8 +13,8 @@ data class LegacyControlUnitDataResponse( val resources: List, val contact: String? = null, ) { - fun toLegacyControlUnit(): LegacyControlUnit { - return LegacyControlUnit( + fun toLegacyControlUnit(): LegacyControlUnit = + LegacyControlUnit( id = id, administration = administration, isArchived = isArchived, @@ -22,5 +22,4 @@ data class LegacyControlUnitDataResponse( resources = resources, contact = contact, ) - } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/responses/StationDataResponse.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/responses/StationDataResponse.kt index 3d31e222a6..f4bce063df 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/responses/StationDataResponse.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/responses/StationDataResponse.kt @@ -10,12 +10,11 @@ data class StationDataResponse( val longitude: Double, val name: String, ) { - fun toStation(): Station { - return Station( + fun toStation(): Station = + Station( id = id, latitude = latitude, longitude = longitude, name = name, ) - } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/oidc/APIOIDCRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/oidc/APIOIDCRepository.kt index a68e5ffaf0..24c7938cdb 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/oidc/APIOIDCRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/oidc/APIOIDCRepository.kt @@ -24,13 +24,14 @@ class APIOIDCRepository( override fun getUserInfo(authorizationHeaderContent: String): UserInfo = runBlocking { val userInfoResponse = - apiClient.httpClient.get( - oidcProperties.issuerUri!! + oidcProperties.userinfoEndpoint!!, - ) { - headers { - append(Authorization, authorizationHeaderContent) - } - }.body() + apiClient.httpClient + .get( + oidcProperties.issuerUri!! + oidcProperties.userinfoEndpoint!!, + ) { + headers { + append(Authorization, authorizationHeaderContent) + } + }.body() return@runBlocking userInfoResponse } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/utils/CustomZonedDateTime.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/utils/CustomZonedDateTime.kt index b3a6c6f2e0..d10cc5f891 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/utils/CustomZonedDateTime.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/utils/CustomZonedDateTime.kt @@ -10,7 +10,9 @@ import java.time.format.DateTimeFormatter * The overridden `toString()` method ensures seconds are always present in the output * (= never omitted when equal to `00`) and removes unnecessary milli/micro/nanoseconds. */ -data class CustomZonedDateTime(private val dateAsZonedDateTime: ZonedDateTime) { +data class CustomZonedDateTime( + private val dateAsZonedDateTime: ZonedDateTime, +) { companion object { val dateTimeFormatter: DateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssX") @@ -42,7 +44,5 @@ data class CustomZonedDateTime(private val dateAsZonedDateTime: ZonedDateTime) { return utcZonedDateTime.format(dateTimeFormatter) } - fun toZonedDateTime(): ZonedDateTime { - return dateAsZonedDateTime.withZoneSameInstant(ZoneOffset.UTC) - } + fun toZonedDateTime(): ZonedDateTime = dateAsZonedDateTime.withZoneSameInstant(ZoneOffset.UTC) } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/utils/ZonedDateTimeDeserializer.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/utils/ZonedDateTimeDeserializer.kt index ac8ad10f3b..fda1182b99 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/utils/ZonedDateTimeDeserializer.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/utils/ZonedDateTimeDeserializer.kt @@ -10,7 +10,5 @@ class ZonedDateTimeDeserializer : JsonDeserializer() { override fun deserialize( jsonParser: JsonParser, deserializationContext: DeserializationContext, - ): ZonedDateTime { - return ZonedDateTime.parse(jsonParser.text).withZoneSameInstant(ZoneOffset.UTC) - } + ): ZonedDateTime = ZonedDateTime.parse(jsonParser.text).withZoneSameInstant(ZoneOffset.UTC) } diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/beacon_malfunctions/VesselBeaconMalfunctionsResumeUTests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/beacon_malfunctions/VesselBeaconMalfunctionsResumeUTests.kt index 52f6470a8b..9c9054246e 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/beacon_malfunctions/VesselBeaconMalfunctionsResumeUTests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/beacon_malfunctions/VesselBeaconMalfunctionsResumeUTests.kt @@ -19,10 +19,21 @@ class VesselBeaconMalfunctionsResumeUTests { BeaconMalfunctionWithDetails( beaconMalfunction = BeaconMalfunction( - 1, "FR224226850", "1236514", "IRCS", - "fr", VesselIdentifier.INTERNAL_REFERENCE_NUMBER, "BIDUBULE", VesselStatus.AT_SEA, - Stage.ARCHIVED, now.minusYears(2), null, now.minusYears(2), - beaconNumber = "123465", beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, vesselId = 123, + 1, + "FR224226850", + "1236514", + "IRCS", + "fr", + VesselIdentifier.INTERNAL_REFERENCE_NUMBER, + "BIDUBULE", + VesselStatus.AT_SEA, + Stage.ARCHIVED, + now.minusYears(2), + null, + now.minusYears(2), + beaconNumber = "123465", + beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, + vesselId = 123, ), comments = listOf( @@ -47,10 +58,21 @@ class VesselBeaconMalfunctionsResumeUTests { BeaconMalfunctionWithDetails( beaconMalfunction = BeaconMalfunction( - 2, "FR224226850", "1236514", "IRCS", - "fr", VesselIdentifier.INTERNAL_REFERENCE_NUMBER, "BIDUBULE", VesselStatus.AT_SEA, - Stage.ARCHIVED, now.minusMinutes(23), null, now.minusMinutes(23), - beaconNumber = "123465", beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, vesselId = 123, + 2, + "FR224226850", + "1236514", + "IRCS", + "fr", + VesselIdentifier.INTERNAL_REFERENCE_NUMBER, + "BIDUBULE", + VesselStatus.AT_SEA, + Stage.ARCHIVED, + now.minusMinutes(23), + null, + now.minusMinutes(23), + beaconNumber = "123465", + beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, + vesselId = 123, ), comments = listOf( @@ -75,10 +97,21 @@ class VesselBeaconMalfunctionsResumeUTests { BeaconMalfunctionWithDetails( beaconMalfunction = BeaconMalfunction( - 3, "FR224226850", "1236514", "IRCS", - "fr", VesselIdentifier.INTERNAL_REFERENCE_NUMBER, "BIDUBULE", VesselStatus.AT_SEA, - Stage.ARCHIVED, now.minusMinutes(5), null, now.minusMinutes(5), - beaconNumber = "123465", beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, vesselId = 123, + 3, + "FR224226850", + "1236514", + "IRCS", + "fr", + VesselIdentifier.INTERNAL_REFERENCE_NUMBER, + "BIDUBULE", + VesselStatus.AT_SEA, + Stage.ARCHIVED, + now.minusMinutes(5), + null, + now.minusMinutes(5), + beaconNumber = "123465", + beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, + vesselId = 123, ), comments = listOf( @@ -110,10 +143,21 @@ class VesselBeaconMalfunctionsResumeUTests { BeaconMalfunctionWithDetails( beaconMalfunction = BeaconMalfunction( - 4, "FR224226850", "1236514", "IRCS", - "fr", VesselIdentifier.INTERNAL_REFERENCE_NUMBER, "BIDUBULE", VesselStatus.AT_PORT, - Stage.ARCHIVED, lastBeaconDateTime, null, lastBeaconDateTime, - beaconNumber = "123465", beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, vesselId = 123, + 4, + "FR224226850", + "1236514", + "IRCS", + "fr", + VesselIdentifier.INTERNAL_REFERENCE_NUMBER, + "BIDUBULE", + VesselStatus.AT_PORT, + Stage.ARCHIVED, + lastBeaconDateTime, + null, + lastBeaconDateTime, + beaconNumber = "123465", + beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, + vesselId = 123, ), comments = listOf( @@ -164,10 +208,21 @@ class VesselBeaconMalfunctionsResumeUTests { BeaconMalfunctionWithDetails( beaconMalfunction = BeaconMalfunction( - 1, "FR224226850", "1236514", "IRCS", - "fr", VesselIdentifier.INTERNAL_REFERENCE_NUMBER, "BIDUBULE", VesselStatus.AT_SEA, - Stage.ARCHIVED, lastBeaconDateTime, null, lastBeaconDateTime, - beaconNumber = "123465", beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, vesselId = 123, + 1, + "FR224226850", + "1236514", + "IRCS", + "fr", + VesselIdentifier.INTERNAL_REFERENCE_NUMBER, + "BIDUBULE", + VesselStatus.AT_SEA, + Stage.ARCHIVED, + lastBeaconDateTime, + null, + lastBeaconDateTime, + beaconNumber = "123465", + beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, + vesselId = 123, ), comments = listOf( @@ -183,10 +238,21 @@ class VesselBeaconMalfunctionsResumeUTests { BeaconMalfunctionWithDetails( beaconMalfunction = BeaconMalfunction( - 2, "FR224226852", "1236514", "IRCS", - "fr", VesselIdentifier.INTERNAL_REFERENCE_NUMBER, "BIDUBULE", VesselStatus.AT_PORT, - Stage.ARCHIVED, now, null, now, - beaconNumber = "123465", beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, vesselId = 123, + 2, + "FR224226852", + "1236514", + "IRCS", + "fr", + VesselIdentifier.INTERNAL_REFERENCE_NUMBER, + "BIDUBULE", + VesselStatus.AT_PORT, + Stage.ARCHIVED, + now, + null, + now, + beaconNumber = "123465", + beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, + vesselId = 123, ), comments = listOf( diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/GetAllCurrentReportingsUTests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/GetAllCurrentReportingsUTests.kt index 3c1ce94a73..6b9ee4acd2 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/GetAllCurrentReportingsUTests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/GetAllCurrentReportingsUTests.kt @@ -60,8 +60,7 @@ class GetAllCurrentReportingsUTests { eq(VesselIdentifier.INTERNAL_REFERENCE_NUMBER), eq("FRFGRGR"), ), - ) - .willReturn(true) + ).willReturn(true) // When val reportings = diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/SilencePendingAlertUTests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/SilencePendingAlertUTests.kt index c10df2787f..3bef2c38e4 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/SilencePendingAlertUTests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/SilencePendingAlertUTests.kt @@ -67,7 +67,13 @@ class SilencePendingAlertUTests { verify(silencedAlertRepository, times(1)).save(eq(pendingAlert), capture(), any()) assertThat(allValues.first().toString().split("T")[0]) - .isEqualTo(ZonedDateTime.now().plusDays(1).toString().split("T")[0]) + .isEqualTo( + ZonedDateTime + .now() + .plusDays(1) + .toString() + .split("T")[0], + ) } } @@ -105,7 +111,13 @@ class SilencePendingAlertUTests { verify(silencedAlertRepository, times(1)).save(eq(pendingAlert), capture(), any()) assertThat(allValues.first().toString().split("T")[0]) - .isEqualTo(ZonedDateTime.now().plusDays(26).toString().split("T")[0]) + .isEqualTo( + ZonedDateTime + .now() + .plusDays(26) + .toString() + .split("T")[0], + ) } } diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/TestUtils.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/TestUtils.kt index 8442029b52..b19c2b3b08 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/TestUtils.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/TestUtils.kt @@ -30,8 +30,8 @@ object TestUtils { alertType: AlertTypeMapping?, isArchived: Boolean? = false, natinfCode: Int? = null, - ): Reporting { - return Reporting( + ): Reporting = + Reporting( id = id, validationDate = validationDate, creationDate = ZonedDateTime.now().minusDays(1), @@ -67,10 +67,9 @@ object TestUtils { internalReferenceNumber = internalReferenceNumber, flagState = CountryCode.FR, ) - } - fun getDummyReportings(dateTime: ZonedDateTime): List { - return listOf( + fun getDummyReportings(dateTime: ZonedDateTime): List = + listOf( Reporting( id = 1, type = ReportingType.ALERT, @@ -117,7 +116,6 @@ object TestUtils { isDeleted = false, ), ) - } fun getDummyLogbookMessages(): List { val gearOne = LogbookTripGear() @@ -182,16 +180,17 @@ object TestUtils { software = "TurboCatch (3.7-1)", message = far, reportDateTime = - ZonedDateTime.of( - 2020, - 5, - 5, - 3, - 4, - 5, - 3, - UTC, - ).minusHours(12), + ZonedDateTime + .of( + 2020, + 5, + 5, + 3, + 4, + 5, + 3, + UTC, + ).minusHours(12), transmissionFormat = LogbookTransmissionFormat.ERS, integrationDateTime = ZonedDateTime.now(), isEnriched = false, @@ -207,16 +206,17 @@ object TestUtils { software = "e-Sacapt Secours ERSV3 V 1.0.10", message = dep, reportDateTime = - ZonedDateTime.of( - 2020, - 5, - 5, - 3, - 4, - 5, - 3, - UTC, - ).minusHours(24), + ZonedDateTime + .of( + 2020, + 5, + 5, + 3, + 4, + 5, + 3, + UTC, + ).minusHours(24), transmissionFormat = LogbookTransmissionFormat.ERS, integrationDateTime = ZonedDateTime.now(), isEnriched = false, @@ -232,16 +232,17 @@ object TestUtils { software = "e-Sacapt Secours ERSV3 V 1.0.7", message = pno, reportDateTime = - ZonedDateTime.of( - 2020, - 5, - 5, - 3, - 4, - 5, - 3, - UTC, - ).minusHours(0), + ZonedDateTime + .of( + 2020, + 5, + 5, + 3, + 4, + 5, + 3, + UTC, + ).minusHours(0), transmissionFormat = LogbookTransmissionFormat.ERS, integrationDateTime = ZonedDateTime.now(), isEnriched = false, @@ -257,16 +258,17 @@ object TestUtils { software = "e-Sacapt Secours ERSV3 V 1.0.7", message = coe, reportDateTime = - ZonedDateTime.of( - 2020, - 5, - 5, - 3, - 4, - 5, - 3, - UTC, - ).minusHours(3), + ZonedDateTime + .of( + 2020, + 5, + 5, + 3, + 4, + 5, + 3, + UTC, + ).minusHours(3), transmissionFormat = LogbookTransmissionFormat.ERS, integrationDateTime = ZonedDateTime.now(), isEnriched = false, @@ -351,16 +353,17 @@ object TestUtils { software = "FT/VISIOCaptures V1.4.7", message = dep, reportDateTime = - ZonedDateTime.of( - 2020, - 5, - 5, - 3, - 4, - 5, - 3, - UTC, - ).minusHours(24), + ZonedDateTime + .of( + 2020, + 5, + 5, + 3, + 4, + 5, + 3, + UTC, + ).minusHours(24), transmissionFormat = LogbookTransmissionFormat.ERS, integrationDateTime = ZonedDateTime.now(), isEnriched = false, @@ -376,16 +379,17 @@ object TestUtils { software = "FP/VISIOCaptures V1.4.7", message = far, reportDateTime = - ZonedDateTime.of( - 2020, - 5, - 5, - 3, - 4, - 5, - 3, - UTC, - ).minusHours(12), + ZonedDateTime + .of( + 2020, + 5, + 5, + 3, + 4, + 5, + 3, + UTC, + ).minusHours(12), transmissionFormat = LogbookTransmissionFormat.ERS, integrationDateTime = ZonedDateTime.now(), isEnriched = false, @@ -401,16 +405,17 @@ object TestUtils { software = "TurboCatch (3.6-1)", message = pno, reportDateTime = - ZonedDateTime.of( - 2020, - 5, - 5, - 3, - 4, - 5, - 3, - UTC, - ).minusHours(0), + ZonedDateTime + .of( + 2020, + 5, + 5, + 3, + 4, + 5, + 3, + UTC, + ).minusHours(0), transmissionFormat = LogbookTransmissionFormat.FLUX, integrationDateTime = ZonedDateTime.now(), isEnriched = false, @@ -451,16 +456,17 @@ object TestUtils { messageType = "FAR", message = far, reportDateTime = - ZonedDateTime.of( - 2020, - 5, - 5, - 3, - 4, - 5, - 3, - UTC, - ).minusHours(12), + ZonedDateTime + .of( + 2020, + 5, + 5, + 3, + 4, + 5, + 3, + UTC, + ).minusHours(12), transmissionFormat = LogbookTransmissionFormat.ERS, integrationDateTime = ZonedDateTime.now(), isEnriched = false, @@ -476,16 +482,17 @@ object TestUtils { messageType = "FAR", message = correctedFar, reportDateTime = - ZonedDateTime.of( - 2020, - 5, - 5, - 3, - 4, - 5, - 3, - UTC, - ).minusHours(12), + ZonedDateTime + .of( + 2020, + 5, + 5, + 3, + 4, + 5, + 3, + UTC, + ).minusHours(12), transmissionFormat = LogbookTransmissionFormat.ERS, integrationDateTime = ZonedDateTime.now(), isEnriched = false, @@ -533,16 +540,17 @@ object TestUtils { messageType = "FAR", message = far, reportDateTime = - ZonedDateTime.of( - 2020, - 5, - 5, - 3, - 4, - 5, - 3, - UTC, - ).minusHours(12), + ZonedDateTime + .of( + 2020, + 5, + 5, + 3, + 4, + 5, + 3, + UTC, + ).minusHours(12), transmissionFormat = LogbookTransmissionFormat.ERS, integrationDateTime = ZonedDateTime.now(), isEnriched = false, @@ -557,16 +565,17 @@ object TestUtils { messageType = "", message = farBadAck, reportDateTime = - ZonedDateTime.of( - 2020, - 5, - 5, - 3, - 4, - 5, - 3, - UTC, - ).minusHours(12), + ZonedDateTime + .of( + 2020, + 5, + 5, + 3, + 4, + 5, + 3, + UTC, + ).minusHours(12), transmissionFormat = LogbookTransmissionFormat.ERS, integrationDateTime = ZonedDateTime.now(), isEnriched = false, @@ -581,16 +590,17 @@ object TestUtils { messageType = "FAR", message = farTwo, reportDateTime = - ZonedDateTime.of( - 2020, - 5, - 5, - 3, - 4, - 5, - 3, - UTC, - ).minusHours(12), + ZonedDateTime + .of( + 2020, + 5, + 5, + 3, + 4, + 5, + 3, + UTC, + ).minusHours(12), transmissionFormat = LogbookTransmissionFormat.ERS, integrationDateTime = ZonedDateTime.now(), isEnriched = false, @@ -605,16 +615,17 @@ object TestUtils { messageType = "", message = farAck, reportDateTime = - ZonedDateTime.of( - 2020, - 5, - 5, - 3, - 4, - 5, - 3, - UTC, - ).minusHours(12), + ZonedDateTime + .of( + 2020, + 5, + 5, + 3, + 4, + 5, + 3, + UTC, + ).minusHours(12), transmissionFormat = LogbookTransmissionFormat.ERS, integrationDateTime = ZonedDateTime.now(), isEnriched = false, @@ -628,16 +639,17 @@ object TestUtils { messageType = "", message = farAck, reportDateTime = - ZonedDateTime.of( - 2020, - 5, - 5, - 3, - 4, - 5, - 3, - UTC, - ).minusHours(12), + ZonedDateTime + .of( + 2020, + 5, + 5, + 3, + 4, + 5, + 3, + UTC, + ).minusHours(12), transmissionFormat = LogbookTransmissionFormat.ERS, integrationDateTime = ZonedDateTime.now(), isEnriched = false, @@ -652,16 +664,17 @@ object TestUtils { messageType = "FAR", message = far, reportDateTime = - ZonedDateTime.of( - 2020, - 5, - 5, - 3, - 9, - 5, - 3, - UTC, - ).minusHours(12), + ZonedDateTime + .of( + 2020, + 5, + 5, + 3, + 9, + 5, + 3, + UTC, + ).minusHours(12), transmissionFormat = LogbookTransmissionFormat.FLUX, integrationDateTime = ZonedDateTime.now(), isEnriched = false, diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/beacon_malfunction/GetAllBeaconMalfunctionsUTests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/beacon_malfunction/GetAllBeaconMalfunctionsUTests.kt index cbfa55d513..c19ecd4959 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/beacon_malfunction/GetAllBeaconMalfunctionsUTests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/beacon_malfunction/GetAllBeaconMalfunctionsUTests.kt @@ -33,7 +33,20 @@ class GetAllBeaconMalfunctionsUTests { val now = ZonedDateTime.now().minusDays(1) val firstPosition = LastPosition( - null, null, "FR224226850", "224226850", null, null, null, CountryCode.FR, PositionType.AIS, 16.445, 48.2525, 1.8, 180.0, riskFactor = 1.23, + null, + null, + "FR224226850", + "224226850", + null, + null, + null, + CountryCode.FR, + PositionType.AIS, + 16.445, + 48.2525, + 1.8, + 180.0, + riskFactor = 1.23, dateTime = now.minusHours( 4, @@ -42,7 +55,20 @@ class GetAllBeaconMalfunctionsUTests { ) val secondPosition = LastPosition( - null, null, "FR123456785", "224226850", null, null, null, CountryCode.FR, PositionType.AIS, 16.445, 48.2525, 1.8, 180.0, riskFactor = 1.54, + null, + null, + "FR123456785", + "224226850", + null, + null, + null, + CountryCode.FR, + PositionType.AIS, + 16.445, + 48.2525, + 1.8, + 180.0, + riskFactor = 1.54, dateTime = now.minusHours( 3, @@ -51,7 +77,20 @@ class GetAllBeaconMalfunctionsUTests { ) val thirdPosition = LastPosition( - null, null, "FR224226856", "224226850", null, null, null, CountryCode.FR, PositionType.AIS, 16.445, 48.2525, 1.8, 180.0, riskFactor = 1.98, + null, + null, + "FR224226856", + "224226850", + null, + null, + null, + CountryCode.FR, + PositionType.AIS, + 16.445, + 48.2525, + 1.8, + 180.0, + riskFactor = 1.98, dateTime = now.minusHours( 2, @@ -60,7 +99,20 @@ class GetAllBeaconMalfunctionsUTests { ) val fourthPosition = LastPosition( - null, null, "FR224226857", "224226850", null, null, null, CountryCode.FR, PositionType.AIS, 16.445, 48.2525, 1.8, 180.0, riskFactor = 1.24, + null, + null, + "FR224226857", + "224226850", + null, + null, + null, + CountryCode.FR, + PositionType.AIS, + 16.445, + 48.2525, + 1.8, + 180.0, + riskFactor = 1.24, dateTime = now.minusHours( 1, @@ -73,32 +125,77 @@ class GetAllBeaconMalfunctionsUTests { given(beaconMalfunctionsRepository.findAllExceptArchived()).willReturn( listOf( BeaconMalfunction( - 1, "FR224226850", "1236514", "IRCS", - null, VesselIdentifier.INTERNAL_REFERENCE_NUMBER, "BIDUBULE", VesselStatus.AT_SEA, Stage.INITIAL_ENCOUNTER, - ZonedDateTime.now(), null, ZonedDateTime.now(), - beaconNumber = "123465", beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, vesselId = 123, + 1, + "FR224226850", + "1236514", + "IRCS", + null, + VesselIdentifier.INTERNAL_REFERENCE_NUMBER, + "BIDUBULE", + VesselStatus.AT_SEA, + Stage.INITIAL_ENCOUNTER, + ZonedDateTime.now(), + null, + ZonedDateTime.now(), + beaconNumber = "123465", + beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, + vesselId = 123, ), BeaconMalfunction( - 2, "FR224226850", "1236514", "IRCS", - null, VesselIdentifier.INTERNAL_REFERENCE_NUMBER, "BIDUBULE", VesselStatus.AT_SEA, Stage.TARGETING_VESSEL, - ZonedDateTime.now(), ZonedDateTime.now(), ZonedDateTime.now(), - beaconNumber = "123465", beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, endOfBeaconMalfunctionReason = EndOfBeaconMalfunctionReason.RESUMED_TRANSMISSION, vesselId = 123, + 2, + "FR224226850", + "1236514", + "IRCS", + null, + VesselIdentifier.INTERNAL_REFERENCE_NUMBER, + "BIDUBULE", + VesselStatus.AT_SEA, + Stage.TARGETING_VESSEL, + ZonedDateTime.now(), + ZonedDateTime.now(), + ZonedDateTime.now(), + beaconNumber = "123465", + beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, + endOfBeaconMalfunctionReason = EndOfBeaconMalfunctionReason.RESUMED_TRANSMISSION, + vesselId = 123, ), BeaconMalfunction( - 3, "FR000123456", "999999", "CALLME", - null, VesselIdentifier.INTERNAL_REFERENCE_NUMBER, "VESSEL UNSUPERVISED", VesselStatus.AT_SEA, Stage.INITIAL_ENCOUNTER, - ZonedDateTime.now(), null, ZonedDateTime.now(), - beaconNumber = "the now unsupervised beacon", beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, vesselId = 123, + 3, + "FR000123456", + "999999", + "CALLME", + null, + VesselIdentifier.INTERNAL_REFERENCE_NUMBER, + "VESSEL UNSUPERVISED", + VesselStatus.AT_SEA, + Stage.INITIAL_ENCOUNTER, + ZonedDateTime.now(), + null, + ZonedDateTime.now(), + beaconNumber = "the now unsupervised beacon", + beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, + vesselId = 123, ), ), ) given(beaconMalfunctionsRepository.findLastSixtyArchived()).willReturn( listOf( BeaconMalfunction( - 4, "FR123456785", "9876543", "IRCS2", - null, VesselIdentifier.INTERNAL_REFERENCE_NUMBER, "SOMEONE ELSE", VesselStatus.AT_SEA, Stage.ARCHIVED, - ZonedDateTime.now(), null, ZonedDateTime.now(), - beaconNumber = "another active beacon", beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, vesselId = 123, + 4, + "FR123456785", + "9876543", + "IRCS2", + null, + VesselIdentifier.INTERNAL_REFERENCE_NUMBER, + "SOMEONE ELSE", + VesselStatus.AT_SEA, + Stage.ARCHIVED, + ZonedDateTime.now(), + null, + ZonedDateTime.now(), + beaconNumber = "another active beacon", + beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, + vesselId = 123, ), ), ) diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/beacon_malfunction/GetBeaconMalfunctionUTests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/beacon_malfunction/GetBeaconMalfunctionUTests.kt index 8ab9376261..b754110e39 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/beacon_malfunction/GetBeaconMalfunctionUTests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/beacon_malfunction/GetBeaconMalfunctionUTests.kt @@ -38,10 +38,21 @@ class GetBeaconMalfunctionUTests { given(beaconMalfunctionsRepository.find(1)) .willReturn( BeaconMalfunction( - 1, "FR224226850", "1236514", "IRCS", - null, VesselIdentifier.INTERNAL_REFERENCE_NUMBER, "BIDUBULE", VesselStatus.AT_SEA, Stage.ARCHIVED, - ZonedDateTime.now(), null, ZonedDateTime.now(), - beaconNumber = "123465", beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, vesselId = 1, + 1, + "FR224226850", + "1236514", + "IRCS", + null, + VesselIdentifier.INTERNAL_REFERENCE_NUMBER, + "BIDUBULE", + VesselStatus.AT_SEA, + Stage.ARCHIVED, + ZonedDateTime.now(), + null, + ZonedDateTime.now(), + beaconNumber = "123465", + beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, + vesselId = 1, ), ) given( @@ -49,23 +60,44 @@ class GetBeaconMalfunctionUTests { eq(1), any(), ), - ) - .willReturn( - listOf( - BeaconMalfunction( - 1, "FR224226850", "1236514", "IRCS", - null, VesselIdentifier.INTERNAL_REFERENCE_NUMBER, "BIDUBULE", VesselStatus.AT_SEA, Stage.ARCHIVED, - ZonedDateTime.now(), null, ZonedDateTime.now(), - beaconNumber = "123465", beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, vesselId = 1, - ), - BeaconMalfunction( - 2, "FR224226850", "1236514", "IRCS", - null, VesselIdentifier.INTERNAL_REFERENCE_NUMBER, "BIDUBULE", VesselStatus.AT_SEA, Stage.INITIAL_ENCOUNTER, - ZonedDateTime.now(), null, ZonedDateTime.now(), - beaconNumber = "123465", beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, vesselId = 1, - ), + ).willReturn( + listOf( + BeaconMalfunction( + 1, + "FR224226850", + "1236514", + "IRCS", + null, + VesselIdentifier.INTERNAL_REFERENCE_NUMBER, + "BIDUBULE", + VesselStatus.AT_SEA, + Stage.ARCHIVED, + ZonedDateTime.now(), + null, + ZonedDateTime.now(), + beaconNumber = "123465", + beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, + vesselId = 1, ), - ) + BeaconMalfunction( + 2, + "FR224226850", + "1236514", + "IRCS", + null, + VesselIdentifier.INTERNAL_REFERENCE_NUMBER, + "BIDUBULE", + VesselStatus.AT_SEA, + Stage.INITIAL_ENCOUNTER, + ZonedDateTime.now(), + null, + ZonedDateTime.now(), + beaconNumber = "123465", + beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, + vesselId = 1, + ), + ), + ) given(beaconMalfunctionCommentsRepository.findAllByBeaconMalfunctionId(1)).willReturn( listOf( BeaconMalfunctionComment( @@ -90,25 +122,37 @@ class GetBeaconMalfunctionUTests { given(beaconMalfunctionNotificationsRepository.findAllByBeaconMalfunctionId(1)).willReturn( listOf( BeaconMalfunctionNotification( - id = 1, beaconMalfunctionId = 1, dateTimeUtc = now, + id = 1, + beaconMalfunctionId = 1, + dateTimeUtc = now, notificationType = BeaconMalfunctionNotificationType.MALFUNCTION_AT_PORT_INITIAL_NOTIFICATION, communicationMeans = CommunicationMeans.SMS, recipientFunction = BeaconMalfunctionNotificationRecipientFunction.VESSEL_CAPTAIN, - recipientName = "Jack Sparrow", recipientAddressOrNumber = "0000000000", success = true, + recipientName = "Jack Sparrow", + recipientAddressOrNumber = "0000000000", + success = true, ), BeaconMalfunctionNotification( - id = 2, beaconMalfunctionId = 1, dateTimeUtc = now.plusDays(2), + id = 2, + beaconMalfunctionId = 1, + dateTimeUtc = now.plusDays(2), notificationType = BeaconMalfunctionNotificationType.MALFUNCTION_AT_PORT_REMINDER, communicationMeans = CommunicationMeans.SMS, recipientFunction = BeaconMalfunctionNotificationRecipientFunction.VESSEL_CAPTAIN, - recipientName = "Jack Sparrow", recipientAddressOrNumber = "0000000000", success = true, + recipientName = "Jack Sparrow", + recipientAddressOrNumber = "0000000000", + success = true, ), BeaconMalfunctionNotification( - id = 3, beaconMalfunctionId = 1, dateTimeUtc = now.plusNanos(123), + id = 3, + beaconMalfunctionId = 1, + dateTimeUtc = now.plusNanos(123), notificationType = BeaconMalfunctionNotificationType.MALFUNCTION_AT_PORT_INITIAL_NOTIFICATION, communicationMeans = CommunicationMeans.EMAIL, recipientFunction = BeaconMalfunctionNotificationRecipientFunction.VESSEL_CAPTAIN, - recipientName = "Jack Sparrow", recipientAddressOrNumber = "0000000000", success = true, + recipientName = "Jack Sparrow", + recipientAddressOrNumber = "0000000000", + success = true, ), ), ) @@ -121,8 +165,7 @@ class GetBeaconMalfunctionUTests { beaconMalfunctionActionsRepository, lastPositionRepository, beaconMalfunctionNotificationsRepository, - ) - .execute(1) + ).execute(1) // Then assertThat(beaconMalfunctions.resume?.numberOfBeaconsAtSea).isEqualTo(1) diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/beacon_malfunction/GetVesselBeaconMalfunctionsUTests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/beacon_malfunction/GetVesselBeaconMalfunctionsUTests.kt index 6e8168c9e6..ef98e6712f 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/beacon_malfunction/GetVesselBeaconMalfunctionsUTests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/beacon_malfunction/GetVesselBeaconMalfunctionsUTests.kt @@ -34,23 +34,44 @@ class GetVesselBeaconMalfunctionsUTests { 1, now.minusYears(1), ), - ) - .willReturn( - listOf( - BeaconMalfunction( - 1, "FR224226850", "1236514", "IRCS", - null, VesselIdentifier.INTERNAL_REFERENCE_NUMBER, "BIDUBULE", VesselStatus.AT_SEA, Stage.ARCHIVED, - ZonedDateTime.now(), null, ZonedDateTime.now(), - beaconNumber = "123465", beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, vesselId = 1, - ), - BeaconMalfunction( - 2, "FR224226850", "1236514", "IRCS", - null, VesselIdentifier.INTERNAL_REFERENCE_NUMBER, "BIDUBULE", VesselStatus.AT_SEA, Stage.INITIAL_ENCOUNTER, - ZonedDateTime.now(), null, ZonedDateTime.now(), - beaconNumber = "123465", beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, vesselId = 1, - ), + ).willReturn( + listOf( + BeaconMalfunction( + 1, + "FR224226850", + "1236514", + "IRCS", + null, + VesselIdentifier.INTERNAL_REFERENCE_NUMBER, + "BIDUBULE", + VesselStatus.AT_SEA, + Stage.ARCHIVED, + ZonedDateTime.now(), + null, + ZonedDateTime.now(), + beaconNumber = "123465", + beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, + vesselId = 1, + ), + BeaconMalfunction( + 2, + "FR224226850", + "1236514", + "IRCS", + null, + VesselIdentifier.INTERNAL_REFERENCE_NUMBER, + "BIDUBULE", + VesselStatus.AT_SEA, + Stage.INITIAL_ENCOUNTER, + ZonedDateTime.now(), + null, + ZonedDateTime.now(), + beaconNumber = "123465", + beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, + vesselId = 1, ), - ) + ), + ) given(beaconMalfunctionCommentsRepository.findAllByBeaconMalfunctionId(1)).willReturn( listOf( BeaconMalfunctionComment( @@ -79,12 +100,15 @@ class GetVesselBeaconMalfunctionsUTests { beaconMalfunctionsRepository, beaconMalfunctionCommentsRepository, beaconMalfunctionActionsRepository, - ) - .execute(1, now.minusYears(1)) + ).execute(1, now.minusYears(1)) // Then assertThat(enrichedBeaconMalfunctions.history).hasSize(1) - assertThat(enrichedBeaconMalfunctions.history.first().beaconMalfunction.id).isEqualTo(1) + assertThat( + enrichedBeaconMalfunctions.history + .first() + .beaconMalfunction.id, + ).isEqualTo(1) assertThat(enrichedBeaconMalfunctions.history.first().actions).hasSize(1) assertThat(enrichedBeaconMalfunctions.history.first().comments).hasSize(1) assertThat(enrichedBeaconMalfunctions.current?.beaconMalfunction?.id).isEqualTo(2) diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/beacon_malfunction/RequestNotificationUTests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/beacon_malfunction/RequestNotificationUTests.kt index 796e2d088a..3daf226be4 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/beacon_malfunction/RequestNotificationUTests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/beacon_malfunction/RequestNotificationUTests.kt @@ -22,8 +22,7 @@ class RequestNotificationUTests { catchThrowable { RequestNotification( beaconMalfunctionsRepository, - ) - .execute(1, BeaconMalfunctionNotificationType.MALFUNCTION_NOTIFICATION_TO_FOREIGN_FMC, null) + ).execute(1, BeaconMalfunctionNotificationType.MALFUNCTION_NOTIFICATION_TO_FOREIGN_FMC, null) } // Then @@ -38,8 +37,7 @@ class RequestNotificationUTests { // When RequestNotification( beaconMalfunctionsRepository, - ) - .execute(1, BeaconMalfunctionNotificationType.MALFUNCTION_NOTIFICATION_TO_FOREIGN_FMC, "ABC") + ).execute(1, BeaconMalfunctionNotificationType.MALFUNCTION_NOTIFICATION_TO_FOREIGN_FMC, "ABC") // Then Mockito.verify(beaconMalfunctionsRepository).requestNotification( @@ -54,12 +52,11 @@ class RequestNotificationUTests { // When RequestNotification( beaconMalfunctionsRepository, + ).execute( + 2, + BeaconMalfunctionNotificationType.MALFUNCTION_AT_SEA_INITIAL_NOTIFICATION, + "Should not be passed to repository", ) - .execute( - 2, - BeaconMalfunctionNotificationType.MALFUNCTION_AT_SEA_INITIAL_NOTIFICATION, - "Should not be passed to repository", - ) // Then Mockito.verify(beaconMalfunctionsRepository).requestNotification( diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/beacon_malfunction/UpdateBeaconMalfunctionUTests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/beacon_malfunction/UpdateBeaconMalfunctionUTests.kt index 7ebd61dfd7..c7250d80e6 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/beacon_malfunction/UpdateBeaconMalfunctionUTests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/beacon_malfunction/UpdateBeaconMalfunctionUTests.kt @@ -39,8 +39,7 @@ class UpdateBeaconMalfunctionUTests { beaconMalfunctionsRepository, beaconMalfunctionActionRepository, getBeaconMalfunction, - ) - .execute(1, null, null, null) + ).execute(1, null, null, null) } // Then @@ -57,8 +56,7 @@ class UpdateBeaconMalfunctionUTests { beaconMalfunctionsRepository, beaconMalfunctionActionRepository, getBeaconMalfunction, - ) - .execute(1, null, Stage.ARCHIVED, null) + ).execute(1, null, Stage.ARCHIVED, null) } // Then @@ -73,10 +71,21 @@ class UpdateBeaconMalfunctionUTests { // Given given(beaconMalfunctionsRepository.find(any())).willReturn( BeaconMalfunction( - 1, "CFR", "EXTERNAL_IMMAT", "IRCS", - "fr", VesselIdentifier.INTERNAL_REFERENCE_NUMBER, "BIDUBULE", VesselStatus.AT_SEA, Stage.INITIAL_ENCOUNTER, - ZonedDateTime.now(), null, ZonedDateTime.now(), - beaconNumber = "123465", beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, vesselId = 123, + 1, + "CFR", + "EXTERNAL_IMMAT", + "IRCS", + "fr", + VesselIdentifier.INTERNAL_REFERENCE_NUMBER, + "BIDUBULE", + VesselStatus.AT_SEA, + Stage.INITIAL_ENCOUNTER, + ZonedDateTime.now(), + null, + ZonedDateTime.now(), + beaconNumber = "123465", + beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, + vesselId = 123, ), ) given(beaconMalfunctionActionRepository.findAllByBeaconMalfunctionId(any())).willReturn( @@ -96,10 +105,21 @@ class UpdateBeaconMalfunctionUTests { BeaconMalfunctionResumeAndDetails( beaconMalfunction = BeaconMalfunction( - 1, "CFR", "EXTERNAL_IMMAT", "IRCS", - "fr", VesselIdentifier.INTERNAL_REFERENCE_NUMBER, "BIDUBULE", VesselStatus.AT_SEA, Stage.INITIAL_ENCOUNTER, - ZonedDateTime.now(), null, ZonedDateTime.now(), - beaconNumber = "123465", beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, vesselId = 123, + 1, + "CFR", + "EXTERNAL_IMMAT", + "IRCS", + "fr", + VesselIdentifier.INTERNAL_REFERENCE_NUMBER, + "BIDUBULE", + VesselStatus.AT_SEA, + Stage.INITIAL_ENCOUNTER, + ZonedDateTime.now(), + null, + ZonedDateTime.now(), + beaconNumber = "123465", + beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, + vesselId = 123, ), comments = listOf( @@ -131,12 +151,16 @@ class UpdateBeaconMalfunctionUTests { notifications = listOf( BeaconMalfunctionNotification( - id = 1, beaconMalfunctionId = 1, dateTimeUtc = ZonedDateTime.now(), + id = 1, + beaconMalfunctionId = 1, + dateTimeUtc = ZonedDateTime.now(), notificationType = BeaconMalfunctionNotificationType.MALFUNCTION_AT_PORT_INITIAL_NOTIFICATION, communicationMeans = CommunicationMeans.SMS, recipientFunction = BeaconMalfunctionNotificationRecipientFunction.VESSEL_CAPTAIN, - recipientName = "Jack Sparrow", recipientAddressOrNumber = "0000000000", - success = false, errorMessage = "This message could not be delivered", + recipientName = "Jack Sparrow", + recipientAddressOrNumber = "0000000000", + success = false, + errorMessage = "This message could not be delivered", ), ), ), @@ -150,8 +174,7 @@ class UpdateBeaconMalfunctionUTests { beaconMalfunctionsRepository, beaconMalfunctionActionRepository, getBeaconMalfunction, - ) - .execute(1, VesselStatus.AT_SEA, null, null) + ).execute(1, VesselStatus.AT_SEA, null, null) // Then assertThat(updatedBeaconMalfunction.actions).hasSize(1) diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/fleet_segment/ComputeFleetSegmentsUTests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/fleet_segment/ComputeFleetSegmentsUTests.kt index d737ab606e..888ba20373 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/fleet_segment/ComputeFleetSegmentsUTests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/fleet_segment/ComputeFleetSegmentsUTests.kt @@ -135,8 +135,7 @@ class ComputeFleetSegmentsUTests { fleetSegmentRepository, vesselRepository, fixedClock, - ) - .execute(1, speciesCatches) + ).execute(1, speciesCatches) // Then assertThat(fleetSegments).hasSize(1) @@ -185,8 +184,7 @@ class ComputeFleetSegmentsUTests { fleetSegmentRepository, vesselRepository, fixedClock, - ) - .execute(1, speciesCatches) + ).execute(1, speciesCatches) // Then assertThat(fleetSegments).hasSize(1) @@ -243,8 +241,7 @@ class ComputeFleetSegmentsUTests { fleetSegmentRepository, vesselRepository, fixedClock, - ) - .execute(1, speciesCatches) + ).execute(1, speciesCatches) // Then assertThat(fleetSegments).hasSize(1) @@ -301,8 +298,7 @@ class ComputeFleetSegmentsUTests { fleetSegmentRepository, vesselRepository, fixedClock, - ) - .execute(1, speciesCatches) + ).execute(1, speciesCatches) // Then assertThat(fleetSegments).hasSize(1) @@ -351,8 +347,7 @@ class ComputeFleetSegmentsUTests { fleetSegmentRepository, vesselRepository, fixedClock, - ) - .execute(1, speciesCatches) + ).execute(1, speciesCatches) // Then assertThat(fleetSegments).hasSize(1) @@ -401,8 +396,7 @@ class ComputeFleetSegmentsUTests { fleetSegmentRepository, vesselRepository, fixedClock, - ) - .execute(1, speciesCatches) + ).execute(1, speciesCatches) // Then assertThat(fleetSegments).hasSize(1) @@ -432,8 +426,7 @@ class ComputeFleetSegmentsUTests { fleetSegmentRepository, vesselRepository, fixedClock, - ) - .execute(1, listOf()) + ).execute(1, listOf()) // Then assertThat(fleetSegments).hasSize(0) diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/TestUtils.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/TestUtils.kt index b66cce8974..59e0049e37 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/TestUtils.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/TestUtils.kt @@ -26,26 +26,27 @@ object TestUtils { } fun getDummyMissionActions(missionIds: List): List { - return missionIds.map { missionId -> - // Generate the number of mission actions corresponding to the id of the mission - // i.e. if the missionId is 5, 5 actions with ids [1, 2, 3, 4, 5] will be generated - return@map (1..missionId).toList().map { - MissionAction( - id = (0..500).random(), - vesselId = 1, - missionId = it, - actionDatetimeUtc = ZonedDateTime.now(), - actionType = MissionActionType.LAND_CONTROL, - seizureAndDiversion = true, - isDeleted = false, - hasSomeGearsSeized = false, - hasSomeSpeciesSeized = false, - isFromPoseidon = false, - completion = Completion.TO_COMPLETE, - userTrigram = "LTH", - flagState = CountryCode.FR, - ) - } - }.flatten() + return missionIds + .map { missionId -> + // Generate the number of mission actions corresponding to the id of the mission + // i.e. if the missionId is 5, 5 actions with ids [1, 2, 3, 4, 5] will be generated + return@map (1..missionId).toList().map { + MissionAction( + id = (0..500).random(), + vesselId = 1, + missionId = it, + actionDatetimeUtc = ZonedDateTime.now(), + actionType = MissionActionType.LAND_CONTROL, + seizureAndDiversion = true, + isDeleted = false, + hasSomeGearsSeized = false, + hasSomeSpeciesSeized = false, + isFromPoseidon = false, + completion = Completion.TO_COMPLETE, + userTrigram = "LTH", + flagState = CountryCode.FR, + ) + } + }.flatten() } } diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetActivityReportsUTests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetActivityReportsUTests.kt index a9358d8ba5..99fa74bebd 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetActivityReportsUTests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetActivityReportsUTests.kt @@ -1084,13 +1084,12 @@ class GetActivityReportsUTests { companion object { @JvmStatic - private fun getDoubleCountTestCases(): Stream { - return Stream.of( + private fun getDoubleCountTestCases(): Stream = + Stream.of( Arguments.of(MissionActionType.LAND_CONTROL, JointDeploymentPlan.WESTERN_WATERS), Arguments.of(MissionActionType.SEA_CONTROL, JointDeploymentPlan.WESTERN_WATERS), Arguments.of(MissionActionType.LAND_CONTROL, JointDeploymentPlan.MEDITERRANEAN_AND_EASTERN_ATLANTIC), Arguments.of(MissionActionType.SEA_CONTROL, JointDeploymentPlan.MEDITERRANEAN_AND_EASTERN_ATLANTIC), ) - } } } diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetVesselControlsUTests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetVesselControlsUTests.kt index bc539c419e..83a6caa889 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetVesselControlsUTests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetVesselControlsUTests.kt @@ -133,7 +133,13 @@ class GetVesselControlsUTests { assertThat(controlResumeAndControls.numberOfControlsWithSomeSpeciesSeized).isEqualTo(2) assertThat(controlResumeAndControls.controls.first().portName).isEqualTo("Al Jazeera Port") - assertThat(controlResumeAndControls.controls.first().gearOnboard.first().gearName).isEqualTo( + assertThat( + controlResumeAndControls.controls + .first() + .gearOnboard + .first() + .gearName, + ).isEqualTo( "Chalut de fond", ) } diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationUTests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationUTests.kt index 960ccf4996..202ab4d819 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationUTests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationUTests.kt @@ -54,8 +54,7 @@ class GetPriorNotificationUTests { fakePriorNotification.reportId!!, fakePriorNotification.logbookMessageAndValue.logbookMessage.operationDateTime, ), - ) - .willReturn(fakePriorNotification) + ).willReturn(fakePriorNotification) // When val result = @@ -116,8 +115,7 @@ class GetPriorNotificationUTests { fakeLogbookMessageReferenceReportId, fakePriorNotification.logbookMessageAndValue.logbookMessage.operationDateTime, ), - ) - .willReturn(fakePriorNotification) + ).willReturn(fakePriorNotification) // When val result = diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationsITests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationsITests.kt index 7e821f68f3..9a6f91f9f4 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationsITests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationsITests.kt @@ -89,8 +89,7 @@ class GetPriorNotificationsITests : AbstractDBTests() { .first { it.logbookMessageAndValue.value.predictedArrivalDatetimeUtc != null } assertThat( firstPriorNotificationWithNonNullArrivalDate.logbookMessageAndValue.value.predictedArrivalDatetimeUtc, - ) - .isBefore(ZonedDateTime.parse("2024-01-01T00:00:00Z")) + ).isBefore(ZonedDateTime.parse("2024-01-01T00:00:00Z")) assertThat(result.data).hasSizeGreaterThan(0) } @@ -122,8 +121,7 @@ class GetPriorNotificationsITests : AbstractDBTests() { .first { it.logbookMessageAndValue.value.predictedArrivalDatetimeUtc != null } assertThat( firstPriorNotificationWithNonNullArrivalDate.logbookMessageAndValue.value.predictedArrivalDatetimeUtc, - ) - .isAfter(ZonedDateTime.now().minusHours(1)) + ).isAfter(ZonedDateTime.now().minusHours(1)) assertThat(result.data).hasSizeGreaterThan(0) } @@ -155,8 +153,7 @@ class GetPriorNotificationsITests : AbstractDBTests() { .first { it.logbookMessageAndValue.value.predictedLandingDatetimeUtc != null } assertThat( firstPriorNotificationWithNonNullLandingDate.logbookMessageAndValue.value.predictedLandingDatetimeUtc, - ) - .isEqualTo(ZonedDateTime.parse("2023-01-01T10:30:00Z")) + ).isEqualTo(ZonedDateTime.parse("2023-01-01T10:30:00Z")) assertThat(result.data).hasSizeGreaterThan(0) } @@ -188,8 +185,7 @@ class GetPriorNotificationsITests : AbstractDBTests() { .first { it.logbookMessageAndValue.value.predictedLandingDatetimeUtc != null } assertThat( firstPriorNotificationWithNonNullLandingDate.logbookMessageAndValue.value.predictedLandingDatetimeUtc, - ) - .isAfter(ZonedDateTime.now().plusHours(4)) + ).isAfter(ZonedDateTime.now().plusHours(4)) assertThat(result.data).hasSizeGreaterThan(0) } diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationsUTests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationsUTests.kt index c66d1d5fdf..6f7339832f 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationsUTests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationsUTests.kt @@ -158,10 +158,16 @@ class GetPriorNotificationsUTests { // Then assertThat(result.data).hasSize(2) - assertThat(result.data[0].logbookMessageAndValue.logbookMessage.reportId).isEqualTo( + assertThat( + result.data[0] + .logbookMessageAndValue.logbookMessage.reportId, + ).isEqualTo( "FAKE_REPORT_ID_1", ) - assertThat(result.data[1].logbookMessageAndValue.logbookMessage.reportId).isEqualTo( + assertThat( + result.data[1] + .logbookMessageAndValue.logbookMessage.reportId, + ).isEqualTo( "FAKE_REPORT_ID_2_COR", ) } diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/VerifyAndSendPriorNotificationITests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/VerifyAndSendPriorNotificationITests.kt index 0dcc9cc267..f8bb8a9b78 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/VerifyAndSendPriorNotificationITests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/VerifyAndSendPriorNotificationITests.kt @@ -51,8 +51,8 @@ class VerifyAndSendPriorNotificationITests : AbstractDBTests() { companion object { @JvmStatic - fun getTestCases(): Stream { - return Stream.of( + fun getTestCases(): Stream = + Stream.of( // ------------------------------------------------------------- // Logbook prior notifications // "00000" -> "00101" @@ -458,7 +458,6 @@ class VerifyAndSendPriorNotificationITests : AbstractDBTests() { PriorNotificationState.PENDING_SEND, ), ) - } } @ParameterizedTest diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/VerifyAndSendPriorNotificationUTests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/VerifyAndSendPriorNotificationUTests.kt index 92891a31f9..762798f28d 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/VerifyAndSendPriorNotificationUTests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/VerifyAndSendPriorNotificationUTests.kt @@ -31,8 +31,7 @@ class VerifyAndSendPriorNotificationUTests { fakePriorNotification.reportId!!, fakePriorNotification.logbookMessageAndValue.logbookMessage.operationDateTime, ), - ) - .willReturn(fakePriorNotification) + ).willReturn(fakePriorNotification) given(manualPriorNotificationRepository.findByReportId(fakePriorNotification.reportId!!)) .willReturn(null) given( @@ -41,8 +40,7 @@ class VerifyAndSendPriorNotificationUTests { fakePriorNotification.logbookMessageAndValue.logbookMessage.operationDateTime, false, ), - ) - .willReturn(fakePriorNotification) + ).willReturn(fakePriorNotification) // When val result = @@ -70,8 +68,7 @@ class VerifyAndSendPriorNotificationUTests { fakePriorNotification.reportId!!, fakePriorNotification.logbookMessageAndValue.logbookMessage.operationDateTime, ), - ) - .willReturn(null) + ).willReturn(null) given(manualPriorNotificationRepository.findByReportId(fakePriorNotification.reportId!!)) .willReturn(fakePriorNotification) given( @@ -80,8 +77,7 @@ class VerifyAndSendPriorNotificationUTests { fakePriorNotification.logbookMessageAndValue.logbookMessage.operationDateTime, true, ), - ) - .willReturn(fakePriorNotification) + ).willReturn(fakePriorNotification) // When val result = diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/vessel/GetLogbookMessagesUTests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/vessel/GetLogbookMessagesUTests.kt index d83fb9d345..961cb136c6 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/vessel/GetLogbookMessagesUTests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/vessel/GetLogbookMessagesUTests.kt @@ -77,8 +77,7 @@ class GetLogbookMessagesUTests { speciesRepository, portRepository, logbookRawMessageRepository, - ) - .execute("FR224226850", ZonedDateTime.now().minusMinutes(5), ZonedDateTime.now(), "345") + ).execute("FR224226850", ZonedDateTime.now().minusMinutes(5), ZonedDateTime.now(), "345") // Then assertThat(ersMessages).hasSize(6) @@ -99,10 +98,34 @@ class GetLogbookMessagesUTests { assertThat(ersMessages[1].rawMessage).isEqualTo("DUMMY XML MESSAGE") val far = ersMessages[1].message as FAR assertThat(far.hauls.size).isEqualTo(1) - assertThat(far.hauls.first().catches.first().species).isEqualTo("SMV") - assertThat(far.hauls.first().catches.first().speciesName).isEqualTo("STOMIAS BREVIBARBATUS") - assertThat(far.hauls.first().catches.last().species).isEqualTo("PNB") - assertThat(far.hauls.first().catches.last().speciesName).isEqualTo("CREVETTE ROYALE ROSE") + assertThat( + far.hauls + .first() + .catches + .first() + .species, + ).isEqualTo("SMV") + assertThat( + far.hauls + .first() + .catches + .first() + .speciesName, + ).isEqualTo("STOMIAS BREVIBARBATUS") + assertThat( + far.hauls + .first() + .catches + .last() + .species, + ).isEqualTo("PNB") + assertThat( + far.hauls + .first() + .catches + .last() + .speciesName, + ).isEqualTo("CREVETTE ROYALE ROSE") assertThat(far.hauls.first().gearName).isEqualTo("Chaluts de fond à panneaux") assertThat(ersMessages[2].message).isInstanceOf(COE::class.java) @@ -152,8 +175,7 @@ class GetLogbookMessagesUTests { speciesRepository, portRepository, logbookRawMessageRepository, - ) - .execute("FR224226850", ZonedDateTime.now().minusMinutes(5), ZonedDateTime.now(), "345") + ).execute("FR224226850", ZonedDateTime.now().minusMinutes(5), ZonedDateTime.now(), "345") // Then assertThat(ersMessages).hasSize(2) @@ -191,8 +213,7 @@ class GetLogbookMessagesUTests { speciesRepository, portRepository, logbookRawMessageRepository, - ) - .execute("FR224226850", ZonedDateTime.now().minusMinutes(5), ZonedDateTime.now(), "345") + ).execute("FR224226850", ZonedDateTime.now().minusMinutes(5), ZonedDateTime.now(), "345") // Then assertThat(ersMessages).hasSize(3) @@ -270,8 +291,7 @@ class GetLogbookMessagesUTests { speciesRepository, portRepository, logbookRawMessageRepository, - ) - .execute("FR224226850", ZonedDateTime.now().minusMinutes(5), ZonedDateTime.now(), "345") + ).execute("FR224226850", ZonedDateTime.now().minusMinutes(5), ZonedDateTime.now(), "345") // Then assertThat(ersMessages).hasSize(3) @@ -300,8 +320,7 @@ class GetLogbookMessagesUTests { speciesRepository, portRepository, logbookRawMessageRepository, - ) - .execute("FR224226850", ZonedDateTime.now().minusMinutes(5), ZonedDateTime.now(), "345") + ).execute("FR224226850", ZonedDateTime.now().minusMinutes(5), ZonedDateTime.now(), "345") // Then assertThat(ersMessages).hasSize(3) @@ -327,8 +346,7 @@ class GetLogbookMessagesUTests { speciesRepository, portRepository, logbookRawMessageRepository, - ) - .execute("FR224226850", ZonedDateTime.now().minusMinutes(5), ZonedDateTime.now(), "345") + ).execute("FR224226850", ZonedDateTime.now().minusMinutes(5), ZonedDateTime.now(), "345") // Then assertThat(ersMessages).hasSize(3) @@ -360,8 +378,7 @@ class GetLogbookMessagesUTests { speciesRepository, portRepository, logbookRawMessageRepository, - ) - .execute("FR224226850", ZonedDateTime.now().minusMinutes(5), ZonedDateTime.now(), "345") + ).execute("FR224226850", ZonedDateTime.now().minusMinutes(5), ZonedDateTime.now(), "345") // Then assertThat(ersMessages).hasSize(6) @@ -386,16 +403,17 @@ class GetLogbookMessagesUTests { messageType = "", message = Acknowledgment().apply { returnStatus = "000" }, reportDateTime = - ZonedDateTime.of( - 2020, - 5, - 5, - 3, - 4, - 5, - 3, - UTC, - ).minusHours(12), + ZonedDateTime + .of( + 2020, + 5, + 5, + 3, + 4, + 5, + 3, + UTC, + ).minusHours(12), transmissionFormat = LogbookTransmissionFormat.ERS, integrationDateTime = ZonedDateTime.now(), isEnriched = false, @@ -416,8 +434,7 @@ class GetLogbookMessagesUTests { speciesRepository, portRepository, logbookRawMessageRepository, - ) - .execute("FR224226850", ZonedDateTime.now().minusMinutes(5), ZonedDateTime.now(), "345") + ).execute("FR224226850", ZonedDateTime.now().minusMinutes(5), ZonedDateTime.now(), "345") // Then assertThat(ersMessages).hasSize(6) diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/vessel/GetVesselPositionsUTests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/vessel/GetVesselPositionsUTests.kt index 55c2843af0..242a5d3d64 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/vessel/GetVesselPositionsUTests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/vessel/GetVesselPositionsUTests.kt @@ -141,8 +141,18 @@ class GetVesselPositionsUTests { // Then assertThat(pair.first).isTrue runBlocking { - assertThat(pair.second.await().first().dateTime).isEqualTo(now.minusHours(4)) - assertThat(pair.second.await().last().dateTime).isEqualTo(now.minusHours(1)) + assertThat( + pair.second + .await() + .first() + .dateTime, + ).isEqualTo(now.minusHours(4)) + assertThat( + pair.second + .await() + .last() + .dateTime, + ).isEqualTo(now.minusHours(1)) } } diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/vessel/GetVesselUTests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/vessel/GetVesselUTests.kt index 03860a2f9b..2a3e1a4aef 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/vessel/GetVesselUTests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/vessel/GetVesselUTests.kt @@ -151,17 +151,16 @@ class GetVesselUTests { riskFactorRepository, beaconRepository, producerOrganizationMembershipRepository, + ).execute( + 123, + "FR224226850", + "", + "", + VesselTrackDepth.TWELVE_HOURS, + VesselIdentifier.INTERNAL_REFERENCE_NUMBER, + null, + null, ) - .execute( - 123, - "FR224226850", - "", - "", - VesselTrackDepth.TWELVE_HOURS, - VesselIdentifier.INTERNAL_REFERENCE_NUMBER, - null, - null, - ) } // Then @@ -169,8 +168,16 @@ class GetVesselUTests { assertThat(pair.second.vessel?.id).isEqualTo(123) assertThat(pair.second.vessel?.hasVisioCaptures).isTrue() assertThat(pair.second.beacon?.beaconNumber).isEqualTo("A_BEACON_NUMBER") - assertThat(pair.second.positions.first().dateTime).isEqualTo(now.minusHours(4)) - assertThat(pair.second.positions.last().dateTime).isEqualTo(now.minusHours(1)) + assertThat( + pair.second.positions + .first() + .dateTime, + ).isEqualTo(now.minusHours(4)) + assertThat( + pair.second.positions + .last() + .dateTime, + ).isEqualTo(now.minusHours(1)) assertThat(pair.second.vesselRiskFactor.impactRiskFactor).isEqualTo(2.3) assertThat(pair.second.vesselRiskFactor.riskFactor).isEqualTo(3.2) assertThat(pair.second.producerOrganization?.organizationName).isEqualTo("Example Name 1") @@ -195,17 +202,16 @@ class GetVesselUTests { riskFactorRepository, beaconRepository, producerOrganizationMembershipRepository, + ).execute( + 123, + "FR224226850", + "", + "", + VesselTrackDepth.TWELVE_HOURS, + VesselIdentifier.INTERNAL_REFERENCE_NUMBER, + null, + null, ) - .execute( - 123, - "FR224226850", - "", - "", - VesselTrackDepth.TWELVE_HOURS, - VesselIdentifier.INTERNAL_REFERENCE_NUMBER, - null, - null, - ) } // Then @@ -233,17 +239,16 @@ class GetVesselUTests { riskFactorRepository, beaconRepository, producerOrganizationMembershipRepository, + ).execute( + 123, + "FR224226850", + "", + "", + VesselTrackDepth.TWELVE_HOURS, + VesselIdentifier.INTERNAL_REFERENCE_NUMBER, + null, + null, ) - .execute( - 123, - "FR224226850", - "", - "", - VesselTrackDepth.TWELVE_HOURS, - VesselIdentifier.INTERNAL_REFERENCE_NUMBER, - null, - null, - ) } // Then diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/fakers/FleetSegmentFaker.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/fakers/FleetSegmentFaker.kt index 8f9eb8d54b..568917d27a 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/fakers/FleetSegmentFaker.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/fakers/FleetSegmentFaker.kt @@ -12,8 +12,8 @@ class FleetSegmentFaker { targetSpecies: List = listOf("SPECIES1", "SPECIES2"), impactRiskFactor: Double = 1.0, year: Int = 2023, - ): FleetSegment { - return FleetSegment( + ): FleetSegment = + FleetSegment( segment = segment, segmentName = segmentName, gears = gears, @@ -28,6 +28,5 @@ class FleetSegmentFaker { priority = 0.0, vesselTypes = listOf(), ) - } } } diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/fakers/FullControlUnitFaker.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/fakers/FullControlUnitFaker.kt index 336add85b1..0d61961214 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/fakers/FullControlUnitFaker.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/fakers/FullControlUnitFaker.kt @@ -22,8 +22,8 @@ class FullControlUnitFaker { isArchived: Boolean = false, name: String = "Fake Control Unit Name", termsNote: String? = "Default Terms Note", - ): FullControlUnit { - return FullControlUnit( + ): FullControlUnit = + FullControlUnit( id = id, areaNote = areaNote, administration = administration, @@ -38,19 +38,17 @@ class FullControlUnitFaker { name = name, termsNote = termsNote, ) - } private fun fakeAdministration( id: Int = 1, isArchived: Boolean = false, name: String = "Fake Administration Name", - ): Administration { - return Administration( + ): Administration = + Administration( id = id, isArchived = isArchived, name = name, ) - } private fun fakeControlUnitContact( id: Int = 1, @@ -60,8 +58,8 @@ class FullControlUnitFaker { isSmsSubscriptionContact: Boolean = false, name: String = "Fake Contact Name", phone: String? = "+1234567890", - ): ControlUnitContact { - return ControlUnitContact( + ): ControlUnitContact = + ControlUnitContact( id = id, controlUnitId = controlUnitId, email = email, @@ -70,7 +68,6 @@ class FullControlUnitFaker { name = name, phone = phone, ) - } private fun fakeFullControlUnitResource( id: Int = 1, @@ -83,8 +80,8 @@ class FullControlUnitFaker { station: Station = StationFaker.fakeStation(), stationId: Int = station.id, type: ControlUnitResourceType = ControlUnitResourceType.FRIGATE, - ): FullControlUnitResource { - return FullControlUnitResource( + ): FullControlUnitResource = + FullControlUnitResource( id = id, controlUnit = controlUnit, controlUnitId = controlUnitId, @@ -96,7 +93,6 @@ class FullControlUnitFaker { stationId = stationId, type = type, ) - } private fun fakeControlUnit( id: Int = 1, @@ -106,8 +102,8 @@ class FullControlUnitFaker { isArchived: Boolean = false, name: String = "Fake Control Unit Name", termsNote: String? = "Default Terms Note", - ): ControlUnit { - return ControlUnit( + ): ControlUnit = + ControlUnit( id = id, areaNote = areaNote, administrationId = administrationId, @@ -116,16 +112,14 @@ class FullControlUnitFaker { name = name, termsNote = termsNote, ) - } private fun fakeControlUnitDepartmentArea( inseeCode: String = "00000", name: String = "Fake Department Area Name", - ): ControlUnitDepartmentArea { - return ControlUnitDepartmentArea( + ): ControlUnitDepartmentArea = + ControlUnitDepartmentArea( inseeCode = inseeCode, name = name, ) - } } } diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/fakers/LogbookMessageFaker.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/fakers/LogbookMessageFaker.kt index e3b2876b7c..f9f99d1a64 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/fakers/LogbookMessageFaker.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/fakers/LogbookMessageFaker.kt @@ -7,8 +7,8 @@ import java.time.ZonedDateTime class LogbookMessageFaker { companion object { - fun fakePnoLogbookMessage(index: Int): LogbookMessage { - return LogbookMessage( + fun fakePnoLogbookMessage(index: Int): LogbookMessage = + LogbookMessage( id = index.toLong(), reportId = "FAKE_REPORT_ID_$index", referencedReportId = null, @@ -24,7 +24,6 @@ class LogbookMessageFaker { reportDateTime = ZonedDateTime.now(), transmissionFormat = LogbookTransmissionFormat.ERS, ) - } fun fakePnoLogbookMessage( id: Long? = null, @@ -55,8 +54,8 @@ class LogbookMessageFaker { tripSegments: List? = emptyList(), vesselId: Int? = null, vesselName: String? = null, - ): LogbookMessage { - return LogbookMessage( + ): LogbookMessage = + LogbookMessage( id = id, reportId = reportId, referencedReportId = referencedReportId, @@ -86,7 +85,6 @@ class LogbookMessageFaker { vesselId = vesselId, vesselName = vesselName, ) - } fun fakeLogbookFishingCatch( conversionFactor: Double? = null, @@ -102,8 +100,8 @@ class LogbookMessageFaker { speciesName: String? = "Fake Species HKE", statisticalRectangle: String? = null, weight: Double? = 42.0, - ): LogbookFishingCatch { - return LogbookFishingCatch( + ): LogbookFishingCatch = + LogbookFishingCatch( conversionFactor = conversionFactor, economicZone = economicZone, effortZone = effortZone, @@ -118,10 +116,9 @@ class LogbookMessageFaker { statisticalRectangle = statisticalRectangle, weight = weight, ) - } - fun fakePnoMessage(): PNO { - return PNO().apply { + fun fakePnoMessage(): PNO = + PNO().apply { hasPortEntranceAuthorization = null hasPortLandingAuthorization = null catchOnboard = listOf(fakeLogbookFishingCatch()) @@ -144,6 +141,5 @@ class LogbookMessageFaker { purpose = LogbookMessagePurpose.LAN statisticalRectangle = null } - } } } diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/fakers/PortFaker.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/fakers/PortFaker.kt index fa3e2c2511..92988f178e 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/fakers/PortFaker.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/fakers/PortFaker.kt @@ -13,8 +13,8 @@ class PortFaker { longitude: Double? = null, name: String = "Fake Port $locode", region: String? = null, - ): Port { - return Port( + ): Port = + Port( locode = locode, countryCode = countryCode, facade = facade, @@ -24,6 +24,5 @@ class PortFaker { name = name, region = region, ) - } } } diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/fakers/PriorNotificationFaker.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/fakers/PriorNotificationFaker.kt index 658ad24e91..c68723e55d 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/fakers/PriorNotificationFaker.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/fakers/PriorNotificationFaker.kt @@ -7,8 +7,8 @@ import java.time.ZonedDateTime class PriorNotificationFaker { companion object { - fun fakePriorNotification(index: Int = 1): PriorNotification { - return PriorNotification( + fun fakePriorNotification(index: Int = 1): PriorNotification = + PriorNotification( reportId = "FAKE_REPORT_ID_$index", createdAt = ZonedDateTime.now(), didNotFishAfterZeroNotice = false, @@ -26,6 +26,5 @@ class PriorNotificationFaker { vessel = VesselFaker.fakeVessel(), lastControlDateTime = null, ) - } } } diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/fakers/StationFaker.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/fakers/StationFaker.kt index 4d1d7cb21a..eb8954bb3c 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/fakers/StationFaker.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/fakers/StationFaker.kt @@ -9,13 +9,12 @@ class StationFaker { latitude: Double = 48.8566, longitude: Double = 2.3522, name: String = "Fake Station Name", - ): Station { - return Station( + ): Station = + Station( id = id, latitude = latitude, longitude = longitude, name = name, ) - } } } diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/fakers/VesselFaker.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/fakers/VesselFaker.kt index 0d78e39f3b..cc5ef9c0ee 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/fakers/VesselFaker.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/fakers/VesselFaker.kt @@ -41,8 +41,8 @@ class VesselFaker { logbookSoftware: String? = null, hasLogbookEsacapt: Boolean = false, hasVisioCaptures: Boolean? = null, - ): Vessel { - return Vessel( + ): Vessel = + Vessel( id = id, internalReferenceNumber = internalReferenceNumber, imo = imo, @@ -78,6 +78,5 @@ class VesselFaker { hasLogbookEsacapt = hasLogbookEsacapt, hasVisioCaptures = hasVisioCaptures, ) - } } } diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/SecurityConfigITests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/SecurityConfigITests.kt index 71df711839..156cd6eb86 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/SecurityConfigITests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/SecurityConfigITests.kt @@ -60,10 +60,11 @@ class SecurityConfigITests { ) // When - mockMvc.perform( - get("/bff/v1/ports") - .header("Authorization", "Bearer $jwtSignedByAnotherPrivateKey"), - ) + mockMvc + .perform( + get("/bff/v1/ports") + .header("Authorization", "Bearer $jwtSignedByAnotherPrivateKey"), + ) // Then .andExpect(status().isUnauthorized) .andExpect( @@ -109,7 +110,8 @@ class SecurityConfigITests { ) // When - mockMvc.perform(get("/bff/v1/ports")) + mockMvc + .perform(get("/bff/v1/ports")) // Then .andExpect(status().isUnauthorized) } @@ -121,7 +123,8 @@ class SecurityConfigITests { `when`(buildProperties.get("commit.hash")).thenReturn("DUMMY HASH") // When - mockMvc.perform(get("/version")) + mockMvc + .perform(get("/version")) // Then .andExpect(status().isOk) } @@ -129,7 +132,8 @@ class SecurityConfigITests { @Test fun `Should return 200 When the root path is not protected (and redirected to error)`() { // When - mockMvc.perform(get("/")) + mockMvc + .perform(get("/")) // Then .andExpect(status().isOk) } @@ -180,10 +184,11 @@ class SecurityConfigITests { ) // When - mockMvc.perform( - get("/bff/v1/ports") - .header("Authorization", "Bearer $jwt"), - ) + mockMvc + .perform( + get("/bff/v1/ports") + .header("Authorization", "Bearer $jwt"), + ) // Then .andExpect(status().isOk) } @@ -225,10 +230,11 @@ class SecurityConfigITests { ) // When - mockMvc.perform( - get("/bff/v1/ports") - .header("Authorization", "Bearer $jwt"), - ) + mockMvc + .perform( + get("/bff/v1/ports") + .header("Authorization", "Bearer $jwt"), + ) // Then .andExpect(status().isUnauthorized) .andExpect( diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/BeaconMalfunctionControllerITests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/BeaconMalfunctionControllerITests.kt index 8cea50b599..c4c4cfe401 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/BeaconMalfunctionControllerITests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/BeaconMalfunctionControllerITests.kt @@ -63,16 +63,28 @@ class BeaconMalfunctionControllerITests { given(this.getAllBeaconMalfunctions.execute()).willReturn( listOf( BeaconMalfunction( - 1, "CFR", "EXTERNAL_IMMAT", "IRCS", - "fr", VesselIdentifier.INTERNAL_REFERENCE_NUMBER, "BIDUBULE", VesselStatus.AT_SEA, Stage.INITIAL_ENCOUNTER, - ZonedDateTime.now(), null, ZonedDateTime.now(), - beaconNumber = "123465", beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, vesselId = 123, + 1, + "CFR", + "EXTERNAL_IMMAT", + "IRCS", + "fr", + VesselIdentifier.INTERNAL_REFERENCE_NUMBER, + "BIDUBULE", + VesselStatus.AT_SEA, + Stage.INITIAL_ENCOUNTER, + ZonedDateTime.now(), + null, + ZonedDateTime.now(), + beaconNumber = "123465", + beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, + vesselId = 123, ), ), ) // When - api.perform(get("/bff/v1/beacon_malfunctions")) + api + .perform(get("/bff/v1/beacon_malfunctions")) // Then .andExpect(status().isOk) .andExpect(jsonPath("$.length()", equalTo(1))) @@ -89,10 +101,21 @@ class BeaconMalfunctionControllerITests { BeaconMalfunctionResumeAndDetails( beaconMalfunction = BeaconMalfunction( - 1, "CFR", "EXTERNAL_IMMAT", "IRCS", - "fr", VesselIdentifier.INTERNAL_REFERENCE_NUMBER, "BIDUBULE", VesselStatus.AT_SEA, Stage.INITIAL_ENCOUNTER, - ZonedDateTime.now(), null, ZonedDateTime.now(), - beaconNumber = "123465", beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, vesselId = 123, + 1, + "CFR", + "EXTERNAL_IMMAT", + "IRCS", + "fr", + VesselIdentifier.INTERNAL_REFERENCE_NUMBER, + "BIDUBULE", + VesselStatus.AT_SEA, + Stage.INITIAL_ENCOUNTER, + ZonedDateTime.now(), + null, + ZonedDateTime.now(), + beaconNumber = "123465", + beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, + vesselId = 123, ), comments = listOf( @@ -119,15 +142,15 @@ class BeaconMalfunctionControllerITests { ) // When - api.perform( - put("/bff/v1/beacon_malfunctions/123") - .content( - objectMapper.writeValueAsString( - UpdateBeaconMalfunctionDataInput(vesselStatus = VesselStatus.AT_SEA), - ), - ) - .contentType(MediaType.APPLICATION_JSON), - ) + api + .perform( + put("/bff/v1/beacon_malfunctions/123") + .content( + objectMapper.writeValueAsString( + UpdateBeaconMalfunctionDataInput(vesselStatus = VesselStatus.AT_SEA), + ), + ).contentType(MediaType.APPLICATION_JSON), + ) // Then .andExpect(status().isOk) .andExpect(jsonPath("$.comments.length()", equalTo(1))) @@ -143,10 +166,13 @@ class BeaconMalfunctionControllerITests { .willThrow(CouldNotUpdateBeaconMalfunctionException("FAIL")) // When - api.perform( - put("/bff/v1/beacon_malfunctions/123", objectMapper.writeValueAsString(UpdateControlObjectiveDataInput())) - .contentType(MediaType.APPLICATION_JSON), - ) + api + .perform( + put( + "/bff/v1/beacon_malfunctions/123", + objectMapper.writeValueAsString(UpdateControlObjectiveDataInput()), + ).contentType(MediaType.APPLICATION_JSON), + ) // Then .andExpect(status().isBadRequest) } @@ -159,10 +185,21 @@ class BeaconMalfunctionControllerITests { BeaconMalfunctionResumeAndDetails( beaconMalfunction = BeaconMalfunction( - 1, "CFR", "EXTERNAL_IMMAT", "IRCS", - "fr", VesselIdentifier.INTERNAL_REFERENCE_NUMBER, "BIDUBULE", VesselStatus.AT_SEA, Stage.INITIAL_ENCOUNTER, - ZonedDateTime.now(), null, ZonedDateTime.now(), - beaconNumber = "123465", beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, vesselId = 123, + 1, + "CFR", + "EXTERNAL_IMMAT", + "IRCS", + "fr", + VesselIdentifier.INTERNAL_REFERENCE_NUMBER, + "BIDUBULE", + VesselStatus.AT_SEA, + Stage.INITIAL_ENCOUNTER, + ZonedDateTime.now(), + null, + ZonedDateTime.now(), + beaconNumber = "123465", + beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, + vesselId = 123, ), resume = VesselBeaconMalfunctionsResume(1, 2, null, null), comments = @@ -195,12 +232,16 @@ class BeaconMalfunctionControllerITests { notifications = listOf( BeaconMalfunctionNotification( - id = 1, beaconMalfunctionId = 1, dateTimeUtc = dateTimeUtc, + id = 1, + beaconMalfunctionId = 1, + dateTimeUtc = dateTimeUtc, notificationType = BeaconMalfunctionNotificationType.MALFUNCTION_AT_PORT_INITIAL_NOTIFICATION, communicationMeans = CommunicationMeans.SMS, recipientFunction = BeaconMalfunctionNotificationRecipientFunction.VESSEL_CAPTAIN, - recipientName = "Jack Sparrow", recipientAddressOrNumber = "0000000000", - success = false, errorMessage = "This message could not be delivered", + recipientName = "Jack Sparrow", + recipientAddressOrNumber = "0000000000", + success = false, + errorMessage = "This message could not be delivered", ), ), ), @@ -209,7 +250,8 @@ class BeaconMalfunctionControllerITests { ) // When - api.perform(get("/bff/v1/beacon_malfunctions/123")) + api + .perform(get("/bff/v1/beacon_malfunctions/123")) // Then .andExpect(status().isOk) .andExpect(jsonPath("$.resume.numberOfBeaconsAtSea", equalTo(1))) @@ -220,8 +262,7 @@ class BeaconMalfunctionControllerITests { .andExpect(jsonPath("$.beaconMalfunction.internalReferenceNumber", equalTo("CFR"))) .andExpect( jsonPath("$.notifications[0].notificationType", equalTo("MALFUNCTION_AT_PORT_INITIAL_NOTIFICATION")), - ) - .andExpect(jsonPath("$.notifications[0].notifications[0].recipientName", equalTo("Jack Sparrow"))) + ).andExpect(jsonPath("$.notifications[0].notifications[0].recipientName", equalTo("Jack Sparrow"))) .andExpect(jsonPath("$.notifications[0].notifications[0].success", equalTo(false))) .andExpect( jsonPath( @@ -238,10 +279,21 @@ class BeaconMalfunctionControllerITests { BeaconMalfunctionResumeAndDetails( beaconMalfunction = BeaconMalfunction( - 1, "CFR", "EXTERNAL_IMMAT", "IRCS", - "fr", VesselIdentifier.INTERNAL_REFERENCE_NUMBER, "BIDUBULE", VesselStatus.AT_SEA, Stage.INITIAL_ENCOUNTER, - ZonedDateTime.now(), null, ZonedDateTime.now(), - beaconNumber = "123465", beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, vesselId = 123, + 1, + "CFR", + "EXTERNAL_IMMAT", + "IRCS", + "fr", + VesselIdentifier.INTERNAL_REFERENCE_NUMBER, + "BIDUBULE", + VesselStatus.AT_SEA, + Stage.INITIAL_ENCOUNTER, + ZonedDateTime.now(), + null, + ZonedDateTime.now(), + beaconNumber = "123465", + beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, + vesselId = 123, ), comments = listOf( @@ -268,7 +320,8 @@ class BeaconMalfunctionControllerITests { ) // When - api.perform(get("/bff/v1/beacon_malfunctions/123")) + api + .perform(get("/bff/v1/beacon_malfunctions/123")) // Then .andExpect(status().isOk) .andExpect(jsonPath("$.resume", equalTo(null))) @@ -285,10 +338,21 @@ class BeaconMalfunctionControllerITests { BeaconMalfunctionResumeAndDetails( beaconMalfunction = BeaconMalfunction( - 1, "CFR", "EXTERNAL_IMMAT", "IRCS", - "fr", VesselIdentifier.INTERNAL_REFERENCE_NUMBER, "BIDUBULE", VesselStatus.AT_SEA, Stage.INITIAL_ENCOUNTER, - ZonedDateTime.now(), null, ZonedDateTime.now(), - beaconNumber = "123465", beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, vesselId = 123, + 1, + "CFR", + "EXTERNAL_IMMAT", + "IRCS", + "fr", + VesselIdentifier.INTERNAL_REFERENCE_NUMBER, + "BIDUBULE", + VesselStatus.AT_SEA, + Stage.INITIAL_ENCOUNTER, + ZonedDateTime.now(), + null, + ZonedDateTime.now(), + beaconNumber = "123465", + beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, + vesselId = 123, ), comments = listOf( @@ -315,15 +379,15 @@ class BeaconMalfunctionControllerITests { ) // When - api.perform( - post("/bff/v1/beacon_malfunctions/123/comments") - .content( - objectMapper.writeValueAsString( - SaveBeaconMalfunctionCommentDataInput("A comment", BeaconMalfunctionCommentUserType.SIP), - ), - ) - .contentType(MediaType.APPLICATION_JSON), - ) + api + .perform( + post("/bff/v1/beacon_malfunctions/123/comments") + .content( + objectMapper.writeValueAsString( + SaveBeaconMalfunctionCommentDataInput("A comment", BeaconMalfunctionCommentUserType.SIP), + ), + ).contentType(MediaType.APPLICATION_JSON), + ) // Then .andExpect(status().isCreated) .andExpect(jsonPath("$.comments.length()", equalTo(1))) @@ -334,7 +398,8 @@ class BeaconMalfunctionControllerITests { @Test fun `Should request a notification`() { // When - api.perform(put("/bff/v1/beacon_malfunctions/123/MALFUNCTION_AT_PORT_INITIAL_NOTIFICATION")) + api + .perform(put("/bff/v1/beacon_malfunctions/123/MALFUNCTION_AT_PORT_INITIAL_NOTIFICATION")) // Then .andExpect(status().isOk) @@ -348,11 +413,12 @@ class BeaconMalfunctionControllerITests { @Test fun `Should request a notification to a foreign fmc`() { // When - api.perform( - put( - "/bff/v1/beacon_malfunctions/123/MALFUNCTION_NOTIFICATION_TO_FOREIGN_FMC?requestedNotificationForeignFmcCode=ABC", - ), - ) + api + .perform( + put( + "/bff/v1/beacon_malfunctions/123/MALFUNCTION_NOTIFICATION_TO_FOREIGN_FMC?requestedNotificationForeignFmcCode=ABC", + ), + ) // Then .andExpect(status().isOk) diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/ControlObjectiveAdminControllerITests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/ControlObjectiveAdminControllerITests.kt index b8846cbe0d..34d0faaea5 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/ControlObjectiveAdminControllerITests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/ControlObjectiveAdminControllerITests.kt @@ -51,13 +51,15 @@ class ControlObjectiveAdminControllerITests { @Test fun `Should return Created When an update of a control objective is done`() { // When - api.perform( - put("/bff/v1/admin/control_objectives/123") - .content( - objectMapper.writeValueAsString(UpdateControlObjectiveDataInput(targetNumberOfControlsAtSea = 123)), - ) - .contentType(MediaType.APPLICATION_JSON), - ) + api + .perform( + put("/bff/v1/admin/control_objectives/123") + .content( + objectMapper.writeValueAsString( + UpdateControlObjectiveDataInput(targetNumberOfControlsAtSea = 123), + ), + ).contentType(MediaType.APPLICATION_JSON), + ) // Then .andExpect(status().isOk) } @@ -65,7 +67,8 @@ class ControlObjectiveAdminControllerITests { @Test fun `Should return Ok When a delete of a control objective is done`() { // When - api.perform(delete("/bff/v1/admin/control_objectives/123")) + api + .perform(delete("/bff/v1/admin/control_objectives/123")) // Then .andExpect(status().isOk) } @@ -73,15 +76,15 @@ class ControlObjectiveAdminControllerITests { @Test fun `Should return the id When a adding a control objective`() { // When - api.perform( - post("/bff/v1/admin/control_objectives") - .content( - objectMapper.writeValueAsString( - AddControlObjectiveDataInput(segment = "SEGMENT", facade = "FACADE", year = 2021), - ), - ) - .contentType(MediaType.APPLICATION_JSON), - ) + api + .perform( + post("/bff/v1/admin/control_objectives") + .content( + objectMapper.writeValueAsString( + AddControlObjectiveDataInput(segment = "SEGMENT", facade = "FACADE", year = 2021), + ), + ).contentType(MediaType.APPLICATION_JSON), + ) // Then .andExpect(status().isOk) } @@ -122,7 +125,8 @@ class ControlObjectiveAdminControllerITests { ) // When - api.perform(get("/bff/v1/admin/control_objectives/2021")) + api + .perform(get("/bff/v1/admin/control_objectives/2021")) // Then .andExpect(status().isOk) .andExpect(jsonPath("$.length()", equalTo(3))) @@ -134,7 +138,8 @@ class ControlObjectiveAdminControllerITests { given(this.getControlObjectiveYearEntries.execute()).willReturn(listOf(2021, 2022)) // When - api.perform(get("/bff/v1/admin/control_objectives/years")) + api + .perform(get("/bff/v1/admin/control_objectives/years")) // Then .andExpect(status().isOk) .andExpect(jsonPath("$.length()", equalTo(2))) @@ -144,7 +149,8 @@ class ControlObjectiveAdminControllerITests { @Test fun `Should add a new control objective year`() { // When - api.perform(post("/bff/v1/admin/control_objectives/years")) + api + .perform(post("/bff/v1/admin/control_objectives/years")) // Then .andExpect(status().isCreated) } diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/DataReferentialControllerITests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/DataReferentialControllerITests.kt index 8c3a578113..8072c5df8e 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/DataReferentialControllerITests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/DataReferentialControllerITests.kt @@ -44,7 +44,8 @@ class DataReferentialControllerITests { given(this.getAllGears.execute()).willReturn(listOf(Gear("CHL", "SUPER CHALUT", "CHALUT"))) // When - api.perform(get("/bff/v1/gears")) + api + .perform(get("/bff/v1/gears")) // Then .andExpect(status().isOk) .andExpect(jsonPath("$.length()", equalTo(1))) @@ -77,7 +78,8 @@ class DataReferentialControllerITests { ) // When - api.perform(get("/bff/v1/species")) + api + .perform(get("/bff/v1/species")) // Then .andExpect(status().isOk) .andExpect(jsonPath("$.species.length()", equalTo(1))) diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/FaoAreaControllerITests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/FaoAreaControllerITests.kt index 9850fd16b3..aa5e760ad3 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/FaoAreaControllerITests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/FaoAreaControllerITests.kt @@ -38,7 +38,8 @@ class FaoAreaControllerITests { given(this.getFAOAreas.execute()).willReturn(listOf("27.1", "27.1.0", "28.1", "28.1.0", "28.1.1")) // When - api.perform(get("/bff/v1/fao_areas")) + api + .perform(get("/bff/v1/fao_areas")) // Then .andExpect(status().isOk) .andExpect(jsonPath("$.length()", equalTo(5))) @@ -52,9 +53,12 @@ class FaoAreaControllerITests { ) // When - api.perform( - get("/bff/v1/fao_areas/compute?internalReferenceNumber=DUMMY_CFR&latitude=12.65&longitude=&portLocode=AY"), - ) + api + .perform( + get( + "/bff/v1/fao_areas/compute?internalReferenceNumber=DUMMY_CFR&latitude=12.65&longitude=&portLocode=AY", + ), + ) // Then .andExpect(status().isOk) .andExpect(jsonPath("$.length()", equalTo(5))) diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/FleetSegmentAdminControllerITests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/FleetSegmentAdminControllerITests.kt index 1f0c7dedd1..09a0fb63b4 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/FleetSegmentAdminControllerITests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/FleetSegmentAdminControllerITests.kt @@ -74,29 +74,29 @@ class FleetSegmentAdminControllerITests { ) // When - api.perform( - put("/bff/v1/admin/fleet_segments?year=2021&segment=A_SEGMENT/WITH/SLASH") - .content( - objectMapper.writeValueAsString( - CreateOrUpdateFleetSegmentDataInput( - gears = listOf("OTB", "OTC"), - segment = null, - segmentName = null, - faoAreas = null, - targetSpecies = null, - mainScipSpeciesType = null, - maxMesh = null, - minMesh = null, - minShareOfTargetSpecies = null, - priority = 0.0, - vesselTypes = listOf(), - impactRiskFactor = null, - year = null, + api + .perform( + put("/bff/v1/admin/fleet_segments?year=2021&segment=A_SEGMENT/WITH/SLASH") + .content( + objectMapper.writeValueAsString( + CreateOrUpdateFleetSegmentDataInput( + gears = listOf("OTB", "OTC"), + segment = null, + segmentName = null, + faoAreas = null, + targetSpecies = null, + mainScipSpeciesType = null, + maxMesh = null, + minMesh = null, + minShareOfTargetSpecies = null, + priority = 0.0, + vesselTypes = listOf(), + impactRiskFactor = null, + year = null, + ), ), - ), - ) - .contentType(MediaType.APPLICATION_JSON), - ) + ).contentType(MediaType.APPLICATION_JSON), + ) // Then .andExpect(status().isOk) .andExpect(jsonPath("$.segment", equalTo("A_SEGMENT/WITH/SLASH"))) @@ -117,7 +117,8 @@ class FleetSegmentAdminControllerITests { @Test fun `Should return Ok When a delete of a fleet segment is done`() { // When - api.perform(delete("/bff/v1/admin/fleet_segments?year=2021&segment=A_SEGMENT/WITH/SLASH")) + api + .perform(delete("/bff/v1/admin/fleet_segments?year=2021&segment=A_SEGMENT/WITH/SLASH")) // Then .andExpect(status().isOk) } @@ -125,7 +126,8 @@ class FleetSegmentAdminControllerITests { @Test fun `Should return Ok When a new year is created`() { // When - api.perform(post("/bff/v1/admin/fleet_segments/2023")) + api + .perform(post("/bff/v1/admin/fleet_segments/2023")) // Then .andExpect(status().isCreated) } @@ -153,29 +155,29 @@ class FleetSegmentAdminControllerITests { ) // When - api.perform( - post("/bff/v1/admin/fleet_segments") - .content( - objectMapper.writeValueAsString( - CreateOrUpdateFleetSegmentDataInput( - segment = "SEGMENT", - gears = listOf("OTB", "OTC"), - year = 2022, - segmentName = "", - priority = 1.2, - vesselTypes = listOf(), - faoAreas = listOf(), - targetSpecies = listOf(), - impactRiskFactor = 1.2, - mainScipSpeciesType = null, - maxMesh = null, - minMesh = null, - minShareOfTargetSpecies = null, + api + .perform( + post("/bff/v1/admin/fleet_segments") + .content( + objectMapper.writeValueAsString( + CreateOrUpdateFleetSegmentDataInput( + segment = "SEGMENT", + gears = listOf("OTB", "OTC"), + year = 2022, + segmentName = "", + priority = 1.2, + vesselTypes = listOf(), + faoAreas = listOf(), + targetSpecies = listOf(), + impactRiskFactor = 1.2, + mainScipSpeciesType = null, + maxMesh = null, + minMesh = null, + minShareOfTargetSpecies = null, + ), ), - ), - ) - .contentType(MediaType.APPLICATION_JSON), - ) + ).contentType(MediaType.APPLICATION_JSON), + ) // Then .andExpect(status().isCreated) @@ -205,29 +207,29 @@ class FleetSegmentAdminControllerITests { .willThrow(IllegalArgumentException("`year` must be provided")) // When - api.perform( - post("/bff/v1/admin/fleet_segments") - .content( - objectMapper.writeValueAsString( - CreateOrUpdateFleetSegmentDataInput( - segment = "SEGMENT", - gears = listOf("OTB", "OTC"), - segmentName = null, - faoAreas = null, - targetSpecies = null, - mainScipSpeciesType = null, - maxMesh = null, - minMesh = null, - minShareOfTargetSpecies = null, - priority = 0.0, - vesselTypes = listOf(), - impactRiskFactor = null, - year = null, + api + .perform( + post("/bff/v1/admin/fleet_segments") + .content( + objectMapper.writeValueAsString( + CreateOrUpdateFleetSegmentDataInput( + segment = "SEGMENT", + gears = listOf("OTB", "OTC"), + segmentName = null, + faoAreas = null, + targetSpecies = null, + mainScipSpeciesType = null, + maxMesh = null, + minMesh = null, + minShareOfTargetSpecies = null, + priority = 0.0, + vesselTypes = listOf(), + impactRiskFactor = null, + year = null, + ), ), - ), - ) - .contentType(MediaType.APPLICATION_JSON), - ) + ).contentType(MediaType.APPLICATION_JSON), + ) // Then .andExpect(status().isBadRequest) diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/FleetSegmentControllerITests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/FleetSegmentControllerITests.kt index 874fdee8cc..8849758061 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/FleetSegmentControllerITests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/FleetSegmentControllerITests.kt @@ -64,7 +64,8 @@ class FleetSegmentControllerITests { ) // When - api.perform(get("/bff/v1/fleet_segments/2021")) + api + .perform(get("/bff/v1/fleet_segments/2021")) // Then .andExpect(status().isOk) .andExpect(jsonPath("$.length()", equalTo(1))) @@ -97,47 +98,47 @@ class FleetSegmentControllerITests { ) // When - api.perform( - post("/bff/v1/fleet_segments/compute") - .content( - objectMapper.writeValueAsString( - ComputeFleetSegmentsDataInput( - faoAreas = listOf("27.1.c", "27.1.b"), - vesselId = 123, - gears = - listOf( - GearControlDataInput( - gearCode = "OTB", - gearName = null, - declaredMesh = null, - controlledMesh = null, - hasUncontrolledMesh = null, - gearWasControlled = null, - comments = null, + api + .perform( + post("/bff/v1/fleet_segments/compute") + .content( + objectMapper.writeValueAsString( + ComputeFleetSegmentsDataInput( + faoAreas = listOf("27.1.c", "27.1.b"), + vesselId = 123, + gears = + listOf( + GearControlDataInput( + gearCode = "OTB", + gearName = null, + declaredMesh = null, + controlledMesh = null, + hasUncontrolledMesh = null, + gearWasControlled = null, + comments = null, + ), ), - ), - species = - listOf( - SpeciesControlDataInput( - speciesCode = "HKE", - nbFish = null, - declaredWeight = null, - controlledWeight = null, - underSized = null, + species = + listOf( + SpeciesControlDataInput( + speciesCode = "HKE", + nbFish = null, + declaredWeight = null, + controlledWeight = null, + underSized = null, + ), + SpeciesControlDataInput( + speciesCode = "BFT", + nbFish = null, + declaredWeight = null, + controlledWeight = null, + underSized = null, + ), ), - SpeciesControlDataInput( - speciesCode = "BFT", - nbFish = null, - declaredWeight = null, - controlledWeight = null, - underSized = null, - ), - ), + ), ), - ), - ) - .contentType(MediaType.APPLICATION_JSON), - ) + ).contentType(MediaType.APPLICATION_JSON), + ) // Then .andExpect(status().isOk) .andExpect(jsonPath("$.length()", equalTo(1))) diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/ForeignFMCsControllerITests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/ForeignFMCsControllerITests.kt index 883b1a683a..287cb1971b 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/ForeignFMCsControllerITests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/ForeignFMCsControllerITests.kt @@ -37,7 +37,8 @@ class ForeignFMCsControllerITests { ) // When - api.perform(get("/bff/v1/foreign_fmcs")) + api + .perform(get("/bff/v1/foreign_fmcs")) // Then .andExpect(status().isOk) .andExpect(jsonPath("$.length()", equalTo(2))) diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/MissionActionsControllerITests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/MissionActionsControllerITests.kt index 33a54914fe..cad8db4eb2 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/MissionActionsControllerITests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/MissionActionsControllerITests.kt @@ -94,7 +94,8 @@ class MissionActionsControllerITests { ) // When - api.perform(get("/bff/v1/mission_actions/controls?vesselId=123&afterDateTime=2020-05-04T03:04:05.000Z")) + api + .perform(get("/bff/v1/mission_actions/controls?vesselId=123&afterDateTime=2020-05-04T03:04:05.000Z")) // Then .andExpect(status().isOk) .andExpect(jsonPath("$.numberOfDiversions", equalTo(3))) @@ -130,7 +131,8 @@ class MissionActionsControllerITests { ) // When - api.perform(get("/bff/v1/mission_actions?missionId=123")) + api + .perform(get("/bff/v1/mission_actions?missionId=123")) // Then .andExpect(status().isOk) .andExpect(jsonPath("$.length()", equalTo(1))) @@ -149,53 +151,53 @@ class MissionActionsControllerITests { given(addMissionAction.execute(any())).willReturn(newMission) // When - api.perform( - post("/bff/v1/mission_actions") - .content( - objectMapper.writeValueAsString( - AddMissionActionDataInput( - actionDatetimeUtc = dateTime, - missionId = 2, - vesselId = 2, - actionType = MissionActionType.SEA_CONTROL, - logbookInfractions = - listOf( - LogbookInfraction( - InfractionType.WITH_RECORD, - 27689, - "Poids à bord MNZ supérieur de 50% au poids déclaré", + api + .perform( + post("/bff/v1/mission_actions") + .content( + objectMapper.writeValueAsString( + AddMissionActionDataInput( + actionDatetimeUtc = dateTime, + missionId = 2, + vesselId = 2, + actionType = MissionActionType.SEA_CONTROL, + logbookInfractions = + listOf( + LogbookInfraction( + InfractionType.WITH_RECORD, + 27689, + "Poids à bord MNZ supérieur de 50% au poids déclaré", + ), ), - ), - faoAreas = listOf("25.6.9", "25.7.9"), - segments = - listOf( - FleetSegment( - segment = "WWSS10", - segmentName = "World Wide Segment", + faoAreas = listOf("25.6.9", "25.7.9"), + segments = + listOf( + FleetSegment( + segment = "WWSS10", + segmentName = "World Wide Segment", + ), ), - ), - gearInfractions = - listOf( - GearInfraction( - InfractionType.WITH_RECORD, - 27689, - "Maille trop petite", + gearInfractions = + listOf( + GearInfraction( + InfractionType.WITH_RECORD, + 27689, + "Maille trop petite", + ), ), - ), - hasSomeGearsSeized = false, - hasSomeSpeciesSeized = false, - isAdministrativeControl = true, - isComplianceWithWaterRegulationsControl = true, - isSafetyEquipmentAndStandardsComplianceControl = true, - isSeafarersControl = true, - flagState = CountryCode.FR, - userTrigram = "LTH", - completion = Completion.TO_COMPLETE, + hasSomeGearsSeized = false, + hasSomeSpeciesSeized = false, + isAdministrativeControl = true, + isComplianceWithWaterRegulationsControl = true, + isSafetyEquipmentAndStandardsComplianceControl = true, + isSeafarersControl = true, + flagState = CountryCode.FR, + userTrigram = "LTH", + completion = Completion.TO_COMPLETE, + ), ), - ), - ) - .contentType(MediaType.APPLICATION_JSON), - ) + ).contentType(MediaType.APPLICATION_JSON), + ) // Then .andExpect(status().isCreated) .andExpect(jsonPath("$.missionId", equalTo(2))) @@ -238,51 +240,51 @@ class MissionActionsControllerITests { comments = null, ) // When - api.perform( - put("/bff/v1/mission_actions/123") - .content( - objectMapper.writeValueAsString( - AddMissionActionDataInput( - actionDatetimeUtc = dateTime, - missionId = 2, - vesselId = 2, - actionType = MissionActionType.SEA_CONTROL, - logbookInfractions = - listOf( - LogbookInfraction( - InfractionType.WITH_RECORD, - 27689, - "Poids à bord MNZ supérieur de 50% au poids déclaré", + api + .perform( + put("/bff/v1/mission_actions/123") + .content( + objectMapper.writeValueAsString( + AddMissionActionDataInput( + actionDatetimeUtc = dateTime, + missionId = 2, + vesselId = 2, + actionType = MissionActionType.SEA_CONTROL, + logbookInfractions = + listOf( + LogbookInfraction( + InfractionType.WITH_RECORD, + 27689, + "Poids à bord MNZ supérieur de 50% au poids déclaré", + ), ), - ), - faoAreas = listOf("25.6.9", "25.7.9"), - segments = - listOf( - FleetSegment( - segment = "WWSS10", - segmentName = "World Wide Segment", + faoAreas = listOf("25.6.9", "25.7.9"), + segments = + listOf( + FleetSegment( + segment = "WWSS10", + segmentName = "World Wide Segment", + ), ), - ), - gearInfractions = - listOf( - GearInfraction( - InfractionType.WITH_RECORD, - 27689, - "Maille trop petite", + gearInfractions = + listOf( + GearInfraction( + InfractionType.WITH_RECORD, + 27689, + "Maille trop petite", + ), ), - ), - gearOnboard = listOf(gearControl), - hasSomeGearsSeized = false, - hasSomeSpeciesSeized = false, - isFromPoseidon = true, - flagState = CountryCode.UNDEFINED, - userTrigram = "LTH", - completion = Completion.TO_COMPLETE, + gearOnboard = listOf(gearControl), + hasSomeGearsSeized = false, + hasSomeSpeciesSeized = false, + isFromPoseidon = true, + flagState = CountryCode.UNDEFINED, + userTrigram = "LTH", + completion = Completion.TO_COMPLETE, + ), ), - ), - ) - .contentType(MediaType.APPLICATION_JSON), - ) + ).contentType(MediaType.APPLICATION_JSON), + ) // Then .andExpect(status().isCreated) .andExpect(jsonPath("$.missionId", equalTo(2))) @@ -316,31 +318,31 @@ class MissionActionsControllerITests { given(updateMissionAction.execute(any(), any())).willReturn(newMission) // When - api.perform( - put("/bff/v1/mission_actions/123") - .content( - """ - { - "id": 3540, - "vesselId": 1778775, - "vesselName": "TEST", - "internalReferenceNumber": "FRA000936666", - "externalReferenceNumber": "SEGESGES", - "ircs": "FEFGEGSGE", - "flagState": null, - "districtCode": "AD", - "faoAreas": [], - "userTrigram": "LTH", - "completion": "COMPLETED", - "flightGoals": [], - "missionId": 10556, - "actionType": "OBSERVATION", - "actionDatetimeUtc": "2024-02-01T14:29:00Z" - } - """.trimIndent(), - ) - .contentType(MediaType.APPLICATION_JSON), - ) + api + .perform( + put("/bff/v1/mission_actions/123") + .content( + """ + { + "id": 3540, + "vesselId": 1778775, + "vesselName": "TEST", + "internalReferenceNumber": "FRA000936666", + "externalReferenceNumber": "SEGESGES", + "ircs": "FEFGEGSGE", + "flagState": null, + "districtCode": "AD", + "faoAreas": [], + "userTrigram": "LTH", + "completion": "COMPLETED", + "flightGoals": [], + "missionId": 10556, + "actionType": "OBSERVATION", + "actionDatetimeUtc": "2024-02-01T14:29:00Z" + } + """.trimIndent(), + ).contentType(MediaType.APPLICATION_JSON), + ) // Then .andExpect(status().isCreated) } @@ -348,7 +350,8 @@ class MissionActionsControllerITests { @Test fun `Should delete a mission action`() { // When - api.perform(delete("/bff/v1/mission_actions/2")) + api + .perform(delete("/bff/v1/mission_actions/2")) // Then .andExpect(status().isNoContent()) @@ -401,11 +404,12 @@ class MissionActionsControllerITests { ) // When - api.perform( - get( - "/bff/v1/mission_actions/controls/activity_reports?beforeDateTime=2020-05-04T03:04:05.000Z&afterDateTime=2020-03-04T03:04:05.000Z&jdp=MEDITERRANEAN_AND_EASTERN_ATLANTIC", - ), - ) + api + .perform( + get( + "/bff/v1/mission_actions/controls/activity_reports?beforeDateTime=2020-05-04T03:04:05.000Z&afterDateTime=2020-03-04T03:04:05.000Z&jdp=MEDITERRANEAN_AND_EASTERN_ATLANTIC", + ), + ) // Then .andExpect(status().isOk) .andExpect(jsonPath("$.activityReports.length()", equalTo(1))) diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/MissionsControllerITests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/MissionsControllerITests.kt index cf91781da8..ef88662254 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/MissionsControllerITests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/MissionsControllerITests.kt @@ -92,9 +92,10 @@ class MissionsControllerITests { ) // When - api.perform( - get( - """ + api + .perform( + get( + """ /bff/v1/missions? pageNumber=1& pageSize=& @@ -104,8 +105,8 @@ class MissionsControllerITests { missionStatus=& seaFronts=MED """.trim().replace("\\s+".toRegex(), ""), - ), - ) + ), + ) // Then .andExpect(status().isOk) .andExpect(jsonPath("$.length()", equalTo(1))) @@ -164,9 +165,10 @@ class MissionsControllerITests { ) // When - api.perform( - get("/bff/v1/missions/123"), - ) + api + .perform( + get("/bff/v1/missions/123"), + ) // Then .andExpect(status().isOk) .andExpect(jsonPath("$.isGeometryComputedFromControls", equalTo(false))) diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/PendingAlertControllerITests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/PendingAlertControllerITests.kt index f9ae15d4e3..fccf97f59e 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/PendingAlertControllerITests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/PendingAlertControllerITests.kt @@ -77,7 +77,8 @@ class PendingAlertControllerITests { ) // When - api.perform(MockMvcRequestBuilders.get("/bff/v1/operational_alerts")) + api + .perform(MockMvcRequestBuilders.get("/bff/v1/operational_alerts")) // Then .andExpect(MockMvcResultMatchers.status().isOk) .andExpect(MockMvcResultMatchers.jsonPath("$.length()", Matchers.equalTo(1))) @@ -88,7 +89,8 @@ class PendingAlertControllerITests { @Test fun `Should validate a pending alert`() { // When - api.perform(MockMvcRequestBuilders.put("/bff/v1/operational_alerts/666/validate")) + api + .perform(MockMvcRequestBuilders.put("/bff/v1/operational_alerts/666/validate")) // Then .andExpect(MockMvcResultMatchers.status().isOk) } @@ -111,18 +113,19 @@ class PendingAlertControllerITests { val before = ZonedDateTime.now() // When - api.perform( - MockMvcRequestBuilders.put("/bff/v1/operational_alerts/666/silence") - .content( - objectMapper.writeValueAsString( - SilenceOperationalAlertDataInput( - silencedAlertPeriod = SilenceAlertPeriod.CUSTOM, - beforeDateTime = before, + api + .perform( + MockMvcRequestBuilders + .put("/bff/v1/operational_alerts/666/silence") + .content( + objectMapper.writeValueAsString( + SilenceOperationalAlertDataInput( + silencedAlertPeriod = SilenceAlertPeriod.CUSTOM, + beforeDateTime = before, + ), ), - ), - ) - .contentType(MediaType.APPLICATION_JSON), - ) + ).contentType(MediaType.APPLICATION_JSON), + ) // Then .andExpect(MockMvcResultMatchers.status().isOk) .andExpect(MockMvcResultMatchers.jsonPath("$.internalReferenceNumber", Matchers.equalTo("FRFGRGR"))) @@ -157,7 +160,8 @@ class PendingAlertControllerITests { ) // When - api.perform(MockMvcRequestBuilders.get("/bff/v1/operational_alerts/silenced")) + api + .perform(MockMvcRequestBuilders.get("/bff/v1/operational_alerts/silenced")) // Then .andExpect(MockMvcResultMatchers.status().isOk) .andExpect(MockMvcResultMatchers.jsonPath("$.length()", Matchers.equalTo(1))) @@ -171,7 +175,8 @@ class PendingAlertControllerITests { @Test fun `Should delete a silenced alert`() { // When - api.perform(MockMvcRequestBuilders.delete("/bff/v1/operational_alerts/silenced/666")) + api + .perform(MockMvcRequestBuilders.delete("/bff/v1/operational_alerts/silenced/666")) // Then .andExpect(MockMvcResultMatchers.status().isOk) } @@ -193,23 +198,24 @@ class PendingAlertControllerITests { ) // When - api.perform( - MockMvcRequestBuilders.post("/bff/v1/operational_alerts/silenced") - .content( - objectMapper.writeValueAsString( - SilencedAlertDataInput( - internalReferenceNumber = "FRFGRGR", - externalReferenceNumber = "RGD", - ircs = "6554fEE", - vesselIdentifier = VesselIdentifier.INTERNAL_REFERENCE_NUMBER, - flagState = CountryCode.FR, - silencedBeforeDate = ZonedDateTime.now(), - value = "{\"type\": \"THREE_MILES_TRAWLING_ALERT\"}", + api + .perform( + MockMvcRequestBuilders + .post("/bff/v1/operational_alerts/silenced") + .content( + objectMapper.writeValueAsString( + SilencedAlertDataInput( + internalReferenceNumber = "FRFGRGR", + externalReferenceNumber = "RGD", + ircs = "6554fEE", + vesselIdentifier = VesselIdentifier.INTERNAL_REFERENCE_NUMBER, + flagState = CountryCode.FR, + silencedBeforeDate = ZonedDateTime.now(), + value = "{\"type\": \"THREE_MILES_TRAWLING_ALERT\"}", + ), ), - ), - ) - .contentType(MediaType.APPLICATION_JSON), - ) + ).contentType(MediaType.APPLICATION_JSON), + ) // Then .andExpect(MockMvcResultMatchers.status().isOk) .andExpect(MockMvcResultMatchers.jsonPath("$.internalReferenceNumber", Matchers.equalTo("FRFGRGR"))) diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/PortControllerITests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/PortControllerITests.kt index 51eb142855..9c3541d551 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/PortControllerITests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/PortControllerITests.kt @@ -37,7 +37,8 @@ class PortControllerITests { ) // When - api.perform(get("/bff/v1/ports")) + api + .perform(get("/bff/v1/ports")) // Then .andExpect(status().isOk) .andExpect(jsonPath("$.length()", equalTo(2))) diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/PriorNotificationControllerUTests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/PriorNotificationControllerUTests.kt index e853e200e2..74981bb10c 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/PriorNotificationControllerUTests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/PriorNotificationControllerUTests.kt @@ -116,11 +116,12 @@ class PriorNotificationControllerUTests { ) // When - api.perform( - get( - "/bff/v1/prior_notifications?willArriveAfter=2000-01-01T00:00:00Z&willArriveBefore=2100-01-01T00:00:00Z&seafrontGroup=ALL&sortColumn=EXPECTED_ARRIVAL_DATE&sortDirection=DESC&pageNumber=0&pageSize=10", - ), - ) + api + .perform( + get( + "/bff/v1/prior_notifications?willArriveAfter=2000-01-01T00:00:00Z&willArriveBefore=2100-01-01T00:00:00Z&seafrontGroup=ALL&sortColumn=EXPECTED_ARRIVAL_DATE&sortDirection=DESC&pageNumber=0&pageSize=10", + ), + ) // Then .andExpect(status().isOk) .andExpect(jsonPath("$.data.length()", equalTo(2))) @@ -146,20 +147,19 @@ class PriorNotificationControllerUTests { note = anyOrNull(), updatedBy = anyOrNull(), ), - ) - .willReturn(fakePriorNotification) + ).willReturn(fakePriorNotification) // When val requestBody = objectMapper.writeValueAsString(LogbookPriorNotificationFormDataInput(note = "Test !")) val pnoValue = fakePriorNotification.logbookMessageAndValue.value - api.perform( - put( - "/bff/v1/prior_notifications/logbook/${fakePriorNotification.reportId!!}?operationDate=${fakePriorNotification.logbookMessageAndValue.logbookMessage.operationDateTime}", + api + .perform( + put( + "/bff/v1/prior_notifications/logbook/${fakePriorNotification.reportId!!}?operationDate=${fakePriorNotification.logbookMessageAndValue.logbookMessage.operationDateTime}", + ).contentType(MediaType.APPLICATION_JSON) + .content(requestBody) + .characterEncoding(UTF_8), ) - .contentType(MediaType.APPLICATION_JSON) - .content(requestBody) - .characterEncoding(UTF_8), - ) // Then .andExpect(status().isOk) .andExpect(jsonPath("$.note", equalTo(pnoValue.note))) @@ -190,11 +190,12 @@ class PriorNotificationControllerUTests { vesselId = 42, ), ) - api.perform( - post("/bff/v1/prior_notifications/manual/compute") - .contentType(MediaType.APPLICATION_JSON) - .content(requestBody), - ) + api + .perform( + post("/bff/v1/prior_notifications/manual/compute") + .contentType(MediaType.APPLICATION_JSON) + .content(requestBody), + ) // Then .andExpect(status().isOk) .andExpect(jsonPath("$.riskFactor", equalTo(1.2))) @@ -224,8 +225,7 @@ class PriorNotificationControllerUTests { anyOrNull(), anyOrNull(), ), - ) - .willReturn(fakePriorNotification) + ).willReturn(fakePriorNotification) // When val requestBody = @@ -246,11 +246,12 @@ class PriorNotificationControllerUTests { vesselId = 42, ), ) - api.perform( - post("/bff/v1/prior_notifications/manual") - .contentType(MediaType.APPLICATION_JSON) - .content(requestBody), - ) + api + .perform( + post("/bff/v1/prior_notifications/manual") + .contentType(MediaType.APPLICATION_JSON) + .content(requestBody), + ) // Then .andExpect(status().isOk) .andExpect(jsonPath("$.reportId", equalTo(fakePriorNotification.reportId))) @@ -280,8 +281,7 @@ class PriorNotificationControllerUTests { tripGearCodes = anyOrNull(), vesselId = anyOrNull(), ), - ) - .willReturn(fakePriorNotification) + ).willReturn(fakePriorNotification) // When val requestBody = @@ -302,11 +302,12 @@ class PriorNotificationControllerUTests { vesselId = 42, ), ) - api.perform( - put("/bff/v1/prior_notifications/manual/${fakePriorNotification.reportId!!}") - .contentType(MediaType.APPLICATION_JSON) - .content(requestBody), - ) + api + .perform( + put("/bff/v1/prior_notifications/manual/${fakePriorNotification.reportId!!}") + .contentType(MediaType.APPLICATION_JSON) + .content(requestBody), + ) // Then .andExpect(status().isOk) .andExpect(jsonPath("$.reportId", equalTo(fakePriorNotification.reportId))) @@ -320,11 +321,12 @@ class PriorNotificationControllerUTests { ) // When - api.perform( - get( - "/bff/v1/prior_notifications/to_verify", - ), - ) + api + .perform( + get( + "/bff/v1/prior_notifications/to_verify", + ), + ) // Then .andExpect(status().isOk) .andExpect(jsonPath("$.perSeafrontGroupCount['ALL']", equalTo(2))) @@ -336,7 +338,8 @@ class PriorNotificationControllerUTests { given(getPriorNotificationTypes.execute()).willReturn(listOf("Préavis de Type A", "Préavis de Type B")) // When - api.perform(get("/bff/v1/prior_notifications/types")) + api + .perform(get("/bff/v1/prior_notifications/types")) // Then .andExpect(status().isOk) .andExpect(jsonPath("$.length()", equalTo(2))) @@ -355,15 +358,15 @@ class PriorNotificationControllerUTests { fakePriorNotification.logbookMessageAndValue.logbookMessage.operationDateTime, false, ), - ) - .willReturn(fakePriorNotification) + ).willReturn(fakePriorNotification) // When - api.perform( - get( - "/bff/v1/prior_notifications/${fakePriorNotification.reportId!!}?operationDate=${fakePriorNotification.logbookMessageAndValue.logbookMessage.operationDateTime}&isManuallyCreated=false", - ), - ) + api + .perform( + get( + "/bff/v1/prior_notifications/${fakePriorNotification.reportId!!}?operationDate=${fakePriorNotification.logbookMessageAndValue.logbookMessage.operationDateTime}&isManuallyCreated=false", + ), + ) // Then .andExpect(status().isOk) .andExpect(jsonPath("$.reportId", equalTo(fakePriorNotification.reportId))) @@ -383,13 +386,25 @@ class PriorNotificationControllerUTests { LogbookMessageFaker.fakePnoMessage().apply { catchOnboard = listOf( - LogbookMessageFaker.fakeLogbookFishingCatch(species = "COD", weight = 12.0), - LogbookMessageFaker.fakeLogbookFishingCatch(species = "HKE", weight = null), + LogbookMessageFaker.fakeLogbookFishingCatch( + species = "COD", + weight = 12.0, + ), + LogbookMessageFaker.fakeLogbookFishingCatch( + species = "HKE", + weight = null, + ), ) catchToLand = listOf( - LogbookMessageFaker.fakeLogbookFishingCatch(species = "COD", weight = 12.0), - LogbookMessageFaker.fakeLogbookFishingCatch(species = "HKE", weight = null), + LogbookMessageFaker.fakeLogbookFishingCatch( + species = "COD", + weight = 12.0, + ), + LogbookMessageFaker.fakeLogbookFishingCatch( + species = "HKE", + weight = null, + ), ) }, ), @@ -404,15 +419,15 @@ class PriorNotificationControllerUTests { fakePriorNotification.logbookMessageAndValue.logbookMessage.operationDateTime, false, ), - ) - .willReturn(fakePriorNotification) + ).willReturn(fakePriorNotification) // When - api.perform( - get( - "/bff/v1/prior_notifications/${fakePriorNotification.reportId!!}?operationDate=${fakePriorNotification.logbookMessageAndValue.logbookMessage.operationDateTime}&isManuallyCreated=false", - ), - ) + api + .perform( + get( + "/bff/v1/prior_notifications/${fakePriorNotification.reportId!!}?operationDate=${fakePriorNotification.logbookMessageAndValue.logbookMessage.operationDateTime}&isManuallyCreated=false", + ), + ) // Then .andExpect(status().isOk) .andExpect(jsonPath("$.reportId", equalTo(fakePriorNotification.reportId!!))) @@ -472,7 +487,8 @@ class PriorNotificationControllerUTests { ) // When - api.perform(get("/bff/v1/prior_notifications/REPORT_ID/pdf")) + api + .perform(get("/bff/v1/prior_notifications/REPORT_ID/pdf")) // Then .andExpect(status().isOk) .andExpect(content().contentType(MediaType.APPLICATION_PDF)) @@ -485,7 +501,8 @@ class PriorNotificationControllerUTests { given(getPriorNotificationPdfDocument.execute("REPORT_ID", true)).willReturn(null) // When - api.perform(get("/bff/v1/prior_notifications/REPORT_ID/pdf/exist")) + api + .perform(get("/bff/v1/prior_notifications/REPORT_ID/pdf/exist")) // Then .andExpect(status().isOk) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) @@ -503,15 +520,15 @@ class PriorNotificationControllerUTests { fakePriorNotification.logbookMessageAndValue.logbookMessage.operationDateTime, false, ), - ) - .willReturn(fakePriorNotification) + ).willReturn(fakePriorNotification) // When - api.perform( - post( - "/bff/v1/prior_notifications/${fakePriorNotification.reportId!!}/verify_and_send?operationDate=${fakePriorNotification.logbookMessageAndValue.logbookMessage.operationDateTime}&isManuallyCreated=false", - ), - ) + api + .perform( + post( + "/bff/v1/prior_notifications/${fakePriorNotification.reportId!!}/verify_and_send?operationDate=${fakePriorNotification.logbookMessageAndValue.logbookMessage.operationDateTime}&isManuallyCreated=false", + ), + ) // Then .andExpect(status().isOk) .andExpect(jsonPath("$.reportId", equalTo(fakePriorNotification.reportId))) @@ -529,15 +546,15 @@ class PriorNotificationControllerUTests { operationDate = anyOrNull(), isManuallyCreated = anyOrNull(), ), - ) - .willReturn(fakePriorNotification) + ).willReturn(fakePriorNotification) // When - api.perform( - put( - "/bff/v1/prior_notifications/${fakePriorNotification.reportId!!}/invalidate?operationDate=${fakePriorNotification.logbookMessageAndValue.logbookMessage.operationDateTime}&isManuallyCreated=false", - ), - ) + api + .perform( + put( + "/bff/v1/prior_notifications/${fakePriorNotification.reportId!!}/invalidate?operationDate=${fakePriorNotification.logbookMessageAndValue.logbookMessage.operationDateTime}&isManuallyCreated=false", + ), + ) // Then .andExpect(status().isOk) .andExpect(jsonPath("$.reportId", equalTo(fakePriorNotification.reportId))) @@ -546,8 +563,7 @@ class PriorNotificationControllerUTests { "$.logbookMessage.message.isInvalidated", equalTo(fakePriorNotification.logbookMessageAndValue.value.isInvalidated), ), - ) - .andExpect(jsonPath("$.reportId", equalTo(fakePriorNotification.reportId))) + ).andExpect(jsonPath("$.reportId", equalTo(fakePriorNotification.reportId))) } @Test @@ -585,7 +601,8 @@ class PriorNotificationControllerUTests { ) // When - api.perform(get("/bff/v1/prior_notifications/$fakeReportId/sent_messages")) + api + .perform(get("/bff/v1/prior_notifications/$fakeReportId/sent_messages")) // Then .andExpect(status().isOk) .andExpect(jsonPath("$.length()", equalTo(2))) diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/PriorNotificationSubscriberControllerUTests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/PriorNotificationSubscriberControllerUTests.kt index a1c5b76f5a..4a2f52b7e7 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/PriorNotificationSubscriberControllerUTests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/PriorNotificationSubscriberControllerUTests.kt @@ -71,9 +71,10 @@ class PriorNotificationSubscriberControllerUTests { ) // When - api.perform( - get("/bff/v1/prior_notification_subscribers?sortColumn=CONTROL_UNIT_NAME&sortDirection=ASC"), - ) + api + .perform( + get("/bff/v1/prior_notification_subscribers?sortColumn=CONTROL_UNIT_NAME&sortDirection=ASC"), + ) // Then .andExpect(status().isOk) .andExpect(jsonPath("$.length()", equalTo(2))) @@ -100,9 +101,10 @@ class PriorNotificationSubscriberControllerUTests { ).willReturn(fakeSubscriber) // When - api.perform( - get("/bff/v1/prior_notification_subscribers/$fakeControlUnitId"), - ) + api + .perform( + get("/bff/v1/prior_notification_subscribers/$fakeControlUnitId"), + ) // Then .andExpect(status().isOk) .andExpect(jsonPath("$.controlUnit.id", equalTo(fakeControlUnitId))) @@ -143,11 +145,12 @@ class PriorNotificationSubscriberControllerUTests { val requestBody = objectMapper.writeValueAsString(fakeDataInput) // When - api.perform( - put("/bff/v1/prior_notification_subscribers/$fakeControlUnitId") - .contentType(MediaType.APPLICATION_JSON) - .content(requestBody), - ) + api + .perform( + put("/bff/v1/prior_notification_subscribers/$fakeControlUnitId") + .contentType(MediaType.APPLICATION_JSON) + .content(requestBody), + ) // Then .andExpect(status().isOk) .andExpect(jsonPath("$.controlUnit.id", equalTo(fakeControlUnitId))) diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/ProducerOrganizationMembershipControllerITests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/ProducerOrganizationMembershipControllerITests.kt index c3cd75aa8f..b99912ef72 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/ProducerOrganizationMembershipControllerITests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/ProducerOrganizationMembershipControllerITests.kt @@ -45,7 +45,8 @@ class ProducerOrganizationMembershipControllerITests { whenever(getAllProducerOrganizationMemberships.execute()).thenReturn(memberships) // When Then - mockMvc.perform(get("/bff/v1/producer_organization_memberships")) + mockMvc + .perform(get("/bff/v1/producer_organization_memberships")) .andExpect(status().isOk) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect(jsonPath("$[0].internalReferenceNumber").value("123")) @@ -62,11 +63,11 @@ class ProducerOrganizationMembershipControllerITests { ) // When Then - mockMvc.perform( - post("/bff/v1/producer_organization_memberships") - .contentType(MediaType.APPLICATION_JSON) - .content(objectMapper.writeValueAsString(memberships)), - ) - .andExpect(status().isCreated) + mockMvc + .perform( + post("/bff/v1/producer_organization_memberships") + .contentType(MediaType.APPLICATION_JSON) + .content(objectMapper.writeValueAsString(memberships)), + ).andExpect(status().isCreated) } } diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/ReportingControllerITests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/ReportingControllerITests.kt index 26f12a75a7..d2d2a9ca8e 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/ReportingControllerITests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/ReportingControllerITests.kt @@ -65,7 +65,8 @@ class ReportingControllerITests { @Test fun `Should archive a reporting`() { // When - api.perform(put("/bff/v1/reportings/123/archive")) + api + .perform(put("/bff/v1/reportings/123/archive")) // Then .andExpect(status().isOk) @@ -75,11 +76,12 @@ class ReportingControllerITests { @Test fun `Should archive multiple reportings`() { // When - api.perform( - put("/bff/v1/reportings/archive") - .content(objectMapper.writeValueAsString(listOf(1, 2, 3))) - .contentType(MediaType.APPLICATION_JSON), - ) + api + .perform( + put("/bff/v1/reportings/archive") + .content(objectMapper.writeValueAsString(listOf(1, 2, 3))) + .contentType(MediaType.APPLICATION_JSON), + ) // Then .andExpect(status().isOk) @@ -89,7 +91,8 @@ class ReportingControllerITests { @Test fun `Should delete a reporting`() { // When - api.perform(delete("/bff/v1/reportings/123")) + api + .perform(delete("/bff/v1/reportings/123")) // Then .andExpect(status().isOk) @@ -99,11 +102,12 @@ class ReportingControllerITests { @Test fun `Should delete multiple reportings`() { // When - api.perform( - delete("/bff/v1/reportings") - .content(objectMapper.writeValueAsString(listOf(1, 2, 3))) - .contentType(MediaType.APPLICATION_JSON), - ) + api + .perform( + delete("/bff/v1/reportings") + .content(objectMapper.writeValueAsString(listOf(1, 2, 3))) + .contentType(MediaType.APPLICATION_JSON), + ) // Then .andExpect(status().isOk) @@ -135,30 +139,30 @@ class ReportingControllerITests { given(addReporting.execute(any())).willReturn(Pair(reporting, null)) // When - api.perform( - post("/bff/v1/reportings") - .content( - objectMapper.writeValueAsString( - CreateReportingDataInput( - internalReferenceNumber = "FRFGRGR", - externalReferenceNumber = "RGD", - ircs = "6554fEE", - vesselIdentifier = VesselIdentifier.INTERNAL_REFERENCE_NUMBER, - flagState = CountryCode.FR, - creationDate = ZonedDateTime.now(), - value = - InfractionSuspicion( - ReportingActor.OPS, - natinfCode = 123456, - authorTrigram = "LTH", - title = "A title", - ), - type = ReportingType.INFRACTION_SUSPICION, + api + .perform( + post("/bff/v1/reportings") + .content( + objectMapper.writeValueAsString( + CreateReportingDataInput( + internalReferenceNumber = "FRFGRGR", + externalReferenceNumber = "RGD", + ircs = "6554fEE", + vesselIdentifier = VesselIdentifier.INTERNAL_REFERENCE_NUMBER, + flagState = CountryCode.FR, + creationDate = ZonedDateTime.now(), + value = + InfractionSuspicion( + ReportingActor.OPS, + natinfCode = 123456, + authorTrigram = "LTH", + title = "A title", + ), + type = ReportingType.INFRACTION_SUSPICION, + ), ), - ), - ) - .contentType(MediaType.APPLICATION_JSON), - ) + ).contentType(MediaType.APPLICATION_JSON), + ) // Then .andExpect(status().isCreated) .andExpect(MockMvcResultMatchers.jsonPath("$.internalReferenceNumber", equalTo("FRFGRGR"))) @@ -197,31 +201,31 @@ class ReportingControllerITests { ) // When - api.perform( - post("/bff/v1/reportings") - .content( - objectMapper.writeValueAsString( - CreateReportingDataInput( - internalReferenceNumber = "FRFGRGR", - externalReferenceNumber = "RGD", - ircs = "6554fEE", - vesselIdentifier = VesselIdentifier.INTERNAL_REFERENCE_NUMBER, - flagState = CountryCode.FR, - creationDate = ZonedDateTime.now(), - value = - InfractionSuspicion( - ReportingActor.OPS, - natinfCode = 123456, - controlUnitId = 1234, - authorTrigram = "LTH", - title = "A title", - ), - type = ReportingType.INFRACTION_SUSPICION, + api + .perform( + post("/bff/v1/reportings") + .content( + objectMapper.writeValueAsString( + CreateReportingDataInput( + internalReferenceNumber = "FRFGRGR", + externalReferenceNumber = "RGD", + ircs = "6554fEE", + vesselIdentifier = VesselIdentifier.INTERNAL_REFERENCE_NUMBER, + flagState = CountryCode.FR, + creationDate = ZonedDateTime.now(), + value = + InfractionSuspicion( + ReportingActor.OPS, + natinfCode = 123456, + controlUnitId = 1234, + authorTrigram = "LTH", + title = "A title", + ), + type = ReportingType.INFRACTION_SUSPICION, + ), ), - ), - ) - .contentType(MediaType.APPLICATION_JSON), - ) + ).contentType(MediaType.APPLICATION_JSON), + ) // Then .andExpect(status().isCreated) .andExpect(MockMvcResultMatchers.jsonPath("$.internalReferenceNumber", equalTo("FRFGRGR"))) @@ -262,7 +266,8 @@ class ReportingControllerITests { ) // When - api.perform(get("/bff/v1/reportings")) + api + .perform(get("/bff/v1/reportings")) // Then .andExpect(status().isOk) .andExpect(MockMvcResultMatchers.jsonPath("$.length()", equalTo(1))) @@ -298,21 +303,21 @@ class ReportingControllerITests { given(updateReporting.execute(any(), any())).willReturn(Pair(reporting, null)) // When - api.perform( - put("/bff/v1/reportings/123") - .content( - objectMapper.writeValueAsString( - UpdateReportingDataInput( - reportingActor = ReportingActor.OPS, - type = ReportingType.INFRACTION_SUSPICION, - natinfCode = 123456, - authorTrigram = "LTH", - title = "A title", + api + .perform( + put("/bff/v1/reportings/123") + .content( + objectMapper.writeValueAsString( + UpdateReportingDataInput( + reportingActor = ReportingActor.OPS, + type = ReportingType.INFRACTION_SUSPICION, + natinfCode = 123456, + authorTrigram = "LTH", + title = "A title", + ), ), - ), - ) - .contentType(MediaType.APPLICATION_JSON), - ) + ).contentType(MediaType.APPLICATION_JSON), + ) // Then .andExpect(status().isOk) @@ -343,29 +348,29 @@ class ReportingControllerITests { given(addReporting.execute(any())).willReturn(Pair(reporting, null)) // When - api.perform( - post("/bff/v1/reportings") - .content( - objectMapper.writeValueAsString( - CreateReportingDataInput( - internalReferenceNumber = "FRFGRGR", - externalReferenceNumber = "RGD", - flagState = CountryCode.FR, - ircs = "6554fEE", - creationDate = ZonedDateTime.now(), - value = - InfractionSuspicion( - ReportingActor.OPS, - natinfCode = 123456, - authorTrigram = "LTH", - title = "A title", - ), - type = ReportingType.INFRACTION_SUSPICION, + api + .perform( + post("/bff/v1/reportings") + .content( + objectMapper.writeValueAsString( + CreateReportingDataInput( + internalReferenceNumber = "FRFGRGR", + externalReferenceNumber = "RGD", + flagState = CountryCode.FR, + ircs = "6554fEE", + creationDate = ZonedDateTime.now(), + value = + InfractionSuspicion( + ReportingActor.OPS, + natinfCode = 123456, + authorTrigram = "LTH", + title = "A title", + ), + type = ReportingType.INFRACTION_SUSPICION, + ), ), - ), - ) - .contentType(MediaType.APPLICATION_JSON), - ) + ).contentType(MediaType.APPLICATION_JSON), + ) // Then .andExpect(status().isCreated) .andExpect(MockMvcResultMatchers.jsonPath("$.internalReferenceNumber", equalTo("FRFGRGR"))) diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/UserAuthorizationControllerITests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/UserAuthorizationControllerITests.kt index 97585a76fc..8e64c30f5e 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/UserAuthorizationControllerITests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/UserAuthorizationControllerITests.kt @@ -58,9 +58,7 @@ class UserAuthorizationControllerITests { @TestConfiguration class TestApiClient { @Bean - fun mockApiClient(): ApiClient { - return getMockApiClient() - } + fun mockApiClient(): ApiClient = getMockApiClient() } @MockBean @@ -73,10 +71,11 @@ class UserAuthorizationControllerITests { given(getAuthorizedUser.execute(any())).willReturn(UserAuthorization("email", true)) // When - api.perform( - get("/bff/v1/authorization/current") - .header("Authorization", "Bearer $VALID_JWT"), - ) + api + .perform( + get("/bff/v1/authorization/current") + .header("Authorization", "Bearer $VALID_JWT"), + ) // Then .andExpect(status().isOk) .andExpect(header().string("EMAIL", "d44b8b1163276cb22a02d462de5883ceb60b461e20c4e27e905b72ec8b649807")) @@ -90,10 +89,11 @@ class UserAuthorizationControllerITests { given(getAuthorizedUser.execute(any())).willReturn(UserAuthorization("email", true)) // When - api.perform( - get("/bff/v1/authorization/current") - .header("Authorization", "Bearer $VALID_JWT"), - ) + api + .perform( + get("/bff/v1/authorization/current") + .header("Authorization", "Bearer $VALID_JWT"), + ) // Then .andExpect(status().isUnauthorized) } @@ -110,10 +110,11 @@ class UserAuthorizationControllerITests { ) // When - api.perform( - get("/bff/v1/authorization/current") - .header("Authorization", "Bearer $VALID_JWT"), - ) + api + .perform( + get("/bff/v1/authorization/current") + .header("Authorization", "Bearer $VALID_JWT"), + ) // Then .andExpect(status().isOk) .andExpect(header().string("EMAIL", "d44b8b1163276cb22a02d462de5883ceb60b461e20c4e27e905b72ec8b649807")) diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/VesselControllerITests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/VesselControllerITests.kt index 02e6ed8741..5e1ebb2235 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/VesselControllerITests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/VesselControllerITests.kt @@ -112,7 +112,8 @@ class VesselControllerITests { estimatedCurrentLongitude = 48.2525, speed = 1.8, course = 180.0, - dateTime = farPastFixedDateTime, vesselIdentifier = VesselIdentifier.INTERNAL_REFERENCE_NUMBER, + dateTime = farPastFixedDateTime, + vesselIdentifier = VesselIdentifier.INTERNAL_REFERENCE_NUMBER, gearOnboard = listOf( gear, @@ -121,7 +122,8 @@ class VesselControllerITests { given(this.getLastPositions.execute()).willReturn(listOf(position)) // When - api.perform(get("/bff/v1/vessels")) + api + .perform(get("/bff/v1/vessels")) // Then .andExpect(status().isOk) .andExpect(jsonPath("$[0].vesselName", equalTo(position.vesselName))) @@ -247,11 +249,12 @@ class VesselControllerITests { } // When - api.perform( - get( - "/bff/v1/vessels/find?vesselId=123&internalReferenceNumber=FR224226850&externalReferenceNumber=123&IRCS=IEF4&trackDepth=TWELVE_HOURS&vesselIdentifier=INTERNAL_REFERENCE_NUMBER", - ), - ) + api + .perform( + get( + "/bff/v1/vessels/find?vesselId=123&internalReferenceNumber=FR224226850&externalReferenceNumber=123&IRCS=IEF4&trackDepth=TWELVE_HOURS&vesselIdentifier=INTERNAL_REFERENCE_NUMBER", + ), + ) // Then .andExpect(status().isOk) .andExpect(jsonPath("$.vessel.declaredFishingGears[0]", equalTo("Trémails"))) @@ -298,11 +301,12 @@ class VesselControllerITests { } // When - api.perform( - get( - "/bff/v1/vessels/find?vesselId=&internalReferenceNumber=FR224226850&externalReferenceNumber=123&IRCS=IEF4&trackDepth=TWELVE_HOURS&vesselIdentifier=INTERNAL_REFERENCE_NUMBER", - ), - ) + api + .perform( + get( + "/bff/v1/vessels/find?vesselId=&internalReferenceNumber=FR224226850&externalReferenceNumber=123&IRCS=IEF4&trackDepth=TWELVE_HOURS&vesselIdentifier=INTERNAL_REFERENCE_NUMBER", + ), + ) // Then .andExpect(status().isAccepted) } @@ -324,12 +328,13 @@ class VesselControllerITests { } // When - api.perform( - get( - "/bff/v1/vessels/find?internalReferenceNumber=FR224226850&externalReferenceNumber=123" + - "&IRCS=IEF4&trackDepth=CUSTOM&vesselIdentifier=INTERNAL_REFERENCE_NUMBER&afterDateTime=2021-03-24T22:07:00.000Z&beforeDateTime=2021-04-24T22:07:00.000Z", - ), - ) + api + .perform( + get( + "/bff/v1/vessels/find?internalReferenceNumber=FR224226850&externalReferenceNumber=123" + + "&IRCS=IEF4&trackDepth=CUSTOM&vesselIdentifier=INTERNAL_REFERENCE_NUMBER&afterDateTime=2021-03-24T22:07:00.000Z&beforeDateTime=2021-04-24T22:07:00.000Z", + ), + ) // Then .andExpect(status().isOk) @@ -421,11 +426,12 @@ class VesselControllerITests { } // When - api.perform( - get( - "/bff/v1/vessels/positions?internalReferenceNumber=FR224226850&externalReferenceNumber=123&IRCS=IEF4&trackDepth=TWELVE_HOURS&vesselIdentifier=INTERNAL_REFERENCE_NUMBER", - ), - ) + api + .perform( + get( + "/bff/v1/vessels/positions?internalReferenceNumber=FR224226850&externalReferenceNumber=123&IRCS=IEF4&trackDepth=TWELVE_HOURS&vesselIdentifier=INTERNAL_REFERENCE_NUMBER", + ), + ) // Then .andExpect(status().isOk) .andExpect(jsonPath("$.length()", equalTo(3))) @@ -478,7 +484,8 @@ class VesselControllerITests { ) // When - api.perform(get("/bff/v1/vessels/search?searched=VESSEL")) + api + .perform(get("/bff/v1/vessels/search?searched=VESSEL")) // Then .andExpect(status().isOk) .andExpect(jsonPath("$.length()", equalTo(2))) @@ -508,9 +515,12 @@ class VesselControllerITests { given(this.getVesselVoyage.execute(any(), any(), anyOrNull())).willReturn(voyage) // When - api.perform( - get("/bff/v1/vessels/logbook/find?internalReferenceNumber=FR224226850&voyageRequest=LAST&beforeDateTime="), - ) + api + .perform( + get( + "/bff/v1/vessels/logbook/find?internalReferenceNumber=FR224226850&voyageRequest=LAST&beforeDateTime=", + ), + ) // Then .andExpect(status().isOk) .andExpect(jsonPath("$.length()", equalTo(6))) @@ -526,8 +536,7 @@ class VesselControllerITests { "$.logbookMessagesAndAlerts.logbookMessages[0].message.hauls[0].dimensions", equalTo("150;120"), ), - ) - .andExpect(jsonPath("$.logbookMessagesAndAlerts.logbookMessages[1].messageType", equalTo("DEP"))) + ).andExpect(jsonPath("$.logbookMessagesAndAlerts.logbookMessages[1].messageType", equalTo("DEP"))) .andExpect(jsonPath("$.logbookMessagesAndAlerts.logbookMessages[1].tripNumber", equalTo("345"))) .andExpect( jsonPath( @@ -547,11 +556,12 @@ class VesselControllerITests { ).willThrow(BackendUsageException(BackendUsageErrorCode.NOT_FOUND_BUT_OK)) // When - api.perform( - get( - "/bff/v1/vessels/logbook/find?internalReferenceNumber=FR224226850&voyageRequest=PREVIOUS&tripNumber=12345", - ), - ) + api + .perform( + get( + "/bff/v1/vessels/logbook/find?internalReferenceNumber=FR224226850&voyageRequest=PREVIOUS&tripNumber=12345", + ), + ) // Then .andExpect(status().isOk) .andExpect(jsonPath("$.code", equalTo("NOT_FOUND_BUT_OK"))) @@ -594,58 +604,15 @@ class VesselControllerITests { eq(123), any(), ), - ) - .willReturn( - VesselBeaconMalfunctionsResumeAndHistory( - resume = VesselBeaconMalfunctionsResume(1, 2, null, null), - history = - listOf( - BeaconMalfunctionWithDetails( - beaconMalfunction = - BeaconMalfunction( - id = 1, - internalReferenceNumber = "FR224226850", - externalReferenceNumber = "1236514", - ircs = "IRCS", - flagState = "fr", - vesselIdentifier = VesselIdentifier.INTERNAL_REFERENCE_NUMBER, - vesselName = "BIDUBULE", - vesselStatus = VesselStatus.AT_SEA, - stage = Stage.ARCHIVED, - malfunctionStartDateTime = ZonedDateTime.now(), - malfunctionEndDateTime = null, - vesselStatusLastModificationDateTime = ZonedDateTime.now(), - endOfBeaconMalfunctionReason = EndOfBeaconMalfunctionReason.RESUMED_TRANSMISSION, - beaconNumber = "123465", - beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, - vesselId = 123, - ), - comments = - listOf( - BeaconMalfunctionComment( - beaconMalfunctionId = 1, - comment = "A comment", - userType = BeaconMalfunctionCommentUserType.SIP, - dateTime = now, - ), - ), - actions = - listOf( - BeaconMalfunctionAction( - beaconMalfunctionId = 1, - propertyName = BeaconMalfunctionActionPropertyName.VESSEL_STATUS, - nextValue = "A VALUE", - previousValue = "A VALUE", - dateTime = now, - ), - ), - ), - ), - current = + ).willReturn( + VesselBeaconMalfunctionsResumeAndHistory( + resume = VesselBeaconMalfunctionsResume(1, 2, null, null), + history = + listOf( BeaconMalfunctionWithDetails( beaconMalfunction = BeaconMalfunction( - id = 2, + id = 1, internalReferenceNumber = "FR224226850", externalReferenceNumber = "1236514", ircs = "IRCS", @@ -653,10 +620,11 @@ class VesselControllerITests { vesselIdentifier = VesselIdentifier.INTERNAL_REFERENCE_NUMBER, vesselName = "BIDUBULE", vesselStatus = VesselStatus.AT_SEA, - stage = Stage.INITIAL_ENCOUNTER, + stage = Stage.ARCHIVED, malfunctionStartDateTime = ZonedDateTime.now(), malfunctionEndDateTime = null, vesselStatusLastModificationDateTime = ZonedDateTime.now(), + endOfBeaconMalfunctionReason = EndOfBeaconMalfunctionReason.RESUMED_TRANSMISSION, beaconNumber = "123465", beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, vesselId = 123, @@ -681,15 +649,57 @@ class VesselControllerITests { ), ), ), - ), - ) - - // When - api.perform( - get( - "/bff/v1/vessels/beacon_malfunctions?vesselId=123&afterDateTime=2021-03-24T22:07:00.000Z", + ), + current = + BeaconMalfunctionWithDetails( + beaconMalfunction = + BeaconMalfunction( + id = 2, + internalReferenceNumber = "FR224226850", + externalReferenceNumber = "1236514", + ircs = "IRCS", + flagState = "fr", + vesselIdentifier = VesselIdentifier.INTERNAL_REFERENCE_NUMBER, + vesselName = "BIDUBULE", + vesselStatus = VesselStatus.AT_SEA, + stage = Stage.INITIAL_ENCOUNTER, + malfunctionStartDateTime = ZonedDateTime.now(), + malfunctionEndDateTime = null, + vesselStatusLastModificationDateTime = ZonedDateTime.now(), + beaconNumber = "123465", + beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, + vesselId = 123, + ), + comments = + listOf( + BeaconMalfunctionComment( + beaconMalfunctionId = 1, + comment = "A comment", + userType = BeaconMalfunctionCommentUserType.SIP, + dateTime = now, + ), + ), + actions = + listOf( + BeaconMalfunctionAction( + beaconMalfunctionId = 1, + propertyName = BeaconMalfunctionActionPropertyName.VESSEL_STATUS, + nextValue = "A VALUE", + previousValue = "A VALUE", + dateTime = now, + ), + ), + ), ), ) + + // When + api + .perform( + get( + "/bff/v1/vessels/beacon_malfunctions?vesselId=123&afterDateTime=2021-03-24T22:07:00.000Z", + ), + ) // Then .andExpect(status().isOk) .andExpect(jsonPath("$.resume.numberOfBeaconsAtSea", equalTo(1))) @@ -707,8 +717,7 @@ class VesselControllerITests { "$.history[0].beaconMalfunction.endOfBeaconMalfunctionReason", equalTo("RESUMED_TRANSMISSION"), ), - ) - .andExpect(jsonPath("$.history[0].actions[0].beaconMalfunctionId", equalTo(1))) + ).andExpect(jsonPath("$.history[0].actions[0].beaconMalfunctionId", equalTo(1))) .andExpect(jsonPath("$.history[0].actions[0].propertyName", equalTo("VESSEL_STATUS"))) .andExpect(jsonPath("$.history[0].comments[0].beaconMalfunctionId", equalTo(1))) .andExpect(jsonPath("$.history[0].comments[0].comment", equalTo("A comment"))) @@ -765,62 +774,62 @@ class VesselControllerITests { eq(VesselIdentifier.INTERNAL_REFERENCE_NUMBER), any(), ), - ) - .willReturn( - VesselReportings( - summary = - ReportingSummary( - infractionSuspicionsSummary = - listOf( - ReportingTitleAndNumberOfOccurrences( - title = "A title", - numberOfOccurrences = 2, - ), - ReportingTitleAndNumberOfOccurrences( - title = "A title", - numberOfOccurrences = 2, - ), + ).willReturn( + VesselReportings( + summary = + ReportingSummary( + infractionSuspicionsSummary = + listOf( + ReportingTitleAndNumberOfOccurrences( + title = "A title", + numberOfOccurrences = 2, + ), + ReportingTitleAndNumberOfOccurrences( + title = "A title", + numberOfOccurrences = 2, ), - numberOfInfractionSuspicions = 4, - numberOfObservations = 5, - ), - current = - listOf( - ReportingAndOccurrences( - otherOccurrencesOfSameAlert = listOf(), - reporting = currentReporting, - controlUnit = null, - ), - ReportingAndOccurrences( - otherOccurrencesOfSameAlert = listOf(), - reporting = currentReporting, - controlUnit = null, ), + numberOfInfractionSuspicions = 4, + numberOfObservations = 5, + ), + current = + listOf( + ReportingAndOccurrences( + otherOccurrencesOfSameAlert = listOf(), + reporting = currentReporting, + controlUnit = null, ), - archived = - mapOf( - 2024 to - listOf( - ReportingAndOccurrences( - otherOccurrencesOfSameAlert = listOf(), - reporting = archivedReporting, - controlUnit = null, - ), - ), - 2023 to emptyList(), - 2022 to emptyList(), - 2021 to emptyList(), + ReportingAndOccurrences( + otherOccurrencesOfSameAlert = listOf(), + reporting = currentReporting, + controlUnit = null, ), - ), - ) - - // When - api.perform( - get( - "/bff/v1/vessels/reportings?vesselId=123456&internalReferenceNumber=FR224226850" + - "&externalReferenceNumber=123&ircs=IEF4&vesselIdentifier=INTERNAL_REFERENCE_NUMBER&fromDate=2021-03-24T22:07:00.000Z", + ), + archived = + mapOf( + 2024 to + listOf( + ReportingAndOccurrences( + otherOccurrencesOfSameAlert = listOf(), + reporting = archivedReporting, + controlUnit = null, + ), + ), + 2023 to emptyList(), + 2022 to emptyList(), + 2021 to emptyList(), + ), ), ) + + // When + api + .perform( + get( + "/bff/v1/vessels/reportings?vesselId=123456&internalReferenceNumber=FR224226850" + + "&externalReferenceNumber=123&ircs=IEF4&vesselIdentifier=INTERNAL_REFERENCE_NUMBER&fromDate=2021-03-24T22:07:00.000Z", + ), + ) // Then .andExpect(status().isOk) .andExpect(jsonPath("$.current.length()", equalTo(2))) @@ -856,27 +865,27 @@ class VesselControllerITests { eq(VesselIdentifier.INTERNAL_REFERENCE_NUMBER), any(), ), + ).willReturn( + VesselReportings( + summary = + ReportingSummary( + infractionSuspicionsSummary = listOf(), + numberOfInfractionSuspicions = 0, + numberOfObservations = 0, + ), + current = listOf(), + archived = mapOf(), + ), ) - .willReturn( - VesselReportings( - summary = - ReportingSummary( - infractionSuspicionsSummary = listOf(), - numberOfInfractionSuspicions = 0, - numberOfObservations = 0, - ), - current = listOf(), - archived = mapOf(), - ), - ) // When - api.perform( - get( - "/bff/v1/vessels/reportings?vesselId=&internalReferenceNumber=FR224226850" + - "&externalReferenceNumber=123&ircs=IEF4&vesselIdentifier=INTERNAL_REFERENCE_NUMBER&fromDate=2021-03-24T22:07:00.000Z", - ), - ) + api + .perform( + get( + "/bff/v1/vessels/reportings?vesselId=&internalReferenceNumber=FR224226850" + + "&externalReferenceNumber=123&ircs=IEF4&vesselIdentifier=INTERNAL_REFERENCE_NUMBER&fromDate=2021-03-24T22:07:00.000Z", + ), + ) // Then .andExpect(status().isOk) @@ -898,7 +907,8 @@ class VesselControllerITests { ) // When - api.perform(get("/bff/v1/vessels/risk_factor?internalReferenceNumber=FR224226850")) + api + .perform(get("/bff/v1/vessels/risk_factor?internalReferenceNumber=FR224226850")) // Then .andExpect(status().isOk) .andExpect(jsonPath("$.impactRiskFactor", equalTo(1.0))) @@ -913,7 +923,8 @@ class VesselControllerITests { given(this.getVesselRiskFactor.execute(any())).willThrow(IllegalArgumentException("Not found")) // When - api.perform(get("/bff/v1/vessels/risk_factor?internalReferenceNumber=FR224226850")) + api + .perform(get("/bff/v1/vessels/risk_factor?internalReferenceNumber=FR224226850")) // Then .andExpect(status().isBadRequest) } @@ -924,9 +935,10 @@ class VesselControllerITests { given(this.getVesselLastTripNumbers.execute(any())).willReturn(listOf("2020000125", "2020000126", "2020000127")) // When - api.perform( - get("/bff/v1/vessels/logbook/last?internalReferenceNumber=FR224226850"), - ) + api + .perform( + get("/bff/v1/vessels/logbook/last?internalReferenceNumber=FR224226850"), + ) // Then .andExpect(status().isOk) .andExpect(jsonPath("$.length()", equalTo(3))) diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/light/VesselLightControllerITests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/light/VesselLightControllerITests.kt index 443b585721..834a611c0f 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/light/VesselLightControllerITests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/light/VesselLightControllerITests.kt @@ -82,11 +82,30 @@ class VesselLightControllerITests { // Given val farPastFixedDateTime = ZonedDateTime.of(EPOCH, LocalTime.MAX.plusSeconds(1), ZoneId.of("UTC")) val position = - LastPosition(0, 1, "MMSI", null, null, null, null, CountryCode.FR, PositionType.AIS, 16.445, 48.2525, 16.445, 48.2525, 1.8, 180.0, farPastFixedDateTime, vesselIdentifier = VesselIdentifier.INTERNAL_REFERENCE_NUMBER) + LastPosition( + 0, + 1, + "MMSI", + null, + null, + null, + null, + CountryCode.FR, + PositionType.AIS, + 16.445, + 48.2525, + 16.445, + 48.2525, + 1.8, + 180.0, + farPastFixedDateTime, + vesselIdentifier = VesselIdentifier.INTERNAL_REFERENCE_NUMBER, + ) given(this.getLastPositions.execute()).willReturn(listOf(position)) // When - api.perform(get("/light/v1/vessels")) + api + .perform(get("/light/v1/vessels")) // Then .andExpect(status().isOk) .andExpect(jsonPath("$[0].vesselName", equalTo(position.vesselName))) @@ -208,11 +227,12 @@ class VesselLightControllerITests { } // When - api.perform( - get( - "/light/v1/vessels/find?vesselId=123&internalReferenceNumber=FR224226850&externalReferenceNumber=123&IRCS=IEF4&trackDepth=TWELVE_HOURS&vesselIdentifier=INTERNAL_REFERENCE_NUMBER", - ), - ) + api + .perform( + get( + "/light/v1/vessels/find?vesselId=123&internalReferenceNumber=FR224226850&externalReferenceNumber=123&IRCS=IEF4&trackDepth=TWELVE_HOURS&vesselIdentifier=INTERNAL_REFERENCE_NUMBER", + ), + ) // Then .andExpect(status().isOk) .andExpect(jsonPath("$.vessel.declaredFishingGears[0]", equalTo("Trémails"))) @@ -253,11 +273,12 @@ class VesselLightControllerITests { given(this.getVesselVoyage.execute(any(), any(), anyOrNull())).willReturn(voyage) // When - api.perform( - get( - "/light/v1/vessels/logbook/find?internalReferenceNumber=FR224226850&voyageRequest=LAST&beforeDateTime=", - ), - ) + api + .perform( + get( + "/light/v1/vessels/logbook/find?internalReferenceNumber=FR224226850&voyageRequest=LAST&beforeDateTime=", + ), + ) // Then .andExpect(status().isOk) .andExpect(jsonPath("$.length()", equalTo(6))) @@ -274,8 +295,7 @@ class VesselLightControllerITests { "$.logbookMessagesAndAlerts.logbookMessages[1].reportDateTime", equalTo("2020-05-04T03:04:05.000000003Z"), ), - ) - .andExpect(jsonPath("$.logbookMessagesAndAlerts.logbookMessages[1].rawMessage").doesNotExist()) + ).andExpect(jsonPath("$.logbookMessagesAndAlerts.logbookMessages[1].rawMessage").doesNotExist()) Mockito.verify(getVesselVoyage).execute("FR224226850", VoyageRequest.LAST, null) } diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/HealthcheckControllerITests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/HealthcheckControllerITests.kt index debcb939a0..71e4f31ba5 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/HealthcheckControllerITests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/HealthcheckControllerITests.kt @@ -40,7 +40,8 @@ class HealthcheckControllerITests { ) // When - api.perform(get("/api/v1/healthcheck")) + api + .perform(get("/api/v1/healthcheck")) // Then .andExpect(status().isOk) .andExpect(jsonPath("$.dateLastPositionUpdatedByPrefect", equalTo("2020-12-21T15:01:00Z"))) diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/InfractionControllerITests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/InfractionControllerITests.kt index 9c9cc58d66..dc82cbd687 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/InfractionControllerITests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/InfractionControllerITests.kt @@ -44,7 +44,8 @@ class InfractionControllerITests { ) // When - api.perform(get("/api/v1/infractions")) + api + .perform(get("/api/v1/infractions")) // Then .andExpect(status().isOk) .andExpect(jsonPath("$.length()", equalTo(2))) diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/PositionsControllerITests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/PositionsControllerITests.kt index 191724a0f3..cc71615f94 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/PositionsControllerITests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/PositionsControllerITests.kt @@ -33,10 +33,12 @@ class PositionsControllerITests { // When val body = - api.perform(post("/api/v1/positions").content("TEST")) + api + .perform(post("/api/v1/positions").content("TEST")) // Then .andExpect(status().isOk) - .andReturn().response.contentAsString + .andReturn() + .response.contentAsString assertThat(body).contains("ARGH for NAF message") } @@ -47,7 +49,8 @@ class PositionsControllerITests { val naf = "//SR//AD/FRA//FR/GBR//RD/20201006//RT/2141//FS/GBR//RC/MGXR6//IR/GBROOC21250//DA/20201006//TI/1625//LT/53.254//LG/.940//SP/96//CO/8//TM/POS//ER//" // When - api.perform(post("/api/v1/positions").content(naf)) + api + .perform(post("/api/v1/positions").content(naf)) // Then .andExpect(status().isCreated) } diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/PublicBeaconMalfunctionControllerITests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/PublicBeaconMalfunctionControllerITests.kt index f06a78f97d..6c089abcbc 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/PublicBeaconMalfunctionControllerITests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/PublicBeaconMalfunctionControllerITests.kt @@ -49,10 +49,21 @@ class PublicBeaconMalfunctionControllerITests { BeaconMalfunctionResumeAndDetails( beaconMalfunction = BeaconMalfunction( - 1, "CFR", "EXTERNAL_IMMAT", "IRCS", - "fr", VesselIdentifier.INTERNAL_REFERENCE_NUMBER, "BIDUBULE", VesselStatus.AT_SEA, Stage.INITIAL_ENCOUNTER, - ZonedDateTime.now(), null, ZonedDateTime.now(), - beaconNumber = "123465", beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, vesselId = 123, + 1, + "CFR", + "EXTERNAL_IMMAT", + "IRCS", + "fr", + VesselIdentifier.INTERNAL_REFERENCE_NUMBER, + "BIDUBULE", + VesselStatus.AT_SEA, + Stage.INITIAL_ENCOUNTER, + ZonedDateTime.now(), + null, + ZonedDateTime.now(), + beaconNumber = "123465", + beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, + vesselId = 123, ), comments = listOf( @@ -79,15 +90,15 @@ class PublicBeaconMalfunctionControllerITests { ) // When - api.perform( - put("/api/v1/beacon_malfunctions/123") - .content( - objectMapper.writeValueAsString( - UpdateBeaconMalfunctionDataInput(vesselStatus = VesselStatus.AT_SEA), - ), - ) - .contentType(MediaType.APPLICATION_JSON), - ) + api + .perform( + put("/api/v1/beacon_malfunctions/123") + .content( + objectMapper.writeValueAsString( + UpdateBeaconMalfunctionDataInput(vesselStatus = VesselStatus.AT_SEA), + ), + ).contentType(MediaType.APPLICATION_JSON), + ) // Then .andExpect(status().isOk) .andExpect(jsonPath("$.comments.length()", equalTo(1))) @@ -103,10 +114,13 @@ class PublicBeaconMalfunctionControllerITests { .willThrow(CouldNotUpdateBeaconMalfunctionException("FAIL")) // When - api.perform( - put("/api/v1/beacon_malfunctions/123", objectMapper.writeValueAsString(UpdateControlObjectiveDataInput())) - .contentType(MediaType.APPLICATION_JSON), - ) + api + .perform( + put( + "/api/v1/beacon_malfunctions/123", + objectMapper.writeValueAsString(UpdateControlObjectiveDataInput()), + ).contentType(MediaType.APPLICATION_JSON), + ) // Then .andExpect(status().isBadRequest) } @@ -114,7 +128,8 @@ class PublicBeaconMalfunctionControllerITests { @Test fun `Should request a notification`() { // When - api.perform(put("/api/v1/beacon_malfunctions/123/MALFUNCTION_AT_PORT_INITIAL_NOTIFICATION")) + api + .perform(put("/api/v1/beacon_malfunctions/123/MALFUNCTION_AT_PORT_INITIAL_NOTIFICATION")) // Then .andExpect(status().isOk) @@ -128,11 +143,12 @@ class PublicBeaconMalfunctionControllerITests { @Test fun `Should request a notification to a foreign fmc`() { // When - api.perform( - put( - "/api/v1/beacon_malfunctions/123/MALFUNCTION_NOTIFICATION_TO_FOREIGN_FMC?requestedNotificationForeignFmcCode=ABC", - ), - ) + api + .perform( + put( + "/api/v1/beacon_malfunctions/123/MALFUNCTION_NOTIFICATION_TO_FOREIGN_FMC?requestedNotificationForeignFmcCode=ABC", + ), + ) // Then .andExpect(status().isOk) diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/PublicMissionActionsControllerITests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/PublicMissionActionsControllerITests.kt index 81b5b71023..85a7691886 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/PublicMissionActionsControllerITests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/PublicMissionActionsControllerITests.kt @@ -66,7 +66,8 @@ class PublicMissionActionsControllerITests { ) // When - api.perform(get("/api/v1/mission_actions?missionId=123")) + api + .perform(get("/api/v1/mission_actions?missionId=123")) // Then .andExpect(status().isOk) .andExpect(jsonPath("$.length()", equalTo(1))) @@ -85,18 +86,18 @@ class PublicMissionActionsControllerITests { given(patchMissionAction.execute(any(), any())).willReturn(newMission) // When - api.perform( - patch("/api/v1/mission_actions/123") - .content( - """ - { - "observationsByUnit": "OBSERVATION", - "actionEndDatetimeUtc": "2024-02-01T14:29:00Z" - } - """.trimIndent(), - ) - .contentType(MediaType.APPLICATION_JSON), - ) + api + .perform( + patch("/api/v1/mission_actions/123") + .content( + """ + { + "observationsByUnit": "OBSERVATION", + "actionEndDatetimeUtc": "2024-02-01T14:29:00Z" + } + """.trimIndent(), + ).contentType(MediaType.APPLICATION_JSON), + ) // Then .andExpect(status().isOk) } diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/PublicPendingAlertControllerITests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/PublicPendingAlertControllerITests.kt index 087248353a..86c2b9e13a 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/PublicPendingAlertControllerITests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/PublicPendingAlertControllerITests.kt @@ -25,7 +25,8 @@ class PublicPendingAlertControllerITests { @Test fun `Should validate an operational alert`() { // When - api.perform(MockMvcRequestBuilders.put("/api/v1/operational_alerts/666/validate")) + api + .perform(MockMvcRequestBuilders.put("/api/v1/operational_alerts/666/validate")) // Then .andExpect(MockMvcResultMatchers.status().isOk) } diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/PublicPortControllerITests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/PublicPortControllerITests.kt index bb7580452c..fe0eea4d79 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/PublicPortControllerITests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/PublicPortControllerITests.kt @@ -1,25 +1,24 @@ package fr.gouv.cnsp.monitorfish.infrastructure.api.public_api import fr.gouv.cnsp.monitorfish.config.SentryConfig +import fr.gouv.cnsp.monitorfish.domain.use_cases.port.GetActivePorts import fr.gouv.cnsp.monitorfish.fakers.PortFaker import fr.gouv.cnsp.monitorfish.infrastructure.cache.CaffeineConfiguration -import fr.gouv.cnsp.monitorfish.domain.use_cases.port.GetActivePorts import org.assertj.core.api.Assertions.assertThat +import org.hamcrest.Matchers.equalTo import org.junit.jupiter.api.Test +import org.mockito.BDDMockito.given import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest +import org.springframework.boot.test.mock.mockito.MockBean import org.springframework.cache.CacheManager import org.springframework.context.annotation.Import import org.springframework.test.web.servlet.MockMvc -import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put -import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status -import org.springframework.boot.test.mock.mockito.MockBean import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put import org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status -import org.hamcrest.Matchers.equalTo -import org.mockito.BDDMockito.given @Import(SentryConfig::class, CaffeineConfiguration::class) @AutoConfigureMockMvc(addFilters = false) @@ -45,7 +44,8 @@ class PublicPortControllerITests { ) // When - api.perform(get("/api/v1/ports")) + api + .perform(get("/api/v1/ports")) // Then .andExpect(status().isOk) .andExpect(jsonPath("$.length()", equalTo(2))) @@ -62,7 +62,8 @@ class PublicPortControllerITests { assertThat(cacheManager.getCache("ports")?.get("PORT123")).isNotNull() // When - api.perform(put("/api/v1/ports/invalidate")) + api + .perform(put("/api/v1/ports/invalidate")) .andExpect(status().isOk) // Then diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/PublicReportingControllerITests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/PublicReportingControllerITests.kt index 8ca83ed9f4..5eb3368057 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/PublicReportingControllerITests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/PublicReportingControllerITests.kt @@ -26,7 +26,8 @@ class PublicReportingControllerITests { @Test fun `Should archive a reporting`() { // When - api.perform(put("/api/v1/reportings/123/archive")) + api + .perform(put("/api/v1/reportings/123/archive")) // Then .andExpect(status().isOk) diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/PublicVesselControllerITests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/PublicVesselControllerITests.kt index 16e64315bd..c4889577d2 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/PublicVesselControllerITests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/PublicVesselControllerITests.kt @@ -2,17 +2,12 @@ package fr.gouv.cnsp.monitorfish.infrastructure.api.public_api import com.neovisionaries.i18n.CountryCode import com.nhaarman.mockitokotlin2.any -import com.nhaarman.mockitokotlin2.anyOrNull -import com.nhaarman.mockitokotlin2.eq import fr.gouv.cnsp.monitorfish.config.SentryConfig -import fr.gouv.cnsp.monitorfish.domain.entities.alerts.type.ThreeMilesTrawlingAlert +import fr.gouv.cnsp.monitorfish.domain.entities.beacon_malfunctions.* import fr.gouv.cnsp.monitorfish.domain.entities.vessel.* -import fr.gouv.cnsp.monitorfish.domain.use_cases.TestUtils import fr.gouv.cnsp.monitorfish.domain.use_cases.vessel.* -import fr.gouv.cnsp.monitorfish.domain.entities.beacon_malfunctions.* import org.hamcrest.Matchers.equalTo import org.junit.jupiter.api.Test -import org.mockito.BDDMockito import org.mockito.BDDMockito.given import org.mockito.Mockito import org.springframework.beans.factory.annotation.Autowired @@ -70,7 +65,8 @@ class PublicVesselControllerITests { ) // When - api.perform(get("/api/v1/vessels/search?searched=VESSEL")) + api + .perform(get("/api/v1/vessels/search?searched=VESSEL")) // Then .andExpect(status().isOk) .andExpect(jsonPath("$.length()", equalTo(2))) diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/UserManagementControllerITests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/UserManagementControllerITests.kt index accb7cb0f2..4ff23df616 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/UserManagementControllerITests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/UserManagementControllerITests.kt @@ -36,11 +36,13 @@ class UserManagementControllerITests { @Test fun `Should save an user`() { // When - api.perform( - post("/api/v1/authorization/management").content( - objectMapper.writeValueAsString(AddUserDataInput("dummy@email.com", true)), - ).contentType(MediaType.APPLICATION_JSON), - ) + api + .perform( + post("/api/v1/authorization/management") + .content( + objectMapper.writeValueAsString(AddUserDataInput("dummy@email.com", true)), + ).contentType(MediaType.APPLICATION_JSON), + ) // Then .andExpect(status().isCreated) } @@ -48,7 +50,8 @@ class UserManagementControllerITests { @Test fun `Should delete an user`() { // When - api.perform(delete("/api/v1/authorization/management/dummy@email.com")) + api + .perform(delete("/api/v1/authorization/management/dummy@email.com")) // Then .andExpect(status().isOk) } diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/security/BffFilterConfigITests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/security/BffFilterConfigITests.kt index 2a3070eb79..cafe9ec9e8 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/security/BffFilterConfigITests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/security/BffFilterConfigITests.kt @@ -66,10 +66,11 @@ class BffFilterConfigITests { "/bff/v1/reportings", "/bff/v1/vessels/risk_factors", ).forEach { - mockMvc.perform( - get(it) - .header("Authorization", "Bearer $VALID_JWT"), - ) + mockMvc + .perform( + get(it) + .header("Authorization", "Bearer $VALID_JWT"), + ) // Then .andExpect(status().isUnauthorized) } @@ -82,9 +83,10 @@ class BffFilterConfigITests { "/api/v1/authorization/management", "/api/v1/beacon_malfunctions/123", ).forEach { - mockMvc.perform( - get(it), - ) + mockMvc + .perform( + get(it), + ) // Then .andExpect(status().isUnauthorized) } @@ -96,9 +98,10 @@ class BffFilterConfigITests { listOf( "/api/v1/authorization/management/dummy@user.com", ).forEach { - mockMvc.perform( - delete(it), - ) + mockMvc + .perform( + delete(it), + ) // Then .andExpect(status().isUnauthorized) } diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/AbstractDBTests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/AbstractDBTests.kt index 2a337a522b..014a14b1ad 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/AbstractDBTests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/AbstractDBTests.kt @@ -55,9 +55,10 @@ abstract class AbstractDBTests { container.followOutput(toStringConsumer, OutputFrame.OutputType.STDOUT) return "jdbc:postgresql://" + container.host + ":" + - container.getMappedPort( - PostgreSQLContainer.POSTGRESQL_PORT, - ).toString() + "/testdb?user=postgres&password=postgres" + container + .getMappedPort( + PostgreSQLContainer.POSTGRESQL_PORT, + ).toString() + "/testdb?user=postgres&password=postgres" } } } diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaFleetSegmentRepositoryITests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaFleetSegmentRepositoryITests.kt index 66680e2c7d..f413f983ee 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaFleetSegmentRepositoryITests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaFleetSegmentRepositoryITests.kt @@ -265,8 +265,33 @@ class JpaFleetSegmentRepositoryITests : AbstractDBTests() { assertThat(gears).hasSize(26) assertThat(gears).isEqualTo( - listOf("SV", "OTB", "TBB", "GTR", "PTB", "TMS", "OTT", "TM", "OTM", "GNC", "SX", "TBS", "SSC", "TBN", - "OT", "PTM", "TX", "SPR", "GNS", "TB", "SDN", "PT", "GN", "GEN", "GTN", "GNF", + listOf( + "SV", + "OTB", + "TBB", + "GTR", + "PTB", + "TMS", + "OTT", + "TM", + "OTM", + "GNC", + "SX", + "TBS", + "SSC", + "TBN", + "OT", + "PTM", + "TX", + "SPR", + "GNS", + "TB", + "SDN", + "PT", + "GN", + "GEN", + "GTN", + "GNF", ), ) } diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaLogbookReportRepositoryITests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaLogbookReportRepositoryITests.kt index 1d09cff590..5990ad7496 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaLogbookReportRepositoryITests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaLogbookReportRepositoryITests.kt @@ -508,7 +508,8 @@ class JpaLogbookReportRepositoryITests : AbstractDBTests() { val messages = TestUtils.getDummyLogbookMessages() jpaLogbookReportRepository.save( - messages.first() + messages + .first() .copy( internalReferenceNumber = "FAK000999999", operationNumber = "FPXE1546546114565", @@ -518,7 +519,8 @@ class JpaLogbookReportRepositoryITests : AbstractDBTests() { ), ) jpaLogbookReportRepository.save( - messages.last() + messages + .last() .copy( internalReferenceNumber = "FAK000999999", operationNumber = "FPXE1546545654481", diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaManualPriorNotificationRepositoryITests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaManualPriorNotificationRepositoryITests.kt index ddc96bea6a..c4a89a95e9 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaManualPriorNotificationRepositoryITests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaManualPriorNotificationRepositoryITests.kt @@ -510,8 +510,10 @@ class JpaManualPriorNotificationRepositoryITests : AbstractDBTests() { pnoTypes = emptyList() port = "FRVNE" portName = "Vannes" - predictedArrivalDatetimeUtc = ZonedDateTime.now().withZoneSameInstant(ZoneOffset.UTC) - predictedLandingDatetimeUtc = ZonedDateTime.now().withZoneSameInstant(ZoneOffset.UTC) + predictedArrivalDatetimeUtc = + ZonedDateTime.now().withZoneSameInstant(ZoneOffset.UTC) + predictedLandingDatetimeUtc = + ZonedDateTime.now().withZoneSameInstant(ZoneOffset.UTC) purpose = LogbookMessagePurpose.LAN riskFactor = 2.1 statisticalRectangle = null diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaMissionActionRepositoryITests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaMissionActionRepositoryITests.kt index a41ec3622e..ac25f20a8e 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaMissionActionRepositoryITests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaMissionActionRepositoryITests.kt @@ -35,7 +35,8 @@ class JpaMissionActionRepositoryITests : AbstractDBTests() { fun `findVesselMissionActionsAfterDateTime Should return all vessel's controls after a date time`() { // Given val dateTime = - ZonedDateTime.now() + ZonedDateTime + .now() .minusYears(1) .minusMonths(1) diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoTypeRepositoryITests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoTypeRepositoryITests.kt index 8a9ca2a5b5..2c5c15e4b3 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoTypeRepositoryITests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoTypeRepositoryITests.kt @@ -20,8 +20,20 @@ class JpaPnoTypeRepositoryITests : AbstractDBTests() { assertThat(pnoTypes.first().name).isEqualTo("Préavis type 1") assertThat(pnoTypes.first().minimumNotificationPeriod).isEqualTo(4.0) assertThat(pnoTypes.first().pnoTypeRules).hasSize(3) - assertThat(pnoTypes.first().pnoTypeRules.first().species).isEqualTo(listOf("HKE", "BSS", "COD", "ANF", "SOL")) - assertThat(pnoTypes.first().pnoTypeRules.first().faoAreas).isEqualTo( + assertThat( + pnoTypes + .first() + .pnoTypeRules + .first() + .species, + ).isEqualTo(listOf("HKE", "BSS", "COD", "ANF", "SOL")) + assertThat( + pnoTypes + .first() + .pnoTypeRules + .first() + .faoAreas, + ).isEqualTo( listOf("27.3.a", "27.4", "27.6", "27.7", "27.8.a", "27.8.b", "27.8.c", "27.8.d", "27.9.a"), ) } diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaReportingRepositoryITests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaReportingRepositoryITests.kt index fa70b6f5a1..360581997a 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaReportingRepositoryITests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaReportingRepositoryITests.kt @@ -221,11 +221,12 @@ class JpaReportingRepositoryITests : AbstractDBTests() { fun `archive Should set the archived flag as true`() { // Given val reportingToArchive = - jpaReportingRepository.findCurrentAndArchivedByVesselIdentifierEquals( - VesselIdentifier.INTERNAL_REFERENCE_NUMBER, - "ABC000180832", - ZonedDateTime.now().minusYears(1), - ).first() + jpaReportingRepository + .findCurrentAndArchivedByVesselIdentifierEquals( + VesselIdentifier.INTERNAL_REFERENCE_NUMBER, + "ABC000180832", + ZonedDateTime.now().minusYears(1), + ).first() assertThat(reportingToArchive.isArchived).isEqualTo(false) // When @@ -233,11 +234,12 @@ class JpaReportingRepositoryITests : AbstractDBTests() { // Then val archivedReporting = - jpaReportingRepository.findCurrentAndArchivedByVesselIdentifierEquals( - VesselIdentifier.INTERNAL_REFERENCE_NUMBER, - "ABC000180832", - ZonedDateTime.now().minusYears(1), - ).first() + jpaReportingRepository + .findCurrentAndArchivedByVesselIdentifierEquals( + VesselIdentifier.INTERNAL_REFERENCE_NUMBER, + "ABC000180832", + ZonedDateTime.now().minusYears(1), + ).first() assertThat(archivedReporting.isArchived).isEqualTo(true) } diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APIMissionRepositoryITest.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APIMissionRepositoryITest.kt index a86ee62495..6e969ab80c 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APIMissionRepositoryITest.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APIMissionRepositoryITest.kt @@ -144,7 +144,8 @@ class APIMissionRepositoryITest { // When val controlUnits = APIMissionRepository(monitorenvProperties, apiClient) - .findControlUnitsOfMission(this, 1).await() + .findControlUnitsOfMission(this, 1) + .await() // Then assertThat(controlUnits).hasSize(3) @@ -174,7 +175,8 @@ class APIMissionRepositoryITest { // When val controlUnits = APIMissionRepository(monitorenvProperties, apiClient) - .findControlUnitsOfMission(this, 1).await() + .findControlUnitsOfMission(this, 1) + .await() // Then assertThat(controlUnits).hasSize(0) @@ -213,10 +215,14 @@ class APIMissionRepositoryITest { // Then assertThat(missions).hasSize(12) - assertThat(mockEngine.requestHistory.first().url.toString()) - .isEqualTo( - "http://test/api/v1/missions?pageNumber=&pageSize=&startedAfterDateTime=&startedBeforeDateTime=", - ) + assertThat( + mockEngine.requestHistory + .first() + .url + .toString(), + ).isEqualTo( + "http://test/api/v1/missions?pageNumber=&pageSize=&startedAfterDateTime=&startedBeforeDateTime=", + ) } } @@ -252,9 +258,13 @@ class APIMissionRepositoryITest { // Then assertThat(missions).hasSize(12) - assertThat(mockEngine.requestHistory.first().url.toString()) - .isEqualTo( - """ + assertThat( + mockEngine.requestHistory + .first() + .url + .toString(), + ).isEqualTo( + """ http://test/api/v1/missions? pageNumber=1& pageSize=2& @@ -264,7 +274,7 @@ class APIMissionRepositoryITest { missionTypes=SEA,LAND& seaFronts=MED """.trim().replace("\\s+".toRegex(), ""), - ) + ) } } @@ -291,10 +301,14 @@ class APIMissionRepositoryITest { // Then assertThat(missions).hasSize(12) - assertThat(mockEngine.requestHistory.first().url.toString()) - .isEqualTo( - "http://test/api/v1/missions/find?ids=123,456", - ) + assertThat( + mockEngine.requestHistory + .first() + .url + .toString(), + ).isEqualTo( + "http://test/api/v1/missions/find?ids=123,456", + ) } } @@ -323,10 +337,14 @@ class APIMissionRepositoryITest { assertThat(mission.createdAtUtc.toString()).isEqualTo("2023-04-20T09:57Z") assertThat(mission.envActions).hasSize(2) assertThat(mission.envActions?.first()?.actionType).isEqualTo(EnvMissionActionType.CONTROL) - assertThat(mockEngine.requestHistory.first().url.toString()) - .isEqualTo( - "http://test/api/v1/missions/123", - ) + assertThat( + mockEngine.requestHistory + .first() + .url + .toString(), + ).isEqualTo( + "http://test/api/v1/missions/123", + ) } } } diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/TestUtils.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/TestUtils.kt index fe8fe4a9cd..1d9c0a784f 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/TestUtils.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/TestUtils.kt @@ -2,336 +2,334 @@ package fr.gouv.cnsp.monitorfish.infrastructure.monitorenv class TestUtils { companion object { - fun getDummyMission(): String { - return """ + fun getDummyMission(): String = + """ + { + "id":263, + "missionTypes":["SEA"], + "controlUnits":[{"id":10197, + "administration":"Marine Nationale", + "isArchived":false, + "name":"BE Jaguar", + "resources":[], + "contact":null}], + "openBy":null, + "completedBy":null, + "observationsCacem":null, + "observationsCnsp":null, + "facade":"NAMO", + "geom":{"type":"MultiPolygon","coordinates":[[[[-3.50814078, 48.92061516],[-3.48954745,48.84160728],[-3.40230182,48.80959241],[-3.28073004,48.85384285],[-3.25212491,48.90557567],[-3.50814078,48.92061516]]]]}, + "createdAtUtc":"2023-04-20T09:57:00Z", + "updatedAtUtc":"2023-04-20T09:57:00Z", + "startDateTimeUtc":"2023-04-20T09:57:00Z", + "startDateTimeUtc":"2023-04-20T09:57:00Z", + "endDateTimeUtc":"2023-04-21T10:57:59Z", + "envActions":[ { - "id":263, - "missionTypes":["SEA"], - "controlUnits":[{"id":10197, - "administration":"Marine Nationale", - "isArchived":false, - "name":"BE Jaguar", - "resources":[], - "contact":null}], - "openBy":null, - "completedBy":null, - "observationsCacem":null, - "observationsCnsp":null, - "facade":"NAMO", - "geom":{"type":"MultiPolygon","coordinates":[[[[-3.50814078, 48.92061516],[-3.48954745,48.84160728],[-3.40230182,48.80959241],[-3.28073004,48.85384285],[-3.25212491,48.90557567],[-3.50814078,48.92061516]]]]}, - "createdAtUtc":"2023-04-20T09:57:00Z", - "updatedAtUtc":"2023-04-20T09:57:00Z", - "startDateTimeUtc":"2023-04-20T09:57:00Z", - "startDateTimeUtc":"2023-04-20T09:57:00Z", - "endDateTimeUtc":"2023-04-21T10:57:59Z", - "envActions":[ - { - "id": "88713755-3966-4ca4-ae18-10cab6249485", - "actionStartDateTimeUtc": "2023-04-21T10:57:59Z", - "actionType": "CONTROL" - }, - { - "id": "69713755-3966-4ca4-ae18-10cab6249485", - "actionStartDateTimeUtc": "2023-04-21T10:57:59Z", - "actionType": "NOTE" - } - ], - "isGeometryComputedFromControls":false, - "missionSource":"MONITORFISH" - } - """.trimIndent() - } - - fun getDummyMissions(): String { - return """ - [{ - "id":263, - "missionTypes":["SEA"], - "controlUnits":[{"id":10197, - "administration":"Marine Nationale", - "isArchived":false, - "name":"BE Jaguar", - "resources":[], - "contact":null}], - "openBy":null, - "completedBy":null, - "observationsCacem":null, - "observationsCnsp":null, - "facade":"NAMO", - "geom":{"type":"MultiPolygon","coordinates":[[[[-3.50814078, 48.92061516],[-3.48954745,48.84160728],[-3.40230182,48.80959241],[-3.28073004,48.85384285],[-3.25212491,48.90557567],[-3.50814078,48.92061516]]]]}, - "createdAtUtc":"2023-04-20T09:57:00Z", - "updatedAtUtc":"2023-04-20T09:57:00Z", - "startDateTimeUtc":"2023-04-20T09:57:00Z", - "startDateTimeUtc":"2023-04-20T09:57:00Z", - "endDateTimeUtc":"2023-04-21T10:57:59Z", - "envActions":[{ - "id": "88713755-3966-4ca4-ae18-10cab6249485", - "actionStartDateTimeUtc": "2023-04-21T10:57:59Z", - "actionType": "CONTROL" - }, - { - "id": "65713755-3966-4ca4-ae18-10cab6249485", - "actionStartDateTimeUtc": "2023-04-21T10:57:59Z", - "actionType": "NOTE" - } - ], - "isGeometryComputedFromControls":false, - "missionSource":"MONITORFISH" - }, - { - "id":264, - "missionTypes":["SEA"], - "controlUnits":[{"id":10062, - "administration":"DDTM", - "isArchived":false, - "name":"Cultures marines 29", - "resources":[], - "contact":null}], - "openBy":"ADE", - "completedBy":"", - "observationsCacem":"", - "observationsCnsp":"", - "facade":"MEMN", - "geom":{"type":"MultiPolygon","coordinates":[[[[-1.24436647, 49.61036285],[-1.32092741,49.54365365],[-1.09842216,49.36479711],[-0.97640316,49.40217759],[-1.24436647,49.61036285]]]]}, - "startDateTimeUtc":"2023-04-19T08:14:28.384Z", - "endDateTimeUtc":"2023-04-21T00:00:00Z", - "envActions":[], - "isGeometryComputedFromControls":false, - "missionSource":"MONITORENV" - }, - { - "id":262, - "missionTypes":["SEA"], - "controlUnits":[{"id":10318, - "administration":"DDTM", - "isArchived":false, - "name":"ULAM 62/80", - "resources":[], - "contact":"0101010101"}], - "openBy":"ADE", - "completedBy":null, - "observationsCacem":null, - "observationsCnsp":null, - "facade":"MEMN", - "geom":{"type":"MultiPolygon","coordinates":[[[[1.57325072, 50.71104277],[1.57907181,50.55597074],[1.49951684,50.47083349],[1.33458581,50.5658318],[1.56354889,50.87662401],[1.57325072,50.71104277]]]]}, - "startDateTimeUtc":"2023-04-18T14:15:08.43Z", - "endDateTimeUtc":"2023-04-18T15:15:08.43Z", - "envActions":[], - "isGeometryComputedFromControls":false, - "missionSource":"MONITORFISH" + "id": "88713755-3966-4ca4-ae18-10cab6249485", + "actionStartDateTimeUtc": "2023-04-21T10:57:59Z", + "actionType": "CONTROL" }, { - "id":257, - "missionTypes":["LAND"], - "controlUnits":[{"id":10434, - "administration":"Gendarmerie Maritime", - "isArchived":false, - "name":"BGMAR Sète - P609 Herault", - "resources":[], - "contact":null}], - "openBy":"", - "completedBy":"", - "observationsCacem":"", - "observationsCnsp":"", - "facade":"MED", - "geom":{"type":"MultiPolygon","coordinates":[[[[3.73377499, 43.41739176],[3.71275338,43.40415684],[3.73013125,43.39601084],[3.7430245,43.40822943],[3.73377499,43.41739176]]]]}, - "startDateTimeUtc":"2023-04-18T13:19:00Z", - "endDateTimeUtc":"2023-04-19T00:00:00Z", - "envActions":[], - "isGeometryComputedFromControls":false, - "missionSource":"MONITORFISH" - }, - { - "id":261, - "missionTypes":["SEA"], - "controlUnits":[{"id":10380, - "administration":"Gendarmerie Maritime", - "isArchived":false, - "name":"BGMAR Anglet - P603 Adour", - "resources":[], - "contact":null}], - "openBy":null, - "completedBy":null, - "observationsCacem":null, - "observationsCnsp":null, - "facade":"NAMO", - "geom":{"type":"MultiPolygon","coordinates":[[[[-4.49284931, 48.23275675],[-4.37611957,48.21491587],[-4.30058856,48.18013116],[-4.3026485,48.09214877],[-4.48048969,48.10498892],[-4.55396076,48.14807171],[-4.51756855, - 48.19432251], - [-4.49284931, - 48.23275675]]], - [[[-4.57868, - 48.23172764], - [-4.56494709, - 48.22898324], - [-4.55293079, - 48.20519226], - [-4.55602069, - 48.17749846], - [-4.56700702, - 48.1765827], - [-4.57936664, - 48.2013023], - [-4.57868, - 48.23172764]]]] - }, - "startDateTimeUtc":"2023-04-18T10:07:08.941Z", - "endDateTimeUtc":"2023-04-18T11:07:08.941Z", - "envActions":[], - "isGeometryComputedFromControls":false, - "missionSource":"MONITORFISH" - }, - { - "id":258, - "missionTypes":["SEA"], - "controlUnits":[{"id":1245, - "administration":"AFB", - "isArchived":true, - "name":"Afb Sd 56 (historique)", - "resources":[], - "contact":null}], - "openBy":null, - "completedBy":null, - "observationsCacem":null, - "observationsCnsp":null, - "facade":null, - "geom":null, - "startDateTimeUtc":"2023-04-18T09:38:20.178Z", - "endDateTimeUtc":"2023-04-18T10:38:20.178Z", - "envActions":[], - "isGeometryComputedFromControls":false, - "missionSource":"MONITORFISH" - }, - { - "id":259, - "missionTypes":["SEA"], - "controlUnits":[{"id":10099, - "administration":"Gendarmerie Maritime", - "isArchived":false, - "name":"BGMAR Concarneau - P601 Elorn", - "resources":[], - "contact":null}], - "openBy":null, - "completedBy":null, - "observationsCacem":null, - "observationsCnsp":null, - "facade":"NAMO", - "geom":{"type":"MultiPolygon","coordinates":[[[[-4.03867489, 47.84522168],[-3.9742397,47.85420683],[-3.98930247,47.883959],[-3.95889799,47.89667798],[-3.92319365,47.86936573],[-3.91553057,47.85777345],[-3.9004678, - 47.83774331], - [-4.03073286, - 47.82912984], - [-4.03867489, - 47.84522168]]]] - }, - "startDateTimeUtc":"2023-04-18T09:00:00Z", - "endDateTimeUtc":"2023-04-18T18:00:59Z", - "envActions":[], - "isGeometryComputedFromControls":false, - "missionSource":"MONITORFISH" - }, - { - "id":260, - "missionTypes":["SEA"], - "controlUnits":[{"id":10020, - "administration":"Douane", - "isArchived":false, - "name":"BSAA Hyères", - "resources":[], - "contact":"154785263"}], - "openBy":"", - "completedBy":"", - "observationsCacem":"", - "observationsCnsp":"", - "facade":"MED", - "geom":{"type":"MultiPolygon","coordinates":[[[[3.61212992, 43.42614558],[3.63511355,43.437544],[3.65781689,43.41637379],[3.63651499,43.39499252],[3.60741576,43.40052814],[3.61212992,43.42614558]]]]}, - "startDateTimeUtc":"2023-04-18T08:09:59.578Z", - "endDateTimeUtc":"2023-04-18T09:09:59.578Z", - "envActions":[], - "isGeometryComputedFromControls":false, - "missionSource":"MONITORFISH" - }, - { - "id":250, - "missionTypes":["SEA"], - "controlUnits":[{"id":10345, - "administration":"DIRM / DM", - "isArchived":false, - "name":"PAM Osiris II", - "resources":[], - "contact":"080012654"}], - "openBy":"ADE", - "completedBy":"", - "observationsCacem":"", - "observationsCnsp":"", - "facade":"MED", - "geom":{"type":"MultiPolygon","coordinates":[[[[51.49119758, -18.10424171],[53.53854137,-22.2000453],[59.22261425,-22.89666373],[61.86261019,-19.04903036],[51.49119758,-18.10424171]]]]},"startDateTimeUtc":"2023-04-16T08:00:00Z","endDateTimeUtc":"2023-04-20T18:00:00Z", - "envActions":[], - "isGeometryComputedFromControls":false, - "missionSource":"MONITORFISH" + "id": "69713755-3966-4ca4-ae18-10cab6249485", + "actionStartDateTimeUtc": "2023-04-21T10:57:59Z", + "actionType": "NOTE" + } + ], + "isGeometryComputedFromControls":false, + "missionSource":"MONITORFISH" + } + """.trimIndent() + + fun getDummyMissions(): String = + """ + [{ + "id":263, + "missionTypes":["SEA"], + "controlUnits":[{"id":10197, + "administration":"Marine Nationale", + "isArchived":false, + "name":"BE Jaguar", + "resources":[], + "contact":null}], + "openBy":null, + "completedBy":null, + "observationsCacem":null, + "observationsCnsp":null, + "facade":"NAMO", + "geom":{"type":"MultiPolygon","coordinates":[[[[-3.50814078, 48.92061516],[-3.48954745,48.84160728],[-3.40230182,48.80959241],[-3.28073004,48.85384285],[-3.25212491,48.90557567],[-3.50814078,48.92061516]]]]}, + "createdAtUtc":"2023-04-20T09:57:00Z", + "updatedAtUtc":"2023-04-20T09:57:00Z", + "startDateTimeUtc":"2023-04-20T09:57:00Z", + "startDateTimeUtc":"2023-04-20T09:57:00Z", + "endDateTimeUtc":"2023-04-21T10:57:59Z", + "envActions":[{ + "id": "88713755-3966-4ca4-ae18-10cab6249485", + "actionStartDateTimeUtc": "2023-04-21T10:57:59Z", + "actionType": "CONTROL" }, { - "id":256, - "missionTypes":["SEA"], - "controlUnits":[{"id":10062, - "administration":"DDTM", - "isArchived":false, - "name":"Cultures marines 29", - "resources":[{"id":557, - "name":"Voiture"}], - "contact":null}], - "openBy":"ADE", - "completedBy":"", - "observationsCacem":"TEST 2", - "observationsCnsp":"TEST", - "facade":null, - "geom":null, - "startDateTimeUtc":"2023-04-13T16:48:53.005Z", - "endDateTimeUtc":"2023-04-13T17:48:53.005Z", - "envActions":[], - "isGeometryComputedFromControls":false, - "missionSource":"MONITORFISH" + "id": "65713755-3966-4ca4-ae18-10cab6249485", + "actionStartDateTimeUtc": "2023-04-21T10:57:59Z", + "actionType": "NOTE" + } + ], + "isGeometryComputedFromControls":false, + "missionSource":"MONITORFISH" + }, + { + "id":264, + "missionTypes":["SEA"], + "controlUnits":[{"id":10062, + "administration":"DDTM", + "isArchived":false, + "name":"Cultures marines 29", + "resources":[], + "contact":null}], + "openBy":"ADE", + "completedBy":"", + "observationsCacem":"", + "observationsCnsp":"", + "facade":"MEMN", + "geom":{"type":"MultiPolygon","coordinates":[[[[-1.24436647, 49.61036285],[-1.32092741,49.54365365],[-1.09842216,49.36479711],[-0.97640316,49.40217759],[-1.24436647,49.61036285]]]]}, + "startDateTimeUtc":"2023-04-19T08:14:28.384Z", + "endDateTimeUtc":"2023-04-21T00:00:00Z", + "envActions":[], + "isGeometryComputedFromControls":false, + "missionSource":"MONITORENV" + }, + { + "id":262, + "missionTypes":["SEA"], + "controlUnits":[{"id":10318, + "administration":"DDTM", + "isArchived":false, + "name":"ULAM 62/80", + "resources":[], + "contact":"0101010101"}], + "openBy":"ADE", + "completedBy":null, + "observationsCacem":null, + "observationsCnsp":null, + "facade":"MEMN", + "geom":{"type":"MultiPolygon","coordinates":[[[[1.57325072, 50.71104277],[1.57907181,50.55597074],[1.49951684,50.47083349],[1.33458581,50.5658318],[1.56354889,50.87662401],[1.57325072,50.71104277]]]]}, + "startDateTimeUtc":"2023-04-18T14:15:08.43Z", + "endDateTimeUtc":"2023-04-18T15:15:08.43Z", + "envActions":[], + "isGeometryComputedFromControls":false, + "missionSource":"MONITORFISH" + }, + { + "id":257, + "missionTypes":["LAND"], + "controlUnits":[{"id":10434, + "administration":"Gendarmerie Maritime", + "isArchived":false, + "name":"BGMAR Sète - P609 Herault", + "resources":[], + "contact":null}], + "openBy":"", + "completedBy":"", + "observationsCacem":"", + "observationsCnsp":"", + "facade":"MED", + "geom":{"type":"MultiPolygon","coordinates":[[[[3.73377499, 43.41739176],[3.71275338,43.40415684],[3.73013125,43.39601084],[3.7430245,43.40822943],[3.73377499,43.41739176]]]]}, + "startDateTimeUtc":"2023-04-18T13:19:00Z", + "endDateTimeUtc":"2023-04-19T00:00:00Z", + "envActions":[], + "isGeometryComputedFromControls":false, + "missionSource":"MONITORFISH" + }, + { + "id":261, + "missionTypes":["SEA"], + "controlUnits":[{"id":10380, + "administration":"Gendarmerie Maritime", + "isArchived":false, + "name":"BGMAR Anglet - P603 Adour", + "resources":[], + "contact":null}], + "openBy":null, + "completedBy":null, + "observationsCacem":null, + "observationsCnsp":null, + "facade":"NAMO", + "geom":{"type":"MultiPolygon","coordinates":[[[[-4.49284931, 48.23275675],[-4.37611957,48.21491587],[-4.30058856,48.18013116],[-4.3026485,48.09214877],[-4.48048969,48.10498892],[-4.55396076,48.14807171],[-4.51756855, + 48.19432251], + [-4.49284931, + 48.23275675]]], + [[[-4.57868, + 48.23172764], + [-4.56494709, + 48.22898324], + [-4.55293079, + 48.20519226], + [-4.55602069, + 48.17749846], + [-4.56700702, + 48.1765827], + [-4.57936664, + 48.2013023], + [-4.57868, + 48.23172764]]]] }, - { - "id":254, - "missionTypes":["SEA", - "LAND"], - "controlUnits":[{"id":10105, - "administration":"Port", - "isArchived":false, - "name":"Autorité portuaire", - "resources":[], - "contact":null}], - "openBy":"ASE", - "completedBy":"", - "observationsCacem":"", - "observationsCnsp":"", - "facade":"MED", - "geom":{"type":"MultiPolygon","coordinates":[[[[3.70244841, 43.39883986],[3.69556248,43.39696361],[3.69470173,43.39321095],[3.70876052,43.39300246],[3.70244841,43.39883986]]]]},"startDateTimeUtc":"2023-04-13T16:40:17.766Z","endDateTimeUtc":null, - "envActions":[], - "isGeometryComputedFromControls":false, - "missionSource":"MONITORENV" + "startDateTimeUtc":"2023-04-18T10:07:08.941Z", + "endDateTimeUtc":"2023-04-18T11:07:08.941Z", + "envActions":[], + "isGeometryComputedFromControls":false, + "missionSource":"MONITORFISH" + }, + { + "id":258, + "missionTypes":["SEA"], + "controlUnits":[{"id":1245, + "administration":"AFB", + "isArchived":true, + "name":"Afb Sd 56 (historique)", + "resources":[], + "contact":null}], + "openBy":null, + "completedBy":null, + "observationsCacem":null, + "observationsCnsp":null, + "facade":null, + "geom":null, + "startDateTimeUtc":"2023-04-18T09:38:20.178Z", + "endDateTimeUtc":"2023-04-18T10:38:20.178Z", + "envActions":[], + "isGeometryComputedFromControls":false, + "missionSource":"MONITORFISH" + }, + { + "id":259, + "missionTypes":["SEA"], + "controlUnits":[{"id":10099, + "administration":"Gendarmerie Maritime", + "isArchived":false, + "name":"BGMAR Concarneau - P601 Elorn", + "resources":[], + "contact":null}], + "openBy":null, + "completedBy":null, + "observationsCacem":null, + "observationsCnsp":null, + "facade":"NAMO", + "geom":{"type":"MultiPolygon","coordinates":[[[[-4.03867489, 47.84522168],[-3.9742397,47.85420683],[-3.98930247,47.883959],[-3.95889799,47.89667798],[-3.92319365,47.86936573],[-3.91553057,47.85777345],[-3.9004678, + 47.83774331], + [-4.03073286, + 47.82912984], + [-4.03867489, + 47.84522168]]]] }, - { - "id":253, - "missionTypes":["SEA"], - "controlUnits":[{"id":10067, - "administration":"Conservatoire du littoral", - "isArchived":false, - "name":"Baie de Boueni", - "resources":[], - "contact":"qsdf"}], - "openBy":"qs", - "completedBy":"dd", - "observationsCacem":"qsdf", - "observationsCnsp":"sqdf", - "facade":"NAMO", - "geom":{"type":"MultiPolygon","coordinates":[[[[-2.09617992, 48.06132211],[-6.00731273,46.66238724],[-5.15037914,45.81132302],[-2.07420727,45.58111736],[-2.05223461,46.97813465],[-2.09617992,48.06132211]]]]}, - "startDateTimeUtc":"2023-04-13T12:14:59.149Z", - "endDateTimeUtc":"2023-04-13T13:14:59.149Z", - "envActions":[], - "isGeometryComputedFromControls":false, - "missionSource":"MONITORFISH" - }] - """.trimIndent() - } + "startDateTimeUtc":"2023-04-18T09:00:00Z", + "endDateTimeUtc":"2023-04-18T18:00:59Z", + "envActions":[], + "isGeometryComputedFromControls":false, + "missionSource":"MONITORFISH" + }, + { + "id":260, + "missionTypes":["SEA"], + "controlUnits":[{"id":10020, + "administration":"Douane", + "isArchived":false, + "name":"BSAA Hyères", + "resources":[], + "contact":"154785263"}], + "openBy":"", + "completedBy":"", + "observationsCacem":"", + "observationsCnsp":"", + "facade":"MED", + "geom":{"type":"MultiPolygon","coordinates":[[[[3.61212992, 43.42614558],[3.63511355,43.437544],[3.65781689,43.41637379],[3.63651499,43.39499252],[3.60741576,43.40052814],[3.61212992,43.42614558]]]]}, + "startDateTimeUtc":"2023-04-18T08:09:59.578Z", + "endDateTimeUtc":"2023-04-18T09:09:59.578Z", + "envActions":[], + "isGeometryComputedFromControls":false, + "missionSource":"MONITORFISH" + }, + { + "id":250, + "missionTypes":["SEA"], + "controlUnits":[{"id":10345, + "administration":"DIRM / DM", + "isArchived":false, + "name":"PAM Osiris II", + "resources":[], + "contact":"080012654"}], + "openBy":"ADE", + "completedBy":"", + "observationsCacem":"", + "observationsCnsp":"", + "facade":"MED", + "geom":{"type":"MultiPolygon","coordinates":[[[[51.49119758, -18.10424171],[53.53854137,-22.2000453],[59.22261425,-22.89666373],[61.86261019,-19.04903036],[51.49119758,-18.10424171]]]]},"startDateTimeUtc":"2023-04-16T08:00:00Z","endDateTimeUtc":"2023-04-20T18:00:00Z", + "envActions":[], + "isGeometryComputedFromControls":false, + "missionSource":"MONITORFISH" + }, + { + "id":256, + "missionTypes":["SEA"], + "controlUnits":[{"id":10062, + "administration":"DDTM", + "isArchived":false, + "name":"Cultures marines 29", + "resources":[{"id":557, + "name":"Voiture"}], + "contact":null}], + "openBy":"ADE", + "completedBy":"", + "observationsCacem":"TEST 2", + "observationsCnsp":"TEST", + "facade":null, + "geom":null, + "startDateTimeUtc":"2023-04-13T16:48:53.005Z", + "endDateTimeUtc":"2023-04-13T17:48:53.005Z", + "envActions":[], + "isGeometryComputedFromControls":false, + "missionSource":"MONITORFISH" + }, + { + "id":254, + "missionTypes":["SEA", + "LAND"], + "controlUnits":[{"id":10105, + "administration":"Port", + "isArchived":false, + "name":"Autorité portuaire", + "resources":[], + "contact":null}], + "openBy":"ASE", + "completedBy":"", + "observationsCacem":"", + "observationsCnsp":"", + "facade":"MED", + "geom":{"type":"MultiPolygon","coordinates":[[[[3.70244841, 43.39883986],[3.69556248,43.39696361],[3.69470173,43.39321095],[3.70876052,43.39300246],[3.70244841,43.39883986]]]]},"startDateTimeUtc":"2023-04-13T16:40:17.766Z","endDateTimeUtc":null, + "envActions":[], + "isGeometryComputedFromControls":false, + "missionSource":"MONITORENV" + }, + { + "id":253, + "missionTypes":["SEA"], + "controlUnits":[{"id":10067, + "administration":"Conservatoire du littoral", + "isArchived":false, + "name":"Baie de Boueni", + "resources":[], + "contact":"qsdf"}], + "openBy":"qs", + "completedBy":"dd", + "observationsCacem":"qsdf", + "observationsCnsp":"sqdf", + "facade":"NAMO", + "geom":{"type":"MultiPolygon","coordinates":[[[[-2.09617992, 48.06132211],[-6.00731273,46.66238724],[-5.15037914,45.81132302],[-2.07420727,45.58111736],[-2.05223461,46.97813465],[-2.09617992,48.06132211]]]]}, + "startDateTimeUtc":"2023-04-13T12:14:59.149Z", + "endDateTimeUtc":"2023-04-13T13:14:59.149Z", + "envActions":[], + "isGeometryComputedFromControls":false, + "missionSource":"MONITORFISH" + }] + """.trimIndent() } }