refactor: supprimer setTypeAssociation/setTypeLibelle doublons dans OrganisationService

- OrganisationService.convertToResponse: ne plus setter typeAssociation ni typeLibelle
- Utiliser uniquement typeOrganisation et typeOrganisationLibelle
- Corriger tests: assertions sur typeOrganisationLibelle au lieu de typeLibelle
This commit is contained in:
dahoud
2026-04-17 20:00:34 +00:00
parent 4b2b326afe
commit 9f14c2e345
2 changed files with 7 additions and 12 deletions

View File

@@ -593,18 +593,14 @@ public class OrganisationService {
}
dto.setTypeOrganisation(organisation.getTypeOrganisation());
dto.setTypeAssociation(organisation.getTypeOrganisation());
dto.setStatut(organisation.getStatut());
// Résolution des libellés
if (organisation.getTypeOrganisation() != null) {
typeReferenceRepository.findByDomaineAndCode("TYPE_ORGANISATION", organisation.getTypeOrganisation())
.ifPresent(ref -> {
dto.setTypeOrganisationLibelle(ref.getLibelle());
dto.setTypeLibelle(ref.getLibelle());
});
if (dto.getTypeLibelle() == null) {
dto.setTypeLibelle(organisation.getTypeOrganisation());
.ifPresent(ref -> dto.setTypeOrganisationLibelle(ref.getLibelle()));
if (dto.getTypeOrganisationLibelle() == null) {
dto.setTypeOrganisationLibelle(organisation.getTypeOrganisation());
}
}
if (organisation.getStatut() != null) {

View File

@@ -958,12 +958,11 @@ class OrganisationServiceTest {
OrganisationResponse resp = organisationService.convertToResponse(org);
assertThat(resp.getTypeOrganisationLibelle()).isEqualTo("Association loi 1901");
assertThat(resp.getTypeLibelle()).isEqualTo("Association loi 1901");
assertThat(resp.getNombreEvenements()).isEqualTo(2);
}
@Test
@DisplayName("TypeOrganisation référence non trouvée: typeLibelle = code")
@DisplayName("TypeOrganisation référence non trouvée: typeOrganisationLibelle = code")
void convertToResponse_typeRefNotFound_usesCode() {
Organisation org = orgFixture("UnknownType", "unknowntype@test.dev");
org.setTypeOrganisation("UNKNOWN_TYPE");
@@ -976,7 +975,7 @@ class OrganisationServiceTest {
OrganisationResponse resp = organisationService.convertToResponse(org);
assertThat(resp.getTypeLibelle()).isEqualTo("UNKNOWN_TYPE");
assertThat(resp.getTypeOrganisationLibelle()).isEqualTo("UNKNOWN_TYPE");
}
@Test
@@ -1067,7 +1066,7 @@ class OrganisationServiceTest {
}
@Test
@DisplayName("Organisation sans typeOrganisation: typeLibelle null")
@DisplayName("Organisation sans typeOrganisation: typeOrganisationLibelle null")
void convertToSummaryResponse_noType() {
Organisation org = orgFixture("Sum", "sum@test.dev");
org.setTypeOrganisation(null);
@@ -1097,7 +1096,7 @@ class OrganisationServiceTest {
}
@Test
@DisplayName("Référence type non trouvée: typeLibelle = code")
@DisplayName("Référence type non trouvée: typeOrganisationLibelle = code")
void convertToSummaryResponse_typeRefNotFound_usesCode() {
Organisation org = orgFixture("SumFall", "sumfall@test.dev");
org.setTypeOrganisation("UNKNOWN");