Skip to content

Commit

Permalink
tech: fix isMissionEnded
Browse files Browse the repository at this point in the history
  • Loading branch information
maximeperrault committed Jan 20, 2025
1 parent 3a62019 commit facb477
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class MissionValidator : Validator<MissionEntity> {

private fun validateEnvActions(mission: MissionEntity) {
val isMissionEnded =
mission.endDateTimeUtc != null && (mission.endDateTimeUtc?.isAfter(ZonedDateTime.now()) == true)
mission.endDateTimeUtc != null && ZonedDateTime.now().isAfter(mission.endDateTimeUtc)

mission.envActions?.forEach { envAction ->
if (envAction is EnvActionControlEntity) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ class EnvActionFixture {
startTime: ZonedDateTime? = null,
endTime: ZonedDateTime? = null,
openBy: String? = "CDA",
controlPlans: List<EnvActionControlPlanEntity>? = listOf(),
controlPlans: List<EnvActionControlPlanEntity>? =
listOf(EnvActionControlPlanEntity(subThemeIds = listOf(1))),
): EnvActionSurveillanceEntity {
return EnvActionSurveillanceEntity(
id = UUID.randomUUID(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ class MissionValidatorUTest {

@Test
fun `validate should throw an exception if there is a control without control plans when mission has ended`() {
val endDateTimeUtc = ZonedDateTime.now().plusSeconds(1)
val endDateTimeUtc = ZonedDateTime.now().minusSeconds(1)
val anEnvActionControl = anEnvActionControl(controlPlans = listOf())
val mission = aMissionEntity(endDateTimeUtc = endDateTimeUtc, envActions = listOf(anEnvActionControl))

Expand All @@ -227,7 +227,7 @@ class MissionValidatorUTest {

@Test
fun `validate should throw an exception if there is a control with control plan without subtheme when mission has ended`() {
val endDateTimeUtc = ZonedDateTime.now().plusSeconds(1)
val endDateTimeUtc = ZonedDateTime.now().minusSeconds(1)
val anEnvActionControl =
anEnvActionControl(controlPlans = listOf(EnvActionControlPlanEntity(subThemeIds = listOf())))
val mission = aMissionEntity(endDateTimeUtc = endDateTimeUtc, envActions = listOf(anEnvActionControl))
Expand All @@ -238,7 +238,7 @@ class MissionValidatorUTest {

@Test
fun `validate should throw an exception if there is a control actionTargetType as VEHICULE without vehiculeType when mission has ended`() {
val endDateTimeUtc = ZonedDateTime.now().plusSeconds(1)
val endDateTimeUtc = ZonedDateTime.now().minusSeconds(1)
val anEnvActionControl = anEnvActionControl(actionTargetTypeEnum = ActionTargetTypeEnum.VEHICLE)
val mission = aMissionEntity(endDateTimeUtc = endDateTimeUtc, envActions = listOf(anEnvActionControl))

Expand All @@ -251,7 +251,7 @@ class MissionValidatorUTest {
fun `validate should pass if there is a control actionTargetType as targetType other than VEHICLE without vehiculeType when mission has ended`(
targetType: ActionTargetTypeEnum,
) {
val endDateTimeUtc = ZonedDateTime.now().plusSeconds(1)
val endDateTimeUtc = ZonedDateTime.now().minusSeconds(1)
val anEnvActionControl = anEnvActionControl(actionTargetTypeEnum = targetType)
val mission = aMissionEntity(endDateTimeUtc = endDateTimeUtc, envActions = listOf(anEnvActionControl))

Expand Down Expand Up @@ -342,7 +342,7 @@ class MissionValidatorUTest {

@Test
fun `validate should throw an exception if there is a surveillance without control plans when mission has ended`() {
val endDateTimeUtc = ZonedDateTime.now().plusSeconds(1)
val endDateTimeUtc = ZonedDateTime.now().minusSeconds(1)
val anEnvActionSurveillance = anEnvActionSurveillance(controlPlans = listOf())
val mission = aMissionEntity(endDateTimeUtc = endDateTimeUtc, envActions = listOf(anEnvActionSurveillance))

Expand All @@ -352,7 +352,7 @@ class MissionValidatorUTest {

@Test
fun `validate should throw an exception if there is a surveillance with control plan without subtheme when mission has ended`() {
val endDateTimeUtc = ZonedDateTime.now().plusSeconds(1)
val endDateTimeUtc = ZonedDateTime.now().minusSeconds(1)
val anEnvActionSurveillance =
anEnvActionSurveillance(controlPlans = listOf(EnvActionControlPlanEntity(subThemeIds = listOf())))
val mission = aMissionEntity(endDateTimeUtc = endDateTimeUtc, envActions = listOf(anEnvActionSurveillance))
Expand Down

0 comments on commit facb477

Please sign in to comment.