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:
@@ -593,18 +593,14 @@ public class OrganisationService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dto.setTypeOrganisation(organisation.getTypeOrganisation());
|
dto.setTypeOrganisation(organisation.getTypeOrganisation());
|
||||||
dto.setTypeAssociation(organisation.getTypeOrganisation());
|
|
||||||
dto.setStatut(organisation.getStatut());
|
dto.setStatut(organisation.getStatut());
|
||||||
|
|
||||||
// Résolution des libellés
|
// Résolution des libellés
|
||||||
if (organisation.getTypeOrganisation() != null) {
|
if (organisation.getTypeOrganisation() != null) {
|
||||||
typeReferenceRepository.findByDomaineAndCode("TYPE_ORGANISATION", organisation.getTypeOrganisation())
|
typeReferenceRepository.findByDomaineAndCode("TYPE_ORGANISATION", organisation.getTypeOrganisation())
|
||||||
.ifPresent(ref -> {
|
.ifPresent(ref -> dto.setTypeOrganisationLibelle(ref.getLibelle()));
|
||||||
dto.setTypeOrganisationLibelle(ref.getLibelle());
|
if (dto.getTypeOrganisationLibelle() == null) {
|
||||||
dto.setTypeLibelle(ref.getLibelle());
|
dto.setTypeOrganisationLibelle(organisation.getTypeOrganisation());
|
||||||
});
|
|
||||||
if (dto.getTypeLibelle() == null) {
|
|
||||||
dto.setTypeLibelle(organisation.getTypeOrganisation());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (organisation.getStatut() != null) {
|
if (organisation.getStatut() != null) {
|
||||||
|
|||||||
@@ -958,12 +958,11 @@ class OrganisationServiceTest {
|
|||||||
OrganisationResponse resp = organisationService.convertToResponse(org);
|
OrganisationResponse resp = organisationService.convertToResponse(org);
|
||||||
|
|
||||||
assertThat(resp.getTypeOrganisationLibelle()).isEqualTo("Association loi 1901");
|
assertThat(resp.getTypeOrganisationLibelle()).isEqualTo("Association loi 1901");
|
||||||
assertThat(resp.getTypeLibelle()).isEqualTo("Association loi 1901");
|
|
||||||
assertThat(resp.getNombreEvenements()).isEqualTo(2);
|
assertThat(resp.getNombreEvenements()).isEqualTo(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@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() {
|
void convertToResponse_typeRefNotFound_usesCode() {
|
||||||
Organisation org = orgFixture("UnknownType", "unknowntype@test.dev");
|
Organisation org = orgFixture("UnknownType", "unknowntype@test.dev");
|
||||||
org.setTypeOrganisation("UNKNOWN_TYPE");
|
org.setTypeOrganisation("UNKNOWN_TYPE");
|
||||||
@@ -976,7 +975,7 @@ class OrganisationServiceTest {
|
|||||||
|
|
||||||
OrganisationResponse resp = organisationService.convertToResponse(org);
|
OrganisationResponse resp = organisationService.convertToResponse(org);
|
||||||
|
|
||||||
assertThat(resp.getTypeLibelle()).isEqualTo("UNKNOWN_TYPE");
|
assertThat(resp.getTypeOrganisationLibelle()).isEqualTo("UNKNOWN_TYPE");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -1067,7 +1066,7 @@ class OrganisationServiceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@DisplayName("Organisation sans typeOrganisation: typeLibelle null")
|
@DisplayName("Organisation sans typeOrganisation: typeOrganisationLibelle null")
|
||||||
void convertToSummaryResponse_noType() {
|
void convertToSummaryResponse_noType() {
|
||||||
Organisation org = orgFixture("Sum", "sum@test.dev");
|
Organisation org = orgFixture("Sum", "sum@test.dev");
|
||||||
org.setTypeOrganisation(null);
|
org.setTypeOrganisation(null);
|
||||||
@@ -1097,7 +1096,7 @@ class OrganisationServiceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@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() {
|
void convertToSummaryResponse_typeRefNotFound_usesCode() {
|
||||||
Organisation org = orgFixture("SumFall", "sumfall@test.dev");
|
Organisation org = orgFixture("SumFall", "sumfall@test.dev");
|
||||||
org.setTypeOrganisation("UNKNOWN");
|
org.setTypeOrganisation("UNKNOWN");
|
||||||
|
|||||||
Reference in New Issue
Block a user