Skip to content

Commit

Permalink
Fix healthcheck date format
Browse files Browse the repository at this point in the history
  • Loading branch information
louptheron committed Dec 4, 2024
1 parent 090fcd2 commit 5def6b3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
package fr.gouv.cnsp.monitorfish.infrastructure.api.outputs

import fr.gouv.cnsp.monitorfish.domain.entities.health.Health
import java.time.ZonedDateTime
import fr.gouv.cnsp.monitorfish.utils.CustomZonedDateTime

data class HealthDataOutput(
val dateLastPositionReceivedByAPI: ZonedDateTime,
val dateLastPositionUpdatedByPrefect: ZonedDateTime,
val dateLogbookMessageReceived: ZonedDateTime,
val dateLastPositionReceivedByAPI: String,
val dateLastPositionUpdatedByPrefect: String,
val dateLogbookMessageReceived: String,
val suddenDropOfPositionsReceived: Boolean,
) {
companion object {
fun fromHealth(health: Health) =
HealthDataOutput(
dateLastPositionUpdatedByPrefect = health.dateLastPositionUpdatedByPrefect,
dateLastPositionReceivedByAPI = health.dateLastPositionReceivedByAPI,
dateLogbookMessageReceived = health.dateLogbookMessageReceived,
dateLastPositionUpdatedByPrefect =
CustomZonedDateTime(
health.dateLastPositionUpdatedByPrefect,
).toString(),
dateLastPositionReceivedByAPI =
CustomZonedDateTime(
health.dateLastPositionReceivedByAPI,
).toString(),
dateLogbookMessageReceived = CustomZonedDateTime(health.dateLogbookMessageReceived).toString(),
suddenDropOfPositionsReceived = health.suddenDropOfPositionsReceived,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import java.time.format.DateTimeFormatter
* A custom and consistent `ZonedDateTime` that always uses UTC as the time zone.
*
* The overridden `toString()` method ensures seconds are always present in the output
* (= never omitted when equal to `00`) and removes unecessary milli/micro/nanoseconds.
* (= never omitted when equal to `00`) and removes unnecessary milli/micro/nanoseconds.
*/
data class CustomZonedDateTime(private val dateAsZonedDateTime: ZonedDateTime) {
companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ class HealthcheckControllerITests {
// Given
given(this.getHealthcheck.execute()).willReturn(
Health(
ZonedDateTime.parse("2020-12-21T15:01:00Z"),
ZonedDateTime.parse("2020-12-21T16:01:00Z"),
ZonedDateTime.parse("2020-12-21T17:01:00Z"),
dateLastPositionUpdatedByPrefect = ZonedDateTime.parse("2020-12-21T15:01:00Z"),
dateLastPositionReceivedByAPI = ZonedDateTime.parse("2020-12-21T16:01:00Z"),
dateLogbookMessageReceived = ZonedDateTime.parse("2020-12-21T17:01:00.000Z"),
suddenDropOfPositionsReceived = false,
),
)
Expand Down

0 comments on commit 5def6b3

Please sign in to comment.