Skip to content

Commit

Permalink
Fix dimensions type from double to string
Browse files Browse the repository at this point in the history
  • Loading branch information
louptheron committed Feb 15, 2024
1 parent 53ed177 commit 218de7e
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ package fr.gouv.cnsp.monitorfish.domain.entities.last_position
class Gear() {
var gear: String? = null
var mesh: Double? = null
var dimensions: Double? = null
var dimensions: String? = null
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ data class Vessel(
val underCharter: Boolean? = null,
) {
fun getNationalIdentifier(): String {
val internalReferenceNumberCountryCode = LIKELY_CONTROLLED_COUNTRY_CODES.find { countryAlpha3 -> internalReferenceNumber?.contains(countryAlpha3) ?: false }
val internalReferenceNumberCountryCode = LIKELY_CONTROLLED_COUNTRY_CODES.find { countryAlpha3 ->
internalReferenceNumber?.contains(
countryAlpha3,
) ?: false
}
val identifier = internalReferenceNumber?.replace("${internalReferenceNumberCountryCode}000", "") ?: ""

if (districtCode.isNullOrEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import fr.gouv.cnsp.monitorfish.domain.entities.last_position.Gear

data class GearLastPositionDataOutput(
var gear: String? = null,
var dimensions: Double? = null,
var dimensions: String? = null,
var mesh: Double? = null,
) {
companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import fr.gouv.cnsp.monitorfish.config.SecurityConfig
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.last_position.Gear
import fr.gouv.cnsp.monitorfish.domain.entities.last_position.LastPosition
import fr.gouv.cnsp.monitorfish.domain.entities.logbook.LogbookMessagesAndAlerts
import fr.gouv.cnsp.monitorfish.domain.entities.logbook.Voyage
Expand Down Expand Up @@ -89,9 +90,18 @@ class VesselControllerITests {
@Test
fun `Should get all vessels last positions`() {
// Given
val gear = Gear()
gear.gear = "OTB"
gear.dimensions = "12;123"

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,
gearOnboard = listOf(
gear,
),
)
given(this.getLastPositions.execute()).willReturn(listOf(position))

// When
Expand All @@ -114,6 +124,8 @@ class VesselControllerITests {
.andExpect(jsonPath("$[0].positionType", equalTo(PositionType.AIS.toString())))
.andExpect(jsonPath("$[0].dateTime", equalTo(position.dateTime.toOffsetDateTime().toString())))
.andExpect(jsonPath("$[0].reportings.length()", equalTo(0)))
.andExpect(jsonPath("$[0].gearOnboard.length()", equalTo(1)))
.andExpect(jsonPath("$[0].gearOnboard[0].dimensions", equalTo("12;123")))
.andExpect(jsonPath("$[0].alerts.length()", equalTo(0)))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class JpaLastPositionRepositoryITests : AbstractDBTests() {
it.internalReferenceNumber == "FAK000999999"
}
assertThat(position?.gearOnboard).hasSize(1)
assertThat(position?.gearOnboard?.first()?.dimensions).isEqualTo(45.0)
assertThat(position?.gearOnboard?.first()?.dimensions).isEqualTo("45.0")
assertThat(position?.gearOnboard?.first()?.gear).isEqualTo("OTB")
assertThat(position?.gearOnboard?.first()?.mesh).isEqualTo(70.0)

Expand Down

0 comments on commit 218de7e

Please sign in to comment.