Skip to content

Commit

Permalink
Merge pull request #447 from MTES-MCT/feature/446-hasbeendone-mission…
Browse files Browse the repository at this point in the history
…-action-tag

feat(control): add hasBeenDone attributes and column
  • Loading branch information
xtiannyeto authored Dec 3, 2024
2 parents e54611a + 80931d0 commit 7210853
Show file tree
Hide file tree
Showing 15 changed files with 228 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ abstract class BaseControlEntity {
open var unitHasConfirmed: Boolean? = null
open val infractions: List<InfractionEntity>? = null
open val observations: String? = null

open val hasBeenDone: Boolean? = null
abstract fun shouldToggleOnUnitHasConfirmed(): Boolean
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ data class ControlAdministrativeEntity(
val upToDateNavigationPermit: ControlResult? = null,
val compliantSecurityDocuments: ControlResult? = null,
override val observations: String? = null,
override val hasBeenDone: Boolean? = null,
override val infractions: List<InfractionEntity>? = null
) : BaseControlEntity() {
override fun shouldToggleOnUnitHasConfirmed(): Boolean =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ data class ControlGensDeMerEntity(
val upToDateMedicalCheck: ControlResult? = null,
val knowledgeOfFrenchLawAndLanguage: ControlResult? = null,
override val observations: String? = null,
override val hasBeenDone: Boolean? = null,
override val infractions: List<InfractionEntity>? = null
) : BaseControlEntity() {
override fun shouldToggleOnUnitHasConfirmed(): Boolean =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ data class ControlNavigationEntity(
override val unitShouldConfirm: Boolean? = null,
override var unitHasConfirmed: Boolean? = null,
override val observations: String? = null,
override val hasBeenDone: Boolean? = null,
override val infractions: List<InfractionEntity>? = null
) : BaseControlEntity() {
override fun shouldToggleOnUnitHasConfirmed(): Boolean =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ data class ControlSecurityEntity(
override val unitShouldConfirm: Boolean? = null,
override var unitHasConfirmed: Boolean? = null,
override val observations: String? = null,
override val hasBeenDone: Boolean? = null,
override val infractions: List<InfractionEntity>? = null
) : BaseControlEntity() {
override fun shouldToggleOnUnitHasConfirmed(): Boolean =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class ControlAdministrativeModel(

@Column(name = "compliant_security_documents", nullable = true)
var compliantSecurityDocuments: String? = null,

) : ControlModel() {
fun toControlAdministrativeEntity() = ControlAdministrativeEntity(
id = id,
Expand All @@ -30,6 +31,7 @@ class ControlAdministrativeModel(
upToDateNavigationPermit = stringToControlResult(upToDateNavigationPermit),
compliantSecurityDocuments = stringToControlResult(compliantSecurityDocuments),
observations = observations,
hasBeenDone = hasBeenDone,
infractions = infractions?.map { it.toInfractionEntity() }
)

Expand All @@ -42,6 +44,7 @@ class ControlAdministrativeModel(
this.unitHasConfirmed = control.unitHasConfirmed
this.unitShouldConfirm = control.unitShouldConfirm
this.observations = control.observations
this.hasBeenDone = control.hasBeenDone
}

fun fromControlAdministrativeEntity(control: ControlAdministrativeEntity): ControlAdministrativeModel {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class ControlGensDeMerModel(
upToDateMedicalCheck = stringToControlResult(upToDateMedicalCheck),
knowledgeOfFrenchLawAndLanguage = stringToControlResult(knowledgeOfFrenchLawAndLanguage),
observations = observations,
hasBeenDone = hasBeenDone,
infractions = infractions?.map { it.toInfractionEntity() }
)

Expand All @@ -42,6 +43,7 @@ class ControlGensDeMerModel(
this.unitHasConfirmed = control.unitHasConfirmed
this.unitShouldConfirm = control.unitShouldConfirm
this.observations = control.observations
this.hasBeenDone = control.hasBeenDone
}

fun fromControlGensDeMerEntity(control: ControlGensDeMerEntity): ControlGensDeMerModel {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ abstract class ControlModel {
@Column(name = "observations", nullable = true)
open var observations: String? = null

@Column(name = "has_been_done", nullable = true)
open var hasBeenDone: Boolean? = false

@OneToMany(
cascade = [CascadeType.ALL],
fetch = FetchType.LAZY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class ControlNavigationModel(
unitHasConfirmed = unitHasConfirmed,
unitShouldConfirm = unitShouldConfirm,
observations = observations,
hasBeenDone = hasBeenDone,
infractions = infractions?.map { it.toInfractionEntity() }
)

Expand All @@ -35,6 +36,7 @@ class ControlNavigationModel(
this.unitHasConfirmed = control.unitHasConfirmed
this.unitShouldConfirm = control.unitShouldConfirm
this.observations = control.observations
this.hasBeenDone = control.hasBeenDone
}

fun fromControlNavigationEntity(control: ControlNavigationEntity): ControlNavigationModel {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class ControlSecurityModel(
unitHasConfirmed = unitHasConfirmed,
unitShouldConfirm = unitShouldConfirm,
observations = observations,
hasBeenDone = hasBeenDone,
infractions = infractions?.map { it.toInfractionEntity() }
)

Expand All @@ -35,6 +36,7 @@ class ControlSecurityModel(
this.unitHasConfirmed = control.unitHasConfirmed
this.unitShouldConfirm = control.unitShouldConfirm
this.observations = control.observations
this.hasBeenDone = control.hasBeenDone
}

fun fromControlSecurityEntity(control: ControlSecurityEntity): ControlSecurityModel {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
DO
$$
BEGIN

ALTER TABLE control_administrative
ADD COLUMN has_been_done BOOLEAN;

ALTER TABLE control_gens_de_mer
ADD COLUMN has_been_done BOOLEAN;

ALTER TABLE control_navigation
ADD COLUMN has_been_done BOOLEAN;

ALTER TABLE control_security
ADD COLUMN has_been_done BOOLEAN;

END
$$;
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package fr.gouv.gmampa.rapportnav.infrastructure.database.model.mission.control

import fr.gouv.dgampa.rapportnav.domain.entities.mission.nav.control.ControlAdministrativeEntity
import fr.gouv.dgampa.rapportnav.infrastructure.database.model.mission.control.ControlAdministrativeModel
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.ExtendWith
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.test.context.junit.jupiter.SpringExtension
import java.util.*

@ExtendWith(SpringExtension::class)
@SpringBootTest(classes = [ControlAdministrativeModel::class])
class ControlAdministrativeModelTest {

@Test
fun `execute should retrieve hasBeenDone in control Administrative entity`() {
val hasBeenDone = false

val controlAdministrative = ControlAdministrativeModel()
controlAdministrative.hasBeenDone = hasBeenDone

val response = controlAdministrative.toControlAdministrativeEntity()
assertThat(response).isNotNull()
assertThat(response.hasBeenDone).isEqualTo(hasBeenDone)
}

@Test
fun `execute should retrieve hasBeenDone in control Administrative Model from Entity`() {
val hasBeenDone = true

val entity = ControlAdministrativeEntity(
id = UUID.randomUUID(),
missionId = 761,
amountOfControls = 3,
hasBeenDone = hasBeenDone,
actionControlId = "myActionId"
)

val response = ControlAdministrativeModel.fromControlAdministrativeEntity(entity)
assertThat(response).isNotNull()
assertThat(response.id).isEqualTo(entity.id)
assertThat(response.missionId).isEqualTo(entity.missionId)
assertThat(response.hasBeenDone).isEqualTo(entity.hasBeenDone)
assertThat(response.actionControlId).isEqualTo(entity.actionControlId)
assertThat(response.amountOfControls).isEqualTo(entity.amountOfControls)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package fr.gouv.gmampa.rapportnav.infrastructure.database.model.mission.control

import fr.gouv.dgampa.rapportnav.domain.entities.mission.nav.control.ControlGensDeMerEntity
import fr.gouv.dgampa.rapportnav.infrastructure.database.model.mission.control.ControlGensDeMerModel
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.ExtendWith
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.test.context.junit.jupiter.SpringExtension
import java.util.*

@ExtendWith(SpringExtension::class)
@SpringBootTest(classes = [ControlGensDeMerModel::class])
class ControlGensDeMerModelTest {

@Test
fun `execute should retrieve hasBeenDone in control gens-de-mer entity`() {
val hasBeenDone = false

val controlGensDeMer = ControlGensDeMerModel()
controlGensDeMer.hasBeenDone = hasBeenDone

val response = controlGensDeMer.toControlGensDeMerEntity()
assertThat(response).isNotNull()
assertThat(response.hasBeenDone).isEqualTo(hasBeenDone)
}

@Test
fun `execute should retrieve hasBeenDone in control gens-de-mer Model from Entity`() {
val hasBeenDone = true

val entity = ControlGensDeMerEntity(
id = UUID.randomUUID(),
missionId = 761,
amountOfControls = 3,
hasBeenDone = hasBeenDone,
actionControlId = "myActionId"
)

val response = ControlGensDeMerModel.fromControlGensDeMerEntity(entity)
assertThat(response).isNotNull()
assertThat(response.id).isEqualTo(entity.id)
assertThat(response.missionId).isEqualTo(entity.missionId)
assertThat(response.hasBeenDone).isEqualTo(entity.hasBeenDone)
assertThat(response.actionControlId).isEqualTo(entity.actionControlId)
assertThat(response.amountOfControls).isEqualTo(entity.amountOfControls)

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package fr.gouv.gmampa.rapportnav.infrastructure.database.model.mission.control

import fr.gouv.dgampa.rapportnav.domain.entities.mission.nav.control.ControlNavigationEntity
import fr.gouv.dgampa.rapportnav.infrastructure.database.model.mission.control.ControlNavigationModel
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.ExtendWith
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.test.context.junit.jupiter.SpringExtension
import java.util.*

@ExtendWith(SpringExtension::class)
@SpringBootTest(classes = [ControlNavigationModel::class])
class ControlNavigationModelTest {

@Test
fun `execute should retrieve hasBeenDone in control navigation entity`() {
val hasBeenDone = false

val controlNavigation = ControlNavigationModel(id = UUID.randomUUID())
controlNavigation.hasBeenDone = hasBeenDone

val response = controlNavigation.toControlNavigationEntity()
assertThat(response).isNotNull()
assertThat(response.hasBeenDone).isEqualTo(hasBeenDone)
}

@Test
fun `execute should retrieve hasBeenDone in control navigation Model from Entity`() {
val hasBeenDone = true

val entity = ControlNavigationEntity(
id = UUID.randomUUID(),
missionId = 761,
amountOfControls = 3,
hasBeenDone = hasBeenDone,
actionControlId = "myActionId"
)

val response = ControlNavigationModel.fromControlNavigationEntity(entity)
assertThat(response).isNotNull()
assertThat(response.id).isEqualTo(entity.id)
assertThat(response.missionId).isEqualTo(entity.missionId)
assertThat(response.hasBeenDone).isEqualTo(entity.hasBeenDone)
assertThat(response.actionControlId).isEqualTo(entity.actionControlId)
assertThat(response.amountOfControls).isEqualTo(entity.amountOfControls)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package fr.gouv.gmampa.rapportnav.infrastructure.database.model.mission.control

import fr.gouv.dgampa.rapportnav.domain.entities.mission.nav.control.ControlSecurityEntity
import fr.gouv.dgampa.rapportnav.infrastructure.database.model.mission.control.ControlSecurityModel
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.ExtendWith
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.test.context.junit.jupiter.SpringExtension
import java.util.*

@ExtendWith(SpringExtension::class)
@SpringBootTest(classes = [ControlSecurityModel::class])
class ControlSecurityModelTest {

@Test
fun `execute should retrieve hasBeenDone in control Security entity`() {
val hasBeenDone = false

val controlSecurity = ControlSecurityModel(id = UUID.randomUUID())
controlSecurity.hasBeenDone = hasBeenDone

val response = controlSecurity.toControlSecurityEntity()
assertThat(response).isNotNull()
assertThat(response.hasBeenDone).isEqualTo(hasBeenDone)
}

@Test
fun `execute should retrieve hasBeenDone in control Security Model from Entity`() {
val hasBeenDone = true

val entity = ControlSecurityEntity(
id = UUID.randomUUID(),
missionId = 761,
amountOfControls = 3,
hasBeenDone = hasBeenDone,
actionControlId = "myActionId"
)

val response = ControlSecurityModel.fromControlSecurityEntity(entity)
assertThat(response).isNotNull()
assertThat(response.id).isEqualTo(entity.id)
assertThat(response.missionId).isEqualTo(entity.missionId)
assertThat(response.hasBeenDone).isEqualTo(entity.hasBeenDone)
assertThat(response.actionControlId).isEqualTo(entity.actionControlId)
assertThat(response.amountOfControls).isEqualTo(entity.amountOfControls)
}
}

0 comments on commit 7210853

Please sign in to comment.