Sync: code local unifié
Synchronisation du code source local (fait foi). Signed-off-by: lions dev Team
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
package dev.lions.unionflow.server;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import io.quarkus.runtime.QuarkusApplication;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import jakarta.inject.Inject;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@QuarkusTest
|
||||
@DisplayName("UnionFlowServerApplication")
|
||||
class UnionFlowServerApplicationTest {
|
||||
|
||||
@Inject
|
||||
UnionFlowServerApplication application;
|
||||
|
||||
@Test
|
||||
@DisplayName("Application est injectée et non null")
|
||||
void applicationInjected() {
|
||||
assertThat(application).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Instance de QuarkusApplication")
|
||||
void isQuarkusApplication() {
|
||||
assertThat(application).isInstanceOf(QuarkusApplication.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Instance de UnionFlowServerApplication")
|
||||
void isUnionFlowServerApplication() {
|
||||
assertThat(application).isInstanceOf(UnionFlowServerApplication.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("main method exists and is callable")
|
||||
void mainMethodExists() throws NoSuchMethodException {
|
||||
assertThat(UnionFlowServerApplication.class.getMethod("main", String[].class)).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("run method exists and is callable")
|
||||
void runMethodExists() throws NoSuchMethodException {
|
||||
assertThat(UnionFlowServerApplication.class.getMethod("run", String[].class)).isNotNull();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package dev.lions.unionflow.server.client;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.List;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Tests pour le client rôles et la classe interne RoleNamesRequest.
|
||||
*/
|
||||
class RoleServiceClientTest {
|
||||
|
||||
@Test
|
||||
@DisplayName("RoleNamesRequest no-arg constructor et getters/setters")
|
||||
void roleNamesRequest_gettersSetters() {
|
||||
RoleServiceClient.RoleNamesRequest req = new RoleServiceClient.RoleNamesRequest();
|
||||
assertThat(req.getRoleNames()).isNull();
|
||||
req.setRoleNames(List.of("ADMIN", "USER"));
|
||||
assertThat(req.getRoleNames()).containsExactly("ADMIN", "USER");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("RoleNamesRequest constructor avec liste")
|
||||
void roleNamesRequest_constructorWithList() {
|
||||
RoleServiceClient.RoleNamesRequest req = new RoleServiceClient.RoleNamesRequest(List.of("ROLE_A"));
|
||||
assertThat(req.getRoleNames()).containsExactly("ROLE_A");
|
||||
}
|
||||
}
|
||||
136
src/test/java/dev/lions/unionflow/server/entity/AdresseTest.java
Normal file
136
src/test/java/dev/lions/unionflow/server/entity/AdresseTest.java
Normal file
@@ -0,0 +1,136 @@
|
||||
package dev.lions.unionflow.server.entity;
|
||||
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("Adresse")
|
||||
class AdresseTest {
|
||||
|
||||
@Test
|
||||
@DisplayName("constructeur par défaut et getters/setters")
|
||||
void constructeurEtGettersSetters() {
|
||||
Adresse a = new Adresse();
|
||||
a.setTypeAdresse("SIEGE");
|
||||
a.setAdresse("1 rue Test");
|
||||
a.setComplementAdresse("Bât A");
|
||||
a.setCodePostal("75001");
|
||||
a.setVille("Paris");
|
||||
a.setRegion("Île-de-France");
|
||||
a.setPays("France");
|
||||
a.setLatitude(new BigDecimal("48.8566"));
|
||||
a.setLongitude(new BigDecimal("2.3522"));
|
||||
a.setPrincipale(true);
|
||||
a.setLibelle("Siège social");
|
||||
a.setNotes("Notes");
|
||||
|
||||
assertThat(a.getTypeAdresse()).isEqualTo("SIEGE");
|
||||
assertThat(a.getAdresse()).isEqualTo("1 rue Test");
|
||||
assertThat(a.getComplementAdresse()).isEqualTo("Bât A");
|
||||
assertThat(a.getCodePostal()).isEqualTo("75001");
|
||||
assertThat(a.getVille()).isEqualTo("Paris");
|
||||
assertThat(a.getRegion()).isEqualTo("Île-de-France");
|
||||
assertThat(a.getPays()).isEqualTo("France");
|
||||
assertThat(a.getLatitude()).isEqualByComparingTo("48.8566");
|
||||
assertThat(a.getLongitude()).isEqualByComparingTo("2.3522");
|
||||
assertThat(a.getPrincipale()).isTrue();
|
||||
assertThat(a.getLibelle()).isEqualTo("Siège social");
|
||||
assertThat(a.getNotes()).isEqualTo("Notes");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("getAdresseComplete: concatène tous les champs non vides")
|
||||
void getAdresseComplete() {
|
||||
Adresse a = Adresse.builder()
|
||||
.typeAdresse("SIEGE")
|
||||
.adresse("1 rue Test")
|
||||
.complementAdresse("Bât A")
|
||||
.codePostal("75001")
|
||||
.ville("Paris")
|
||||
.region("IDF")
|
||||
.pays("France")
|
||||
.build();
|
||||
assertThat(a.getAdresseComplete()).contains("1 rue Test", "Bât A", "75001", "Paris", "IDF", "France");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("getAdresseComplete: retourne chaîne vide quand tout null")
|
||||
void getAdresseComplete_vide() {
|
||||
Adresse a = new Adresse();
|
||||
a.setTypeAdresse("SIEGE");
|
||||
assertThat(a.getAdresseComplete()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("getAdresseComplete: un seul champ")
|
||||
void getAdresseComplete_unChamp() {
|
||||
Adresse a = new Adresse();
|
||||
a.setTypeAdresse("SIEGE");
|
||||
a.setVille("Lyon");
|
||||
assertThat(a.getAdresseComplete()).isEqualTo("Lyon");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("hasCoordinates: true si latitude et longitude renseignées")
|
||||
void hasCoordinates_true() {
|
||||
Adresse a = new Adresse();
|
||||
a.setTypeAdresse("SIEGE");
|
||||
a.setLatitude(new BigDecimal("48.0"));
|
||||
a.setLongitude(new BigDecimal("2.0"));
|
||||
assertThat(a.hasCoordinates()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("hasCoordinates: false si un champ null")
|
||||
void hasCoordinates_false() {
|
||||
Adresse a = new Adresse();
|
||||
a.setTypeAdresse("SIEGE");
|
||||
assertThat(a.hasCoordinates()).isFalse();
|
||||
a.setLatitude(new BigDecimal("48.0"));
|
||||
assertThat(a.hasCoordinates()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("equals et hashCode")
|
||||
void equalsHashCode() {
|
||||
UUID id = UUID.randomUUID();
|
||||
Adresse a = new Adresse();
|
||||
a.setId(id);
|
||||
a.setTypeAdresse("SIEGE");
|
||||
Adresse b = new Adresse();
|
||||
b.setId(id);
|
||||
b.setTypeAdresse("SIEGE");
|
||||
assertThat(a).isEqualTo(b);
|
||||
assertThat(a.hashCode()).isEqualTo(b.hashCode());
|
||||
assertThat(a).isNotEqualTo(null);
|
||||
assertThat(a).isNotEqualTo("x");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toString non null")
|
||||
void toString_nonNull() {
|
||||
Adresse a = new Adresse();
|
||||
a.setTypeAdresse("SIEGE");
|
||||
assertThat(a.toString()).isNotNull().isNotEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("relations: organisation, membre, evenement")
|
||||
void relations() {
|
||||
Adresse a = new Adresse();
|
||||
a.setTypeAdresse("SIEGE");
|
||||
Organisation o = new Organisation();
|
||||
Membre m = new Membre();
|
||||
Evenement e = new Evenement();
|
||||
a.setOrganisation(o);
|
||||
a.setMembre(m);
|
||||
a.setEvenement(e);
|
||||
assertThat(a.getOrganisation()).isSameAs(o);
|
||||
assertThat(a.getMembre()).isSameAs(m);
|
||||
assertThat(a.getEvenement()).isSameAs(e);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package dev.lions.unionflow.server.entity;
|
||||
|
||||
import dev.lions.unionflow.server.api.enums.audit.PorteeAudit;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("AuditLog")
|
||||
class AuditLogTest {
|
||||
|
||||
@Test
|
||||
@DisplayName("getters/setters de tous les champs")
|
||||
void gettersSetters() {
|
||||
AuditLog log = new AuditLog();
|
||||
log.setTypeAction("CREATE");
|
||||
log.setSeverite("INFO");
|
||||
log.setUtilisateur("user@test.com");
|
||||
log.setRole("ADMIN");
|
||||
log.setModule("MEMBRE");
|
||||
log.setDescription("Création membre");
|
||||
log.setDetails("{\"id\":\"x\"}");
|
||||
log.setIpAddress("127.0.0.1");
|
||||
log.setUserAgent("Mozilla/5.0");
|
||||
log.setSessionId("sess-123");
|
||||
LocalDateTime dh = LocalDateTime.now();
|
||||
log.setDateHeure(dh);
|
||||
log.setDonneesAvant("{}");
|
||||
log.setDonneesApres("{\"id\":\"y\"}");
|
||||
log.setEntiteId("uuid-1");
|
||||
log.setEntiteType("Membre");
|
||||
log.setPortee(PorteeAudit.ORGANISATION);
|
||||
|
||||
assertThat(log.getTypeAction()).isEqualTo("CREATE");
|
||||
assertThat(log.getSeverite()).isEqualTo("INFO");
|
||||
assertThat(log.getUtilisateur()).isEqualTo("user@test.com");
|
||||
assertThat(log.getRole()).isEqualTo("ADMIN");
|
||||
assertThat(log.getModule()).isEqualTo("MEMBRE");
|
||||
assertThat(log.getDescription()).isEqualTo("Création membre");
|
||||
assertThat(log.getDetails()).isEqualTo("{\"id\":\"x\"}");
|
||||
assertThat(log.getIpAddress()).isEqualTo("127.0.0.1");
|
||||
assertThat(log.getUserAgent()).isEqualTo("Mozilla/5.0");
|
||||
assertThat(log.getSessionId()).isEqualTo("sess-123");
|
||||
assertThat(log.getDateHeure()).isEqualTo(dh);
|
||||
assertThat(log.getDonneesAvant()).isEqualTo("{}");
|
||||
assertThat(log.getDonneesApres()).isEqualTo("{\"id\":\"y\"}");
|
||||
assertThat(log.getEntiteId()).isEqualTo("uuid-1");
|
||||
assertThat(log.getEntiteType()).isEqualTo("Membre");
|
||||
assertThat(log.getPortee()).isEqualTo(PorteeAudit.ORGANISATION);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("portee par défaut PLATEFORME")
|
||||
void porteeDefaut() {
|
||||
AuditLog log = new AuditLog();
|
||||
assertThat(log.getPortee()).isEqualTo(PorteeAudit.PLATEFORME);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("onCreate initialise dateHeure si null")
|
||||
void onCreate_initialiseDateHeure() throws Exception {
|
||||
AuditLog log = new AuditLog();
|
||||
log.setDateHeure(null);
|
||||
Method onCreate = AuditLog.class.getDeclaredMethod("onCreate");
|
||||
onCreate.setAccessible(true);
|
||||
onCreate.invoke(log);
|
||||
assertThat(log.getDateHeure()).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("relation organisation")
|
||||
void relationOrganisation() {
|
||||
AuditLog log = new AuditLog();
|
||||
Organisation o = new Organisation();
|
||||
log.setOrganisation(o);
|
||||
assertThat(log.getOrganisation()).isSameAs(o);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("héritage BaseEntity: id, actif, etc.")
|
||||
void heritageBaseEntity() {
|
||||
AuditLog log = new AuditLog();
|
||||
UUID id = UUID.randomUUID();
|
||||
log.setId(id);
|
||||
log.setActif(false);
|
||||
assertThat(log.getId()).isEqualTo(id);
|
||||
assertThat(log.getActif()).isFalse();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
package dev.lions.unionflow.server.entity;
|
||||
|
||||
import dev.lions.unionflow.server.api.enums.ayantdroit.LienParente;
|
||||
import dev.lions.unionflow.server.api.enums.ayantdroit.StatutAyantDroit;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("AyantDroit")
|
||||
class AyantDroitTest {
|
||||
|
||||
private static MembreOrganisation newMembreOrganisation() {
|
||||
Membre m = new Membre();
|
||||
m.setId(UUID.randomUUID());
|
||||
Organisation o = new Organisation();
|
||||
o.setId(UUID.randomUUID());
|
||||
MembreOrganisation mo = new MembreOrganisation();
|
||||
mo.setMembre(m);
|
||||
mo.setOrganisation(o);
|
||||
return mo;
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("getters/setters et constructeur")
|
||||
void gettersSetters() {
|
||||
MembreOrganisation mo = newMembreOrganisation();
|
||||
AyantDroit a = new AyantDroit();
|
||||
a.setMembreOrganisation(mo);
|
||||
a.setPrenom("Jean");
|
||||
a.setNom("Dupont");
|
||||
a.setDateNaissance(LocalDate.of(1990, 5, 15));
|
||||
a.setLienParente(LienParente.ENFANT);
|
||||
a.setNumeroBeneficiaire("BEN-001");
|
||||
a.setDateDebutCouverture(LocalDate.of(2024, 1, 1));
|
||||
a.setDateFinCouverture(LocalDate.of(2024, 12, 31));
|
||||
a.setSexe("M");
|
||||
a.setPieceIdentite("CNI");
|
||||
a.setPourcentageCouvertureSante(new BigDecimal("80.00"));
|
||||
a.setStatut(StatutAyantDroit.ACTIF);
|
||||
|
||||
assertThat(a.getMembreOrganisation()).isSameAs(mo);
|
||||
assertThat(a.getPrenom()).isEqualTo("Jean");
|
||||
assertThat(a.getNom()).isEqualTo("Dupont");
|
||||
assertThat(a.getDateNaissance()).isEqualTo(LocalDate.of(1990, 5, 15));
|
||||
assertThat(a.getLienParente()).isEqualTo(LienParente.ENFANT);
|
||||
assertThat(a.getNumeroBeneficiaire()).isEqualTo("BEN-001");
|
||||
assertThat(a.getDateDebutCouverture()).isEqualTo(LocalDate.of(2024, 1, 1));
|
||||
assertThat(a.getDateFinCouverture()).isEqualTo(LocalDate.of(2024, 12, 31));
|
||||
assertThat(a.getSexe()).isEqualTo("M");
|
||||
assertThat(a.getPieceIdentite()).isEqualTo("CNI");
|
||||
assertThat(a.getPourcentageCouvertureSante()).isEqualByComparingTo("80.00");
|
||||
assertThat(a.getStatut()).isEqualTo(StatutAyantDroit.ACTIF);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("statut par défaut EN_ATTENTE")
|
||||
void statutDefaut() {
|
||||
AyantDroit a = new AyantDroit();
|
||||
a.setMembreOrganisation(newMembreOrganisation());
|
||||
a.setPrenom("X");
|
||||
a.setNom("Y");
|
||||
a.setLienParente(LienParente.CONJOINT);
|
||||
assertThat(a.getStatut()).isEqualTo(StatutAyantDroit.EN_ATTENTE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("getNomComplet")
|
||||
void getNomComplet() {
|
||||
AyantDroit a = new AyantDroit();
|
||||
a.setMembreOrganisation(newMembreOrganisation());
|
||||
a.setPrenom("Marie");
|
||||
a.setNom("Martin");
|
||||
a.setLienParente(LienParente.ENFANT);
|
||||
assertThat(a.getNomComplet()).isEqualTo("Marie Martin");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("isCouvertAujourdhui: false si dateDebut dans le futur")
|
||||
void isCouvertAujourdhui_false_debutFutur() {
|
||||
AyantDroit a = new AyantDroit();
|
||||
a.setMembreOrganisation(newMembreOrganisation());
|
||||
a.setPrenom("X");
|
||||
a.setNom("Y");
|
||||
a.setLienParente(LienParente.ENFANT);
|
||||
a.setDateDebutCouverture(LocalDate.now().plusDays(10));
|
||||
a.setActif(true);
|
||||
assertThat(a.isCouvertAujourdhui()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("isCouvertAujourdhui: false si dateFin dans le passé")
|
||||
void isCouvertAujourdhui_false_finPassee() {
|
||||
AyantDroit a = new AyantDroit();
|
||||
a.setMembreOrganisation(newMembreOrganisation());
|
||||
a.setPrenom("X");
|
||||
a.setNom("Y");
|
||||
a.setLienParente(LienParente.ENFANT);
|
||||
a.setDateDebutCouverture(LocalDate.now().minusDays(10));
|
||||
a.setDateFinCouverture(LocalDate.now().minusDays(1));
|
||||
a.setActif(true);
|
||||
assertThat(a.isCouvertAujourdhui()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("isCouvertAujourdhui: true si actif et dates couvrent aujourd'hui")
|
||||
void isCouvertAujourdhui_true() {
|
||||
AyantDroit a = new AyantDroit();
|
||||
a.setMembreOrganisation(newMembreOrganisation());
|
||||
a.setPrenom("X");
|
||||
a.setNom("Y");
|
||||
a.setLienParente(LienParente.ENFANT);
|
||||
a.setDateDebutCouverture(LocalDate.now().minusDays(1));
|
||||
a.setDateFinCouverture(null);
|
||||
a.setActif(true);
|
||||
assertThat(a.isCouvertAujourdhui()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("equals et hashCode")
|
||||
void equalsHashCode() {
|
||||
UUID id = UUID.randomUUID();
|
||||
MembreOrganisation mo = newMembreOrganisation();
|
||||
AyantDroit a = new AyantDroit();
|
||||
a.setId(id);
|
||||
a.setMembreOrganisation(mo);
|
||||
a.setPrenom("A");
|
||||
a.setNom("B");
|
||||
a.setLienParente(LienParente.ENFANT);
|
||||
AyantDroit b = new AyantDroit();
|
||||
b.setId(id);
|
||||
b.setMembreOrganisation(mo);
|
||||
b.setPrenom("A");
|
||||
b.setNom("B");
|
||||
b.setLienParente(LienParente.ENFANT);
|
||||
assertThat(a).isEqualTo(b);
|
||||
assertThat(a.hashCode()).isEqualTo(b.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toString non null")
|
||||
void toString_nonNull() {
|
||||
AyantDroit a = new AyantDroit();
|
||||
a.setMembreOrganisation(newMembreOrganisation());
|
||||
a.setPrenom("X");
|
||||
a.setNom("Y");
|
||||
a.setLienParente(LienParente.ENFANT);
|
||||
assertThat(a.toString()).isNotNull().isNotEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
package dev.lions.unionflow.server.entity;
|
||||
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests unitaires pour BaseEntity (getters/setters, callbacks @PrePersist/@PreUpdate, marquerCommeModifie).
|
||||
* BaseEntity étant abstraite, on s'appuie sur une sous-classe concrète (Adresse).
|
||||
*/
|
||||
@DisplayName("BaseEntity")
|
||||
class BaseEntityTest {
|
||||
|
||||
@Test
|
||||
@DisplayName("getters/setters: id, dateCreation, dateModification, creePar, modifiePar, version, actif")
|
||||
void gettersSetters() {
|
||||
Adresse entity = new Adresse();
|
||||
UUID id = UUID.randomUUID();
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
LocalDateTime later = now.plusHours(1);
|
||||
|
||||
entity.setId(id);
|
||||
entity.setDateCreation(now);
|
||||
entity.setDateModification(later);
|
||||
entity.setCreePar("createur@test.com");
|
||||
entity.setModifiePar("modif@test.com");
|
||||
entity.setVersion(1L);
|
||||
entity.setActif(true);
|
||||
|
||||
assertThat(entity.getId()).isEqualTo(id);
|
||||
assertThat(entity.getDateCreation()).isEqualTo(now);
|
||||
assertThat(entity.getDateModification()).isEqualTo(later);
|
||||
assertThat(entity.getCreePar()).isEqualTo("createur@test.com");
|
||||
assertThat(entity.getModifiePar()).isEqualTo("modif@test.com");
|
||||
assertThat(entity.getVersion()).isEqualTo(1L);
|
||||
assertThat(entity.getActif()).isTrue();
|
||||
|
||||
entity.setActif(false);
|
||||
assertThat(entity.getActif()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("marquerCommeModifie met à jour dateModification et modifiePar")
|
||||
void marquerCommeModifie() {
|
||||
Adresse entity = new Adresse();
|
||||
entity.setDateModification(null);
|
||||
entity.setModifiePar(null);
|
||||
|
||||
entity.marquerCommeModifie("user@test.com");
|
||||
|
||||
assertThat(entity.getDateModification()).isNotNull();
|
||||
assertThat(entity.getModifiePar()).isEqualTo("user@test.com");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("@PrePersist onCreate: initialise dateCreation si null")
|
||||
void onCreate_initialiseDateCreationSiNull() throws Exception {
|
||||
Adresse entity = new Adresse();
|
||||
entity.setDateCreation(null);
|
||||
entity.setActif(null);
|
||||
|
||||
Method onCreate = BaseEntity.class.getDeclaredMethod("onCreate");
|
||||
onCreate.setAccessible(true);
|
||||
onCreate.invoke(entity);
|
||||
|
||||
assertThat(entity.getDateCreation()).isNotNull();
|
||||
assertThat(entity.getActif()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("@PrePersist onCreate: ne modifie pas dateCreation si déjà renseignée")
|
||||
void onCreate_neModifiePasDateCreationSiDejaRenseignee() throws Exception {
|
||||
Adresse entity = new Adresse();
|
||||
LocalDateTime fixed = LocalDateTime.of(2025, 1, 1, 12, 0);
|
||||
entity.setDateCreation(fixed);
|
||||
entity.setActif(true);
|
||||
|
||||
Method onCreate = BaseEntity.class.getDeclaredMethod("onCreate");
|
||||
onCreate.setAccessible(true);
|
||||
onCreate.invoke(entity);
|
||||
|
||||
assertThat(entity.getDateCreation()).isEqualTo(fixed);
|
||||
assertThat(entity.getActif()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("@PrePersist onCreate: initialise actif à true si null")
|
||||
void onCreate_initialiseActifSiNull() throws Exception {
|
||||
Adresse entity = new Adresse();
|
||||
entity.setDateCreation(LocalDateTime.now());
|
||||
entity.setActif(null);
|
||||
|
||||
Method onCreate = BaseEntity.class.getDeclaredMethod("onCreate");
|
||||
onCreate.setAccessible(true);
|
||||
onCreate.invoke(entity);
|
||||
|
||||
assertThat(entity.getActif()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("@PreUpdate onUpdate: met à jour dateModification")
|
||||
void onUpdate_metAJourDateModification() throws Exception {
|
||||
Adresse entity = new Adresse();
|
||||
entity.setDateModification(null);
|
||||
|
||||
Method onUpdate = BaseEntity.class.getDeclaredMethod("onUpdate");
|
||||
onUpdate.setAccessible(true);
|
||||
onUpdate.invoke(entity);
|
||||
|
||||
assertThat(entity.getDateModification()).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toString non null")
|
||||
void toString_nonNull() {
|
||||
Adresse entity = new Adresse();
|
||||
entity.setId(UUID.randomUUID());
|
||||
assertThat(entity.toString()).isNotNull().isNotEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("equals et hashCode cohérents avec champs de base")
|
||||
void equalsHashCode() {
|
||||
Adresse a = new Adresse();
|
||||
a.setId(UUID.randomUUID());
|
||||
a.setTypeAdresse("SIEGE");
|
||||
Adresse b = new Adresse();
|
||||
b.setId(a.getId());
|
||||
b.setTypeAdresse("SIEGE");
|
||||
|
||||
assertThat(a).isEqualTo(b);
|
||||
assertThat(a.hashCode()).isEqualTo(b.hashCode());
|
||||
assertThat(a).isEqualTo(a);
|
||||
assertThat(a).isNotEqualTo(null);
|
||||
assertThat(a).isNotEqualTo("autre type");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
package dev.lions.unionflow.server.entity;
|
||||
|
||||
import dev.lions.unionflow.server.api.enums.comptabilite.TypeCompteComptable;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("CompteComptable")
|
||||
class CompteComptableTest {
|
||||
|
||||
@Test
|
||||
@DisplayName("getters/setters et valeurs par défaut")
|
||||
void gettersSetters() {
|
||||
CompteComptable c = new CompteComptable();
|
||||
c.setNumeroCompte("411000");
|
||||
c.setLibelle("Clients");
|
||||
c.setTypeCompte(TypeCompteComptable.CHARGES);
|
||||
c.setClasseComptable(4);
|
||||
c.setSoldeInitial(new BigDecimal("1000.00"));
|
||||
c.setSoldeActuel(new BigDecimal("1500.00"));
|
||||
c.setCompteCollectif(true);
|
||||
c.setCompteAnalytique(true);
|
||||
c.setDescription("Compte clients");
|
||||
|
||||
assertThat(c.getNumeroCompte()).isEqualTo("411000");
|
||||
assertThat(c.getLibelle()).isEqualTo("Clients");
|
||||
assertThat(c.getTypeCompte()).isEqualTo(TypeCompteComptable.CHARGES);
|
||||
assertThat(c.getClasseComptable()).isEqualTo(4);
|
||||
assertThat(c.getSoldeInitial()).isEqualByComparingTo("1000.00");
|
||||
assertThat(c.getSoldeActuel()).isEqualByComparingTo("1500.00");
|
||||
assertThat(c.getCompteCollectif()).isTrue();
|
||||
assertThat(c.getCompteAnalytique()).isTrue();
|
||||
assertThat(c.getDescription()).isEqualTo("Compte clients");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("getNumeroFormate")
|
||||
void getNumeroFormate() {
|
||||
CompteComptable c = new CompteComptable();
|
||||
c.setNumeroCompte("512");
|
||||
assertThat(c.getNumeroFormate()).hasSize(10).startsWith("512");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("isTresorerie true quand type TRESORERIE")
|
||||
void isTresorerie_true() {
|
||||
CompteComptable c = new CompteComptable();
|
||||
c.setTypeCompte(TypeCompteComptable.TRESORERIE);
|
||||
assertThat(c.isTresorerie()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("isTresorerie false pour autre type")
|
||||
void isTresorerie_false() {
|
||||
CompteComptable c = new CompteComptable();
|
||||
c.setTypeCompte(TypeCompteComptable.CHARGES);
|
||||
assertThat(c.isTresorerie()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("onCreate initialise soldeInitial, soldeActuel, compteCollectif, compteAnalytique")
|
||||
void onCreate_initialiseChamps() throws Exception {
|
||||
CompteComptable c = new CompteComptable();
|
||||
c.setNumeroCompte("411000");
|
||||
c.setLibelle("X");
|
||||
c.setTypeCompte(TypeCompteComptable.CHARGES);
|
||||
c.setClasseComptable(1);
|
||||
c.setSoldeInitial(null);
|
||||
c.setSoldeActuel(null);
|
||||
c.setCompteCollectif(null);
|
||||
c.setCompteAnalytique(null);
|
||||
Method onCreate = CompteComptable.class.getDeclaredMethod("onCreate");
|
||||
onCreate.setAccessible(true);
|
||||
onCreate.invoke(c);
|
||||
assertThat(c.getSoldeInitial()).isEqualByComparingTo(BigDecimal.ZERO);
|
||||
assertThat(c.getSoldeActuel()).isEqualByComparingTo(BigDecimal.ZERO);
|
||||
assertThat(c.getCompteCollectif()).isFalse();
|
||||
assertThat(c.getCompteAnalytique()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("equals et hashCode")
|
||||
void equalsHashCode() {
|
||||
UUID id = UUID.randomUUID();
|
||||
CompteComptable a = new CompteComptable();
|
||||
a.setId(id);
|
||||
a.setNumeroCompte("411000");
|
||||
a.setLibelle("C");
|
||||
a.setTypeCompte(TypeCompteComptable.CHARGES);
|
||||
a.setClasseComptable(4);
|
||||
CompteComptable b = new CompteComptable();
|
||||
b.setId(id);
|
||||
b.setNumeroCompte("411000");
|
||||
b.setLibelle("C");
|
||||
b.setTypeCompte(TypeCompteComptable.CHARGES);
|
||||
b.setClasseComptable(4);
|
||||
assertThat(a).isEqualTo(b);
|
||||
assertThat(a.hashCode()).isEqualTo(b.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toString non null")
|
||||
void toString_nonNull() {
|
||||
CompteComptable c = new CompteComptable();
|
||||
c.setNumeroCompte("411000");
|
||||
c.setLibelle("Clients");
|
||||
c.setTypeCompte(TypeCompteComptable.CHARGES);
|
||||
c.setClasseComptable(4);
|
||||
assertThat(c.toString()).isNotNull().isNotEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package dev.lions.unionflow.server.entity;
|
||||
|
||||
import dev.lions.unionflow.server.api.enums.wave.StatutCompteWave;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("CompteWave")
|
||||
class CompteWaveTest {
|
||||
|
||||
@Test
|
||||
@DisplayName("getters/setters")
|
||||
void gettersSetters() {
|
||||
CompteWave c = new CompteWave();
|
||||
c.setNumeroTelephone("+22507000001");
|
||||
c.setStatutCompte(StatutCompteWave.VERIFIE);
|
||||
c.setWaveAccountId("wa-1");
|
||||
c.setWaveApiKey("key");
|
||||
c.setEnvironnement("PRODUCTION");
|
||||
LocalDateTime dt = LocalDateTime.now();
|
||||
c.setDateDerniereVerification(dt);
|
||||
c.setCommentaire("OK");
|
||||
|
||||
assertThat(c.getNumeroTelephone()).isEqualTo("+22507000001");
|
||||
assertThat(c.getStatutCompte()).isEqualTo(StatutCompteWave.VERIFIE);
|
||||
assertThat(c.getWaveAccountId()).isEqualTo("wa-1");
|
||||
assertThat(c.getWaveApiKey()).isEqualTo("key");
|
||||
assertThat(c.getEnvironnement()).isEqualTo("PRODUCTION");
|
||||
assertThat(c.getDateDerniereVerification()).isEqualTo(dt);
|
||||
assertThat(c.getCommentaire()).isEqualTo("OK");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("statut par défaut NON_VERIFIE")
|
||||
void statutDefaut() {
|
||||
CompteWave c = new CompteWave();
|
||||
c.setNumeroTelephone("+22507000002");
|
||||
assertThat(c.getStatutCompte()).isEqualTo(StatutCompteWave.NON_VERIFIE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("relations organisation et membre")
|
||||
void relations() {
|
||||
CompteWave c = new CompteWave();
|
||||
c.setNumeroTelephone("+22507000003");
|
||||
Organisation o = new Organisation();
|
||||
Membre m = new Membre();
|
||||
c.setOrganisation(o);
|
||||
c.setMembre(m);
|
||||
assertThat(c.getOrganisation()).isSameAs(o);
|
||||
assertThat(c.getMembre()).isSameAs(m);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("equals et hashCode")
|
||||
void equalsHashCode() {
|
||||
UUID id = UUID.randomUUID();
|
||||
CompteWave a = new CompteWave();
|
||||
a.setId(id);
|
||||
a.setNumeroTelephone("+22507000004");
|
||||
CompteWave b = new CompteWave();
|
||||
b.setId(id);
|
||||
b.setNumeroTelephone("+22507000004");
|
||||
assertThat(a).isEqualTo(b);
|
||||
assertThat(a.hashCode()).isEqualTo(b.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("isVerifie et peutEtreUtilise true quand VERIFIE")
|
||||
void isVerifie_peutEtreUtilise() {
|
||||
CompteWave c = new CompteWave();
|
||||
c.setNumeroTelephone("+22507000006");
|
||||
c.setStatutCompte(StatutCompteWave.VERIFIE);
|
||||
assertThat(c.isVerifie()).isTrue();
|
||||
assertThat(c.peutEtreUtilise()).isTrue();
|
||||
c.setStatutCompte(StatutCompteWave.NON_VERIFIE);
|
||||
assertThat(c.isVerifie()).isFalse();
|
||||
assertThat(c.peutEtreUtilise()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toString non null")
|
||||
void toString_nonNull() {
|
||||
CompteWave c = new CompteWave();
|
||||
c.setNumeroTelephone("+22507000005");
|
||||
assertThat(c.toString()).isNotNull().isNotEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package dev.lions.unionflow.server.entity;
|
||||
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("Configuration")
|
||||
class ConfigurationTest {
|
||||
|
||||
@Test
|
||||
@DisplayName("getters/setters")
|
||||
void gettersSetters() {
|
||||
Configuration c = new Configuration();
|
||||
c.setCle("app.name");
|
||||
c.setValeur("UnionFlow");
|
||||
c.setType("STRING");
|
||||
c.setCategorie("SYSTEME");
|
||||
c.setDescription("Nom de l'application");
|
||||
c.setModifiable(true);
|
||||
c.setVisible(true);
|
||||
c.setMetadonnees("{}");
|
||||
|
||||
assertThat(c.getCle()).isEqualTo("app.name");
|
||||
assertThat(c.getValeur()).isEqualTo("UnionFlow");
|
||||
assertThat(c.getType()).isEqualTo("STRING");
|
||||
assertThat(c.getCategorie()).isEqualTo("SYSTEME");
|
||||
assertThat(c.getDescription()).isEqualTo("Nom de l'application");
|
||||
assertThat(c.getModifiable()).isTrue();
|
||||
assertThat(c.getVisible()).isTrue();
|
||||
assertThat(c.getMetadonnees()).isEqualTo("{}");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("modifiable et visible par défaut true")
|
||||
void defauts() {
|
||||
Configuration c = new Configuration();
|
||||
c.setCle("x");
|
||||
assertThat(c.getModifiable()).isTrue();
|
||||
assertThat(c.getVisible()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("equals et hashCode")
|
||||
void equalsHashCode() {
|
||||
UUID id = UUID.randomUUID();
|
||||
Configuration a = new Configuration();
|
||||
a.setId(id);
|
||||
a.setCle("k1");
|
||||
a.setValeur("v1");
|
||||
Configuration b = new Configuration();
|
||||
b.setId(id);
|
||||
b.setCle("k1");
|
||||
b.setValeur("v1");
|
||||
assertThat(a).isEqualTo(b);
|
||||
assertThat(a.hashCode()).isEqualTo(b.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toString non null")
|
||||
void toString_nonNull() {
|
||||
Configuration c = new Configuration();
|
||||
c.setCle("x");
|
||||
assertThat(c.toString()).isNotNull().isNotEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package dev.lions.unionflow.server.entity;
|
||||
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("ConfigurationWave")
|
||||
class ConfigurationWaveTest {
|
||||
|
||||
@Test
|
||||
@DisplayName("getters/setters")
|
||||
void gettersSetters() {
|
||||
ConfigurationWave c = new ConfigurationWave();
|
||||
c.setCle("wave.api.url");
|
||||
c.setValeur("https://api.wave.com");
|
||||
c.setDescription("URL API Wave");
|
||||
c.setTypeValeur("STRING");
|
||||
c.setEnvironnement("PRODUCTION");
|
||||
|
||||
assertThat(c.getCle()).isEqualTo("wave.api.url");
|
||||
assertThat(c.getValeur()).isEqualTo("https://api.wave.com");
|
||||
assertThat(c.getDescription()).isEqualTo("URL API Wave");
|
||||
assertThat(c.getTypeValeur()).isEqualTo("STRING");
|
||||
assertThat(c.getEnvironnement()).isEqualTo("PRODUCTION");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("isEncryptee true quand typeValeur ENCRYPTED")
|
||||
void isEncryptee_true() {
|
||||
ConfigurationWave c = new ConfigurationWave();
|
||||
c.setCle("x");
|
||||
c.setTypeValeur("ENCRYPTED");
|
||||
assertThat(c.isEncryptee()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("isEncryptee false sinon")
|
||||
void isEncryptee_false() {
|
||||
ConfigurationWave c = new ConfigurationWave();
|
||||
c.setCle("x");
|
||||
c.setTypeValeur("STRING");
|
||||
assertThat(c.isEncryptee()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("onCreate initialise typeValeur et environnement si null")
|
||||
void onCreate_initialiseChamps() throws Exception {
|
||||
ConfigurationWave c = new ConfigurationWave();
|
||||
c.setCle("k");
|
||||
c.setTypeValeur(null);
|
||||
c.setEnvironnement(null);
|
||||
Method onCreate = ConfigurationWave.class.getDeclaredMethod("onCreate");
|
||||
onCreate.setAccessible(true);
|
||||
onCreate.invoke(c);
|
||||
assertThat(c.getTypeValeur()).isEqualTo("STRING");
|
||||
assertThat(c.getEnvironnement()).isEqualTo("COMMON");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("equals et hashCode")
|
||||
void equalsHashCode() {
|
||||
UUID id = UUID.randomUUID();
|
||||
ConfigurationWave a = new ConfigurationWave();
|
||||
a.setId(id);
|
||||
a.setCle("k1");
|
||||
ConfigurationWave b = new ConfigurationWave();
|
||||
b.setId(id);
|
||||
b.setCle("k1");
|
||||
assertThat(a).isEqualTo(b);
|
||||
assertThat(a.hashCode()).isEqualTo(b.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toString non null")
|
||||
void toString_nonNull() {
|
||||
ConfigurationWave c = new ConfigurationWave();
|
||||
c.setCle("x");
|
||||
assertThat(c.toString()).isNotNull().isNotEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
package dev.lions.unionflow.server.entity;
|
||||
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("Cotisation")
|
||||
class CotisationTest {
|
||||
|
||||
private static Membre newMembre() {
|
||||
Membre m = new Membre();
|
||||
m.setId(UUID.randomUUID());
|
||||
return m;
|
||||
}
|
||||
|
||||
private static Organisation newOrganisation() {
|
||||
Organisation o = new Organisation();
|
||||
o.setId(UUID.randomUUID());
|
||||
return o;
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("getters/setters")
|
||||
void gettersSetters() {
|
||||
Cotisation c = new Cotisation();
|
||||
c.setNumeroReference("COT-2025-00000001");
|
||||
c.setMembre(newMembre());
|
||||
c.setOrganisation(newOrganisation());
|
||||
c.setTypeCotisation("MENSUEL");
|
||||
c.setLibelle("Cotisation janvier");
|
||||
c.setMontantDu(new BigDecimal("5000.00"));
|
||||
c.setMontantPaye(new BigDecimal("2000.00"));
|
||||
c.setCodeDevise("XOF");
|
||||
c.setStatut("EN_ATTENTE");
|
||||
c.setDateEcheance(LocalDate.now().plusMonths(1));
|
||||
c.setAnnee(2025);
|
||||
c.setMois(1);
|
||||
c.setRecurrente(true);
|
||||
|
||||
assertThat(c.getNumeroReference()).isEqualTo("COT-2025-00000001");
|
||||
assertThat(c.getTypeCotisation()).isEqualTo("MENSUEL");
|
||||
assertThat(c.getLibelle()).isEqualTo("Cotisation janvier");
|
||||
assertThat(c.getMontantDu()).isEqualByComparingTo("5000.00");
|
||||
assertThat(c.getMontantPaye()).isEqualByComparingTo("2000.00");
|
||||
assertThat(c.getCodeDevise()).isEqualTo("XOF");
|
||||
assertThat(c.getStatut()).isEqualTo("EN_ATTENTE");
|
||||
assertThat(c.getAnnee()).isEqualTo(2025);
|
||||
assertThat(c.getMois()).isEqualTo(1);
|
||||
assertThat(c.getRecurrente()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("getMontantRestant")
|
||||
void getMontantRestant() {
|
||||
Cotisation c = new Cotisation();
|
||||
c.setMontantDu(new BigDecimal("100.00"));
|
||||
c.setMontantPaye(new BigDecimal("30.00"));
|
||||
assertThat(c.getMontantRestant()).isEqualByComparingTo("70.00");
|
||||
c.setMontantPaye(null);
|
||||
assertThat(c.getMontantRestant()).isEqualByComparingTo(BigDecimal.ZERO);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("isEntierementPayee")
|
||||
void isEntierementPayee() {
|
||||
Cotisation c = new Cotisation();
|
||||
c.setMontantDu(new BigDecimal("100.00"));
|
||||
c.setMontantPaye(new BigDecimal("100.00"));
|
||||
assertThat(c.isEntierementPayee()).isTrue();
|
||||
c.setMontantPaye(new BigDecimal("50.00"));
|
||||
assertThat(c.isEntierementPayee()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("isEnRetard: true si échéance passée et non payée")
|
||||
void isEnRetard() {
|
||||
Cotisation c = new Cotisation();
|
||||
c.setDateEcheance(LocalDate.now().minusDays(1));
|
||||
c.setMontantDu(new BigDecimal("100.00"));
|
||||
c.setMontantPaye(BigDecimal.ZERO);
|
||||
assertThat(c.isEnRetard()).isTrue();
|
||||
c.setMontantPaye(new BigDecimal("100.00"));
|
||||
assertThat(c.isEnRetard()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("genererNumeroReference non null")
|
||||
void genererNumeroReference() {
|
||||
String ref = Cotisation.genererNumeroReference();
|
||||
assertThat(ref).startsWith("COT-").isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("equals et hashCode")
|
||||
void equalsHashCode() {
|
||||
UUID id = UUID.randomUUID();
|
||||
Cotisation a = new Cotisation();
|
||||
a.setId(id);
|
||||
a.setNumeroReference("REF-1");
|
||||
a.setMembre(newMembre());
|
||||
a.setOrganisation(newOrganisation());
|
||||
a.setTypeCotisation("MENSUEL");
|
||||
a.setLibelle("L");
|
||||
a.setMontantDu(BigDecimal.ONE);
|
||||
a.setCodeDevise("XOF");
|
||||
a.setStatut("EN_ATTENTE");
|
||||
a.setDateEcheance(LocalDate.now());
|
||||
a.setAnnee(2025);
|
||||
Cotisation b = new Cotisation();
|
||||
b.setId(id);
|
||||
b.setNumeroReference("REF-1");
|
||||
b.setMembre(a.getMembre());
|
||||
b.setOrganisation(a.getOrganisation());
|
||||
b.setTypeCotisation("MENSUEL");
|
||||
b.setLibelle("L");
|
||||
b.setMontantDu(BigDecimal.ONE);
|
||||
b.setCodeDevise("XOF");
|
||||
b.setStatut("EN_ATTENTE");
|
||||
b.setDateEcheance(LocalDate.now());
|
||||
b.setAnnee(2025);
|
||||
assertThat(a).isEqualTo(b);
|
||||
assertThat(a.hashCode()).isEqualTo(b.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toString non null")
|
||||
void toString_nonNull() {
|
||||
Cotisation c = new Cotisation();
|
||||
c.setNumeroReference("REF");
|
||||
c.setTypeCotisation("MENSUEL");
|
||||
c.setLibelle("L");
|
||||
c.setMontantDu(BigDecimal.ONE);
|
||||
c.setCodeDevise("XOF");
|
||||
c.setStatut("EN_ATTENTE");
|
||||
c.setDateEcheance(LocalDate.now());
|
||||
c.setAnnee(2025);
|
||||
assertThat(c.toString()).isNotNull().isNotEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package dev.lions.unionflow.server.entity;
|
||||
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("DemandeAdhesion")
|
||||
class DemandeAdhesionTest {
|
||||
|
||||
private static Membre newMembre() {
|
||||
Membre m = new Membre();
|
||||
m.setId(UUID.randomUUID());
|
||||
return m;
|
||||
}
|
||||
|
||||
private static Organisation newOrganisation() {
|
||||
Organisation o = new Organisation();
|
||||
o.setId(UUID.randomUUID());
|
||||
return o;
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("getters/setters")
|
||||
void gettersSetters() {
|
||||
DemandeAdhesion d = new DemandeAdhesion();
|
||||
d.setNumeroReference("DA-001");
|
||||
d.setUtilisateur(newMembre());
|
||||
d.setOrganisation(newOrganisation());
|
||||
d.setStatut("APPROUVEE");
|
||||
d.setFraisAdhesion(new BigDecimal("5000.00"));
|
||||
d.setMontantPaye(new BigDecimal("5000.00"));
|
||||
d.setCodeDevise("XOF");
|
||||
LocalDateTime dt = LocalDateTime.now();
|
||||
d.setDateDemande(dt);
|
||||
d.setDateTraitement(dt);
|
||||
|
||||
assertThat(d.getNumeroReference()).isEqualTo("DA-001");
|
||||
assertThat(d.getStatut()).isEqualTo("APPROUVEE");
|
||||
assertThat(d.getFraisAdhesion()).isEqualByComparingTo("5000.00");
|
||||
assertThat(d.getMontantPaye()).isEqualByComparingTo("5000.00");
|
||||
assertThat(d.getCodeDevise()).isEqualTo("XOF");
|
||||
assertThat(d.getDateDemande()).isEqualTo(dt);
|
||||
assertThat(d.getDateTraitement()).isEqualTo(dt);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("statut et codeDevise par défaut")
|
||||
void defauts() {
|
||||
DemandeAdhesion d = new DemandeAdhesion();
|
||||
d.setNumeroReference("x");
|
||||
d.setUtilisateur(newMembre());
|
||||
d.setOrganisation(newOrganisation());
|
||||
assertThat(d.getStatut()).isEqualTo("EN_ATTENTE");
|
||||
assertThat(d.getCodeDevise()).isEqualTo("XOF");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("equals et hashCode")
|
||||
void equalsHashCode() {
|
||||
UUID id = UUID.randomUUID();
|
||||
LocalDateTime sameDate = LocalDateTime.now();
|
||||
Membre m = newMembre();
|
||||
Organisation o = newOrganisation();
|
||||
DemandeAdhesion a = new DemandeAdhesion();
|
||||
a.setId(id);
|
||||
a.setNumeroReference("DA-1");
|
||||
a.setUtilisateur(m);
|
||||
a.setOrganisation(o);
|
||||
a.setDateDemande(sameDate);
|
||||
DemandeAdhesion b = new DemandeAdhesion();
|
||||
b.setId(id);
|
||||
b.setNumeroReference("DA-1");
|
||||
b.setUtilisateur(m);
|
||||
b.setOrganisation(o);
|
||||
b.setDateDemande(sameDate);
|
||||
assertThat(a).isEqualTo(b);
|
||||
assertThat(a.hashCode()).isEqualTo(b.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toString non null")
|
||||
void toString_nonNull() {
|
||||
DemandeAdhesion d = new DemandeAdhesion();
|
||||
d.setNumeroReference("x");
|
||||
d.setUtilisateur(newMembre());
|
||||
d.setOrganisation(newOrganisation());
|
||||
assertThat(d.toString()).isNotNull().isNotEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
package dev.lions.unionflow.server.entity;
|
||||
|
||||
import dev.lions.unionflow.server.api.enums.solidarite.StatutAide;
|
||||
import dev.lions.unionflow.server.api.enums.solidarite.TypeAide;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("DemandeAide")
|
||||
class DemandeAideTest {
|
||||
|
||||
private static Membre newMembre() {
|
||||
Membre m = new Membre();
|
||||
m.setId(UUID.randomUUID());
|
||||
return m;
|
||||
}
|
||||
|
||||
private static Organisation newOrganisation() {
|
||||
Organisation o = new Organisation();
|
||||
o.setId(UUID.randomUUID());
|
||||
return o;
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("getters/setters")
|
||||
void gettersSetters() {
|
||||
DemandeAide d = new DemandeAide();
|
||||
d.setTitre("Aide médicale");
|
||||
d.setDescription("Description");
|
||||
d.setTypeAide(TypeAide.AIDE_FRAIS_MEDICAUX);
|
||||
d.setStatut(StatutAide.APPROUVEE);
|
||||
d.setMontantDemande(new BigDecimal("100000"));
|
||||
d.setMontantApprouve(new BigDecimal("80000"));
|
||||
d.setDateDemande(LocalDateTime.now());
|
||||
d.setDemandeur(newMembre());
|
||||
d.setOrganisation(newOrganisation());
|
||||
d.setJustification("Justif");
|
||||
d.setUrgence(true);
|
||||
|
||||
assertThat(d.getTitre()).isEqualTo("Aide médicale");
|
||||
assertThat(d.getDescription()).isEqualTo("Description");
|
||||
assertThat(d.getTypeAide()).isEqualTo(TypeAide.AIDE_FRAIS_MEDICAUX);
|
||||
assertThat(d.getStatut()).isEqualTo(StatutAide.APPROUVEE);
|
||||
assertThat(d.getMontantDemande()).isEqualByComparingTo("100000");
|
||||
assertThat(d.getMontantApprouve()).isEqualByComparingTo("80000");
|
||||
assertThat(d.getJustification()).isEqualTo("Justif");
|
||||
assertThat(d.getUrgence()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("isEnAttente, isApprouvee, isRejetee")
|
||||
void statutBooleans() {
|
||||
DemandeAide d = new DemandeAide();
|
||||
d.setDemandeur(newMembre());
|
||||
d.setOrganisation(newOrganisation());
|
||||
d.setTitre("T");
|
||||
d.setDescription("D");
|
||||
d.setTypeAide(TypeAide.AIDE_FRAIS_MEDICAUX);
|
||||
d.setStatut(StatutAide.EN_ATTENTE);
|
||||
assertThat(d.isEnAttente()).isTrue();
|
||||
assertThat(d.isApprouvee()).isFalse();
|
||||
d.setStatut(StatutAide.APPROUVEE);
|
||||
assertThat(d.isApprouvee()).isTrue();
|
||||
d.setStatut(StatutAide.REJETEE);
|
||||
assertThat(d.isRejetee()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("isUrgente")
|
||||
void isUrgente() {
|
||||
DemandeAide d = new DemandeAide();
|
||||
d.setUrgence(true);
|
||||
assertThat(d.isUrgente()).isTrue();
|
||||
d.setUrgence(false);
|
||||
assertThat(d.isUrgente()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("getPourcentageApprobation: ZERO si montantDemande null ou zéro")
|
||||
void getPourcentageApprobation_zeroSiDemandeNullOuZero() {
|
||||
DemandeAide d = new DemandeAide();
|
||||
assertThat(d.getPourcentageApprobation()).isEqualByComparingTo(BigDecimal.ZERO);
|
||||
d.setMontantDemande(BigDecimal.ZERO);
|
||||
d.setMontantApprouve(new BigDecimal("50"));
|
||||
assertThat(d.getPourcentageApprobation()).isEqualByComparingTo(BigDecimal.ZERO);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("getPourcentageApprobation: ZERO si montantApprouve null")
|
||||
void getPourcentageApprobation_zeroSiApprouveNull() {
|
||||
DemandeAide d = new DemandeAide();
|
||||
d.setMontantDemande(new BigDecimal("100"));
|
||||
assertThat(d.getPourcentageApprobation()).isEqualByComparingTo(BigDecimal.ZERO);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("getPourcentageApprobation: calcule le pourcentage")
|
||||
void getPourcentageApprobation_calcule() {
|
||||
DemandeAide d = new DemandeAide();
|
||||
d.setMontantDemande(new BigDecimal("100"));
|
||||
d.setMontantApprouve(new BigDecimal("50"));
|
||||
assertThat(d.getPourcentageApprobation()).isEqualByComparingTo("50.0000");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("equals et hashCode")
|
||||
void equalsHashCode() {
|
||||
UUID id = UUID.randomUUID();
|
||||
DemandeAide a = new DemandeAide();
|
||||
a.setId(id);
|
||||
a.setTitre("T");
|
||||
a.setDescription("D");
|
||||
a.setTypeAide(TypeAide.AIDE_FRAIS_MEDICAUX);
|
||||
a.setStatut(StatutAide.EN_ATTENTE);
|
||||
a.setDateDemande(LocalDateTime.now());
|
||||
a.setDemandeur(newMembre());
|
||||
a.setOrganisation(newOrganisation());
|
||||
DemandeAide b = new DemandeAide();
|
||||
b.setId(id);
|
||||
b.setTitre("T");
|
||||
b.setDescription("D");
|
||||
b.setTypeAide(TypeAide.AIDE_FRAIS_MEDICAUX);
|
||||
b.setStatut(StatutAide.EN_ATTENTE);
|
||||
b.setDateDemande(a.getDateDemande());
|
||||
b.setDemandeur(a.getDemandeur());
|
||||
b.setOrganisation(a.getOrganisation());
|
||||
assertThat(a).isEqualTo(b);
|
||||
assertThat(a.hashCode()).isEqualTo(b.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toString non null")
|
||||
void toString_nonNull() {
|
||||
DemandeAide d = new DemandeAide();
|
||||
d.setTitre("T");
|
||||
d.setDescription("D");
|
||||
d.setTypeAide(TypeAide.AIDE_FRAIS_MEDICAUX);
|
||||
d.setStatut(StatutAide.EN_ATTENTE);
|
||||
d.setDemandeur(newMembre());
|
||||
d.setOrganisation(newOrganisation());
|
||||
assertThat(d.toString()).isNotNull().isNotEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
package dev.lions.unionflow.server.entity;
|
||||
|
||||
import dev.lions.unionflow.server.api.enums.document.TypeDocument;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("Document")
|
||||
class DocumentTest {
|
||||
|
||||
@Test
|
||||
@DisplayName("getters/setters")
|
||||
void gettersSetters() {
|
||||
Document d = new Document();
|
||||
d.setNomFichier("doc.pdf");
|
||||
d.setNomOriginal("MonDoc.pdf");
|
||||
d.setCheminStockage("/storage/doc.pdf");
|
||||
d.setTypeMime("application/pdf");
|
||||
d.setTailleOctets(1024L);
|
||||
d.setTypeDocument(TypeDocument.FACTURE);
|
||||
d.setHashMd5("abc123");
|
||||
d.setHashSha256("def456");
|
||||
d.setDescription("Facture");
|
||||
d.setNombreTelechargements(5);
|
||||
d.setDateDernierTelechargement(LocalDateTime.now());
|
||||
|
||||
assertThat(d.getNomFichier()).isEqualTo("doc.pdf");
|
||||
assertThat(d.getNomOriginal()).isEqualTo("MonDoc.pdf");
|
||||
assertThat(d.getCheminStockage()).isEqualTo("/storage/doc.pdf");
|
||||
assertThat(d.getTypeMime()).isEqualTo("application/pdf");
|
||||
assertThat(d.getTailleOctets()).isEqualTo(1024L);
|
||||
assertThat(d.getTypeDocument()).isEqualTo(TypeDocument.FACTURE);
|
||||
assertThat(d.getHashMd5()).isEqualTo("abc123");
|
||||
assertThat(d.getHashSha256()).isEqualTo("def456");
|
||||
assertThat(d.getDescription()).isEqualTo("Facture");
|
||||
assertThat(d.getNombreTelechargements()).isEqualTo(5);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("verifierIntegriteMd5: true quand hash égal (insensible casse)")
|
||||
void verifierIntegriteMd5() {
|
||||
Document d = new Document();
|
||||
d.setHashMd5("ABC123");
|
||||
assertThat(d.verifierIntegriteMd5("abc123")).isTrue();
|
||||
assertThat(d.verifierIntegriteMd5("autre")).isFalse();
|
||||
d.setHashMd5(null);
|
||||
assertThat(d.verifierIntegriteMd5("x")).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("verifierIntegriteSha256")
|
||||
void verifierIntegriteSha256() {
|
||||
Document d = new Document();
|
||||
d.setHashSha256("DEF456");
|
||||
assertThat(d.verifierIntegriteSha256("def456")).isTrue();
|
||||
assertThat(d.verifierIntegriteSha256("autre")).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("getTailleFormatee: B, KB, MB")
|
||||
void getTailleFormatee() {
|
||||
Document d = new Document();
|
||||
d.setNomFichier("x");
|
||||
d.setCheminStockage("/x");
|
||||
d.setTailleOctets(500L);
|
||||
assertThat(d.getTailleFormatee()).isEqualTo("500 B");
|
||||
d.setTailleOctets(2048L);
|
||||
assertThat(d.getTailleFormatee()).contains("KB");
|
||||
d.setTailleOctets(1024L * 1024 * 2);
|
||||
assertThat(d.getTailleFormatee()).contains("MB");
|
||||
d.setTailleOctets(null);
|
||||
assertThat(d.getTailleFormatee()).isEqualTo("0 B");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("equals et hashCode")
|
||||
void equalsHashCode() {
|
||||
UUID id = UUID.randomUUID();
|
||||
Document a = new Document();
|
||||
a.setId(id);
|
||||
a.setNomFichier("a.pdf");
|
||||
a.setCheminStockage("/a");
|
||||
a.setTailleOctets(1L);
|
||||
Document b = new Document();
|
||||
b.setId(id);
|
||||
b.setNomFichier("a.pdf");
|
||||
b.setCheminStockage("/a");
|
||||
b.setTailleOctets(1L);
|
||||
assertThat(a).isEqualTo(b);
|
||||
assertThat(a.hashCode()).isEqualTo(b.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toString non null")
|
||||
void toString_nonNull() {
|
||||
Document d = new Document();
|
||||
d.setNomFichier("x");
|
||||
d.setCheminStockage("/x");
|
||||
d.setTailleOctets(1L);
|
||||
assertThat(d.toString()).isNotNull().isNotEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
package dev.lions.unionflow.server.entity;
|
||||
|
||||
import dev.lions.unionflow.server.api.enums.comptabilite.TypeJournalComptable;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("EcritureComptable")
|
||||
class EcritureComptableTest {
|
||||
|
||||
private static JournalComptable newJournal() {
|
||||
JournalComptable j = new JournalComptable();
|
||||
j.setId(UUID.randomUUID());
|
||||
j.setCode("BQ");
|
||||
j.setLibelle("Banque");
|
||||
j.setTypeJournal(TypeJournalComptable.BANQUE);
|
||||
return j;
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("getters/setters")
|
||||
void gettersSetters() {
|
||||
EcritureComptable e = new EcritureComptable();
|
||||
e.setNumeroPiece("ECR-001");
|
||||
e.setDateEcriture(LocalDate.now());
|
||||
e.setLibelle("Virement");
|
||||
e.setReference("REF-1");
|
||||
e.setLettrage("L1");
|
||||
e.setPointe(true);
|
||||
e.setMontantDebit(new BigDecimal("100.00"));
|
||||
e.setMontantCredit(new BigDecimal("100.00"));
|
||||
e.setJournal(newJournal());
|
||||
|
||||
assertThat(e.getNumeroPiece()).isEqualTo("ECR-001");
|
||||
assertThat(e.getLibelle()).isEqualTo("Virement");
|
||||
assertThat(e.getMontantDebit()).isEqualByComparingTo("100.00");
|
||||
assertThat(e.getMontantCredit()).isEqualByComparingTo("100.00");
|
||||
assertThat(e.getPointe()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("isEquilibree: true si débit = crédit")
|
||||
void isEquilibree() {
|
||||
EcritureComptable e = new EcritureComptable();
|
||||
e.setJournal(newJournal());
|
||||
e.setNumeroPiece("X");
|
||||
e.setDateEcriture(LocalDate.now());
|
||||
e.setLibelle("L");
|
||||
e.setMontantDebit(new BigDecimal("50.00"));
|
||||
e.setMontantCredit(new BigDecimal("50.00"));
|
||||
assertThat(e.isEquilibree()).isTrue();
|
||||
e.setMontantCredit(new BigDecimal("60.00"));
|
||||
assertThat(e.isEquilibree()).isFalse();
|
||||
e.setMontantDebit(null);
|
||||
assertThat(e.isEquilibree()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("calculerTotaux: à partir des lignes")
|
||||
void calculerTotaux() {
|
||||
JournalComptable j = newJournal();
|
||||
EcritureComptable e = new EcritureComptable();
|
||||
e.setJournal(j);
|
||||
e.setNumeroPiece("X");
|
||||
e.setDateEcriture(LocalDate.now());
|
||||
e.setLibelle("L");
|
||||
e.setMontantDebit(BigDecimal.ZERO);
|
||||
e.setMontantCredit(BigDecimal.ZERO);
|
||||
LigneEcriture l1 = new LigneEcriture();
|
||||
l1.setMontantDebit(new BigDecimal("100"));
|
||||
l1.setMontantCredit(BigDecimal.ZERO);
|
||||
LigneEcriture l2 = new LigneEcriture();
|
||||
l2.setMontantDebit(BigDecimal.ZERO);
|
||||
l2.setMontantCredit(new BigDecimal("100"));
|
||||
e.getLignes().add(l1);
|
||||
e.getLignes().add(l2);
|
||||
e.calculerTotaux();
|
||||
assertThat(e.getMontantDebit()).isEqualByComparingTo("100");
|
||||
assertThat(e.getMontantCredit()).isEqualByComparingTo("100");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("genererNumeroPiece")
|
||||
void genererNumeroPiece() {
|
||||
String num = EcritureComptable.genererNumeroPiece("ECR", LocalDate.of(2025, 3, 15));
|
||||
assertThat(num).startsWith("ECR-20250315-");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("equals et hashCode")
|
||||
void equalsHashCode() {
|
||||
UUID id = UUID.randomUUID();
|
||||
JournalComptable j = newJournal();
|
||||
EcritureComptable a = new EcritureComptable();
|
||||
a.setId(id);
|
||||
a.setNumeroPiece("N1");
|
||||
a.setDateEcriture(LocalDate.now());
|
||||
a.setLibelle("L");
|
||||
a.setJournal(j);
|
||||
EcritureComptable b = new EcritureComptable();
|
||||
b.setId(id);
|
||||
b.setNumeroPiece("N1");
|
||||
b.setDateEcriture(a.getDateEcriture());
|
||||
b.setLibelle("L");
|
||||
b.setJournal(j);
|
||||
assertThat(a).isEqualTo(b);
|
||||
assertThat(a.hashCode()).isEqualTo(b.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toString non null")
|
||||
void toString_nonNull() {
|
||||
EcritureComptable e = new EcritureComptable();
|
||||
e.setNumeroPiece("X");
|
||||
e.setDateEcriture(LocalDate.now());
|
||||
e.setLibelle("L");
|
||||
e.setJournal(newJournal());
|
||||
assertThat(e.toString()).isNotNull().isNotEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,243 @@
|
||||
package dev.lions.unionflow.server.entity;
|
||||
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("Evenement")
|
||||
class EvenementTest {
|
||||
|
||||
@Test
|
||||
@DisplayName("getters/setters")
|
||||
void gettersSetters() {
|
||||
Evenement e = new Evenement();
|
||||
e.setTitre("AG 2025");
|
||||
e.setDescription("Assemblée générale");
|
||||
e.setDateDebut(LocalDateTime.now().plusDays(1));
|
||||
e.setDateFin(LocalDateTime.now().plusDays(1).plusHours(2));
|
||||
e.setLieu("Salle A");
|
||||
e.setTypeEvenement("ASSEMBLEE_GENERALE");
|
||||
e.setStatut("PLANIFIE");
|
||||
e.setCapaciteMax(100);
|
||||
e.setPrix(new BigDecimal("0"));
|
||||
e.setInscriptionRequise(true);
|
||||
e.setVisiblePublic(true);
|
||||
|
||||
assertThat(e.getTitre()).isEqualTo("AG 2025");
|
||||
assertThat(e.getDescription()).isEqualTo("Assemblée générale");
|
||||
assertThat(e.getLieu()).isEqualTo("Salle A");
|
||||
assertThat(e.getStatut()).isEqualTo("PLANIFIE");
|
||||
assertThat(e.getCapaciteMax()).isEqualTo(100);
|
||||
assertThat(e.getInscriptionRequise()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("getNombreInscrits: 0 quand pas d'inscriptions")
|
||||
void getNombreInscrits() {
|
||||
Evenement e = new Evenement();
|
||||
e.setTitre("Ev");
|
||||
e.setDateDebut(LocalDateTime.now());
|
||||
assertThat(e.getNombreInscrits()).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("isComplet: true si capaciteMax atteinte")
|
||||
void isComplet() {
|
||||
Evenement e = new Evenement();
|
||||
e.setTitre("Ev");
|
||||
e.setDateDebut(LocalDateTime.now());
|
||||
e.setCapaciteMax(2);
|
||||
InscriptionEvenement i1 = new InscriptionEvenement();
|
||||
i1.setStatut(InscriptionEvenement.StatutInscription.CONFIRMEE.name());
|
||||
i1.setMembre(new Membre());
|
||||
InscriptionEvenement i2 = new InscriptionEvenement();
|
||||
i2.setStatut(InscriptionEvenement.StatutInscription.CONFIRMEE.name());
|
||||
i2.setMembre(new Membre());
|
||||
e.getInscriptions().add(i1);
|
||||
e.getInscriptions().add(i2);
|
||||
assertThat(e.isComplet()).isTrue();
|
||||
e.getInscriptions().remove(1);
|
||||
assertThat(e.isComplet()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("getDureeEnHeures")
|
||||
void getDureeEnHeures() {
|
||||
LocalDateTime debut = LocalDateTime.of(2025, 6, 1, 10, 0);
|
||||
LocalDateTime fin = LocalDateTime.of(2025, 6, 1, 12, 0);
|
||||
Evenement e = new Evenement();
|
||||
e.setTitre("Ev");
|
||||
e.setDateDebut(debut);
|
||||
e.setDateFin(fin);
|
||||
assertThat(e.getDureeEnHeures()).isEqualTo(2L);
|
||||
e.setDateFin(null);
|
||||
assertThat(e.getDureeEnHeures()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("getPlacesRestantes")
|
||||
void getPlacesRestantes() {
|
||||
Evenement e = new Evenement();
|
||||
e.setTitre("Ev");
|
||||
e.setDateDebut(LocalDateTime.now());
|
||||
e.setCapaciteMax(10);
|
||||
assertThat(e.getPlacesRestantes()).isEqualTo(10);
|
||||
e.setCapaciteMax(null);
|
||||
assertThat(e.getPlacesRestantes()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("isTermine: true si statut TERMINE")
|
||||
void isTermine_true_statutTermine() {
|
||||
Evenement e = new Evenement();
|
||||
e.setTitre("Ev");
|
||||
e.setDateDebut(LocalDateTime.now().minusDays(2));
|
||||
e.setDateFin(LocalDateTime.now().minusDays(1));
|
||||
e.setStatut("TERMINE");
|
||||
assertThat(e.isTermine()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("isTermine: false si statut PLANIFIE et dateFin null")
|
||||
void isTermine_false() {
|
||||
Evenement e = new Evenement();
|
||||
e.setTitre("Ev");
|
||||
e.setDateDebut(LocalDateTime.now().plusDays(1));
|
||||
e.setDateFin(null);
|
||||
e.setStatut("PLANIFIE");
|
||||
assertThat(e.isTermine()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("getTauxRemplissage")
|
||||
void getTauxRemplissage() {
|
||||
Evenement e = new Evenement();
|
||||
e.setTitre("Ev");
|
||||
e.setDateDebut(LocalDateTime.now());
|
||||
e.setCapaciteMax(10);
|
||||
assertThat(e.getTauxRemplissage()).isEqualTo(0.0);
|
||||
e.setCapaciteMax(0);
|
||||
assertThat(e.getTauxRemplissage()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("TypeEvenement enum values and getLibelle")
|
||||
void typeEvenementEnum() {
|
||||
assertThat(Evenement.TypeEvenement.ASSEMBLEE_GENERALE.getLibelle()).isEqualTo("Assemblée Générale");
|
||||
assertThat(Evenement.TypeEvenement.REUNION.getLibelle()).isEqualTo("Réunion");
|
||||
assertThat(Evenement.TypeEvenement.FORMATION.getLibelle()).isEqualTo("Formation");
|
||||
assertThat(Evenement.TypeEvenement.CONFERENCE.getLibelle()).isEqualTo("Conférence");
|
||||
assertThat(Evenement.TypeEvenement.ATELIER.getLibelle()).isEqualTo("Atelier");
|
||||
assertThat(Evenement.TypeEvenement.SEMINAIRE.getLibelle()).isEqualTo("Séminaire");
|
||||
assertThat(Evenement.TypeEvenement.EVENEMENT_SOCIAL.getLibelle()).isEqualTo("Événement Social");
|
||||
assertThat(Evenement.TypeEvenement.MANIFESTATION.getLibelle()).isEqualTo("Manifestation");
|
||||
assertThat(Evenement.TypeEvenement.CELEBRATION.getLibelle()).isEqualTo("Célébration");
|
||||
assertThat(Evenement.TypeEvenement.AUTRE.getLibelle()).isEqualTo("Autre");
|
||||
assertThat(Evenement.TypeEvenement.values()).hasSize(10);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("StatutEvenement enum values and getLibelle")
|
||||
void statutEvenementEnum() {
|
||||
assertThat(Evenement.StatutEvenement.PLANIFIE.getLibelle()).isEqualTo("Planifié");
|
||||
assertThat(Evenement.StatutEvenement.CONFIRME.getLibelle()).isEqualTo("Confirmé");
|
||||
assertThat(Evenement.StatutEvenement.EN_COURS.getLibelle()).isEqualTo("En cours");
|
||||
assertThat(Evenement.StatutEvenement.TERMINE.getLibelle()).isEqualTo("Terminé");
|
||||
assertThat(Evenement.StatutEvenement.ANNULE.getLibelle()).isEqualTo("Annulé");
|
||||
assertThat(Evenement.StatutEvenement.REPORTE.getLibelle()).isEqualTo("Reporté");
|
||||
assertThat(Evenement.StatutEvenement.values()).hasSize(6);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("equals et hashCode")
|
||||
void equalsHashCode() {
|
||||
UUID id = UUID.randomUUID();
|
||||
LocalDateTime dt = LocalDateTime.now();
|
||||
Evenement a = new Evenement();
|
||||
a.setId(id);
|
||||
a.setTitre("Ev");
|
||||
a.setDateDebut(dt);
|
||||
a.setStatut("PLANIFIE");
|
||||
Evenement b = new Evenement();
|
||||
b.setId(id);
|
||||
b.setTitre("Ev");
|
||||
b.setDateDebut(dt);
|
||||
b.setStatut("PLANIFIE");
|
||||
assertThat(a).isEqualTo(b);
|
||||
assertThat(a.hashCode()).isEqualTo(b.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toString non null")
|
||||
void toString_nonNull() {
|
||||
Evenement e = new Evenement();
|
||||
e.setTitre("Ev");
|
||||
e.setDateDebut(LocalDateTime.now());
|
||||
assertThat(e.toString()).isNotNull().isNotEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("isOuvertAuxInscriptions: false si inscription non requise")
|
||||
void isOuvertAuxInscriptions_false_sansInscription() {
|
||||
Evenement e = new Evenement();
|
||||
e.setTitre("Ev");
|
||||
e.setDateDebut(LocalDateTime.now().plusDays(1));
|
||||
e.setInscriptionRequise(false);
|
||||
e.setStatut("PLANIFIE");
|
||||
e.setActif(true);
|
||||
assertThat(e.isOuvertAuxInscriptions()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("isOuvertAuxInscriptions: true si ouvert")
|
||||
void isOuvertAuxInscriptions_true() {
|
||||
Evenement e = new Evenement();
|
||||
e.setTitre("Ev");
|
||||
e.setDateDebut(LocalDateTime.now().plusDays(1));
|
||||
e.setDateLimiteInscription(LocalDateTime.now().plusDays(1));
|
||||
e.setInscriptionRequise(true);
|
||||
e.setStatut("PLANIFIE");
|
||||
e.setActif(true);
|
||||
assertThat(e.isOuvertAuxInscriptions()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("isEnCours: true si entre dateDebut et dateFin")
|
||||
void isEnCours_true() {
|
||||
Evenement e = new Evenement();
|
||||
e.setTitre("Ev");
|
||||
e.setDateDebut(LocalDateTime.now().minusHours(1));
|
||||
e.setDateFin(LocalDateTime.now().plusHours(1));
|
||||
assertThat(e.isEnCours()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("isMemberInscrit: true si membre confirmé")
|
||||
void isMemberInscrit_true() {
|
||||
UUID membreId = UUID.randomUUID();
|
||||
Membre m = new Membre();
|
||||
m.setId(membreId);
|
||||
InscriptionEvenement i = new InscriptionEvenement();
|
||||
i.setMembre(m);
|
||||
i.setStatut(InscriptionEvenement.StatutInscription.CONFIRMEE.name());
|
||||
Evenement e = new Evenement();
|
||||
e.setTitre("Ev");
|
||||
e.setDateDebut(LocalDateTime.now());
|
||||
e.getInscriptions().add(i);
|
||||
assertThat(e.isMemberInscrit(membreId)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("isMemberInscrit: false si pas d'inscriptions")
|
||||
void isMemberInscrit_false() {
|
||||
Evenement e = new Evenement();
|
||||
e.setTitre("Ev");
|
||||
e.setDateDebut(LocalDateTime.now());
|
||||
assertThat(e.isMemberInscrit(UUID.randomUUID())).isFalse();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package dev.lions.unionflow.server.entity;
|
||||
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("Favori")
|
||||
class FavoriTest {
|
||||
|
||||
@Test
|
||||
@DisplayName("getters/setters")
|
||||
void gettersSetters() {
|
||||
UUID userId = UUID.randomUUID();
|
||||
Favori f = new Favori();
|
||||
f.setUtilisateurId(userId);
|
||||
f.setTypeFavori("PAGE");
|
||||
f.setTitre("Tableau de bord");
|
||||
f.setDescription("Accès rapide");
|
||||
f.setUrl("/dashboard");
|
||||
f.setIcon("home");
|
||||
f.setCouleur("blue");
|
||||
f.setCategorie("Navigation");
|
||||
f.setOrdre(1);
|
||||
f.setNbVisites(10);
|
||||
f.setDerniereVisite(LocalDateTime.now());
|
||||
f.setEstPlusUtilise(false);
|
||||
|
||||
assertThat(f.getUtilisateurId()).isEqualTo(userId);
|
||||
assertThat(f.getTypeFavori()).isEqualTo("PAGE");
|
||||
assertThat(f.getTitre()).isEqualTo("Tableau de bord");
|
||||
assertThat(f.getUrl()).isEqualTo("/dashboard");
|
||||
assertThat(f.getOrdre()).isEqualTo(1);
|
||||
assertThat(f.getNbVisites()).isEqualTo(10);
|
||||
assertThat(f.getEstPlusUtilise()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("ordre et nbVisites par défaut 0")
|
||||
void defauts() {
|
||||
Favori f = new Favori();
|
||||
f.setUtilisateurId(UUID.randomUUID());
|
||||
f.setTypeFavori("PAGE");
|
||||
f.setTitre("X");
|
||||
assertThat(f.getOrdre()).isEqualTo(0);
|
||||
assertThat(f.getNbVisites()).isEqualTo(0);
|
||||
assertThat(f.getEstPlusUtilise()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("equals et hashCode")
|
||||
void equalsHashCode() {
|
||||
UUID id = UUID.randomUUID();
|
||||
UUID userId = UUID.randomUUID();
|
||||
Favori a = new Favori();
|
||||
a.setId(id);
|
||||
a.setUtilisateurId(userId);
|
||||
a.setTypeFavori("PAGE");
|
||||
a.setTitre("T");
|
||||
Favori b = new Favori();
|
||||
b.setId(id);
|
||||
b.setUtilisateurId(userId);
|
||||
b.setTypeFavori("PAGE");
|
||||
b.setTitre("T");
|
||||
assertThat(a).isEqualTo(b);
|
||||
assertThat(a.hashCode()).isEqualTo(b.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toString non null")
|
||||
void toString_nonNull() {
|
||||
Favori f = new Favori();
|
||||
f.setUtilisateurId(UUID.randomUUID());
|
||||
f.setTypeFavori("PAGE");
|
||||
f.setTitre("X");
|
||||
assertThat(f.toString()).isNotNull().isNotEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package dev.lions.unionflow.server.entity;
|
||||
|
||||
import dev.lions.unionflow.server.api.enums.abonnement.TypeFormule;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("FormuleAbonnement")
|
||||
class FormuleAbonnementTest {
|
||||
|
||||
@Test
|
||||
@DisplayName("getters/setters")
|
||||
void gettersSetters() {
|
||||
FormuleAbonnement f = new FormuleAbonnement();
|
||||
f.setCode(TypeFormule.STARTER);
|
||||
f.setLibelle("Starter");
|
||||
f.setDescription("Pour petites structures");
|
||||
f.setMaxMembres(50);
|
||||
f.setMaxStockageMo(1024);
|
||||
f.setPrixMensuel(new BigDecimal("5000.00"));
|
||||
f.setPrixAnnuel(new BigDecimal("50000.00"));
|
||||
f.setOrdreAffichage(1);
|
||||
|
||||
assertThat(f.getCode()).isEqualTo(TypeFormule.STARTER);
|
||||
assertThat(f.getLibelle()).isEqualTo("Starter");
|
||||
assertThat(f.getMaxMembres()).isEqualTo(50);
|
||||
assertThat(f.getMaxStockageMo()).isEqualTo(1024);
|
||||
assertThat(f.getPrixMensuel()).isEqualByComparingTo("5000.00");
|
||||
assertThat(f.getPrixAnnuel()).isEqualByComparingTo("50000.00");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("isIllimitee: true si maxMembres null")
|
||||
void isIllimitee() {
|
||||
FormuleAbonnement f = new FormuleAbonnement();
|
||||
f.setCode(TypeFormule.CRYSTAL);
|
||||
f.setLibelle("Crystal");
|
||||
f.setPrixMensuel(BigDecimal.ZERO);
|
||||
f.setPrixAnnuel(BigDecimal.ZERO);
|
||||
f.setMaxMembres(null);
|
||||
assertThat(f.isIllimitee()).isTrue();
|
||||
f.setMaxMembres(500);
|
||||
assertThat(f.isIllimitee()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("accepteNouveauMembre")
|
||||
void accepteNouveauMembre() {
|
||||
FormuleAbonnement f = new FormuleAbonnement();
|
||||
f.setCode(TypeFormule.STARTER);
|
||||
f.setLibelle("S");
|
||||
f.setPrixMensuel(BigDecimal.ONE);
|
||||
f.setPrixAnnuel(BigDecimal.TEN);
|
||||
f.setMaxMembres(50);
|
||||
assertThat(f.accepteNouveauMembre(49)).isTrue();
|
||||
assertThat(f.accepteNouveauMembre(50)).isFalse();
|
||||
f.setMaxMembres(null);
|
||||
assertThat(f.accepteNouveauMembre(1000)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("equals et hashCode")
|
||||
void equalsHashCode() {
|
||||
UUID id = UUID.randomUUID();
|
||||
FormuleAbonnement a = new FormuleAbonnement();
|
||||
a.setId(id);
|
||||
a.setCode(TypeFormule.STARTER);
|
||||
a.setLibelle("S");
|
||||
a.setPrixMensuel(BigDecimal.ONE);
|
||||
a.setPrixAnnuel(BigDecimal.TEN);
|
||||
FormuleAbonnement b = new FormuleAbonnement();
|
||||
b.setId(id);
|
||||
b.setCode(TypeFormule.STARTER);
|
||||
b.setLibelle("S");
|
||||
b.setPrixMensuel(BigDecimal.ONE);
|
||||
b.setPrixAnnuel(BigDecimal.TEN);
|
||||
assertThat(a).isEqualTo(b);
|
||||
assertThat(a.hashCode()).isEqualTo(b.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toString non null")
|
||||
void toString_nonNull() {
|
||||
FormuleAbonnement f = new FormuleAbonnement();
|
||||
f.setCode(TypeFormule.STARTER);
|
||||
f.setLibelle("S");
|
||||
f.setPrixMensuel(BigDecimal.ONE);
|
||||
f.setPrixAnnuel(BigDecimal.TEN);
|
||||
assertThat(f.toString()).isNotNull().isNotEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
package dev.lions.unionflow.server.entity;
|
||||
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("InscriptionEvenement")
|
||||
class InscriptionEvenementTest {
|
||||
|
||||
private static Membre newMembre() {
|
||||
Membre m = new Membre();
|
||||
m.setId(UUID.randomUUID());
|
||||
return m;
|
||||
}
|
||||
|
||||
private static Evenement newEvenement() {
|
||||
Evenement e = new Evenement();
|
||||
e.setId(UUID.randomUUID());
|
||||
e.setTitre("Ev");
|
||||
e.setDateDebut(LocalDateTime.now());
|
||||
return e;
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("getters/setters")
|
||||
void gettersSetters() {
|
||||
InscriptionEvenement i = new InscriptionEvenement();
|
||||
i.setMembre(newMembre());
|
||||
i.setEvenement(newEvenement());
|
||||
i.setDateInscription(LocalDateTime.now());
|
||||
i.setStatut(InscriptionEvenement.StatutInscription.CONFIRMEE.name());
|
||||
i.setCommentaire("OK");
|
||||
|
||||
assertThat(i.getStatut()).isEqualTo("CONFIRMEE");
|
||||
assertThat(i.getCommentaire()).isEqualTo("OK");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("isConfirmee, isEnAttente, isAnnulee")
|
||||
void statutBooleans() {
|
||||
InscriptionEvenement i = new InscriptionEvenement();
|
||||
i.setMembre(newMembre());
|
||||
i.setEvenement(newEvenement());
|
||||
i.setStatut(InscriptionEvenement.StatutInscription.CONFIRMEE.name());
|
||||
assertThat(i.isConfirmee()).isTrue();
|
||||
assertThat(i.isEnAttente()).isFalse();
|
||||
i.setStatut(InscriptionEvenement.StatutInscription.EN_ATTENTE.name());
|
||||
assertThat(i.isEnAttente()).isTrue();
|
||||
i.setStatut(InscriptionEvenement.StatutInscription.ANNULEE.name());
|
||||
assertThat(i.isAnnulee()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("confirmer, annuler, mettreEnAttente, refuser")
|
||||
void actionsStatut() {
|
||||
InscriptionEvenement i = new InscriptionEvenement();
|
||||
i.setMembre(newMembre());
|
||||
i.setEvenement(newEvenement());
|
||||
i.setStatut(InscriptionEvenement.StatutInscription.EN_ATTENTE.name());
|
||||
i.confirmer();
|
||||
assertThat(i.getStatut()).isEqualTo("CONFIRMEE");
|
||||
i.annuler("Annulé");
|
||||
assertThat(i.getStatut()).isEqualTo("ANNULEE");
|
||||
assertThat(i.getCommentaire()).isEqualTo("Annulé");
|
||||
i.mettreEnAttente("En attente");
|
||||
assertThat(i.getStatut()).isEqualTo("EN_ATTENTE");
|
||||
i.refuser("Refusé");
|
||||
assertThat(i.getStatut()).isEqualTo("REFUSEE");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("statut par défaut CONFIRMEE")
|
||||
void statutDefaut() {
|
||||
InscriptionEvenement i = new InscriptionEvenement();
|
||||
i.setMembre(newMembre());
|
||||
i.setEvenement(newEvenement());
|
||||
assertThat(i.getStatut()).isEqualTo("CONFIRMEE");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("statut enum StatutInscription")
|
||||
void statutInscriptionEnum() {
|
||||
assertThat(InscriptionEvenement.StatutInscription.CONFIRMEE.name()).isEqualTo("CONFIRMEE");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("equals et hashCode")
|
||||
void equalsHashCode() {
|
||||
UUID id = UUID.randomUUID();
|
||||
Membre m = newMembre();
|
||||
Evenement e = newEvenement();
|
||||
LocalDateTime dt = LocalDateTime.now();
|
||||
InscriptionEvenement a = new InscriptionEvenement();
|
||||
a.setId(id);
|
||||
a.setMembre(m);
|
||||
a.setEvenement(e);
|
||||
a.setDateInscription(dt);
|
||||
a.setStatut("CONFIRMEE");
|
||||
InscriptionEvenement b = new InscriptionEvenement();
|
||||
b.setId(id);
|
||||
b.setMembre(m);
|
||||
b.setEvenement(e);
|
||||
b.setDateInscription(dt);
|
||||
b.setStatut("CONFIRMEE");
|
||||
assertThat(a).isEqualTo(b);
|
||||
assertThat(a.hashCode()).isEqualTo(b.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toString non null")
|
||||
void toString_nonNull() {
|
||||
InscriptionEvenement i = new InscriptionEvenement();
|
||||
i.setMembre(newMembre());
|
||||
i.setEvenement(newEvenement());
|
||||
assertThat(i.toString()).isNotNull().isNotEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
package dev.lions.unionflow.server.entity;
|
||||
|
||||
import dev.lions.unionflow.server.api.enums.paiement.StatutIntentionPaiement;
|
||||
import dev.lions.unionflow.server.api.enums.paiement.TypeObjetIntentionPaiement;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("IntentionPaiement")
|
||||
class IntentionPaiementTest {
|
||||
|
||||
private static Membre newMembre() {
|
||||
Membre m = new Membre();
|
||||
m.setId(UUID.randomUUID());
|
||||
return m;
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("getters/setters")
|
||||
void gettersSetters() {
|
||||
IntentionPaiement i = new IntentionPaiement();
|
||||
i.setUtilisateur(newMembre());
|
||||
i.setMontantTotal(new BigDecimal("5000.00"));
|
||||
i.setCodeDevise("XOF");
|
||||
i.setTypeObjet(TypeObjetIntentionPaiement.COTISATION);
|
||||
i.setStatut(StatutIntentionPaiement.INITIEE);
|
||||
i.setWaveCheckoutSessionId("sess-1");
|
||||
i.setWaveLaunchUrl("https://wave.com/pay");
|
||||
i.setObjetsCibles("[{\"type\":\"COTISATION\"}]");
|
||||
i.setDateExpiration(LocalDateTime.now().plusMinutes(30));
|
||||
|
||||
assertThat(i.getMontantTotal()).isEqualByComparingTo("5000.00");
|
||||
assertThat(i.getCodeDevise()).isEqualTo("XOF");
|
||||
assertThat(i.getTypeObjet()).isEqualTo(TypeObjetIntentionPaiement.COTISATION);
|
||||
assertThat(i.getStatut()).isEqualTo(StatutIntentionPaiement.INITIEE);
|
||||
assertThat(i.getWaveCheckoutSessionId()).isEqualTo("sess-1");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("statut et codeDevise par défaut")
|
||||
void defauts() {
|
||||
IntentionPaiement i = new IntentionPaiement();
|
||||
i.setUtilisateur(newMembre());
|
||||
i.setMontantTotal(BigDecimal.ONE);
|
||||
i.setTypeObjet(TypeObjetIntentionPaiement.COTISATION);
|
||||
assertThat(i.getStatut()).isEqualTo(StatutIntentionPaiement.INITIEE);
|
||||
assertThat(i.getCodeDevise()).isEqualTo("XOF");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("isActive: true si INITIEE ou EN_COURS")
|
||||
void isActive() {
|
||||
IntentionPaiement i = new IntentionPaiement();
|
||||
i.setUtilisateur(newMembre());
|
||||
i.setMontantTotal(BigDecimal.ONE);
|
||||
i.setTypeObjet(TypeObjetIntentionPaiement.COTISATION);
|
||||
i.setStatut(StatutIntentionPaiement.INITIEE);
|
||||
assertThat(i.isActive()).isTrue();
|
||||
i.setStatut(StatutIntentionPaiement.EN_COURS);
|
||||
assertThat(i.isActive()).isTrue();
|
||||
i.setStatut(StatutIntentionPaiement.COMPLETEE);
|
||||
assertThat(i.isActive()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("isExpiree: true si dateExpiration dans le passé")
|
||||
void isExpiree() {
|
||||
IntentionPaiement i = new IntentionPaiement();
|
||||
i.setUtilisateur(newMembre());
|
||||
i.setMontantTotal(BigDecimal.ONE);
|
||||
i.setTypeObjet(TypeObjetIntentionPaiement.COTISATION);
|
||||
i.setDateExpiration(LocalDateTime.now().minusMinutes(1));
|
||||
assertThat(i.isExpiree()).isTrue();
|
||||
i.setDateExpiration(LocalDateTime.now().plusHours(1));
|
||||
assertThat(i.isExpiree()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("isCompletee")
|
||||
void isCompletee() {
|
||||
IntentionPaiement i = new IntentionPaiement();
|
||||
i.setUtilisateur(newMembre());
|
||||
i.setMontantTotal(BigDecimal.ONE);
|
||||
i.setTypeObjet(TypeObjetIntentionPaiement.COTISATION);
|
||||
i.setStatut(StatutIntentionPaiement.COMPLETEE);
|
||||
assertThat(i.isCompletee()).isTrue();
|
||||
i.setStatut(StatutIntentionPaiement.INITIEE);
|
||||
assertThat(i.isCompletee()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("equals et hashCode")
|
||||
void equalsHashCode() {
|
||||
UUID id = UUID.randomUUID();
|
||||
Membre m = newMembre();
|
||||
IntentionPaiement a = new IntentionPaiement();
|
||||
a.setId(id);
|
||||
a.setUtilisateur(m);
|
||||
a.setMontantTotal(new BigDecimal("100"));
|
||||
a.setTypeObjet(TypeObjetIntentionPaiement.COTISATION);
|
||||
IntentionPaiement b = new IntentionPaiement();
|
||||
b.setId(id);
|
||||
b.setUtilisateur(m);
|
||||
b.setMontantTotal(new BigDecimal("100"));
|
||||
b.setTypeObjet(TypeObjetIntentionPaiement.COTISATION);
|
||||
assertThat(a).isEqualTo(b);
|
||||
assertThat(a.hashCode()).isEqualTo(b.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toString non null")
|
||||
void toString_nonNull() {
|
||||
IntentionPaiement i = new IntentionPaiement();
|
||||
i.setUtilisateur(newMembre());
|
||||
i.setMontantTotal(BigDecimal.ONE);
|
||||
i.setTypeObjet(TypeObjetIntentionPaiement.COTISATION);
|
||||
assertThat(i.toString()).isNotNull().isNotEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package dev.lions.unionflow.server.entity;
|
||||
|
||||
import dev.lions.unionflow.server.api.enums.comptabilite.TypeJournalComptable;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("JournalComptable")
|
||||
class JournalComptableTest {
|
||||
|
||||
@Test
|
||||
@DisplayName("getters/setters")
|
||||
void gettersSetters() {
|
||||
JournalComptable j = new JournalComptable();
|
||||
j.setCode("BQ");
|
||||
j.setLibelle("Banque");
|
||||
j.setTypeJournal(TypeJournalComptable.BANQUE);
|
||||
j.setDateDebut(LocalDate.of(2025, 1, 1));
|
||||
j.setDateFin(LocalDate.of(2025, 12, 31));
|
||||
j.setStatut("OUVERT");
|
||||
j.setDescription("Journal banque");
|
||||
|
||||
assertThat(j.getCode()).isEqualTo("BQ");
|
||||
assertThat(j.getLibelle()).isEqualTo("Banque");
|
||||
assertThat(j.getTypeJournal()).isEqualTo(TypeJournalComptable.BANQUE);
|
||||
assertThat(j.getStatut()).isEqualTo("OUVERT");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("isOuvert")
|
||||
void isOuvert() {
|
||||
JournalComptable j = new JournalComptable();
|
||||
j.setCode("BQ");
|
||||
j.setLibelle("B");
|
||||
j.setTypeJournal(TypeJournalComptable.BANQUE);
|
||||
j.setStatut("OUVERT");
|
||||
assertThat(j.isOuvert()).isTrue();
|
||||
j.setStatut("FERME");
|
||||
assertThat(j.isOuvert()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("estDansPeriode")
|
||||
void estDansPeriode() {
|
||||
JournalComptable j = new JournalComptable();
|
||||
j.setCode("BQ");
|
||||
j.setLibelle("B");
|
||||
j.setTypeJournal(TypeJournalComptable.BANQUE);
|
||||
j.setDateDebut(LocalDate.of(2025, 1, 1));
|
||||
j.setDateFin(LocalDate.of(2025, 12, 31));
|
||||
assertThat(j.estDansPeriode(LocalDate.of(2025, 6, 15))).isTrue();
|
||||
assertThat(j.estDansPeriode(LocalDate.of(2024, 12, 31))).isFalse();
|
||||
assertThat(j.estDansPeriode(LocalDate.of(2026, 1, 1))).isFalse();
|
||||
j.setDateDebut(null);
|
||||
j.setDateFin(null);
|
||||
assertThat(j.estDansPeriode(LocalDate.now())).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("statut par défaut OUVERT")
|
||||
void statutDefaut() {
|
||||
JournalComptable j = new JournalComptable();
|
||||
j.setCode("BQ");
|
||||
j.setLibelle("B");
|
||||
j.setTypeJournal(TypeJournalComptable.BANQUE);
|
||||
assertThat(j.getStatut()).isEqualTo("OUVERT");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("equals et hashCode")
|
||||
void equalsHashCode() {
|
||||
UUID id = UUID.randomUUID();
|
||||
JournalComptable a = new JournalComptable();
|
||||
a.setId(id);
|
||||
a.setCode("BQ");
|
||||
a.setLibelle("Banque");
|
||||
a.setTypeJournal(TypeJournalComptable.BANQUE);
|
||||
JournalComptable b = new JournalComptable();
|
||||
b.setId(id);
|
||||
b.setCode("BQ");
|
||||
b.setLibelle("Banque");
|
||||
b.setTypeJournal(TypeJournalComptable.BANQUE);
|
||||
assertThat(a).isEqualTo(b);
|
||||
assertThat(a.hashCode()).isEqualTo(b.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toString non null")
|
||||
void toString_nonNull() {
|
||||
JournalComptable j = new JournalComptable();
|
||||
j.setCode("BQ");
|
||||
j.setLibelle("Banque");
|
||||
j.setTypeJournal(TypeJournalComptable.BANQUE);
|
||||
assertThat(j.toString()).isNotNull().isNotEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
package dev.lions.unionflow.server.entity;
|
||||
|
||||
import dev.lions.unionflow.server.api.enums.comptabilite.TypeCompteComptable;
|
||||
import dev.lions.unionflow.server.api.enums.comptabilite.TypeJournalComptable;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("LigneEcriture")
|
||||
class LigneEcritureTest {
|
||||
|
||||
private static EcritureComptable newEcriture() {
|
||||
JournalComptable j = new JournalComptable();
|
||||
j.setId(UUID.randomUUID());
|
||||
j.setCode("BQ");
|
||||
j.setLibelle("B");
|
||||
j.setTypeJournal(TypeJournalComptable.BANQUE);
|
||||
EcritureComptable e = new EcritureComptable();
|
||||
e.setId(UUID.randomUUID());
|
||||
e.setNumeroPiece("ECR-1");
|
||||
e.setDateEcriture(java.time.LocalDate.now());
|
||||
e.setLibelle("L");
|
||||
e.setJournal(j);
|
||||
return e;
|
||||
}
|
||||
|
||||
private static CompteComptable newCompte() {
|
||||
CompteComptable c = new CompteComptable();
|
||||
c.setId(UUID.randomUUID());
|
||||
c.setNumeroCompte("512000");
|
||||
c.setLibelle("Banque");
|
||||
c.setTypeCompte(TypeCompteComptable.TRESORERIE);
|
||||
c.setClasseComptable(5);
|
||||
return c;
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("getters/setters")
|
||||
void gettersSetters() {
|
||||
LigneEcriture l = new LigneEcriture();
|
||||
l.setNumeroLigne(1);
|
||||
l.setMontantDebit(new BigDecimal("100.00"));
|
||||
l.setMontantCredit(BigDecimal.ZERO);
|
||||
l.setLibelle("Ligne 1");
|
||||
l.setEcriture(newEcriture());
|
||||
l.setCompteComptable(newCompte());
|
||||
|
||||
assertThat(l.getNumeroLigne()).isEqualTo(1);
|
||||
assertThat(l.getMontantDebit()).isEqualByComparingTo("100.00");
|
||||
assertThat(l.getMontantCredit()).isEqualByComparingTo(BigDecimal.ZERO);
|
||||
assertThat(l.getLibelle()).isEqualTo("Ligne 1");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("isValide: true si débit XOR crédit")
|
||||
void isValide() {
|
||||
LigneEcriture l = new LigneEcriture();
|
||||
l.setEcriture(newEcriture());
|
||||
l.setCompteComptable(newCompte());
|
||||
l.setNumeroLigne(1);
|
||||
l.setMontantDebit(new BigDecimal("100"));
|
||||
l.setMontantCredit(BigDecimal.ZERO);
|
||||
assertThat(l.isValide()).isTrue();
|
||||
l.setMontantDebit(BigDecimal.ZERO);
|
||||
l.setMontantCredit(new BigDecimal("100"));
|
||||
assertThat(l.isValide()).isTrue();
|
||||
l.setMontantDebit(new BigDecimal("50"));
|
||||
l.setMontantCredit(new BigDecimal("50"));
|
||||
assertThat(l.isValide()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("getMontant: débit ou crédit")
|
||||
void getMontant() {
|
||||
LigneEcriture l = new LigneEcriture();
|
||||
l.setEcriture(newEcriture());
|
||||
l.setCompteComptable(newCompte());
|
||||
l.setNumeroLigne(1);
|
||||
l.setMontantDebit(new BigDecimal("100"));
|
||||
l.setMontantCredit(BigDecimal.ZERO);
|
||||
assertThat(l.getMontant()).isEqualByComparingTo("100");
|
||||
l.setMontantDebit(BigDecimal.ZERO);
|
||||
l.setMontantCredit(new BigDecimal("200"));
|
||||
assertThat(l.getMontant()).isEqualByComparingTo("200");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("equals et hashCode")
|
||||
void equalsHashCode() {
|
||||
UUID id = UUID.randomUUID();
|
||||
EcritureComptable e = newEcriture();
|
||||
CompteComptable c = newCompte();
|
||||
LigneEcriture a = new LigneEcriture();
|
||||
a.setId(id);
|
||||
a.setNumeroLigne(1);
|
||||
a.setEcriture(e);
|
||||
a.setCompteComptable(c);
|
||||
LigneEcriture b = new LigneEcriture();
|
||||
b.setId(id);
|
||||
b.setNumeroLigne(1);
|
||||
b.setEcriture(e);
|
||||
b.setCompteComptable(c);
|
||||
assertThat(a).isEqualTo(b);
|
||||
assertThat(a.hashCode()).isEqualTo(b.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toString non null")
|
||||
void toString_nonNull() {
|
||||
LigneEcriture l = new LigneEcriture();
|
||||
l.setNumeroLigne(1);
|
||||
l.setEcriture(newEcriture());
|
||||
l.setCompteComptable(newCompte());
|
||||
assertThat(l.toString()).isNotNull().isNotEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package dev.lions.unionflow.server.entity;
|
||||
|
||||
import dev.lions.unionflow.server.api.enums.membre.StatutMembre;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("MembreOrganisation")
|
||||
class MembreOrganisationTest {
|
||||
|
||||
private static Membre newMembre() {
|
||||
Membre m = new Membre();
|
||||
m.setId(UUID.randomUUID());
|
||||
m.setNumeroMembre("M1");
|
||||
m.setPrenom("A");
|
||||
m.setNom("B");
|
||||
m.setEmail("a@test.com");
|
||||
m.setDateNaissance(LocalDate.now());
|
||||
return m;
|
||||
}
|
||||
|
||||
private static Organisation newOrganisation() {
|
||||
Organisation o = new Organisation();
|
||||
o.setId(UUID.randomUUID());
|
||||
return o;
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("getters/setters")
|
||||
void gettersSetters() {
|
||||
MembreOrganisation mo = new MembreOrganisation();
|
||||
mo.setMembre(newMembre());
|
||||
mo.setOrganisation(newOrganisation());
|
||||
mo.setStatutMembre(StatutMembre.ACTIF);
|
||||
mo.setDateAdhesion(LocalDate.now());
|
||||
mo.setMotifStatut("Approuvé");
|
||||
|
||||
assertThat(mo.getStatutMembre()).isEqualTo(StatutMembre.ACTIF);
|
||||
assertThat(mo.getDateAdhesion()).isNotNull();
|
||||
assertThat(mo.getMotifStatut()).isEqualTo("Approuvé");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("isActif: true si ACTIF et actif true")
|
||||
void isActif() {
|
||||
MembreOrganisation mo = new MembreOrganisation();
|
||||
mo.setMembre(newMembre());
|
||||
mo.setOrganisation(newOrganisation());
|
||||
mo.setStatutMembre(StatutMembre.ACTIF);
|
||||
mo.setActif(true);
|
||||
assertThat(mo.isActif()).isTrue();
|
||||
mo.setStatutMembre(StatutMembre.EN_ATTENTE_VALIDATION);
|
||||
assertThat(mo.isActif()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("peutDemanderAide")
|
||||
void peutDemanderAide() {
|
||||
MembreOrganisation mo = new MembreOrganisation();
|
||||
mo.setMembre(newMembre());
|
||||
mo.setOrganisation(newOrganisation());
|
||||
mo.setStatutMembre(StatutMembre.ACTIF);
|
||||
assertThat(mo.peutDemanderAide()).isTrue();
|
||||
mo.setStatutMembre(StatutMembre.EN_ATTENTE_VALIDATION);
|
||||
assertThat(mo.peutDemanderAide()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("equals et hashCode")
|
||||
void equalsHashCode() {
|
||||
UUID id = UUID.randomUUID();
|
||||
Membre m = newMembre();
|
||||
Organisation o = newOrganisation();
|
||||
MembreOrganisation a = new MembreOrganisation();
|
||||
a.setId(id);
|
||||
a.setMembre(m);
|
||||
a.setOrganisation(o);
|
||||
a.setStatutMembre(StatutMembre.ACTIF);
|
||||
MembreOrganisation b = new MembreOrganisation();
|
||||
b.setId(id);
|
||||
b.setMembre(m);
|
||||
b.setOrganisation(o);
|
||||
b.setStatutMembre(StatutMembre.ACTIF);
|
||||
assertThat(a).isEqualTo(b);
|
||||
assertThat(a.hashCode()).isEqualTo(b.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toString non null")
|
||||
void toString_nonNull() {
|
||||
MembreOrganisation mo = new MembreOrganisation();
|
||||
mo.setMembre(newMembre());
|
||||
mo.setOrganisation(newOrganisation());
|
||||
assertThat(mo.toString()).isNotNull().isNotEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
package dev.lions.unionflow.server.entity;
|
||||
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("MembreRole")
|
||||
class MembreRoleTest {
|
||||
|
||||
private static MembreOrganisation newMembreOrganisation() {
|
||||
Membre m = new Membre();
|
||||
m.setId(UUID.randomUUID());
|
||||
m.setNumeroMembre("M1");
|
||||
m.setPrenom("A");
|
||||
m.setNom("B");
|
||||
m.setEmail("a@test.com");
|
||||
m.setDateNaissance(LocalDate.now());
|
||||
Organisation o = new Organisation();
|
||||
o.setId(UUID.randomUUID());
|
||||
MembreOrganisation mo = new MembreOrganisation();
|
||||
mo.setMembre(m);
|
||||
mo.setOrganisation(o);
|
||||
return mo;
|
||||
}
|
||||
|
||||
private static Role newRole() {
|
||||
Role r = new Role();
|
||||
r.setId(UUID.randomUUID());
|
||||
r.setCode("ADMIN");
|
||||
r.setLibelle("Administrateur");
|
||||
return r;
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("getters/setters")
|
||||
void gettersSetters() {
|
||||
MembreRole mr = new MembreRole();
|
||||
mr.setMembreOrganisation(newMembreOrganisation());
|
||||
mr.setOrganisation(new Organisation());
|
||||
mr.setRole(newRole());
|
||||
mr.setDateDebut(LocalDate.now());
|
||||
mr.setCommentaire("Attribution");
|
||||
|
||||
assertThat(mr.getDateDebut()).isNotNull();
|
||||
assertThat(mr.getCommentaire()).isEqualTo("Attribution");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("isActif: false si dateDebut dans le futur")
|
||||
void isActif_false_debutFutur() {
|
||||
MembreRole mr = new MembreRole();
|
||||
mr.setMembreOrganisation(newMembreOrganisation());
|
||||
mr.setRole(newRole());
|
||||
mr.setActif(true);
|
||||
mr.setDateDebut(LocalDate.now().plusDays(10));
|
||||
assertThat(mr.isActif()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("isActif: true si dans la période")
|
||||
void isActif_true() {
|
||||
MembreRole mr = new MembreRole();
|
||||
mr.setMembreOrganisation(newMembreOrganisation());
|
||||
mr.setRole(newRole());
|
||||
mr.setActif(true);
|
||||
mr.setDateDebut(LocalDate.now().minusDays(1));
|
||||
mr.setDateFin(null);
|
||||
assertThat(mr.isActif()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("equals et hashCode")
|
||||
void equalsHashCode() {
|
||||
UUID id = UUID.randomUUID();
|
||||
MembreOrganisation mo = newMembreOrganisation();
|
||||
Role r = newRole();
|
||||
MembreRole a = new MembreRole();
|
||||
a.setId(id);
|
||||
a.setMembreOrganisation(mo);
|
||||
a.setRole(r);
|
||||
MembreRole b = new MembreRole();
|
||||
b.setId(id);
|
||||
b.setMembreOrganisation(mo);
|
||||
b.setRole(r);
|
||||
assertThat(a).isEqualTo(b);
|
||||
assertThat(a.hashCode()).isEqualTo(b.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toString non null")
|
||||
void toString_nonNull() {
|
||||
MembreRole mr = new MembreRole();
|
||||
mr.setMembreOrganisation(newMembreOrganisation());
|
||||
mr.setRole(newRole());
|
||||
assertThat(mr.toString()).isNotNull().isNotEmpty();
|
||||
}
|
||||
}
|
||||
118
src/test/java/dev/lions/unionflow/server/entity/MembreTest.java
Normal file
118
src/test/java/dev/lions/unionflow/server/entity/MembreTest.java
Normal file
@@ -0,0 +1,118 @@
|
||||
package dev.lions.unionflow.server.entity;
|
||||
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("Membre")
|
||||
class MembreTest {
|
||||
|
||||
@Test
|
||||
@DisplayName("getters/setters")
|
||||
void gettersSetters() {
|
||||
Membre m = new Membre();
|
||||
m.setNumeroMembre("MEM-001");
|
||||
m.setPrenom("Jean");
|
||||
m.setNom("Dupont");
|
||||
m.setEmail("jean@test.com");
|
||||
m.setTelephone("+22507000001");
|
||||
m.setDateNaissance(LocalDate.of(1990, 5, 15));
|
||||
m.setStatutCompte("ACTIF");
|
||||
|
||||
assertThat(m.getNumeroMembre()).isEqualTo("MEM-001");
|
||||
assertThat(m.getPrenom()).isEqualTo("Jean");
|
||||
assertThat(m.getNom()).isEqualTo("Dupont");
|
||||
assertThat(m.getEmail()).isEqualTo("jean@test.com");
|
||||
assertThat(m.getDateNaissance()).isEqualTo(LocalDate.of(1990, 5, 15));
|
||||
assertThat(m.getStatutCompte()).isEqualTo("ACTIF");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("getNomComplet")
|
||||
void getNomComplet() {
|
||||
Membre m = new Membre();
|
||||
m.setNumeroMembre("X");
|
||||
m.setPrenom("Marie");
|
||||
m.setNom("Martin");
|
||||
m.setEmail("m@test.com");
|
||||
m.setDateNaissance(LocalDate.now());
|
||||
assertThat(m.getNomComplet()).isEqualTo("Marie Martin");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("isMajeur: true si 18+ ans")
|
||||
void isMajeur() {
|
||||
Membre m = new Membre();
|
||||
m.setNumeroMembre("X");
|
||||
m.setPrenom("A");
|
||||
m.setNom("B");
|
||||
m.setEmail("a@test.com");
|
||||
m.setDateNaissance(LocalDate.now().minusYears(25));
|
||||
assertThat(m.isMajeur()).isTrue();
|
||||
m.setDateNaissance(LocalDate.now().minusYears(10));
|
||||
assertThat(m.isMajeur()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("getAge")
|
||||
void getAge() {
|
||||
Membre m = new Membre();
|
||||
m.setNumeroMembre("X");
|
||||
m.setPrenom("A");
|
||||
m.setNom("B");
|
||||
m.setEmail("a@test.com");
|
||||
m.setDateNaissance(LocalDate.now().minusYears(30));
|
||||
assertThat(m.getAge()).isEqualTo(30);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("statutCompte par défaut")
|
||||
void statutDefaut() {
|
||||
Membre m = new Membre();
|
||||
m.setNumeroMembre("X");
|
||||
m.setPrenom("A");
|
||||
m.setNom("B");
|
||||
m.setEmail("a@test.com");
|
||||
m.setDateNaissance(LocalDate.now());
|
||||
m.setStatutCompte(null);
|
||||
assertThat(m.getStatutCompte()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("equals et hashCode")
|
||||
void equalsHashCode() {
|
||||
UUID id = UUID.randomUUID();
|
||||
Membre a = new Membre();
|
||||
a.setId(id);
|
||||
a.setNumeroMembre("N1");
|
||||
a.setPrenom("A");
|
||||
a.setNom("B");
|
||||
a.setEmail("a@test.com");
|
||||
a.setDateNaissance(LocalDate.now());
|
||||
Membre b = new Membre();
|
||||
b.setId(id);
|
||||
b.setNumeroMembre("N1");
|
||||
b.setPrenom("A");
|
||||
b.setNom("B");
|
||||
b.setEmail("a@test.com");
|
||||
b.setDateNaissance(a.getDateNaissance());
|
||||
assertThat(a).isEqualTo(b);
|
||||
assertThat(a.hashCode()).isEqualTo(b.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toString non null")
|
||||
void toString_nonNull() {
|
||||
Membre m = new Membre();
|
||||
m.setNumeroMembre("X");
|
||||
m.setPrenom("A");
|
||||
m.setNom("B");
|
||||
m.setEmail("a@test.com");
|
||||
m.setDateNaissance(LocalDate.now());
|
||||
assertThat(m.toString()).isNotNull().isNotEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package dev.lions.unionflow.server.entity;
|
||||
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("ModuleDisponible")
|
||||
class ModuleDisponibleTest {
|
||||
|
||||
@Test
|
||||
@DisplayName("getters/setters")
|
||||
void gettersSetters() {
|
||||
ModuleDisponible m = new ModuleDisponible();
|
||||
m.setCode("CREDIT_EPARGNE");
|
||||
m.setLibelle("Crédit et épargne");
|
||||
m.setDescription("Module mutuelle");
|
||||
m.setTypesOrgCompatibles("[\"MUTUELLE_SANTE\"]");
|
||||
m.setOrdreAffichage(1);
|
||||
|
||||
assertThat(m.getCode()).isEqualTo("CREDIT_EPARGNE");
|
||||
assertThat(m.getLibelle()).isEqualTo("Crédit et épargne");
|
||||
assertThat(m.getTypesOrgCompatibles()).contains("MUTUELLE_SANTE");
|
||||
assertThat(m.getOrdreAffichage()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("estCompatibleAvec: true si ALL")
|
||||
void estCompatibleAvec_all() {
|
||||
ModuleDisponible m = new ModuleDisponible();
|
||||
m.setCode("X");
|
||||
m.setLibelle("X");
|
||||
m.setTypesOrgCompatibles("[\"ALL\"]");
|
||||
assertThat(m.estCompatibleAvec("MUTUELLE_SANTE")).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("estCompatibleAvec: true si type contenu")
|
||||
void estCompatibleAvec_typeContenu() {
|
||||
ModuleDisponible m = new ModuleDisponible();
|
||||
m.setCode("X");
|
||||
m.setLibelle("X");
|
||||
m.setTypesOrgCompatibles("[\"MUTUELLE_SANTE\",\"ONG\"]");
|
||||
assertThat(m.estCompatibleAvec("MUTUELLE_SANTE")).isTrue();
|
||||
assertThat(m.estCompatibleAvec("AUTRE")).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("estCompatibleAvec: false si typesOrgCompatibles null")
|
||||
void estCompatibleAvec_null() {
|
||||
ModuleDisponible m = new ModuleDisponible();
|
||||
m.setCode("X");
|
||||
m.setLibelle("X");
|
||||
m.setTypesOrgCompatibles(null);
|
||||
assertThat(m.estCompatibleAvec("X")).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("equals et hashCode")
|
||||
void equalsHashCode() {
|
||||
UUID id = UUID.randomUUID();
|
||||
ModuleDisponible a = new ModuleDisponible();
|
||||
a.setId(id);
|
||||
a.setCode("C1");
|
||||
a.setLibelle("L1");
|
||||
ModuleDisponible b = new ModuleDisponible();
|
||||
b.setId(id);
|
||||
b.setCode("C1");
|
||||
b.setLibelle("L1");
|
||||
assertThat(a).isEqualTo(b);
|
||||
assertThat(a.hashCode()).isEqualTo(b.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toString non null")
|
||||
void toString_nonNull() {
|
||||
ModuleDisponible m = new ModuleDisponible();
|
||||
m.setCode("X");
|
||||
m.setLibelle("X");
|
||||
assertThat(m.toString()).isNotNull().isNotEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package dev.lions.unionflow.server.entity;
|
||||
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("ModuleOrganisationActif")
|
||||
class ModuleOrganisationActifTest {
|
||||
|
||||
private static Organisation newOrganisation() {
|
||||
Organisation o = new Organisation();
|
||||
o.setId(UUID.randomUUID());
|
||||
return o;
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("getters/setters")
|
||||
void gettersSetters() {
|
||||
ModuleOrganisationActif m = new ModuleOrganisationActif();
|
||||
m.setOrganisation(newOrganisation());
|
||||
m.setModuleCode("CREDIT_EPARGNE");
|
||||
m.setDateActivation(LocalDateTime.now());
|
||||
m.setParametres("{\"taux_max\":18}");
|
||||
|
||||
assertThat(m.getModuleCode()).isEqualTo("CREDIT_EPARGNE");
|
||||
assertThat(m.getDateActivation()).isNotNull();
|
||||
assertThat(m.getParametres()).contains("taux_max");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("dateActivation par défaut")
|
||||
void dateActivationDefaut() {
|
||||
ModuleOrganisationActif m = new ModuleOrganisationActif();
|
||||
m.setOrganisation(newOrganisation());
|
||||
m.setModuleCode("X");
|
||||
assertThat(m.getDateActivation()).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("equals et hashCode")
|
||||
void equalsHashCode() {
|
||||
UUID id = UUID.randomUUID();
|
||||
Organisation o = newOrganisation();
|
||||
LocalDateTime sameDate = LocalDateTime.of(2026, 1, 15, 10, 0);
|
||||
ModuleOrganisationActif a = new ModuleOrganisationActif();
|
||||
a.setId(id);
|
||||
a.setOrganisation(o);
|
||||
a.setModuleCode("M1");
|
||||
a.setDateActivation(sameDate);
|
||||
ModuleOrganisationActif b = new ModuleOrganisationActif();
|
||||
b.setId(id);
|
||||
b.setOrganisation(o);
|
||||
b.setModuleCode("M1");
|
||||
b.setDateActivation(sameDate);
|
||||
assertThat(a).isEqualTo(b);
|
||||
assertThat(a.hashCode()).isEqualTo(b.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toString non null")
|
||||
void toString_nonNull() {
|
||||
ModuleOrganisationActif m = new ModuleOrganisationActif();
|
||||
m.setOrganisation(newOrganisation());
|
||||
m.setModuleCode("X");
|
||||
assertThat(m.toString()).isNotNull().isNotEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package dev.lions.unionflow.server.entity;
|
||||
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("Notification")
|
||||
class NotificationTest {
|
||||
|
||||
@Test
|
||||
@DisplayName("getters/setters")
|
||||
void gettersSetters() {
|
||||
Notification n = new Notification();
|
||||
n.setTypeNotification("EMAIL");
|
||||
n.setPriorite("HAUTE");
|
||||
n.setStatut("EN_ATTENTE");
|
||||
n.setSujet("Sujet");
|
||||
n.setCorps("Corps du message");
|
||||
n.setDateEnvoiPrevue(LocalDateTime.now());
|
||||
n.setNombreTentatives(1);
|
||||
n.setDonneesAdditionnelles("{}");
|
||||
|
||||
assertThat(n.getTypeNotification()).isEqualTo("EMAIL");
|
||||
assertThat(n.getPriorite()).isEqualTo("HAUTE");
|
||||
assertThat(n.getStatut()).isEqualTo("EN_ATTENTE");
|
||||
assertThat(n.getSujet()).isEqualTo("Sujet");
|
||||
assertThat(n.getCorps()).isEqualTo("Corps du message");
|
||||
assertThat(n.getNombreTentatives()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("priorite et statut par défaut")
|
||||
void defauts() {
|
||||
Notification n = new Notification();
|
||||
n.setTypeNotification("EMAIL");
|
||||
assertThat(n.getPriorite()).isEqualTo("NORMALE");
|
||||
assertThat(n.getStatut()).isEqualTo("EN_ATTENTE");
|
||||
assertThat(n.getNombreTentatives()).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("isEnvoyee et isLue")
|
||||
void isEnvoyee_isLue() {
|
||||
Notification n = new Notification();
|
||||
n.setTypeNotification("EMAIL");
|
||||
n.setStatut("ENVOYEE");
|
||||
assertThat(n.isEnvoyee()).isTrue();
|
||||
n.setStatut("LUE");
|
||||
assertThat(n.isLue()).isTrue();
|
||||
n.setStatut("EN_ATTENTE");
|
||||
assertThat(n.isEnvoyee()).isFalse();
|
||||
assertThat(n.isLue()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("relations membre, organisation, template")
|
||||
void relations() {
|
||||
Notification n = new Notification();
|
||||
n.setTypeNotification("EMAIL");
|
||||
Membre m = new Membre();
|
||||
Organisation o = new Organisation();
|
||||
TemplateNotification t = new TemplateNotification();
|
||||
n.setMembre(m);
|
||||
n.setOrganisation(o);
|
||||
n.setTemplate(t);
|
||||
assertThat(n.getMembre()).isSameAs(m);
|
||||
assertThat(n.getOrganisation()).isSameAs(o);
|
||||
assertThat(n.getTemplate()).isSameAs(t);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("equals et hashCode")
|
||||
void equalsHashCode() {
|
||||
UUID id = UUID.randomUUID();
|
||||
Notification a = new Notification();
|
||||
a.setId(id);
|
||||
a.setTypeNotification("EMAIL");
|
||||
a.setStatut("EN_ATTENTE");
|
||||
Notification b = new Notification();
|
||||
b.setId(id);
|
||||
b.setTypeNotification("EMAIL");
|
||||
b.setStatut("EN_ATTENTE");
|
||||
assertThat(a).isEqualTo(b);
|
||||
assertThat(a.hashCode()).isEqualTo(b.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toString non null")
|
||||
void toString_nonNull() {
|
||||
Notification n = new Notification();
|
||||
n.setTypeNotification("EMAIL");
|
||||
assertThat(n.toString()).isNotNull().isNotEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
package dev.lions.unionflow.server.entity;
|
||||
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("Organisation")
|
||||
class OrganisationTest {
|
||||
|
||||
@Test
|
||||
@DisplayName("getters/setters")
|
||||
void gettersSetters() {
|
||||
Organisation o = new Organisation();
|
||||
o.setNom("Club Lions Paris");
|
||||
o.setNomCourt("CL Paris");
|
||||
o.setTypeOrganisation("ASSOCIATION");
|
||||
o.setStatut("ACTIVE");
|
||||
o.setEmail("contact@club.fr");
|
||||
o.setTelephone("+33100000000");
|
||||
o.setDevise("XOF");
|
||||
o.setNombreMembres(50);
|
||||
o.setEstOrganisationRacine(true);
|
||||
o.setAccepteNouveauxMembres(true);
|
||||
|
||||
assertThat(o.getNom()).isEqualTo("Club Lions Paris");
|
||||
assertThat(o.getNomCourt()).isEqualTo("CL Paris");
|
||||
assertThat(o.getStatut()).isEqualTo("ACTIVE");
|
||||
assertThat(o.getEmail()).isEqualTo("contact@club.fr");
|
||||
assertThat(o.getNombreMembres()).isEqualTo(50);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("getNomComplet: avec et sans nomCourt")
|
||||
void getNomComplet() {
|
||||
Organisation o = new Organisation();
|
||||
o.setNom("Club A");
|
||||
o.setNomCourt("CA");
|
||||
o.setTypeOrganisation("X");
|
||||
o.setStatut("ACTIVE");
|
||||
o.setEmail("a@b.com");
|
||||
assertThat(o.getNomComplet()).isEqualTo("Club A (CA)");
|
||||
o.setNomCourt(null);
|
||||
assertThat(o.getNomComplet()).isEqualTo("Club A");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("getAncienneteAnnees et isRecente")
|
||||
void anciennete() {
|
||||
Organisation o = new Organisation();
|
||||
o.setNom("X");
|
||||
o.setTypeOrganisation("X");
|
||||
o.setStatut("ACTIVE");
|
||||
o.setEmail("x@y.com");
|
||||
o.setDateFondation(LocalDate.now().minusYears(5));
|
||||
assertThat(o.getAncienneteAnnees()).isEqualTo(5);
|
||||
assertThat(o.isRecente()).isFalse();
|
||||
o.setDateFondation(LocalDate.now().minusYears(1));
|
||||
assertThat(o.isRecente()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("isActive")
|
||||
void isActive() {
|
||||
Organisation o = new Organisation();
|
||||
o.setNom("X");
|
||||
o.setTypeOrganisation("X");
|
||||
o.setStatut("ACTIVE");
|
||||
o.setEmail("x@y.com");
|
||||
o.setActif(true);
|
||||
assertThat(o.isActive()).isTrue();
|
||||
o.setStatut("SUSPENDUE");
|
||||
assertThat(o.isActive()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("ajouterMembre et retirerMembre")
|
||||
void ajouterRetirerMembre() {
|
||||
Organisation o = new Organisation();
|
||||
o.setNom("X");
|
||||
o.setTypeOrganisation("X");
|
||||
o.setStatut("ACTIVE");
|
||||
o.setEmail("x@y.com");
|
||||
o.setNombreMembres(10);
|
||||
o.ajouterMembre();
|
||||
assertThat(o.getNombreMembres()).isEqualTo(11);
|
||||
o.retirerMembre();
|
||||
o.retirerMembre();
|
||||
assertThat(o.getNombreMembres()).isEqualTo(9);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("activer, suspendre, dissoudre")
|
||||
void activerSuspendreDissoudre() {
|
||||
Organisation o = new Organisation();
|
||||
o.setNom("X");
|
||||
o.setTypeOrganisation("X");
|
||||
o.setStatut("SUSPENDUE");
|
||||
o.setEmail("x@y.com");
|
||||
o.activer("admin@test.com");
|
||||
assertThat(o.getStatut()).isEqualTo("ACTIVE");
|
||||
assertThat(o.getActif()).isTrue();
|
||||
o.suspendre("admin@test.com");
|
||||
assertThat(o.getStatut()).isEqualTo("SUSPENDUE");
|
||||
assertThat(o.getAccepteNouveauxMembres()).isFalse();
|
||||
o.dissoudre("admin@test.com");
|
||||
assertThat(o.getStatut()).isEqualTo("DISSOUTE");
|
||||
assertThat(o.getActif()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("equals et hashCode")
|
||||
void equalsHashCode() {
|
||||
UUID id = UUID.randomUUID();
|
||||
Organisation a = new Organisation();
|
||||
a.setId(id);
|
||||
a.setNom("N");
|
||||
a.setTypeOrganisation("X");
|
||||
a.setStatut("ACTIVE");
|
||||
a.setEmail("e@e.com");
|
||||
Organisation b = new Organisation();
|
||||
b.setId(id);
|
||||
b.setNom("N");
|
||||
b.setTypeOrganisation("X");
|
||||
b.setStatut("ACTIVE");
|
||||
b.setEmail("e@e.com");
|
||||
assertThat(a).isEqualTo(b);
|
||||
assertThat(a.hashCode()).isEqualTo(b.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toString non null")
|
||||
void toString_nonNull() {
|
||||
Organisation o = new Organisation();
|
||||
o.setNom("X");
|
||||
o.setTypeOrganisation("X");
|
||||
o.setStatut("ACTIVE");
|
||||
o.setEmail("x@y.com");
|
||||
assertThat(o.toString()).isNotNull().isNotEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package dev.lions.unionflow.server.entity;
|
||||
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("PaiementObjet")
|
||||
class PaiementObjetTest {
|
||||
|
||||
private static Paiement newPaiement() {
|
||||
Membre m = new Membre();
|
||||
m.setId(UUID.randomUUID());
|
||||
m.setNumeroMembre("M1");
|
||||
m.setPrenom("A");
|
||||
m.setNom("B");
|
||||
m.setEmail("a@test.com");
|
||||
m.setDateNaissance(java.time.LocalDate.now());
|
||||
Paiement p = new Paiement();
|
||||
p.setId(UUID.randomUUID());
|
||||
p.setNumeroReference("PAY-1");
|
||||
p.setMontant(BigDecimal.TEN);
|
||||
p.setCodeDevise("XOF");
|
||||
p.setMethodePaiement("WAVE");
|
||||
p.setMembre(m);
|
||||
return p;
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("getters/setters")
|
||||
void gettersSetters() {
|
||||
PaiementObjet po = new PaiementObjet();
|
||||
po.setPaiement(newPaiement());
|
||||
po.setTypeObjetCible("COTISATION");
|
||||
po.setObjetCibleId(UUID.randomUUID());
|
||||
po.setMontantApplique(new BigDecimal("5000.00"));
|
||||
po.setDateApplication(LocalDateTime.now());
|
||||
po.setCommentaire("Cotisation janvier");
|
||||
|
||||
assertThat(po.getTypeObjetCible()).isEqualTo("COTISATION");
|
||||
assertThat(po.getMontantApplique()).isEqualByComparingTo("5000.00");
|
||||
assertThat(po.getCommentaire()).isEqualTo("Cotisation janvier");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("equals et hashCode")
|
||||
void equalsHashCode() {
|
||||
UUID id = UUID.randomUUID();
|
||||
UUID objId = UUID.randomUUID();
|
||||
Paiement p = newPaiement();
|
||||
PaiementObjet a = new PaiementObjet();
|
||||
a.setId(id);
|
||||
a.setPaiement(p);
|
||||
a.setTypeObjetCible("COTISATION");
|
||||
a.setObjetCibleId(objId);
|
||||
a.setMontantApplique(BigDecimal.ONE);
|
||||
PaiementObjet b = new PaiementObjet();
|
||||
b.setId(id);
|
||||
b.setPaiement(p);
|
||||
b.setTypeObjetCible("COTISATION");
|
||||
b.setObjetCibleId(objId);
|
||||
b.setMontantApplique(BigDecimal.ONE);
|
||||
assertThat(a).isEqualTo(b);
|
||||
assertThat(a.hashCode()).isEqualTo(b.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toString non null")
|
||||
void toString_nonNull() {
|
||||
PaiementObjet po = new PaiementObjet();
|
||||
po.setPaiement(newPaiement());
|
||||
po.setTypeObjetCible("COTISATION");
|
||||
po.setObjetCibleId(UUID.randomUUID());
|
||||
po.setMontantApplique(BigDecimal.ONE);
|
||||
assertThat(po.toString()).isNotNull().isNotEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
package dev.lions.unionflow.server.entity;
|
||||
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("Paiement")
|
||||
class PaiementTest {
|
||||
|
||||
private static Membre newMembre() {
|
||||
Membre m = new Membre();
|
||||
m.setId(UUID.randomUUID());
|
||||
m.setNumeroMembre("M1");
|
||||
m.setPrenom("A");
|
||||
m.setNom("B");
|
||||
m.setEmail("a@test.com");
|
||||
m.setDateNaissance(java.time.LocalDate.now());
|
||||
return m;
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("getters/setters")
|
||||
void gettersSetters() {
|
||||
Paiement p = new Paiement();
|
||||
p.setNumeroReference("PAY-2025-001");
|
||||
p.setMontant(new BigDecimal("10000.00"));
|
||||
p.setCodeDevise("XOF");
|
||||
p.setMethodePaiement("WAVE");
|
||||
p.setStatutPaiement("VALIDE");
|
||||
p.setDatePaiement(LocalDateTime.now());
|
||||
p.setMembre(newMembre());
|
||||
|
||||
assertThat(p.getNumeroReference()).isEqualTo("PAY-2025-001");
|
||||
assertThat(p.getMontant()).isEqualByComparingTo("10000.00");
|
||||
assertThat(p.getCodeDevise()).isEqualTo("XOF");
|
||||
assertThat(p.getStatutPaiement()).isEqualTo("VALIDE");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("genererNumeroReference")
|
||||
void genererNumeroReference() {
|
||||
String ref = Paiement.genererNumeroReference();
|
||||
assertThat(ref).startsWith("PAY-").isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("isValide et peutEtreModifie")
|
||||
void isValide_peutEtreModifie() {
|
||||
Paiement p = new Paiement();
|
||||
p.setNumeroReference("X");
|
||||
p.setMontant(BigDecimal.ONE);
|
||||
p.setCodeDevise("XOF");
|
||||
p.setMethodePaiement("WAVE");
|
||||
p.setMembre(newMembre());
|
||||
p.setStatutPaiement("VALIDE");
|
||||
assertThat(p.isValide()).isTrue();
|
||||
assertThat(p.peutEtreModifie()).isFalse();
|
||||
p.setStatutPaiement("EN_ATTENTE");
|
||||
assertThat(p.peutEtreModifie()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("equals et hashCode")
|
||||
void equalsHashCode() {
|
||||
UUID id = UUID.randomUUID();
|
||||
Membre m = newMembre();
|
||||
Paiement a = new Paiement();
|
||||
a.setId(id);
|
||||
a.setNumeroReference("REF-1");
|
||||
a.setMontant(BigDecimal.ONE);
|
||||
a.setCodeDevise("XOF");
|
||||
a.setMethodePaiement("WAVE");
|
||||
a.setMembre(m);
|
||||
Paiement b = new Paiement();
|
||||
b.setId(id);
|
||||
b.setNumeroReference("REF-1");
|
||||
b.setMontant(BigDecimal.ONE);
|
||||
b.setCodeDevise("XOF");
|
||||
b.setMethodePaiement("WAVE");
|
||||
b.setMembre(m);
|
||||
assertThat(a).isEqualTo(b);
|
||||
assertThat(a.hashCode()).isEqualTo(b.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toString non null")
|
||||
void toString_nonNull() {
|
||||
Paiement p = new Paiement();
|
||||
p.setNumeroReference("X");
|
||||
p.setMontant(BigDecimal.ONE);
|
||||
p.setCodeDevise("XOF");
|
||||
p.setMethodePaiement("WAVE");
|
||||
p.setMembre(newMembre());
|
||||
assertThat(p.toString()).isNotNull().isNotEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package dev.lions.unionflow.server.entity;
|
||||
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("ParametresCotisationOrganisation")
|
||||
class ParametresCotisationOrganisationTest {
|
||||
|
||||
private static Organisation newOrganisation() {
|
||||
Organisation o = new Organisation();
|
||||
o.setId(UUID.randomUUID());
|
||||
o.setNom("Org");
|
||||
o.setTypeOrganisation("X");
|
||||
o.setStatut("ACTIVE");
|
||||
o.setEmail("org@test.com");
|
||||
return o;
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("getters/setters")
|
||||
void gettersSetters() {
|
||||
ParametresCotisationOrganisation p = new ParametresCotisationOrganisation();
|
||||
p.setOrganisation(newOrganisation());
|
||||
p.setMontantCotisationMensuelle(new BigDecimal("1000.00"));
|
||||
p.setMontantCotisationAnnuelle(new BigDecimal("12000.00"));
|
||||
p.setDevise("XOF");
|
||||
p.setDateDebutCalculAjour(LocalDate.now().minusMonths(1));
|
||||
p.setDelaiRetardAvantInactifJours(30);
|
||||
p.setCotisationObligatoire(true);
|
||||
|
||||
assertThat(p.getMontantCotisationMensuelle()).isEqualByComparingTo("1000.00");
|
||||
assertThat(p.getMontantCotisationAnnuelle()).isEqualByComparingTo("12000.00");
|
||||
assertThat(p.getDevise()).isEqualTo("XOF");
|
||||
assertThat(p.getDelaiRetardAvantInactifJours()).isEqualTo(30);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("isCalculAjourActive")
|
||||
void isCalculAjourActive() {
|
||||
ParametresCotisationOrganisation p = new ParametresCotisationOrganisation();
|
||||
p.setOrganisation(newOrganisation());
|
||||
p.setDevise("XOF");
|
||||
assertThat(p.isCalculAjourActive()).isFalse();
|
||||
p.setDateDebutCalculAjour(LocalDate.now());
|
||||
assertThat(p.isCalculAjourActive()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("equals et hashCode")
|
||||
void equalsHashCode() {
|
||||
UUID id = UUID.randomUUID();
|
||||
Organisation o = newOrganisation();
|
||||
ParametresCotisationOrganisation a = new ParametresCotisationOrganisation();
|
||||
a.setId(id);
|
||||
a.setOrganisation(o);
|
||||
a.setDevise("XOF");
|
||||
ParametresCotisationOrganisation b = new ParametresCotisationOrganisation();
|
||||
b.setId(id);
|
||||
b.setOrganisation(o);
|
||||
b.setDevise("XOF");
|
||||
assertThat(a).isEqualTo(b);
|
||||
assertThat(a.hashCode()).isEqualTo(b.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toString non null")
|
||||
void toString_nonNull() {
|
||||
ParametresCotisationOrganisation p = new ParametresCotisationOrganisation();
|
||||
p.setOrganisation(newOrganisation());
|
||||
p.setDevise("XOF");
|
||||
assertThat(p.toString()).isNotNull().isNotEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package dev.lions.unionflow.server.entity;
|
||||
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("Permission")
|
||||
class PermissionTest {
|
||||
|
||||
@Test
|
||||
@DisplayName("getters/setters")
|
||||
void gettersSetters() {
|
||||
Permission p = new Permission();
|
||||
p.setCode("ORG > MEMBRE > CREATE");
|
||||
p.setModule("ORG");
|
||||
p.setRessource("MEMBRE");
|
||||
p.setAction("CREATE");
|
||||
p.setLibelle("Créer un membre");
|
||||
p.setDescription("Permission de création");
|
||||
|
||||
assertThat(p.getCode()).isEqualTo("ORG > MEMBRE > CREATE");
|
||||
assertThat(p.getModule()).isEqualTo("ORG");
|
||||
assertThat(p.getRessource()).isEqualTo("MEMBRE");
|
||||
assertThat(p.getAction()).isEqualTo("CREATE");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("genererCode")
|
||||
void genererCode() {
|
||||
String code = Permission.genererCode("org", "membre", "create");
|
||||
assertThat(code).isEqualTo("ORG > MEMBRE > CREATE");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("isCodeValide")
|
||||
void isCodeValide() {
|
||||
Permission p = new Permission();
|
||||
p.setCode("A > B > C");
|
||||
assertThat(p.isCodeValide()).isTrue();
|
||||
p.setCode("invalid");
|
||||
assertThat(p.isCodeValide()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("equals et hashCode")
|
||||
void equalsHashCode() {
|
||||
UUID id = UUID.randomUUID();
|
||||
Permission a = new Permission();
|
||||
a.setId(id);
|
||||
a.setCode("X > Y > Z");
|
||||
a.setModule("X");
|
||||
a.setRessource("Y");
|
||||
a.setAction("Z");
|
||||
Permission b = new Permission();
|
||||
b.setId(id);
|
||||
b.setCode("X > Y > Z");
|
||||
b.setModule("X");
|
||||
b.setRessource("Y");
|
||||
b.setAction("Z");
|
||||
assertThat(a).isEqualTo(b);
|
||||
assertThat(a.hashCode()).isEqualTo(b.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toString non null")
|
||||
void toString_nonNull() {
|
||||
Permission p = new Permission();
|
||||
p.setCode("X > Y > Z");
|
||||
p.setModule("X");
|
||||
p.setRessource("Y");
|
||||
p.setAction("Z");
|
||||
assertThat(p.toString()).isNotNull().isNotEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package dev.lions.unionflow.server.entity;
|
||||
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("PieceJointe")
|
||||
class PieceJointeTest {
|
||||
|
||||
private static Document newDocument() {
|
||||
Document d = new Document();
|
||||
d.setId(UUID.randomUUID());
|
||||
d.setNomFichier("f.pdf");
|
||||
d.setCheminStockage("/f.pdf");
|
||||
d.setTailleOctets(100L);
|
||||
return d;
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("getters/setters")
|
||||
void gettersSetters() {
|
||||
PieceJointe pj = new PieceJointe();
|
||||
pj.setOrdre(1);
|
||||
pj.setLibelle("Pièce 1");
|
||||
pj.setCommentaire("Comment");
|
||||
pj.setDocument(newDocument());
|
||||
pj.setTypeEntiteRattachee("MEMBRE");
|
||||
pj.setEntiteRattacheeId(UUID.randomUUID());
|
||||
|
||||
assertThat(pj.getOrdre()).isEqualTo(1);
|
||||
assertThat(pj.getLibelle()).isEqualTo("Pièce 1");
|
||||
assertThat(pj.getTypeEntiteRattachee()).isEqualTo("MEMBRE");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("equals et hashCode")
|
||||
void equalsHashCode() {
|
||||
UUID id = UUID.randomUUID();
|
||||
UUID entiteId = UUID.randomUUID();
|
||||
Document d = newDocument();
|
||||
PieceJointe a = new PieceJointe();
|
||||
a.setId(id);
|
||||
a.setOrdre(1);
|
||||
a.setDocument(d);
|
||||
a.setTypeEntiteRattachee("MEMBRE");
|
||||
a.setEntiteRattacheeId(entiteId);
|
||||
PieceJointe b = new PieceJointe();
|
||||
b.setId(id);
|
||||
b.setOrdre(1);
|
||||
b.setDocument(d);
|
||||
b.setTypeEntiteRattachee("MEMBRE");
|
||||
b.setEntiteRattacheeId(entiteId);
|
||||
assertThat(a).isEqualTo(b);
|
||||
assertThat(a.hashCode()).isEqualTo(b.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toString non null")
|
||||
void toString_nonNull() {
|
||||
PieceJointe pj = new PieceJointe();
|
||||
pj.setOrdre(1);
|
||||
pj.setDocument(newDocument());
|
||||
pj.setTypeEntiteRattachee("MEMBRE");
|
||||
pj.setEntiteRattacheeId(UUID.randomUUID());
|
||||
assertThat(pj.toString()).isNotNull().isNotEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package dev.lions.unionflow.server.entity;
|
||||
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("RolePermission")
|
||||
class RolePermissionTest {
|
||||
|
||||
private static Role newRole() {
|
||||
Role r = new Role();
|
||||
r.setId(UUID.randomUUID());
|
||||
r.setCode("ADMIN");
|
||||
r.setLibelle("Admin");
|
||||
r.setNiveauHierarchique(1);
|
||||
r.setTypeRole("SYSTEME");
|
||||
return r;
|
||||
}
|
||||
|
||||
private static Permission newPermission() {
|
||||
Permission p = new Permission();
|
||||
p.setId(UUID.randomUUID());
|
||||
p.setCode("X > Y > Z");
|
||||
p.setModule("X");
|
||||
p.setRessource("Y");
|
||||
p.setAction("Z");
|
||||
return p;
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("getters/setters")
|
||||
void gettersSetters() {
|
||||
RolePermission rp = new RolePermission();
|
||||
rp.setRole(newRole());
|
||||
rp.setPermission(newPermission());
|
||||
rp.setCommentaire("Association");
|
||||
|
||||
assertThat(rp.getRole()).isNotNull();
|
||||
assertThat(rp.getPermission()).isNotNull();
|
||||
assertThat(rp.getCommentaire()).isEqualTo("Association");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("equals et hashCode")
|
||||
void equalsHashCode() {
|
||||
UUID id = UUID.randomUUID();
|
||||
Role role = newRole();
|
||||
Permission perm = newPermission();
|
||||
RolePermission a = new RolePermission();
|
||||
a.setId(id);
|
||||
a.setRole(role);
|
||||
a.setPermission(perm);
|
||||
RolePermission b = new RolePermission();
|
||||
b.setId(id);
|
||||
b.setRole(role);
|
||||
b.setPermission(perm);
|
||||
assertThat(a).isEqualTo(b);
|
||||
assertThat(a.hashCode()).isEqualTo(b.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toString non null")
|
||||
void toString_nonNull() {
|
||||
RolePermission rp = new RolePermission();
|
||||
rp.setRole(newRole());
|
||||
rp.setPermission(newPermission());
|
||||
assertThat(rp.toString()).isNotNull().isNotEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package dev.lions.unionflow.server.entity;
|
||||
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("Role")
|
||||
class RoleTest {
|
||||
|
||||
@Test
|
||||
@DisplayName("getters/setters")
|
||||
void gettersSetters() {
|
||||
Role r = new Role();
|
||||
r.setCode("ADMIN");
|
||||
r.setLibelle("Administrateur");
|
||||
r.setDescription("Rôle admin");
|
||||
r.setNiveauHierarchique(10);
|
||||
r.setTypeRole(Role.TypeRole.SYSTEME.name());
|
||||
|
||||
assertThat(r.getCode()).isEqualTo("ADMIN");
|
||||
assertThat(r.getLibelle()).isEqualTo("Administrateur");
|
||||
assertThat(r.getNiveauHierarchique()).isEqualTo(10);
|
||||
assertThat(r.getTypeRole()).isEqualTo("SYSTEME");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("isRoleSysteme")
|
||||
void isRoleSysteme() {
|
||||
Role r = new Role();
|
||||
r.setCode("X");
|
||||
r.setLibelle("X");
|
||||
r.setTypeRole(Role.TypeRole.SYSTEME.name());
|
||||
assertThat(r.isRoleSysteme()).isTrue();
|
||||
r.setTypeRole(Role.TypeRole.ORGANISATION.name());
|
||||
assertThat(r.isRoleSysteme()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("TypeRole enum")
|
||||
void typeRoleEnum() {
|
||||
assertThat(Role.TypeRole.SYSTEME.name()).isEqualTo("SYSTEME");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("equals et hashCode")
|
||||
void equalsHashCode() {
|
||||
UUID id = UUID.randomUUID();
|
||||
Role a = new Role();
|
||||
a.setId(id);
|
||||
a.setCode("C1");
|
||||
a.setLibelle("L1");
|
||||
a.setNiveauHierarchique(1);
|
||||
a.setTypeRole("SYSTEME");
|
||||
Role b = new Role();
|
||||
b.setId(id);
|
||||
b.setCode("C1");
|
||||
b.setLibelle("L1");
|
||||
b.setNiveauHierarchique(1);
|
||||
b.setTypeRole("SYSTEME");
|
||||
assertThat(a).isEqualTo(b);
|
||||
assertThat(a.hashCode()).isEqualTo(b.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toString non null")
|
||||
void toString_nonNull() {
|
||||
Role r = new Role();
|
||||
r.setCode("X");
|
||||
r.setLibelle("X");
|
||||
r.setNiveauHierarchique(100);
|
||||
r.setTypeRole("PERSONNALISE");
|
||||
assertThat(r.toString()).isNotNull().isNotEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
package dev.lions.unionflow.server.entity;
|
||||
|
||||
import dev.lions.unionflow.server.api.enums.abonnement.StatutSouscription;
|
||||
import dev.lions.unionflow.server.api.enums.abonnement.TypeFormule;
|
||||
import dev.lions.unionflow.server.api.enums.abonnement.TypePeriodeAbonnement;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("SouscriptionOrganisation")
|
||||
class SouscriptionOrganisationTest {
|
||||
|
||||
private static Organisation newOrganisation() {
|
||||
Organisation o = new Organisation();
|
||||
o.setId(UUID.randomUUID());
|
||||
o.setNom("Org");
|
||||
o.setTypeOrganisation("X");
|
||||
o.setStatut("ACTIVE");
|
||||
o.setEmail("org@test.com");
|
||||
return o;
|
||||
}
|
||||
|
||||
private static FormuleAbonnement newFormule() {
|
||||
FormuleAbonnement f = new FormuleAbonnement();
|
||||
f.setId(UUID.randomUUID());
|
||||
f.setCode(TypeFormule.STARTER);
|
||||
f.setLibelle("Starter");
|
||||
f.setMaxMembres(100);
|
||||
f.setPrixMensuel(java.math.BigDecimal.valueOf(5000));
|
||||
f.setPrixAnnuel(java.math.BigDecimal.valueOf(50000));
|
||||
return f;
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("getters/setters")
|
||||
void gettersSetters() {
|
||||
SouscriptionOrganisation s = new SouscriptionOrganisation();
|
||||
s.setOrganisation(newOrganisation());
|
||||
s.setFormule(newFormule());
|
||||
s.setTypePeriode(TypePeriodeAbonnement.MENSUEL);
|
||||
s.setDateDebut(LocalDate.now());
|
||||
s.setDateFin(LocalDate.now().plusYears(1));
|
||||
s.setQuotaMax(50);
|
||||
s.setQuotaUtilise(10);
|
||||
s.setStatut(StatutSouscription.ACTIVE);
|
||||
|
||||
assertThat(s.getTypePeriode()).isEqualTo(TypePeriodeAbonnement.MENSUEL);
|
||||
assertThat(s.getQuotaMax()).isEqualTo(50);
|
||||
assertThat(s.getQuotaUtilise()).isEqualTo(10);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("isActive")
|
||||
void isActive() {
|
||||
SouscriptionOrganisation s = new SouscriptionOrganisation();
|
||||
s.setOrganisation(newOrganisation());
|
||||
s.setFormule(newFormule());
|
||||
s.setDateDebut(LocalDate.now().minusMonths(1));
|
||||
s.setDateFin(LocalDate.now().plusMonths(1));
|
||||
s.setStatut(StatutSouscription.ACTIVE);
|
||||
assertThat(s.isActive()).isTrue();
|
||||
s.setDateFin(LocalDate.now().minusDays(1));
|
||||
assertThat(s.isActive()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("isQuotaDepasse et getPlacesRestantes")
|
||||
void isQuotaDepasse_getPlacesRestantes() {
|
||||
SouscriptionOrganisation s = new SouscriptionOrganisation();
|
||||
s.setOrganisation(newOrganisation());
|
||||
s.setFormule(newFormule());
|
||||
s.setDateDebut(LocalDate.now());
|
||||
s.setDateFin(LocalDate.now().plusYears(1));
|
||||
s.setQuotaMax(10);
|
||||
s.setQuotaUtilise(10);
|
||||
assertThat(s.isQuotaDepasse()).isTrue();
|
||||
assertThat(s.getPlacesRestantes()).isEqualTo(0);
|
||||
s.setQuotaUtilise(5);
|
||||
assertThat(s.isQuotaDepasse()).isFalse();
|
||||
assertThat(s.getPlacesRestantes()).isEqualTo(5);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("incrementerQuota et decrementerQuota")
|
||||
void incrementerDecrementerQuota() {
|
||||
SouscriptionOrganisation s = new SouscriptionOrganisation();
|
||||
s.setOrganisation(newOrganisation());
|
||||
s.setFormule(newFormule());
|
||||
s.setQuotaUtilise(5);
|
||||
s.incrementerQuota();
|
||||
assertThat(s.getQuotaUtilise()).isEqualTo(6);
|
||||
s.decrementerQuota();
|
||||
s.decrementerQuota();
|
||||
assertThat(s.getQuotaUtilise()).isEqualTo(4);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("equals et hashCode")
|
||||
void equalsHashCode() {
|
||||
UUID id = UUID.randomUUID();
|
||||
Organisation o = newOrganisation();
|
||||
FormuleAbonnement f = newFormule();
|
||||
LocalDate debut = LocalDate.now();
|
||||
LocalDate fin = LocalDate.now().plusYears(1);
|
||||
SouscriptionOrganisation a = new SouscriptionOrganisation();
|
||||
a.setId(id);
|
||||
a.setOrganisation(o);
|
||||
a.setFormule(f);
|
||||
a.setDateDebut(debut);
|
||||
a.setDateFin(fin);
|
||||
SouscriptionOrganisation b = new SouscriptionOrganisation();
|
||||
b.setId(id);
|
||||
b.setOrganisation(o);
|
||||
b.setFormule(f);
|
||||
b.setDateDebut(debut);
|
||||
b.setDateFin(fin);
|
||||
assertThat(a).isEqualTo(b);
|
||||
assertThat(a.hashCode()).isEqualTo(b.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toString non null")
|
||||
void toString_nonNull() {
|
||||
SouscriptionOrganisation s = new SouscriptionOrganisation();
|
||||
s.setOrganisation(newOrganisation());
|
||||
s.setFormule(newFormule());
|
||||
s.setDateDebut(LocalDate.now());
|
||||
s.setDateFin(LocalDate.now().plusYears(1));
|
||||
assertThat(s.toString()).isNotNull().isNotEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package dev.lions.unionflow.server.entity;
|
||||
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("Suggestion")
|
||||
class SuggestionTest {
|
||||
|
||||
@Test
|
||||
@DisplayName("getters/setters")
|
||||
void gettersSetters() {
|
||||
Suggestion s = new Suggestion();
|
||||
s.setUtilisateurId(UUID.randomUUID());
|
||||
s.setUtilisateurNom("User");
|
||||
s.setTitre("Titre");
|
||||
s.setDescription("Desc");
|
||||
s.setCategorie("FEATURE");
|
||||
s.setStatut("NOUVELLE");
|
||||
s.setNbVotes(5);
|
||||
s.setDateSoumission(LocalDateTime.now());
|
||||
|
||||
assertThat(s.getTitre()).isEqualTo("Titre");
|
||||
assertThat(s.getCategorie()).isEqualTo("FEATURE");
|
||||
assertThat(s.getStatut()).isEqualTo("NOUVELLE");
|
||||
assertThat(s.getNbVotes()).isEqualTo(5);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("equals et hashCode")
|
||||
void equalsHashCode() {
|
||||
UUID id = UUID.randomUUID();
|
||||
UUID userId = UUID.randomUUID();
|
||||
Suggestion a = new Suggestion();
|
||||
a.setId(id);
|
||||
a.setUtilisateurId(userId);
|
||||
a.setTitre("T");
|
||||
Suggestion b = new Suggestion();
|
||||
b.setId(id);
|
||||
b.setUtilisateurId(userId);
|
||||
b.setTitre("T");
|
||||
assertThat(a).isEqualTo(b);
|
||||
assertThat(a.hashCode()).isEqualTo(b.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toString non null")
|
||||
void toString_nonNull() {
|
||||
Suggestion s = new Suggestion();
|
||||
s.setUtilisateurId(UUID.randomUUID());
|
||||
s.setTitre("T");
|
||||
assertThat(s.toString()).isNotNull().isNotEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package dev.lions.unionflow.server.entity;
|
||||
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("SuggestionVote")
|
||||
class SuggestionVoteTest {
|
||||
|
||||
@Test
|
||||
@DisplayName("getters/setters")
|
||||
void gettersSetters() {
|
||||
UUID suggestionId = UUID.randomUUID();
|
||||
UUID userId = UUID.randomUUID();
|
||||
LocalDateTime dateVote = LocalDateTime.now();
|
||||
SuggestionVote v = new SuggestionVote();
|
||||
v.setSuggestionId(suggestionId);
|
||||
v.setUtilisateurId(userId);
|
||||
v.setDateVote(dateVote);
|
||||
|
||||
assertThat(v.getSuggestionId()).isEqualTo(suggestionId);
|
||||
assertThat(v.getUtilisateurId()).isEqualTo(userId);
|
||||
assertThat(v.getDateVote()).isEqualTo(dateVote);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("equals et hashCode")
|
||||
void equalsHashCode() {
|
||||
UUID id = UUID.randomUUID();
|
||||
UUID sId = UUID.randomUUID();
|
||||
UUID uId = UUID.randomUUID();
|
||||
LocalDateTime dt = LocalDateTime.now();
|
||||
SuggestionVote a = new SuggestionVote();
|
||||
a.setId(id);
|
||||
a.setSuggestionId(sId);
|
||||
a.setUtilisateurId(uId);
|
||||
a.setDateVote(dt);
|
||||
SuggestionVote b = new SuggestionVote();
|
||||
b.setId(id);
|
||||
b.setSuggestionId(sId);
|
||||
b.setUtilisateurId(uId);
|
||||
b.setDateVote(dt);
|
||||
assertThat(a).isEqualTo(b);
|
||||
assertThat(a.hashCode()).isEqualTo(b.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toString non null")
|
||||
void toString_nonNull() {
|
||||
SuggestionVote v = new SuggestionVote();
|
||||
v.setSuggestionId(UUID.randomUUID());
|
||||
v.setUtilisateurId(UUID.randomUUID());
|
||||
v.setDateVote(LocalDateTime.now());
|
||||
assertThat(v.toString()).isNotNull().isNotEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package dev.lions.unionflow.server.entity;
|
||||
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("TemplateNotification")
|
||||
class TemplateNotificationTest {
|
||||
|
||||
@Test
|
||||
@DisplayName("getters/setters")
|
||||
void gettersSetters() {
|
||||
TemplateNotification t = new TemplateNotification();
|
||||
t.setCode("WELCOME");
|
||||
t.setSujet("Bienvenue");
|
||||
t.setCorpsTexte("Bonjour {{nom}}");
|
||||
t.setCorpsHtml("<p>Bonjour {{nom}}</p>");
|
||||
t.setLangue("fr");
|
||||
t.setDescription("Template de bienvenue");
|
||||
|
||||
assertThat(t.getCode()).isEqualTo("WELCOME");
|
||||
assertThat(t.getSujet()).isEqualTo("Bienvenue");
|
||||
assertThat(t.getLangue()).isEqualTo("fr");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("equals et hashCode")
|
||||
void equalsHashCode() {
|
||||
UUID id = UUID.randomUUID();
|
||||
TemplateNotification a = new TemplateNotification();
|
||||
a.setId(id);
|
||||
a.setCode("C1");
|
||||
a.setSujet("S1");
|
||||
TemplateNotification b = new TemplateNotification();
|
||||
b.setId(id);
|
||||
b.setCode("C1");
|
||||
b.setSujet("S1");
|
||||
assertThat(a).isEqualTo(b);
|
||||
assertThat(a.hashCode()).isEqualTo(b.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toString non null")
|
||||
void toString_nonNull() {
|
||||
TemplateNotification t = new TemplateNotification();
|
||||
t.setCode("X");
|
||||
t.setSujet("Y");
|
||||
assertThat(t.toString()).isNotNull().isNotEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package dev.lions.unionflow.server.entity;
|
||||
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("Ticket")
|
||||
class TicketTest {
|
||||
|
||||
@Test
|
||||
@DisplayName("getters/setters")
|
||||
void gettersSetters() {
|
||||
Ticket t = new Ticket();
|
||||
t.setNumeroTicket("TKT-001");
|
||||
t.setUtilisateurId(UUID.randomUUID());
|
||||
t.setSujet("Problème");
|
||||
t.setDescription("Description");
|
||||
t.setCategorie("TECHNIQUE");
|
||||
t.setPriorite("HAUTE");
|
||||
t.setStatut("OUVERT");
|
||||
t.setNbMessages(2);
|
||||
t.setDateResolution(LocalDateTime.now());
|
||||
|
||||
assertThat(t.getNumeroTicket()).isEqualTo("TKT-001");
|
||||
assertThat(t.getSujet()).isEqualTo("Problème");
|
||||
assertThat(t.getStatut()).isEqualTo("OUVERT");
|
||||
assertThat(t.getNbMessages()).isEqualTo(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("equals et hashCode")
|
||||
void equalsHashCode() {
|
||||
UUID id = UUID.randomUUID();
|
||||
UUID userId = UUID.randomUUID();
|
||||
Ticket a = new Ticket();
|
||||
a.setId(id);
|
||||
a.setNumeroTicket("N1");
|
||||
a.setUtilisateurId(userId);
|
||||
a.setSujet("S");
|
||||
Ticket b = new Ticket();
|
||||
b.setId(id);
|
||||
b.setNumeroTicket("N1");
|
||||
b.setUtilisateurId(userId);
|
||||
b.setSujet("S");
|
||||
assertThat(a).isEqualTo(b);
|
||||
assertThat(a.hashCode()).isEqualTo(b.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toString non null")
|
||||
void toString_nonNull() {
|
||||
Ticket t = new Ticket();
|
||||
t.setNumeroTicket("X");
|
||||
t.setUtilisateurId(UUID.randomUUID());
|
||||
t.setSujet("S");
|
||||
assertThat(t.toString()).isNotNull().isNotEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package dev.lions.unionflow.server.entity;
|
||||
|
||||
import dev.lions.unionflow.server.api.enums.wave.StatutCompteWave;
|
||||
import dev.lions.unionflow.server.api.enums.wave.StatutTransactionWave;
|
||||
import dev.lions.unionflow.server.api.enums.wave.TypeTransactionWave;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("TransactionWave")
|
||||
class TransactionWaveTest {
|
||||
|
||||
private static CompteWave newCompteWave() {
|
||||
CompteWave c = new CompteWave();
|
||||
c.setId(UUID.randomUUID());
|
||||
c.setNumeroTelephone("+22507000001");
|
||||
c.setStatutCompte(StatutCompteWave.VERIFIE);
|
||||
return c;
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("getters/setters")
|
||||
void gettersSetters() {
|
||||
TransactionWave t = new TransactionWave();
|
||||
t.setWaveTransactionId("wave-123");
|
||||
t.setTypeTransaction(TypeTransactionWave.DEPOT);
|
||||
t.setStatutTransaction(StatutTransactionWave.REUSSIE);
|
||||
t.setMontant(new BigDecimal("5000.00"));
|
||||
t.setCodeDevise("XOF");
|
||||
t.setCompteWave(newCompteWave());
|
||||
|
||||
assertThat(t.getWaveTransactionId()).isEqualTo("wave-123");
|
||||
assertThat(t.getTypeTransaction()).isEqualTo(TypeTransactionWave.DEPOT);
|
||||
assertThat(t.getStatutTransaction()).isEqualTo(StatutTransactionWave.REUSSIE);
|
||||
assertThat(t.getMontant()).isEqualByComparingTo("5000.00");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("isReussie")
|
||||
void isReussie() {
|
||||
TransactionWave t = new TransactionWave();
|
||||
t.setWaveTransactionId("x");
|
||||
t.setTypeTransaction(TypeTransactionWave.DEPOT);
|
||||
t.setMontant(BigDecimal.ONE);
|
||||
t.setCodeDevise("XOF");
|
||||
t.setCompteWave(newCompteWave());
|
||||
t.setStatutTransaction(StatutTransactionWave.REUSSIE);
|
||||
assertThat(t.isReussie()).isTrue();
|
||||
t.setStatutTransaction(StatutTransactionWave.ECHOUE);
|
||||
assertThat(t.isReussie()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("peutEtreRetentee")
|
||||
void peutEtreRetentee() {
|
||||
TransactionWave t = new TransactionWave();
|
||||
t.setWaveTransactionId("x");
|
||||
t.setTypeTransaction(TypeTransactionWave.DEPOT);
|
||||
t.setMontant(BigDecimal.ONE);
|
||||
t.setCodeDevise("XOF");
|
||||
t.setCompteWave(newCompteWave());
|
||||
t.setStatutTransaction(StatutTransactionWave.ECHOUE);
|
||||
t.setNombreTentatives(2);
|
||||
assertThat(t.peutEtreRetentee()).isTrue();
|
||||
t.setNombreTentatives(5);
|
||||
assertThat(t.peutEtreRetentee()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("equals et hashCode")
|
||||
void equalsHashCode() {
|
||||
UUID id = UUID.randomUUID();
|
||||
CompteWave c = newCompteWave();
|
||||
TransactionWave a = new TransactionWave();
|
||||
a.setId(id);
|
||||
a.setWaveTransactionId("w1");
|
||||
a.setTypeTransaction(TypeTransactionWave.DEPOT);
|
||||
a.setStatutTransaction(StatutTransactionWave.REUSSIE);
|
||||
a.setMontant(BigDecimal.ONE);
|
||||
a.setCodeDevise("XOF");
|
||||
a.setCompteWave(c);
|
||||
TransactionWave b = new TransactionWave();
|
||||
b.setId(id);
|
||||
b.setWaveTransactionId("w1");
|
||||
b.setTypeTransaction(TypeTransactionWave.DEPOT);
|
||||
b.setStatutTransaction(StatutTransactionWave.REUSSIE);
|
||||
b.setMontant(BigDecimal.ONE);
|
||||
b.setCodeDevise("XOF");
|
||||
b.setCompteWave(c);
|
||||
assertThat(a).isEqualTo(b);
|
||||
assertThat(a.hashCode()).isEqualTo(b.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toString non null")
|
||||
void toString_nonNull() {
|
||||
TransactionWave t = new TransactionWave();
|
||||
t.setWaveTransactionId("x");
|
||||
t.setTypeTransaction(TypeTransactionWave.DEPOT);
|
||||
t.setMontant(BigDecimal.ONE);
|
||||
t.setCodeDevise("XOF");
|
||||
t.setCompteWave(newCompteWave());
|
||||
assertThat(t.toString()).isNotNull().isNotEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package dev.lions.unionflow.server.entity;
|
||||
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("TypeReference")
|
||||
class TypeReferenceTest {
|
||||
|
||||
@Test
|
||||
@DisplayName("getters/setters")
|
||||
void gettersSetters() {
|
||||
TypeReference tr = new TypeReference();
|
||||
tr.setDomaine("STATUT_ORGANISATION");
|
||||
tr.setCode("ACTIVE");
|
||||
tr.setLibelle("Actif");
|
||||
tr.setDescription("Organisation active");
|
||||
tr.setOrdreAffichage(1);
|
||||
tr.setEstDefaut(true);
|
||||
tr.setEstSysteme(false);
|
||||
|
||||
assertThat(tr.getDomaine()).isEqualTo("STATUT_ORGANISATION");
|
||||
assertThat(tr.getCode()).isEqualTo("ACTIVE");
|
||||
assertThat(tr.getLibelle()).isEqualTo("Actif");
|
||||
assertThat(tr.getOrdreAffichage()).isEqualTo(1);
|
||||
assertThat(tr.getEstDefaut()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("equals et hashCode")
|
||||
void equalsHashCode() {
|
||||
UUID id = UUID.randomUUID();
|
||||
TypeReference a = new TypeReference();
|
||||
a.setId(id);
|
||||
a.setDomaine("D");
|
||||
a.setCode("C");
|
||||
a.setLibelle("L");
|
||||
TypeReference b = new TypeReference();
|
||||
b.setId(id);
|
||||
b.setDomaine("D");
|
||||
b.setCode("C");
|
||||
b.setLibelle("L");
|
||||
assertThat(a).isEqualTo(b);
|
||||
assertThat(a.hashCode()).isEqualTo(b.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toString non null")
|
||||
void toString_nonNull() {
|
||||
TypeReference tr = new TypeReference();
|
||||
tr.setDomaine("D");
|
||||
tr.setCode("C");
|
||||
tr.setLibelle("L");
|
||||
assertThat(tr.toString()).isNotNull().isNotEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package dev.lions.unionflow.server.entity;
|
||||
|
||||
import dev.lions.unionflow.server.api.enums.solidarite.StatutAide;
|
||||
import dev.lions.unionflow.server.api.enums.solidarite.StatutValidationEtape;
|
||||
import dev.lions.unionflow.server.api.enums.solidarite.TypeAide;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("ValidationEtapeDemande")
|
||||
class ValidationEtapeDemandeTest {
|
||||
|
||||
private static DemandeAide newDemandeAide() {
|
||||
DemandeAide d = new DemandeAide();
|
||||
d.setId(UUID.randomUUID());
|
||||
d.setTitre("Aide");
|
||||
d.setDescription("Desc");
|
||||
d.setTypeAide(TypeAide.AIDE_FRAIS_MEDICAUX);
|
||||
d.setStatut(StatutAide.EN_ATTENTE);
|
||||
d.setMontantDemande(java.math.BigDecimal.ONE);
|
||||
d.setDateDemande(LocalDateTime.now());
|
||||
return d;
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("getters/setters")
|
||||
void gettersSetters() {
|
||||
ValidationEtapeDemande v = new ValidationEtapeDemande();
|
||||
v.setDemandeAide(newDemandeAide());
|
||||
v.setEtapeNumero(1);
|
||||
v.setStatut(StatutValidationEtape.EN_ATTENTE);
|
||||
v.setDateValidation(LocalDateTime.now());
|
||||
v.setCommentaire("OK");
|
||||
|
||||
assertThat(v.getEtapeNumero()).isEqualTo(1);
|
||||
assertThat(v.getStatut()).isEqualTo(StatutValidationEtape.EN_ATTENTE);
|
||||
assertThat(v.getCommentaire()).isEqualTo("OK");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("estEnAttente et estFinalisee")
|
||||
void estEnAttente_estFinalisee() {
|
||||
ValidationEtapeDemande v = new ValidationEtapeDemande();
|
||||
v.setDemandeAide(newDemandeAide());
|
||||
v.setEtapeNumero(1);
|
||||
v.setStatut(StatutValidationEtape.EN_ATTENTE);
|
||||
assertThat(v.estEnAttente()).isTrue();
|
||||
assertThat(v.estFinalisee()).isFalse();
|
||||
v.setStatut(StatutValidationEtape.APPROUVEE);
|
||||
assertThat(v.estEnAttente()).isFalse();
|
||||
assertThat(v.estFinalisee()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("equals et hashCode")
|
||||
void equalsHashCode() {
|
||||
UUID id = UUID.randomUUID();
|
||||
DemandeAide d = newDemandeAide();
|
||||
ValidationEtapeDemande a = new ValidationEtapeDemande();
|
||||
a.setId(id);
|
||||
a.setDemandeAide(d);
|
||||
a.setEtapeNumero(1);
|
||||
a.setStatut(StatutValidationEtape.EN_ATTENTE);
|
||||
ValidationEtapeDemande b = new ValidationEtapeDemande();
|
||||
b.setId(id);
|
||||
b.setDemandeAide(d);
|
||||
b.setEtapeNumero(1);
|
||||
b.setStatut(StatutValidationEtape.EN_ATTENTE);
|
||||
assertThat(a).isEqualTo(b);
|
||||
assertThat(a.hashCode()).isEqualTo(b.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toString non null")
|
||||
void toString_nonNull() {
|
||||
ValidationEtapeDemande v = new ValidationEtapeDemande();
|
||||
v.setDemandeAide(newDemandeAide());
|
||||
v.setEtapeNumero(1);
|
||||
v.setStatut(StatutValidationEtape.EN_ATTENTE);
|
||||
assertThat(v.toString()).isNotNull().isNotEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package dev.lions.unionflow.server.entity;
|
||||
|
||||
import dev.lions.unionflow.server.api.enums.wave.StatutWebhook;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("WebhookWave")
|
||||
class WebhookWaveTest {
|
||||
|
||||
@Test
|
||||
@DisplayName("getters/setters")
|
||||
void gettersSetters() {
|
||||
WebhookWave w = new WebhookWave();
|
||||
w.setWaveEventId("evt-123");
|
||||
w.setTypeEvenement("PAYMENT_SUCCESS");
|
||||
w.setStatutTraitement(StatutWebhook.TRAITE.name());
|
||||
w.setPayload("{}");
|
||||
w.setDateReception(LocalDateTime.now());
|
||||
w.setNombreTentatives(1);
|
||||
|
||||
assertThat(w.getWaveEventId()).isEqualTo("evt-123");
|
||||
assertThat(w.getTypeEvenement()).isEqualTo("PAYMENT_SUCCESS");
|
||||
assertThat(w.getStatutTraitement()).isEqualTo("TRAITE");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("isTraite")
|
||||
void isTraite() {
|
||||
WebhookWave w = new WebhookWave();
|
||||
w.setWaveEventId("x");
|
||||
w.setStatutTraitement(StatutWebhook.TRAITE.name());
|
||||
assertThat(w.isTraite()).isTrue();
|
||||
w.setStatutTraitement(StatutWebhook.EN_ATTENTE.name());
|
||||
assertThat(w.isTraite()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("peutEtreRetente")
|
||||
void peutEtreRetente() {
|
||||
WebhookWave w = new WebhookWave();
|
||||
w.setWaveEventId("x");
|
||||
w.setStatutTraitement(StatutWebhook.ECHOUE.name());
|
||||
w.setNombreTentatives(2);
|
||||
assertThat(w.peutEtreRetente()).isTrue();
|
||||
w.setNombreTentatives(5);
|
||||
assertThat(w.peutEtreRetente()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("equals et hashCode")
|
||||
void equalsHashCode() {
|
||||
UUID id = UUID.randomUUID();
|
||||
WebhookWave a = new WebhookWave();
|
||||
a.setId(id);
|
||||
a.setWaveEventId("evt-1");
|
||||
a.setStatutTraitement(StatutWebhook.EN_ATTENTE.name());
|
||||
WebhookWave b = new WebhookWave();
|
||||
b.setId(id);
|
||||
b.setWaveEventId("evt-1");
|
||||
b.setStatutTraitement(StatutWebhook.EN_ATTENTE.name());
|
||||
assertThat(a).isEqualTo(b);
|
||||
assertThat(a.hashCode()).isEqualTo(b.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toString non null")
|
||||
void toString_nonNull() {
|
||||
WebhookWave w = new WebhookWave();
|
||||
w.setWaveEventId("x");
|
||||
w.setStatutTraitement(StatutWebhook.EN_ATTENTE.name());
|
||||
assertThat(w.toString()).isNotNull().isNotEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package dev.lions.unionflow.server.entity;
|
||||
|
||||
import dev.lions.unionflow.server.api.enums.solidarite.TypeWorkflow;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("WorkflowValidationConfig")
|
||||
class WorkflowValidationConfigTest {
|
||||
|
||||
private static Organisation newOrganisation() {
|
||||
Organisation o = new Organisation();
|
||||
o.setId(UUID.randomUUID());
|
||||
o.setNom("Org");
|
||||
o.setTypeOrganisation("X");
|
||||
o.setStatut("ACTIVE");
|
||||
o.setEmail("org@test.com");
|
||||
return o;
|
||||
}
|
||||
|
||||
private static Role newRole() {
|
||||
Role r = new Role();
|
||||
r.setId(UUID.randomUUID());
|
||||
r.setCode("SECRETAIRE");
|
||||
r.setLibelle("Secrétaire");
|
||||
r.setNiveauHierarchique(1);
|
||||
r.setTypeRole("ORGANISATION");
|
||||
return r;
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("getters/setters")
|
||||
void gettersSetters() {
|
||||
WorkflowValidationConfig w = new WorkflowValidationConfig();
|
||||
w.setOrganisation(newOrganisation());
|
||||
w.setTypeWorkflow(TypeWorkflow.DEMANDE_AIDE);
|
||||
w.setEtapeNumero(1);
|
||||
w.setRoleRequis(newRole());
|
||||
w.setLibelleEtape("Étape 1 - Secrétaire");
|
||||
w.setDelaiMaxHeures(72);
|
||||
|
||||
assertThat(w.getTypeWorkflow()).isEqualTo(TypeWorkflow.DEMANDE_AIDE);
|
||||
assertThat(w.getEtapeNumero()).isEqualTo(1);
|
||||
assertThat(w.getLibelleEtape()).isEqualTo("Étape 1 - Secrétaire");
|
||||
assertThat(w.getDelaiMaxHeures()).isEqualTo(72);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("equals et hashCode")
|
||||
void equalsHashCode() {
|
||||
UUID id = UUID.randomUUID();
|
||||
Organisation o = newOrganisation();
|
||||
WorkflowValidationConfig a = new WorkflowValidationConfig();
|
||||
a.setId(id);
|
||||
a.setOrganisation(o);
|
||||
a.setTypeWorkflow(TypeWorkflow.DEMANDE_AIDE);
|
||||
a.setEtapeNumero(1);
|
||||
a.setLibelleEtape("E1");
|
||||
WorkflowValidationConfig b = new WorkflowValidationConfig();
|
||||
b.setId(id);
|
||||
b.setOrganisation(o);
|
||||
b.setTypeWorkflow(TypeWorkflow.DEMANDE_AIDE);
|
||||
b.setEtapeNumero(1);
|
||||
b.setLibelleEtape("E1");
|
||||
assertThat(a).isEqualTo(b);
|
||||
assertThat(a.hashCode()).isEqualTo(b.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toString non null")
|
||||
void toString_nonNull() {
|
||||
WorkflowValidationConfig w = new WorkflowValidationConfig();
|
||||
w.setOrganisation(newOrganisation());
|
||||
w.setTypeWorkflow(TypeWorkflow.DEMANDE_AIDE);
|
||||
w.setEtapeNumero(1);
|
||||
w.setLibelleEtape("E1");
|
||||
assertThat(w.toString()).isNotNull().isNotEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package dev.lions.unionflow.server.entity.agricole;
|
||||
|
||||
import dev.lions.unionflow.server.api.enums.agricole.StatutCampagneAgricole;
|
||||
import dev.lions.unionflow.server.entity.Organisation;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("CampagneAgricole")
|
||||
class CampagneAgricoleTest {
|
||||
|
||||
private static Organisation newOrganisation() {
|
||||
Organisation o = new Organisation();
|
||||
o.setId(UUID.randomUUID());
|
||||
o.setNom("Org");
|
||||
o.setTypeOrganisation("X");
|
||||
o.setStatut("ACTIVE");
|
||||
o.setEmail("org@test.com");
|
||||
return o;
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("getters/setters")
|
||||
void gettersSetters() {
|
||||
CampagneAgricole c = new CampagneAgricole();
|
||||
c.setOrganisation(newOrganisation());
|
||||
c.setDesignation("Campagne maïs 2025");
|
||||
c.setTypeCulturePrincipale("Maïs");
|
||||
c.setSurfaceTotaleEstimeeHectares(new BigDecimal("10.5"));
|
||||
c.setVolumePrevisionnelTonnes(new BigDecimal("50"));
|
||||
c.setVolumeReelTonnes(new BigDecimal("48"));
|
||||
c.setStatut(StatutCampagneAgricole.RECOLTE);
|
||||
|
||||
assertThat(c.getDesignation()).isEqualTo("Campagne maïs 2025");
|
||||
assertThat(c.getTypeCulturePrincipale()).isEqualTo("Maïs");
|
||||
assertThat(c.getStatut()).isEqualTo(StatutCampagneAgricole.RECOLTE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("equals et hashCode")
|
||||
void equalsHashCode() {
|
||||
UUID id = UUID.randomUUID();
|
||||
Organisation o = newOrganisation();
|
||||
CampagneAgricole a = new CampagneAgricole();
|
||||
a.setId(id);
|
||||
a.setOrganisation(o);
|
||||
a.setDesignation("D");
|
||||
a.setStatut(StatutCampagneAgricole.PREPARATION);
|
||||
CampagneAgricole b = new CampagneAgricole();
|
||||
b.setId(id);
|
||||
b.setOrganisation(o);
|
||||
b.setDesignation("D");
|
||||
b.setStatut(StatutCampagneAgricole.PREPARATION);
|
||||
assertThat(a).isEqualTo(b);
|
||||
assertThat(a.hashCode()).isEqualTo(b.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toString non null")
|
||||
void toString_nonNull() {
|
||||
CampagneAgricole c = new CampagneAgricole();
|
||||
c.setOrganisation(newOrganisation());
|
||||
c.setDesignation("X");
|
||||
c.setStatut(StatutCampagneAgricole.PREPARATION);
|
||||
assertThat(c.toString()).isNotNull().isNotEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package dev.lions.unionflow.server.entity.collectefonds;
|
||||
|
||||
import dev.lions.unionflow.server.api.enums.collectefonds.StatutCampagneCollecte;
|
||||
import dev.lions.unionflow.server.entity.Organisation;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("CampagneCollecte")
|
||||
class CampagneCollecteTest {
|
||||
|
||||
private static Organisation newOrganisation() {
|
||||
Organisation o = new Organisation();
|
||||
o.setId(UUID.randomUUID());
|
||||
o.setNom("Org");
|
||||
o.setTypeOrganisation("X");
|
||||
o.setStatut("ACTIVE");
|
||||
o.setEmail("org@test.com");
|
||||
return o;
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("getters/setters")
|
||||
void gettersSetters() {
|
||||
CampagneCollecte c = new CampagneCollecte();
|
||||
c.setOrganisation(newOrganisation());
|
||||
c.setTitre("Collecte solidarité");
|
||||
c.setCourteDescription("Courte desc");
|
||||
c.setObjectifFinancier(new BigDecimal("1000000"));
|
||||
c.setMontantCollecteActuel(new BigDecimal("500000"));
|
||||
c.setNombreDonateurs(10);
|
||||
c.setStatut(StatutCampagneCollecte.EN_COURS);
|
||||
c.setDateOuverture(LocalDateTime.now());
|
||||
c.setEstPublique(true);
|
||||
|
||||
assertThat(c.getTitre()).isEqualTo("Collecte solidarité");
|
||||
assertThat(c.getStatut()).isEqualTo(StatutCampagneCollecte.EN_COURS);
|
||||
assertThat(c.getNombreDonateurs()).isEqualTo(10);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("equals et hashCode")
|
||||
void equalsHashCode() {
|
||||
UUID id = UUID.randomUUID();
|
||||
Organisation o = newOrganisation();
|
||||
CampagneCollecte a = new CampagneCollecte();
|
||||
a.setId(id);
|
||||
a.setOrganisation(o);
|
||||
a.setTitre("T");
|
||||
a.setStatut(StatutCampagneCollecte.BROUILLON);
|
||||
CampagneCollecte b = new CampagneCollecte();
|
||||
b.setId(id);
|
||||
b.setOrganisation(o);
|
||||
b.setTitre("T");
|
||||
b.setStatut(StatutCampagneCollecte.BROUILLON);
|
||||
assertThat(a).isEqualTo(b);
|
||||
assertThat(a.hashCode()).isEqualTo(b.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toString non null")
|
||||
void toString_nonNull() {
|
||||
CampagneCollecte c = new CampagneCollecte();
|
||||
c.setOrganisation(newOrganisation());
|
||||
c.setTitre("X");
|
||||
c.setStatut(StatutCampagneCollecte.BROUILLON);
|
||||
assertThat(c.toString()).isNotNull().isNotEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package dev.lions.unionflow.server.entity.collectefonds;
|
||||
|
||||
import dev.lions.unionflow.server.api.enums.wave.StatutTransactionWave;
|
||||
import dev.lions.unionflow.server.entity.Membre;
|
||||
import dev.lions.unionflow.server.entity.Organisation;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("ContributionCollecte")
|
||||
class ContributionCollecteTest {
|
||||
|
||||
private static CampagneCollecte newCampagne() {
|
||||
Organisation o = new Organisation();
|
||||
o.setId(UUID.randomUUID());
|
||||
o.setNom("Org");
|
||||
o.setTypeOrganisation("X");
|
||||
o.setStatut("ACTIVE");
|
||||
o.setEmail("org@test.com");
|
||||
CampagneCollecte c = new CampagneCollecte();
|
||||
c.setId(UUID.randomUUID());
|
||||
c.setOrganisation(o);
|
||||
c.setTitre("Campagne");
|
||||
c.setStatut(dev.lions.unionflow.server.api.enums.collectefonds.StatutCampagneCollecte.EN_COURS);
|
||||
return c;
|
||||
}
|
||||
|
||||
private static Membre newMembre() {
|
||||
Membre m = new Membre();
|
||||
m.setId(UUID.randomUUID());
|
||||
m.setNumeroMembre("M1");
|
||||
m.setPrenom("A");
|
||||
m.setNom("B");
|
||||
m.setEmail("a@test.com");
|
||||
m.setDateNaissance(java.time.LocalDate.now());
|
||||
return m;
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("getters/setters")
|
||||
void gettersSetters() {
|
||||
ContributionCollecte cc = new ContributionCollecte();
|
||||
cc.setCampagne(newCampagne());
|
||||
cc.setMembreDonateur(newMembre());
|
||||
cc.setMontantSoutien(new BigDecimal("5000"));
|
||||
cc.setDateContribution(LocalDateTime.now());
|
||||
cc.setEstAnonyme(false);
|
||||
cc.setStatutPaiement(StatutTransactionWave.REUSSIE);
|
||||
|
||||
assertThat(cc.getMontantSoutien()).isEqualByComparingTo("5000");
|
||||
assertThat(cc.getStatutPaiement()).isEqualTo(StatutTransactionWave.REUSSIE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("equals et hashCode")
|
||||
void equalsHashCode() {
|
||||
UUID id = UUID.randomUUID();
|
||||
CampagneCollecte camp = newCampagne();
|
||||
ContributionCollecte a = new ContributionCollecte();
|
||||
a.setId(id);
|
||||
a.setCampagne(camp);
|
||||
a.setMontantSoutien(BigDecimal.ONE);
|
||||
a.setDateContribution(LocalDateTime.now());
|
||||
ContributionCollecte b = new ContributionCollecte();
|
||||
b.setId(id);
|
||||
b.setCampagne(camp);
|
||||
b.setMontantSoutien(BigDecimal.ONE);
|
||||
b.setDateContribution(a.getDateContribution());
|
||||
assertThat(a).isEqualTo(b);
|
||||
assertThat(a.hashCode()).isEqualTo(b.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toString non null")
|
||||
void toString_nonNull() {
|
||||
ContributionCollecte cc = new ContributionCollecte();
|
||||
cc.setCampagne(newCampagne());
|
||||
cc.setMontantSoutien(BigDecimal.ONE);
|
||||
cc.setDateContribution(LocalDateTime.now());
|
||||
assertThat(cc.toString()).isNotNull().isNotEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package dev.lions.unionflow.server.entity.culte;
|
||||
|
||||
import dev.lions.unionflow.server.api.enums.culte.TypeDonReligieux;
|
||||
import dev.lions.unionflow.server.entity.Membre;
|
||||
import dev.lions.unionflow.server.entity.Organisation;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("DonReligieux")
|
||||
class DonReligieuxTest {
|
||||
|
||||
private static Organisation newOrganisation() {
|
||||
Organisation o = new Organisation();
|
||||
o.setId(UUID.randomUUID());
|
||||
o.setNom("Paroisse");
|
||||
o.setTypeOrganisation("X");
|
||||
o.setStatut("ACTIVE");
|
||||
o.setEmail("paroisse@test.com");
|
||||
return o;
|
||||
}
|
||||
|
||||
private static Membre newMembre() {
|
||||
Membre m = new Membre();
|
||||
m.setId(UUID.randomUUID());
|
||||
m.setNumeroMembre("M1");
|
||||
m.setPrenom("A");
|
||||
m.setNom("B");
|
||||
m.setEmail("a@test.com");
|
||||
m.setDateNaissance(java.time.LocalDate.now());
|
||||
return m;
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("getters/setters")
|
||||
void gettersSetters() {
|
||||
DonReligieux d = new DonReligieux();
|
||||
d.setInstitution(newOrganisation());
|
||||
d.setFidele(newMembre());
|
||||
d.setTypeDon(TypeDonReligieux.QUETE_ORDINAIRE);
|
||||
d.setMontant(new BigDecimal("5000"));
|
||||
d.setDateEncaissement(LocalDateTime.now());
|
||||
d.setPeriodeOuNatureAssociee("Dimanche");
|
||||
|
||||
assertThat(d.getTypeDon()).isEqualTo(TypeDonReligieux.QUETE_ORDINAIRE);
|
||||
assertThat(d.getMontant()).isEqualByComparingTo("5000");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("equals et hashCode")
|
||||
void equalsHashCode() {
|
||||
UUID id = UUID.randomUUID();
|
||||
Organisation o = newOrganisation();
|
||||
DonReligieux a = new DonReligieux();
|
||||
a.setId(id);
|
||||
a.setInstitution(o);
|
||||
a.setTypeDon(TypeDonReligieux.QUETE_ORDINAIRE);
|
||||
a.setMontant(BigDecimal.ONE);
|
||||
a.setDateEncaissement(LocalDateTime.now());
|
||||
DonReligieux b = new DonReligieux();
|
||||
b.setId(id);
|
||||
b.setInstitution(o);
|
||||
b.setTypeDon(TypeDonReligieux.QUETE_ORDINAIRE);
|
||||
b.setMontant(BigDecimal.ONE);
|
||||
b.setDateEncaissement(a.getDateEncaissement());
|
||||
assertThat(a).isEqualTo(b);
|
||||
assertThat(a.hashCode()).isEqualTo(b.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toString non null")
|
||||
void toString_nonNull() {
|
||||
DonReligieux d = new DonReligieux();
|
||||
d.setInstitution(newOrganisation());
|
||||
d.setTypeDon(TypeDonReligieux.QUETE_ORDINAIRE);
|
||||
d.setMontant(BigDecimal.ONE);
|
||||
d.setDateEncaissement(LocalDateTime.now());
|
||||
assertThat(d.toString()).isNotNull().isNotEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package dev.lions.unionflow.server.entity.gouvernance;
|
||||
|
||||
import dev.lions.unionflow.server.api.enums.gouvernance.NiveauEchelon;
|
||||
import dev.lions.unionflow.server.entity.Organisation;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("EchelonOrganigramme")
|
||||
class EchelonOrganigrammeTest {
|
||||
|
||||
private static Organisation newOrganisation() {
|
||||
Organisation o = new Organisation();
|
||||
o.setId(UUID.randomUUID());
|
||||
o.setNom("Org");
|
||||
o.setTypeOrganisation("X");
|
||||
o.setStatut("ACTIVE");
|
||||
o.setEmail("org@test.com");
|
||||
return o;
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("getters/setters")
|
||||
void gettersSetters() {
|
||||
EchelonOrganigramme e = new EchelonOrganigramme();
|
||||
e.setOrganisation(newOrganisation());
|
||||
e.setNiveau(NiveauEchelon.NATIONAL);
|
||||
e.setDesignation("Direction générale");
|
||||
e.setZoneGeographiqueOuDelegation("Siège");
|
||||
|
||||
assertThat(e.getNiveau()).isEqualTo(NiveauEchelon.NATIONAL);
|
||||
assertThat(e.getDesignation()).isEqualTo("Direction générale");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("equals et hashCode")
|
||||
void equalsHashCode() {
|
||||
UUID id = UUID.randomUUID();
|
||||
Organisation o = newOrganisation();
|
||||
EchelonOrganigramme a = new EchelonOrganigramme();
|
||||
a.setId(id);
|
||||
a.setOrganisation(o);
|
||||
a.setNiveau(NiveauEchelon.NATIONAL);
|
||||
a.setDesignation("D");
|
||||
EchelonOrganigramme b = new EchelonOrganigramme();
|
||||
b.setId(id);
|
||||
b.setOrganisation(o);
|
||||
b.setNiveau(NiveauEchelon.NATIONAL);
|
||||
b.setDesignation("D");
|
||||
assertThat(a).isEqualTo(b);
|
||||
assertThat(a.hashCode()).isEqualTo(b.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toString non null")
|
||||
void toString_nonNull() {
|
||||
EchelonOrganigramme e = new EchelonOrganigramme();
|
||||
e.setOrganisation(newOrganisation());
|
||||
e.setNiveau(NiveauEchelon.NATIONAL);
|
||||
e.setDesignation("X");
|
||||
assertThat(e.toString()).isNotNull().isNotEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package dev.lions.unionflow.server.entity.listener;
|
||||
|
||||
import dev.lions.unionflow.server.entity.Adresse;
|
||||
import dev.lions.unionflow.server.entity.BaseEntity;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests unitaires pour AuditEntityListener (avantCreation, avantModification, toutes les branches).
|
||||
*/
|
||||
@DisplayName("AuditEntityListener")
|
||||
class AuditEntityListenerTest {
|
||||
|
||||
private final AuditEntityListener listener = new AuditEntityListener();
|
||||
|
||||
@Test
|
||||
@DisplayName("avantCreation: renseigne creePar quand null")
|
||||
void avantCreation_creeParNull_renseigneAvecUtilisateurCourant() {
|
||||
BaseEntity entity = new Adresse();
|
||||
entity.setCreePar(null);
|
||||
|
||||
listener.avantCreation(entity);
|
||||
|
||||
assertThat(entity.getCreePar()).isNotNull().isNotEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("avantCreation: renseigne creePar quand blank")
|
||||
void avantCreation_creeParBlank_renseigneAvecUtilisateurCourant() {
|
||||
BaseEntity entity = new Adresse();
|
||||
entity.setCreePar(" ");
|
||||
|
||||
listener.avantCreation(entity);
|
||||
|
||||
assertThat(entity.getCreePar()).isNotNull().isNotEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("avantCreation: ne modifie pas creePar quand déjà renseigné")
|
||||
void avantCreation_creeParDejaRenseigne_neModifiePas() {
|
||||
BaseEntity entity = new Adresse();
|
||||
entity.setCreePar("deja@test.com");
|
||||
|
||||
listener.avantCreation(entity);
|
||||
|
||||
assertThat(entity.getCreePar()).isEqualTo("deja@test.com");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("avantCreation: ne modifie pas creePar quand chaîne non vide")
|
||||
void avantCreation_creeParNonVide_neModifiePas() {
|
||||
BaseEntity entity = new Adresse();
|
||||
entity.setCreePar("x");
|
||||
|
||||
listener.avantCreation(entity);
|
||||
|
||||
assertThat(entity.getCreePar()).isEqualTo("x");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("avantModification: renseigne toujours modifiePar")
|
||||
void avantModification_renseigneModifiePar() {
|
||||
BaseEntity entity = new Adresse();
|
||||
entity.setModifiePar(null);
|
||||
|
||||
listener.avantModification(entity);
|
||||
|
||||
assertThat(entity.getModifiePar()).isNotNull().isNotEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("avantModification: écrase modifiePar existant")
|
||||
void avantModification_ecraseModifieParExistant() {
|
||||
BaseEntity entity = new Adresse();
|
||||
entity.setModifiePar("ancien@test.com");
|
||||
|
||||
listener.avantModification(entity);
|
||||
|
||||
assertThat(entity.getModifiePar()).isNotNull();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
package dev.lions.unionflow.server.entity.mutuelle.credit;
|
||||
|
||||
import dev.lions.unionflow.server.api.enums.mutuelle.credit.StatutDemandeCredit;
|
||||
import dev.lions.unionflow.server.api.enums.mutuelle.credit.TypeCredit;
|
||||
import dev.lions.unionflow.server.entity.Membre;
|
||||
import dev.lions.unionflow.server.entity.mutuelle.epargne.CompteEpargne;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("DemandeCredit")
|
||||
class DemandeCreditTest {
|
||||
|
||||
private static Membre newMembre() {
|
||||
Membre m = new Membre();
|
||||
m.setId(UUID.randomUUID());
|
||||
m.setNumeroMembre("M1");
|
||||
m.setPrenom("A");
|
||||
m.setNom("B");
|
||||
m.setEmail("a@test.com");
|
||||
m.setDateNaissance(LocalDate.now());
|
||||
return m;
|
||||
}
|
||||
|
||||
private static CompteEpargne newCompteEpargne() {
|
||||
CompteEpargne c = new CompteEpargne();
|
||||
c.setId(UUID.randomUUID());
|
||||
c.setNumeroCompte("CE-001");
|
||||
c.setMembre(newMembre());
|
||||
c.setOrganisation(new dev.lions.unionflow.server.entity.Organisation());
|
||||
c.getOrganisation().setId(UUID.randomUUID());
|
||||
c.getOrganisation().setNom("O");
|
||||
c.getOrganisation().setTypeOrganisation("X");
|
||||
c.getOrganisation().setStatut("ACTIVE");
|
||||
c.getOrganisation().setEmail("o@test.com");
|
||||
c.setTypeCompte(dev.lions.unionflow.server.api.enums.mutuelle.epargne.TypeCompteEpargne.EPARGNE_LIBRE);
|
||||
c.setSoldeActuel(BigDecimal.ZERO);
|
||||
c.setSoldeBloque(BigDecimal.ZERO);
|
||||
c.setStatut(dev.lions.unionflow.server.api.enums.mutuelle.epargne.StatutCompteEpargne.ACTIF);
|
||||
c.setDateOuverture(LocalDate.now());
|
||||
return c;
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("getters/setters")
|
||||
void gettersSetters() {
|
||||
DemandeCredit d = new DemandeCredit();
|
||||
d.setNumeroDossier("DC-2025-001");
|
||||
d.setMembre(newMembre());
|
||||
d.setTypeCredit(TypeCredit.CONSOMMATION);
|
||||
d.setCompteLie(newCompteEpargne());
|
||||
d.setMontantDemande(new BigDecimal("500000"));
|
||||
d.setDureeMoisDemande(12);
|
||||
d.setStatut(StatutDemandeCredit.SOUMISE);
|
||||
d.setDateSoumission(LocalDate.now());
|
||||
|
||||
assertThat(d.getNumeroDossier()).isEqualTo("DC-2025-001");
|
||||
assertThat(d.getTypeCredit()).isEqualTo(TypeCredit.CONSOMMATION);
|
||||
assertThat(d.getMontantDemande()).isEqualByComparingTo("500000");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("equals et hashCode")
|
||||
void equalsHashCode() {
|
||||
UUID id = UUID.randomUUID();
|
||||
Membre m = newMembre();
|
||||
DemandeCredit a = new DemandeCredit();
|
||||
a.setId(id);
|
||||
a.setNumeroDossier("N1");
|
||||
a.setMembre(m);
|
||||
a.setTypeCredit(TypeCredit.CONSOMMATION);
|
||||
a.setMontantDemande(BigDecimal.ONE);
|
||||
a.setDureeMoisDemande(12);
|
||||
a.setStatut(StatutDemandeCredit.SOUMISE);
|
||||
a.setDateSoumission(LocalDate.now());
|
||||
DemandeCredit b = new DemandeCredit();
|
||||
b.setId(id);
|
||||
b.setNumeroDossier("N1");
|
||||
b.setMembre(m);
|
||||
b.setTypeCredit(TypeCredit.CONSOMMATION);
|
||||
b.setMontantDemande(BigDecimal.ONE);
|
||||
b.setDureeMoisDemande(12);
|
||||
b.setStatut(StatutDemandeCredit.SOUMISE);
|
||||
b.setDateSoumission(a.getDateSoumission());
|
||||
assertThat(a).isEqualTo(b);
|
||||
assertThat(a.hashCode()).isEqualTo(b.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toString non null")
|
||||
void toString_nonNull() {
|
||||
DemandeCredit d = new DemandeCredit();
|
||||
d.setNumeroDossier("X");
|
||||
d.setMembre(newMembre());
|
||||
d.setTypeCredit(TypeCredit.CONSOMMATION);
|
||||
d.setMontantDemande(BigDecimal.ONE);
|
||||
d.setDureeMoisDemande(12);
|
||||
d.setStatut(StatutDemandeCredit.SOUMISE);
|
||||
d.setDateSoumission(LocalDate.now());
|
||||
assertThat(d.toString()).isNotNull().isNotEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package dev.lions.unionflow.server.entity.mutuelle.credit;
|
||||
|
||||
import dev.lions.unionflow.server.api.enums.mutuelle.credit.StatutDemandeCredit;
|
||||
import dev.lions.unionflow.server.api.enums.mutuelle.credit.StatutEcheanceCredit;
|
||||
import dev.lions.unionflow.server.entity.Membre;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("EcheanceCredit")
|
||||
class EcheanceCreditTest {
|
||||
|
||||
private static DemandeCredit newDemandeCredit() {
|
||||
Membre m = new Membre();
|
||||
m.setId(UUID.randomUUID());
|
||||
m.setNumeroMembre("M1");
|
||||
m.setPrenom("A");
|
||||
m.setNom("B");
|
||||
m.setEmail("a@test.com");
|
||||
m.setDateNaissance(LocalDate.now());
|
||||
DemandeCredit d = new DemandeCredit();
|
||||
d.setId(UUID.randomUUID());
|
||||
d.setNumeroDossier("DC-1");
|
||||
d.setMembre(m);
|
||||
d.setTypeCredit(dev.lions.unionflow.server.api.enums.mutuelle.credit.TypeCredit.CONSOMMATION);
|
||||
d.setMontantDemande(BigDecimal.valueOf(100000));
|
||||
d.setDureeMoisDemande(12);
|
||||
d.setStatut(StatutDemandeCredit.SOUMISE);
|
||||
d.setDateSoumission(LocalDate.now());
|
||||
return d;
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("getters/setters")
|
||||
void gettersSetters() {
|
||||
EcheanceCredit e = new EcheanceCredit();
|
||||
e.setDemandeCredit(newDemandeCredit());
|
||||
e.setOrdre(1);
|
||||
e.setDateEcheancePrevue(LocalDate.now().plusMonths(1));
|
||||
e.setCapitalAmorti(new BigDecimal("10000"));
|
||||
e.setInteretsDeLaPeriode(new BigDecimal("500"));
|
||||
e.setMontantTotalExigible(new BigDecimal("10500"));
|
||||
e.setCapitalRestantDu(new BigDecimal("90000"));
|
||||
e.setStatut(StatutEcheanceCredit.A_VENIR);
|
||||
|
||||
assertThat(e.getOrdre()).isEqualTo(1);
|
||||
assertThat(e.getStatut()).isEqualTo(StatutEcheanceCredit.A_VENIR);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("equals et hashCode")
|
||||
void equalsHashCode() {
|
||||
UUID id = UUID.randomUUID();
|
||||
DemandeCredit d = newDemandeCredit();
|
||||
EcheanceCredit a = new EcheanceCredit();
|
||||
a.setId(id);
|
||||
a.setDemandeCredit(d);
|
||||
a.setOrdre(1);
|
||||
a.setDateEcheancePrevue(LocalDate.now());
|
||||
a.setCapitalAmorti(BigDecimal.ONE);
|
||||
a.setInteretsDeLaPeriode(BigDecimal.ZERO);
|
||||
a.setMontantTotalExigible(BigDecimal.ONE);
|
||||
a.setCapitalRestantDu(BigDecimal.ONE);
|
||||
a.setStatut(StatutEcheanceCredit.A_VENIR);
|
||||
EcheanceCredit b = new EcheanceCredit();
|
||||
b.setId(id);
|
||||
b.setDemandeCredit(d);
|
||||
b.setOrdre(1);
|
||||
b.setDateEcheancePrevue(a.getDateEcheancePrevue());
|
||||
b.setCapitalAmorti(BigDecimal.ONE);
|
||||
b.setInteretsDeLaPeriode(BigDecimal.ZERO);
|
||||
b.setMontantTotalExigible(BigDecimal.ONE);
|
||||
b.setCapitalRestantDu(BigDecimal.ONE);
|
||||
b.setStatut(StatutEcheanceCredit.A_VENIR);
|
||||
assertThat(a).isEqualTo(b);
|
||||
assertThat(a.hashCode()).isEqualTo(b.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toString non null")
|
||||
void toString_nonNull() {
|
||||
EcheanceCredit e = new EcheanceCredit();
|
||||
e.setDemandeCredit(newDemandeCredit());
|
||||
e.setOrdre(1);
|
||||
e.setDateEcheancePrevue(LocalDate.now());
|
||||
e.setCapitalAmorti(BigDecimal.ONE);
|
||||
e.setInteretsDeLaPeriode(BigDecimal.ZERO);
|
||||
e.setMontantTotalExigible(BigDecimal.ONE);
|
||||
e.setCapitalRestantDu(BigDecimal.ONE);
|
||||
e.setStatut(StatutEcheanceCredit.A_VENIR);
|
||||
assertThat(e.toString()).isNotNull().isNotEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package dev.lions.unionflow.server.entity.mutuelle.credit;
|
||||
|
||||
import dev.lions.unionflow.server.api.enums.mutuelle.credit.StatutDemandeCredit;
|
||||
import dev.lions.unionflow.server.api.enums.mutuelle.credit.TypeGarantie;
|
||||
import dev.lions.unionflow.server.entity.Membre;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("GarantieDemande")
|
||||
class GarantieDemandeTest {
|
||||
|
||||
private static DemandeCredit newDemandeCredit() {
|
||||
Membre m = new Membre();
|
||||
m.setId(UUID.randomUUID());
|
||||
m.setNumeroMembre("M1");
|
||||
m.setPrenom("A");
|
||||
m.setNom("B");
|
||||
m.setEmail("a@test.com");
|
||||
m.setDateNaissance(LocalDate.now());
|
||||
DemandeCredit d = new DemandeCredit();
|
||||
d.setId(UUID.randomUUID());
|
||||
d.setNumeroDossier("DC-1");
|
||||
d.setMembre(m);
|
||||
d.setTypeCredit(dev.lions.unionflow.server.api.enums.mutuelle.credit.TypeCredit.CONSOMMATION);
|
||||
d.setMontantDemande(BigDecimal.valueOf(100000));
|
||||
d.setDureeMoisDemande(12);
|
||||
d.setStatut(StatutDemandeCredit.SOUMISE);
|
||||
d.setDateSoumission(LocalDate.now());
|
||||
return d;
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("getters/setters")
|
||||
void gettersSetters() {
|
||||
GarantieDemande g = new GarantieDemande();
|
||||
g.setDemandeCredit(newDemandeCredit());
|
||||
g.setTypeGarantie(TypeGarantie.CAUTION_SOLIDAIRE);
|
||||
g.setValeurEstimee(new BigDecimal("200000"));
|
||||
g.setReferenceOuDescription("Caution solidaire");
|
||||
|
||||
assertThat(g.getTypeGarantie()).isEqualTo(TypeGarantie.CAUTION_SOLIDAIRE);
|
||||
assertThat(g.getValeurEstimee()).isEqualByComparingTo("200000");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("equals et hashCode")
|
||||
void equalsHashCode() {
|
||||
UUID id = UUID.randomUUID();
|
||||
DemandeCredit d = newDemandeCredit();
|
||||
GarantieDemande a = new GarantieDemande();
|
||||
a.setId(id);
|
||||
a.setDemandeCredit(d);
|
||||
a.setTypeGarantie(TypeGarantie.CAUTION_SOLIDAIRE);
|
||||
GarantieDemande b = new GarantieDemande();
|
||||
b.setId(id);
|
||||
b.setDemandeCredit(d);
|
||||
b.setTypeGarantie(TypeGarantie.CAUTION_SOLIDAIRE);
|
||||
assertThat(a).isEqualTo(b);
|
||||
assertThat(a.hashCode()).isEqualTo(b.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toString non null")
|
||||
void toString_nonNull() {
|
||||
GarantieDemande g = new GarantieDemande();
|
||||
g.setDemandeCredit(newDemandeCredit());
|
||||
g.setTypeGarantie(TypeGarantie.CAUTION_SOLIDAIRE);
|
||||
assertThat(g.toString()).isNotNull().isNotEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package dev.lions.unionflow.server.entity.mutuelle.epargne;
|
||||
|
||||
import dev.lions.unionflow.server.api.enums.mutuelle.epargne.StatutCompteEpargne;
|
||||
import dev.lions.unionflow.server.api.enums.mutuelle.epargne.TypeCompteEpargne;
|
||||
import dev.lions.unionflow.server.entity.Membre;
|
||||
import dev.lions.unionflow.server.entity.Organisation;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("CompteEpargne")
|
||||
class CompteEpargneTest {
|
||||
|
||||
private static Membre newMembre() {
|
||||
Membre m = new Membre();
|
||||
m.setId(UUID.randomUUID());
|
||||
m.setNumeroMembre("M1");
|
||||
m.setPrenom("A");
|
||||
m.setNom("B");
|
||||
m.setEmail("a@test.com");
|
||||
m.setDateNaissance(LocalDate.now());
|
||||
return m;
|
||||
}
|
||||
|
||||
private static Organisation newOrganisation() {
|
||||
Organisation o = new Organisation();
|
||||
o.setId(UUID.randomUUID());
|
||||
o.setNom("Org");
|
||||
o.setTypeOrganisation("X");
|
||||
o.setStatut("ACTIVE");
|
||||
o.setEmail("org@test.com");
|
||||
return o;
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("getters/setters")
|
||||
void gettersSetters() {
|
||||
CompteEpargne c = new CompteEpargne();
|
||||
c.setMembre(newMembre());
|
||||
c.setOrganisation(newOrganisation());
|
||||
c.setNumeroCompte("CE-001");
|
||||
c.setTypeCompte(TypeCompteEpargne.EPARGNE_LIBRE);
|
||||
c.setSoldeActuel(new BigDecimal("100000"));
|
||||
c.setSoldeBloque(BigDecimal.ZERO);
|
||||
c.setStatut(StatutCompteEpargne.ACTIF);
|
||||
c.setDateOuverture(LocalDate.now());
|
||||
|
||||
assertThat(c.getNumeroCompte()).isEqualTo("CE-001");
|
||||
assertThat(c.getTypeCompte()).isEqualTo(TypeCompteEpargne.EPARGNE_LIBRE);
|
||||
assertThat(c.getStatut()).isEqualTo(StatutCompteEpargne.ACTIF);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("equals et hashCode")
|
||||
void equalsHashCode() {
|
||||
UUID id = UUID.randomUUID();
|
||||
Membre m = newMembre();
|
||||
Organisation o = newOrganisation();
|
||||
CompteEpargne a = new CompteEpargne();
|
||||
a.setId(id);
|
||||
a.setMembre(m);
|
||||
a.setOrganisation(o);
|
||||
a.setNumeroCompte("N1");
|
||||
a.setTypeCompte(TypeCompteEpargne.EPARGNE_LIBRE);
|
||||
a.setSoldeActuel(BigDecimal.ZERO);
|
||||
a.setSoldeBloque(BigDecimal.ZERO);
|
||||
a.setStatut(StatutCompteEpargne.ACTIF);
|
||||
a.setDateOuverture(LocalDate.now());
|
||||
CompteEpargne b = new CompteEpargne();
|
||||
b.setId(id);
|
||||
b.setMembre(m);
|
||||
b.setOrganisation(o);
|
||||
b.setNumeroCompte("N1");
|
||||
b.setTypeCompte(TypeCompteEpargne.EPARGNE_LIBRE);
|
||||
b.setSoldeActuel(BigDecimal.ZERO);
|
||||
b.setSoldeBloque(BigDecimal.ZERO);
|
||||
b.setStatut(StatutCompteEpargne.ACTIF);
|
||||
b.setDateOuverture(a.getDateOuverture());
|
||||
assertThat(a).isEqualTo(b);
|
||||
assertThat(a.hashCode()).isEqualTo(b.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toString non null")
|
||||
void toString_nonNull() {
|
||||
CompteEpargne c = new CompteEpargne();
|
||||
c.setMembre(newMembre());
|
||||
c.setOrganisation(newOrganisation());
|
||||
c.setNumeroCompte("X");
|
||||
c.setTypeCompte(TypeCompteEpargne.EPARGNE_LIBRE);
|
||||
c.setSoldeActuel(BigDecimal.ZERO);
|
||||
c.setSoldeBloque(BigDecimal.ZERO);
|
||||
c.setStatut(StatutCompteEpargne.ACTIF);
|
||||
c.setDateOuverture(LocalDate.now());
|
||||
assertThat(c.toString()).isNotNull().isNotEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package dev.lions.unionflow.server.entity.mutuelle.epargne;
|
||||
|
||||
import dev.lions.unionflow.server.api.enums.mutuelle.epargne.TypeTransactionEpargne;
|
||||
import dev.lions.unionflow.server.api.enums.wave.StatutTransactionWave;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("TransactionEpargne")
|
||||
class TransactionEpargneTest {
|
||||
|
||||
private static CompteEpargne newCompte() {
|
||||
dev.lions.unionflow.server.entity.Membre m = new dev.lions.unionflow.server.entity.Membre();
|
||||
m.setId(UUID.randomUUID());
|
||||
m.setNumeroMembre("M1");
|
||||
m.setPrenom("A");
|
||||
m.setNom("B");
|
||||
m.setEmail("a@test.com");
|
||||
m.setDateNaissance(java.time.LocalDate.now());
|
||||
dev.lions.unionflow.server.entity.Organisation o = new dev.lions.unionflow.server.entity.Organisation();
|
||||
o.setId(UUID.randomUUID());
|
||||
o.setNom("O");
|
||||
o.setTypeOrganisation("X");
|
||||
o.setStatut("ACTIVE");
|
||||
o.setEmail("o@test.com");
|
||||
CompteEpargne c = new CompteEpargne();
|
||||
c.setId(UUID.randomUUID());
|
||||
c.setMembre(m);
|
||||
c.setOrganisation(o);
|
||||
c.setNumeroCompte("CE-1");
|
||||
c.setTypeCompte(dev.lions.unionflow.server.api.enums.mutuelle.epargne.TypeCompteEpargne.EPARGNE_LIBRE);
|
||||
c.setSoldeActuel(BigDecimal.ZERO);
|
||||
c.setSoldeBloque(BigDecimal.ZERO);
|
||||
c.setStatut(dev.lions.unionflow.server.api.enums.mutuelle.epargne.StatutCompteEpargne.ACTIF);
|
||||
c.setDateOuverture(java.time.LocalDate.now());
|
||||
return c;
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("getters/setters")
|
||||
void gettersSetters() {
|
||||
TransactionEpargne t = new TransactionEpargne();
|
||||
t.setCompte(newCompte());
|
||||
t.setType(TypeTransactionEpargne.DEPOT);
|
||||
t.setMontant(new BigDecimal("50000"));
|
||||
t.setDateTransaction(LocalDateTime.now());
|
||||
t.setStatutExecution(StatutTransactionWave.REUSSIE);
|
||||
|
||||
assertThat(t.getType()).isEqualTo(TypeTransactionEpargne.DEPOT);
|
||||
assertThat(t.getMontant()).isEqualByComparingTo("50000");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("equals et hashCode")
|
||||
void equalsHashCode() {
|
||||
UUID id = UUID.randomUUID();
|
||||
CompteEpargne compte = newCompte();
|
||||
LocalDateTime dt = LocalDateTime.now();
|
||||
TransactionEpargne a = new TransactionEpargne();
|
||||
a.setId(id);
|
||||
a.setCompte(compte);
|
||||
a.setType(TypeTransactionEpargne.DEPOT);
|
||||
a.setMontant(BigDecimal.ONE);
|
||||
a.setDateTransaction(dt);
|
||||
TransactionEpargne b = new TransactionEpargne();
|
||||
b.setId(id);
|
||||
b.setCompte(compte);
|
||||
b.setType(TypeTransactionEpargne.DEPOT);
|
||||
b.setMontant(BigDecimal.ONE);
|
||||
b.setDateTransaction(dt);
|
||||
assertThat(a).isEqualTo(b);
|
||||
assertThat(a.hashCode()).isEqualTo(b.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toString non null")
|
||||
void toString_nonNull() {
|
||||
TransactionEpargne t = new TransactionEpargne();
|
||||
t.setCompte(newCompte());
|
||||
t.setType(TypeTransactionEpargne.DEPOT);
|
||||
t.setMontant(BigDecimal.ONE);
|
||||
t.setDateTransaction(LocalDateTime.now());
|
||||
assertThat(t.toString()).isNotNull().isNotEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package dev.lions.unionflow.server.entity.ong;
|
||||
|
||||
import dev.lions.unionflow.server.api.enums.ong.StatutProjetOng;
|
||||
import dev.lions.unionflow.server.entity.Organisation;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("ProjetOng")
|
||||
class ProjetOngTest {
|
||||
|
||||
private static Organisation newOrganisation() {
|
||||
Organisation o = new Organisation();
|
||||
o.setId(UUID.randomUUID());
|
||||
o.setNom("ONG");
|
||||
o.setTypeOrganisation("X");
|
||||
o.setStatut("ACTIVE");
|
||||
o.setEmail("ong@test.com");
|
||||
return o;
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("getters/setters")
|
||||
void gettersSetters() {
|
||||
ProjetOng p = new ProjetOng();
|
||||
p.setOrganisation(newOrganisation());
|
||||
p.setNomProjet("Projet santé");
|
||||
p.setDescriptionMandat("Description");
|
||||
p.setZoneGeographiqueIntervention("Abidjan");
|
||||
p.setBudgetPrevisionnel(new BigDecimal("5000000"));
|
||||
p.setDepensesReelles(new BigDecimal("1000000"));
|
||||
p.setStatut(StatutProjetOng.EN_COURS);
|
||||
p.setDateLancement(LocalDate.now());
|
||||
|
||||
assertThat(p.getNomProjet()).isEqualTo("Projet santé");
|
||||
assertThat(p.getStatut()).isEqualTo(StatutProjetOng.EN_COURS);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("equals et hashCode")
|
||||
void equalsHashCode() {
|
||||
UUID id = UUID.randomUUID();
|
||||
Organisation o = newOrganisation();
|
||||
ProjetOng a = new ProjetOng();
|
||||
a.setId(id);
|
||||
a.setOrganisation(o);
|
||||
a.setNomProjet("P");
|
||||
a.setStatut(StatutProjetOng.EN_ETUDE);
|
||||
ProjetOng b = new ProjetOng();
|
||||
b.setId(id);
|
||||
b.setOrganisation(o);
|
||||
b.setNomProjet("P");
|
||||
b.setStatut(StatutProjetOng.EN_ETUDE);
|
||||
assertThat(a).isEqualTo(b);
|
||||
assertThat(a.hashCode()).isEqualTo(b.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toString non null")
|
||||
void toString_nonNull() {
|
||||
ProjetOng p = new ProjetOng();
|
||||
p.setOrganisation(newOrganisation());
|
||||
p.setNomProjet("X");
|
||||
p.setStatut(StatutProjetOng.EN_ETUDE);
|
||||
assertThat(p.toString()).isNotNull().isNotEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package dev.lions.unionflow.server.entity.registre;
|
||||
|
||||
import dev.lions.unionflow.server.api.enums.registre.StatutAgrement;
|
||||
import dev.lions.unionflow.server.entity.Membre;
|
||||
import dev.lions.unionflow.server.entity.Organisation;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("AgrementProfessionnel")
|
||||
class AgrementProfessionnelTest {
|
||||
|
||||
private static Membre newMembre() {
|
||||
Membre m = new Membre();
|
||||
m.setId(UUID.randomUUID());
|
||||
m.setNumeroMembre("M1");
|
||||
m.setPrenom("A");
|
||||
m.setNom("B");
|
||||
m.setEmail("a@test.com");
|
||||
m.setDateNaissance(LocalDate.now());
|
||||
return m;
|
||||
}
|
||||
|
||||
private static Organisation newOrganisation() {
|
||||
Organisation o = new Organisation();
|
||||
o.setId(UUID.randomUUID());
|
||||
o.setNom("Org");
|
||||
o.setTypeOrganisation("X");
|
||||
o.setStatut("ACTIVE");
|
||||
o.setEmail("org@test.com");
|
||||
return o;
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("getters/setters")
|
||||
void gettersSetters() {
|
||||
AgrementProfessionnel a = new AgrementProfessionnel();
|
||||
a.setMembre(newMembre());
|
||||
a.setOrganisation(newOrganisation());
|
||||
a.setSecteurOuOrdre("Médecine");
|
||||
a.setNumeroLicenceOuRegistre("LIC-123");
|
||||
a.setDateDelivrance(LocalDate.now());
|
||||
a.setDateExpiration(LocalDate.now().plusYears(5));
|
||||
a.setStatut(StatutAgrement.VALIDE);
|
||||
|
||||
assertThat(a.getSecteurOuOrdre()).isEqualTo("Médecine");
|
||||
assertThat(a.getStatut()).isEqualTo(StatutAgrement.VALIDE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("equals et hashCode")
|
||||
void equalsHashCode() {
|
||||
UUID id = UUID.randomUUID();
|
||||
Membre m = newMembre();
|
||||
Organisation o = newOrganisation();
|
||||
AgrementProfessionnel a = new AgrementProfessionnel();
|
||||
a.setId(id);
|
||||
a.setMembre(m);
|
||||
a.setOrganisation(o);
|
||||
a.setStatut(StatutAgrement.PROVISOIRE);
|
||||
AgrementProfessionnel b = new AgrementProfessionnel();
|
||||
b.setId(id);
|
||||
b.setMembre(m);
|
||||
b.setOrganisation(o);
|
||||
b.setStatut(StatutAgrement.PROVISOIRE);
|
||||
assertThat(a).isEqualTo(b);
|
||||
assertThat(a.hashCode()).isEqualTo(b.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toString non null")
|
||||
void toString_nonNull() {
|
||||
AgrementProfessionnel a = new AgrementProfessionnel();
|
||||
a.setMembre(newMembre());
|
||||
a.setOrganisation(newOrganisation());
|
||||
a.setStatut(StatutAgrement.PROVISOIRE);
|
||||
assertThat(a.toString()).isNotNull().isNotEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package dev.lions.unionflow.server.entity.tontine;
|
||||
|
||||
import dev.lions.unionflow.server.api.enums.tontine.FrequenceTour;
|
||||
import dev.lions.unionflow.server.api.enums.tontine.StatutTontine;
|
||||
import dev.lions.unionflow.server.api.enums.tontine.TypeTontine;
|
||||
import dev.lions.unionflow.server.entity.Organisation;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("Tontine")
|
||||
class TontineTest {
|
||||
|
||||
private static Organisation newOrganisation() {
|
||||
Organisation o = new Organisation();
|
||||
o.setId(UUID.randomUUID());
|
||||
o.setNom("Org");
|
||||
o.setTypeOrganisation("X");
|
||||
o.setStatut("ACTIVE");
|
||||
o.setEmail("org@test.com");
|
||||
return o;
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("getters/setters")
|
||||
void gettersSetters() {
|
||||
Tontine t = new Tontine();
|
||||
t.setNom("Tontine mensuelle");
|
||||
t.setDescription("Description");
|
||||
t.setOrganisation(newOrganisation());
|
||||
t.setTypeTontine(TypeTontine.ROTATIVE_CLASSIQUE);
|
||||
t.setFrequence(FrequenceTour.MENSUELLE);
|
||||
t.setStatut(StatutTontine.EN_COURS);
|
||||
t.setMontantMiseParTour(new BigDecimal("10000"));
|
||||
t.setLimiteParticipants(20);
|
||||
|
||||
assertThat(t.getNom()).isEqualTo("Tontine mensuelle");
|
||||
assertThat(t.getTypeTontine()).isEqualTo(TypeTontine.ROTATIVE_CLASSIQUE);
|
||||
assertThat(t.getFrequence()).isEqualTo(FrequenceTour.MENSUELLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("equals et hashCode")
|
||||
void equalsHashCode() {
|
||||
UUID id = UUID.randomUUID();
|
||||
Organisation o = newOrganisation();
|
||||
Tontine a = new Tontine();
|
||||
a.setId(id);
|
||||
a.setNom("N");
|
||||
a.setOrganisation(o);
|
||||
a.setTypeTontine(TypeTontine.ROTATIVE_CLASSIQUE);
|
||||
a.setFrequence(FrequenceTour.MENSUELLE);
|
||||
a.setStatut(StatutTontine.PLANIFIEE);
|
||||
Tontine b = new Tontine();
|
||||
b.setId(id);
|
||||
b.setNom("N");
|
||||
b.setOrganisation(o);
|
||||
b.setTypeTontine(TypeTontine.ROTATIVE_CLASSIQUE);
|
||||
b.setFrequence(FrequenceTour.MENSUELLE);
|
||||
b.setStatut(StatutTontine.PLANIFIEE);
|
||||
assertThat(a).isEqualTo(b);
|
||||
assertThat(a.hashCode()).isEqualTo(b.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toString non null")
|
||||
void toString_nonNull() {
|
||||
Tontine t = new Tontine();
|
||||
t.setNom("X");
|
||||
t.setOrganisation(newOrganisation());
|
||||
t.setTypeTontine(TypeTontine.ROTATIVE_CLASSIQUE);
|
||||
t.setFrequence(FrequenceTour.MENSUELLE);
|
||||
t.setStatut(StatutTontine.PLANIFIEE);
|
||||
assertThat(t.toString()).isNotNull().isNotEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package dev.lions.unionflow.server.entity.tontine;
|
||||
|
||||
import dev.lions.unionflow.server.api.enums.tontine.FrequenceTour;
|
||||
import dev.lions.unionflow.server.api.enums.tontine.StatutTontine;
|
||||
import dev.lions.unionflow.server.api.enums.tontine.TypeTontine;
|
||||
import dev.lions.unionflow.server.entity.Membre;
|
||||
import dev.lions.unionflow.server.entity.Organisation;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("TourTontine")
|
||||
class TourTontineTest {
|
||||
|
||||
private static Tontine newTontine() {
|
||||
Organisation o = new Organisation();
|
||||
o.setId(UUID.randomUUID());
|
||||
o.setNom("Org");
|
||||
o.setTypeOrganisation("X");
|
||||
o.setStatut("ACTIVE");
|
||||
o.setEmail("org@test.com");
|
||||
Tontine t = new Tontine();
|
||||
t.setId(UUID.randomUUID());
|
||||
t.setNom("T");
|
||||
t.setOrganisation(o);
|
||||
t.setTypeTontine(TypeTontine.ROTATIVE_CLASSIQUE);
|
||||
t.setFrequence(FrequenceTour.MENSUELLE);
|
||||
t.setStatut(StatutTontine.PLANIFIEE);
|
||||
return t;
|
||||
}
|
||||
|
||||
private static Membre newMembre() {
|
||||
Membre m = new Membre();
|
||||
m.setId(UUID.randomUUID());
|
||||
m.setNumeroMembre("M1");
|
||||
m.setPrenom("A");
|
||||
m.setNom("B");
|
||||
m.setEmail("a@test.com");
|
||||
m.setDateNaissance(LocalDate.now());
|
||||
return m;
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("getters/setters")
|
||||
void gettersSetters() {
|
||||
TourTontine tour = new TourTontine();
|
||||
tour.setTontine(newTontine());
|
||||
tour.setOrdreTour(1);
|
||||
tour.setDateOuvertureCotisations(LocalDate.now());
|
||||
tour.setMontantCible(new BigDecimal("200000"));
|
||||
tour.setCagnotteCollectee(BigDecimal.ZERO);
|
||||
tour.setMembreBeneficiaire(newMembre());
|
||||
|
||||
assertThat(tour.getOrdreTour()).isEqualTo(1);
|
||||
assertThat(tour.getMontantCible()).isEqualByComparingTo("200000");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("equals et hashCode")
|
||||
void equalsHashCode() {
|
||||
UUID id = UUID.randomUUID();
|
||||
Tontine t = newTontine();
|
||||
LocalDate date = LocalDate.now();
|
||||
TourTontine a = new TourTontine();
|
||||
a.setId(id);
|
||||
a.setTontine(t);
|
||||
a.setOrdreTour(1);
|
||||
a.setDateOuvertureCotisations(date);
|
||||
a.setMontantCible(BigDecimal.ONE);
|
||||
a.setCagnotteCollectee(BigDecimal.ZERO);
|
||||
TourTontine b = new TourTontine();
|
||||
b.setId(id);
|
||||
b.setTontine(t);
|
||||
b.setOrdreTour(1);
|
||||
b.setDateOuvertureCotisations(date);
|
||||
b.setMontantCible(BigDecimal.ONE);
|
||||
b.setCagnotteCollectee(BigDecimal.ZERO);
|
||||
assertThat(a).isEqualTo(b);
|
||||
assertThat(a.hashCode()).isEqualTo(b.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toString non null")
|
||||
void toString_nonNull() {
|
||||
TourTontine tour = new TourTontine();
|
||||
tour.setTontine(newTontine());
|
||||
tour.setOrdreTour(1);
|
||||
tour.setDateOuvertureCotisations(LocalDate.now());
|
||||
tour.setMontantCible(BigDecimal.ONE);
|
||||
tour.setCagnotteCollectee(BigDecimal.ZERO);
|
||||
assertThat(tour.toString()).isNotNull().isNotEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package dev.lions.unionflow.server.entity.vote;
|
||||
|
||||
import dev.lions.unionflow.server.api.enums.vote.ModeScrutin;
|
||||
import dev.lions.unionflow.server.api.enums.vote.StatutVote;
|
||||
import dev.lions.unionflow.server.api.enums.vote.TypeVote;
|
||||
import dev.lions.unionflow.server.entity.Organisation;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("CampagneVote")
|
||||
class CampagneVoteTest {
|
||||
|
||||
private static Organisation newOrganisation() {
|
||||
Organisation o = new Organisation();
|
||||
o.setId(UUID.randomUUID());
|
||||
o.setNom("Org");
|
||||
o.setTypeOrganisation("X");
|
||||
o.setStatut("ACTIVE");
|
||||
o.setEmail("org@test.com");
|
||||
return o;
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("getters/setters")
|
||||
void gettersSetters() {
|
||||
LocalDateTime ouverture = LocalDateTime.now();
|
||||
LocalDateTime fermeture = LocalDateTime.now().plusDays(7);
|
||||
CampagneVote c = new CampagneVote();
|
||||
c.setTitre("Élection bureau");
|
||||
c.setDescriptionOuResolution("Description");
|
||||
c.setOrganisation(newOrganisation());
|
||||
c.setTypeVote(TypeVote.ELECTION_BUREAU);
|
||||
c.setModeScrutin(ModeScrutin.MAJORITAIRE_UN_TOUR);
|
||||
c.setStatut(StatutVote.OUVERT);
|
||||
c.setDateOuverture(ouverture);
|
||||
c.setDateFermeture(fermeture);
|
||||
c.setRestreindreMembresAJour(true);
|
||||
c.setAutoriserVoteBlanc(true);
|
||||
|
||||
assertThat(c.getTitre()).isEqualTo("Élection bureau");
|
||||
assertThat(c.getTypeVote()).isEqualTo(TypeVote.ELECTION_BUREAU);
|
||||
assertThat(c.getStatut()).isEqualTo(StatutVote.OUVERT);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("equals et hashCode")
|
||||
void equalsHashCode() {
|
||||
UUID id = UUID.randomUUID();
|
||||
Organisation o = newOrganisation();
|
||||
LocalDateTime ouverture = LocalDateTime.now();
|
||||
LocalDateTime fermeture = ouverture.plusDays(1);
|
||||
CampagneVote a = new CampagneVote();
|
||||
a.setId(id);
|
||||
a.setTitre("T");
|
||||
a.setOrganisation(o);
|
||||
a.setTypeVote(TypeVote.ELECTION_BUREAU);
|
||||
a.setModeScrutin(ModeScrutin.MAJORITAIRE_UN_TOUR);
|
||||
a.setStatut(StatutVote.BROUILLON);
|
||||
a.setDateOuverture(ouverture);
|
||||
a.setDateFermeture(fermeture);
|
||||
CampagneVote b = new CampagneVote();
|
||||
b.setId(id);
|
||||
b.setTitre("T");
|
||||
b.setOrganisation(o);
|
||||
b.setTypeVote(TypeVote.ELECTION_BUREAU);
|
||||
b.setModeScrutin(ModeScrutin.MAJORITAIRE_UN_TOUR);
|
||||
b.setStatut(StatutVote.BROUILLON);
|
||||
b.setDateOuverture(ouverture);
|
||||
b.setDateFermeture(fermeture);
|
||||
assertThat(a).isEqualTo(b);
|
||||
assertThat(a.hashCode()).isEqualTo(b.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toString non null")
|
||||
void toString_nonNull() {
|
||||
CampagneVote c = new CampagneVote();
|
||||
c.setTitre("X");
|
||||
c.setOrganisation(newOrganisation());
|
||||
c.setTypeVote(TypeVote.ELECTION_BUREAU);
|
||||
c.setModeScrutin(ModeScrutin.MAJORITAIRE_UN_TOUR);
|
||||
c.setStatut(StatutVote.BROUILLON);
|
||||
c.setDateOuverture(LocalDateTime.now());
|
||||
c.setDateFermeture(LocalDateTime.now().plusDays(1));
|
||||
assertThat(c.toString()).isNotNull().isNotEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package dev.lions.unionflow.server.entity.vote;
|
||||
|
||||
import dev.lions.unionflow.server.api.enums.vote.ModeScrutin;
|
||||
import dev.lions.unionflow.server.api.enums.vote.StatutVote;
|
||||
import dev.lions.unionflow.server.api.enums.vote.TypeVote;
|
||||
import dev.lions.unionflow.server.entity.Organisation;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("Candidat")
|
||||
class CandidatTest {
|
||||
|
||||
private static CampagneVote newCampagneVote() {
|
||||
Organisation o = new Organisation();
|
||||
o.setId(UUID.randomUUID());
|
||||
o.setNom("Org");
|
||||
o.setTypeOrganisation("X");
|
||||
o.setStatut("ACTIVE");
|
||||
o.setEmail("org@test.com");
|
||||
CampagneVote c = new CampagneVote();
|
||||
c.setId(UUID.randomUUID());
|
||||
c.setTitre("Campagne");
|
||||
c.setOrganisation(o);
|
||||
c.setTypeVote(TypeVote.ELECTION_BUREAU);
|
||||
c.setModeScrutin(ModeScrutin.MAJORITAIRE_UN_TOUR);
|
||||
c.setStatut(StatutVote.OUVERT);
|
||||
c.setDateOuverture(LocalDateTime.now());
|
||||
c.setDateFermeture(LocalDateTime.now().plusDays(1));
|
||||
return c;
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("getters/setters")
|
||||
void gettersSetters() {
|
||||
Candidat cand = new Candidat();
|
||||
cand.setCampagneVote(newCampagneVote());
|
||||
cand.setNomCandidatureOuChoix("Jean Dupont");
|
||||
cand.setProfessionDeFoi("Profession de foi");
|
||||
cand.setNombreDeVoix(10);
|
||||
cand.setPourcentageObtenu(new BigDecimal("25.50"));
|
||||
|
||||
assertThat(cand.getNomCandidatureOuChoix()).isEqualTo("Jean Dupont");
|
||||
assertThat(cand.getNombreDeVoix()).isEqualTo(10);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("equals et hashCode")
|
||||
void equalsHashCode() {
|
||||
UUID id = UUID.randomUUID();
|
||||
CampagneVote camp = newCampagneVote();
|
||||
Candidat a = new Candidat();
|
||||
a.setId(id);
|
||||
a.setCampagneVote(camp);
|
||||
a.setNomCandidatureOuChoix("C1");
|
||||
Candidat b = new Candidat();
|
||||
b.setId(id);
|
||||
b.setCampagneVote(camp);
|
||||
b.setNomCandidatureOuChoix("C1");
|
||||
assertThat(a).isEqualTo(b);
|
||||
assertThat(a.hashCode()).isEqualTo(b.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toString non null")
|
||||
void toString_nonNull() {
|
||||
Candidat cand = new Candidat();
|
||||
cand.setCampagneVote(newCampagneVote());
|
||||
cand.setNomCandidatureOuChoix("X");
|
||||
assertThat(cand.toString()).isNotNull().isNotEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package dev.lions.unionflow.server.exception;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.quarkus.test.security.TestSecurity;
|
||||
import io.restassured.http.ContentType;
|
||||
import java.util.UUID;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@QuarkusTest
|
||||
class BusinessExceptionMapperTest {
|
||||
|
||||
@Test
|
||||
@TestSecurity(user = "admin@unionflow.com", roles = { "ADMIN" })
|
||||
@DisplayName("IllegalArgumentException → 400 + body error/message")
|
||||
void toResponse_IllegalArgumentException_returns400() {
|
||||
given()
|
||||
.contentType(ContentType.JSON)
|
||||
.body("{}")
|
||||
.when()
|
||||
.post("/api/membres/search/advanced")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body("error", equalTo("Requête invalide"))
|
||||
.body("message", notNullValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestSecurity(user = "admin@unionflow.com", roles = { "ADMIN" })
|
||||
@DisplayName("NotFoundException → 404 + body error/message")
|
||||
void toResponse_NotFoundException_returns404() {
|
||||
given()
|
||||
.pathParam("id", UUID.randomUUID())
|
||||
.when()
|
||||
.get("/api/membres/{id}")
|
||||
.then()
|
||||
.statusCode(404)
|
||||
.body("error", equalTo("Non trouvé"))
|
||||
.body("message", notNullValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestSecurity(user = "admin@unionflow.com", roles = { "ADMIN" })
|
||||
@DisplayName("NotFoundException événement → 404")
|
||||
void toResponse_NotFoundException_event_returns404() {
|
||||
given()
|
||||
.pathParam("id", UUID.randomUUID())
|
||||
.when()
|
||||
.get("/api/evenements/{id}")
|
||||
.then()
|
||||
.statusCode(404)
|
||||
.body("error", equalTo("Non trouvé"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestSecurity(user = "admin@unionflow.com", roles = { "ADMIN" })
|
||||
@DisplayName("NotFoundException organisation → 404")
|
||||
void toResponse_NotFoundException_organisation_returns404() {
|
||||
given()
|
||||
.pathParam("id", UUID.randomUUID())
|
||||
.when()
|
||||
.get("/api/organisations/{id}")
|
||||
.then()
|
||||
.statusCode(404)
|
||||
.body("error", equalTo("Non trouvé"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,237 @@
|
||||
package dev.lions.unionflow.server.exception;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonParseException;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import com.fasterxml.jackson.databind.exc.InvalidFormatException;
|
||||
import com.fasterxml.jackson.databind.exc.MismatchedInputException;
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.BadRequestException;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Tests du {@link GlobalExceptionMapper} : vérification des réponses HTTP
|
||||
* selon le type d'exception, en appelant le mapper directement pour limiter
|
||||
* le bruit (filtres, OIDC) et les appels REST superflus.
|
||||
*/
|
||||
@QuarkusTest
|
||||
class GlobalExceptionMapperTest {
|
||||
|
||||
@Inject
|
||||
GlobalExceptionMapper globalExceptionMapper;
|
||||
|
||||
@Nested
|
||||
@DisplayName("Appel direct au mapper")
|
||||
class MapperDirect {
|
||||
|
||||
@Test
|
||||
@DisplayName("RuntimeException générique → 500")
|
||||
void mapRuntimeException_otherRuntime_returns500() {
|
||||
Response r = globalExceptionMapper.mapRuntimeException(new RuntimeException("inattendu"));
|
||||
assertThat(r.getStatus()).isEqualTo(500);
|
||||
assertThat(r.getEntity()).isNotNull();
|
||||
@SuppressWarnings("unchecked")
|
||||
java.util.Map<String, Object> body = (java.util.Map<String, Object>) r.getEntity();
|
||||
assertThat(body.get("error")).isEqualTo("Erreur interne");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("IllegalArgumentException → 400")
|
||||
void mapRuntimeException_illegalArgument_returns400() {
|
||||
Response r = globalExceptionMapper.mapRuntimeException(new IllegalArgumentException("critère manquant"));
|
||||
assertThat(r.getStatus()).isEqualTo(400);
|
||||
assertThat(r.getEntity()).isNotNull();
|
||||
@SuppressWarnings("unchecked")
|
||||
java.util.Map<String, Object> body = (java.util.Map<String, Object>) r.getEntity();
|
||||
assertThat(body.get("error")).isEqualTo("Requête invalide");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("IllegalStateException → 409")
|
||||
void mapRuntimeException_illegalState_returns409() {
|
||||
Response r = globalExceptionMapper.mapRuntimeException(new IllegalStateException("déjà existant"));
|
||||
assertThat(r.getStatus()).isEqualTo(409);
|
||||
@SuppressWarnings("unchecked")
|
||||
java.util.Map<String, Object> body = (java.util.Map<String, Object>) r.getEntity();
|
||||
assertThat(body.get("error")).isEqualTo("Conflit");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("NotFoundException → 404")
|
||||
void mapRuntimeException_notFound_returns404() {
|
||||
Response r = globalExceptionMapper.mapRuntimeException(
|
||||
new jakarta.ws.rs.NotFoundException("Ressource introuvable"));
|
||||
assertThat(r.getStatus()).isEqualTo(404);
|
||||
@SuppressWarnings("unchecked")
|
||||
java.util.Map<String, Object> body = (java.util.Map<String, Object>) r.getEntity();
|
||||
assertThat(body.get("error")).isEqualTo("Non trouvé");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("WebApplicationException 400 avec message non vide → 400")
|
||||
void mapRuntimeException_webApp4xx_withMessage_returns4xx() {
|
||||
Response r = globalExceptionMapper.mapRuntimeException(
|
||||
new jakarta.ws.rs.WebApplicationException("Bad Request", jakarta.ws.rs.core.Response.status(400).build()));
|
||||
assertThat(r.getStatus()).isEqualTo(400);
|
||||
@SuppressWarnings("unchecked")
|
||||
java.util.Map<String, Object> body = (java.util.Map<String, Object>) r.getEntity();
|
||||
assertThat(body.get("error")).isEqualTo("Erreur Client");
|
||||
assertThat(body.get("message")).isEqualTo("Bad Request");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("WebApplicationException 404 avec message null → Détails non disponibles")
|
||||
void mapRuntimeException_webApp4xx_messageNull_returnsDetailsNonDisponibles() {
|
||||
Response r = globalExceptionMapper.mapRuntimeException(
|
||||
new jakarta.ws.rs.WebApplicationException((String) null, jakarta.ws.rs.core.Response.status(404).build()));
|
||||
assertThat(r.getStatus()).isEqualTo(404);
|
||||
@SuppressWarnings("unchecked")
|
||||
java.util.Map<String, Object> body = (java.util.Map<String, Object>) r.getEntity();
|
||||
assertThat(body.get("error")).isEqualTo("Erreur Client");
|
||||
assertThat(body.get("message")).isEqualTo("Détails non disponibles");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("WebApplicationException 403 avec message vide → Détails non disponibles")
|
||||
void mapRuntimeException_webApp4xx_messageEmpty_returnsDetailsNonDisponibles() {
|
||||
Response r = globalExceptionMapper.mapRuntimeException(
|
||||
new jakarta.ws.rs.WebApplicationException("", jakarta.ws.rs.core.Response.status(403).build()));
|
||||
assertThat(r.getStatus()).isEqualTo(403);
|
||||
@SuppressWarnings("unchecked")
|
||||
java.util.Map<String, Object> body = (java.util.Map<String, Object>) r.getEntity();
|
||||
assertThat(body.get("message")).isEqualTo("Détails non disponibles");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("WebApplicationException 500 → pas dans 4xx, fallback 500")
|
||||
void mapRuntimeException_webApp5xx_fallbackTo500() {
|
||||
Response r = globalExceptionMapper.mapRuntimeException(
|
||||
new jakarta.ws.rs.WebApplicationException("Server Error", jakarta.ws.rs.core.Response.status(500).build()));
|
||||
assertThat(r.getStatus()).isEqualTo(500);
|
||||
@SuppressWarnings("unchecked")
|
||||
java.util.Map<String, Object> body = (java.util.Map<String, Object>) r.getEntity();
|
||||
assertThat(body.get("error")).isEqualTo("Erreur interne");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("WebApplicationException 399 → pas 4xx client, fallback 500")
|
||||
void mapRuntimeException_webApp399_fallbackTo500() {
|
||||
Response r = globalExceptionMapper.mapRuntimeException(
|
||||
new jakarta.ws.rs.WebApplicationException("OK", jakarta.ws.rs.core.Response.status(399).build()));
|
||||
assertThat(r.getStatus()).isEqualTo(500);
|
||||
assertThat(((java.util.Map<?, ?>) r.getEntity()).get("error")).isEqualTo("Erreur interne");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("BadRequestException → 400")
|
||||
void mapBadRequestException_returns400() {
|
||||
Response r = globalExceptionMapper.mapBadRequestException(new BadRequestException("requête mal formée"));
|
||||
assertThat(r.getStatus()).isEqualTo(400);
|
||||
assertThat(r.getEntity()).isNotNull();
|
||||
@SuppressWarnings("unchecked")
|
||||
java.util.Map<String, Object> body = (java.util.Map<String, Object>) r.getEntity();
|
||||
assertThat(body.get("message")).isEqualTo("requête mal formée");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("BadRequestException avec message null → buildResponse utilise error pour message")
|
||||
void mapBadRequestException_nullMessage_usesErrorAsMessage() {
|
||||
Response r = globalExceptionMapper.mapBadRequestException(new BadRequestException((String) null));
|
||||
assertThat(r.getStatus()).isEqualTo(400);
|
||||
@SuppressWarnings("unchecked")
|
||||
java.util.Map<String, Object> body = (java.util.Map<String, Object>) r.getEntity();
|
||||
assertThat(body.get("error")).isEqualTo("Requête mal formée");
|
||||
assertThat(body.get("message")).isEqualTo("Requête mal formée");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@DisplayName("mapJsonException - tous les types")
|
||||
class MapJsonException {
|
||||
|
||||
/** Sous-classe pour appeler le constructeur protégé MismatchedInputException(JsonParser, String). */
|
||||
private static final class StubMismatchedInputException extends MismatchedInputException {
|
||||
StubMismatchedInputException() {
|
||||
super((JsonParser) null, "msg");
|
||||
}
|
||||
}
|
||||
|
||||
/** Sous-classe pour appeler le constructeur protégé InvalidFormatException(JsonParser, String, Object, Class). */
|
||||
private static final class StubInvalidFormatException extends InvalidFormatException {
|
||||
StubInvalidFormatException() {
|
||||
super((JsonParser) null, "invalid", null, (Class<?>) null);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("MismatchedInputException → message spécifique")
|
||||
void mapJsonException_mismatchedInput() {
|
||||
Response r = globalExceptionMapper.mapJsonException(new StubMismatchedInputException());
|
||||
assertThat(r.getStatus()).isEqualTo(400);
|
||||
@SuppressWarnings("unchecked")
|
||||
java.util.Map<String, Object> body = (java.util.Map<String, Object>) r.getEntity();
|
||||
assertThat(body.get("message")).isEqualTo("Format JSON invalide ou body manquant");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("InvalidFormatException → message spécifique")
|
||||
void mapJsonException_invalidFormat() {
|
||||
Response r = globalExceptionMapper.mapJsonException(new StubInvalidFormatException());
|
||||
assertThat(r.getStatus()).isEqualTo(400);
|
||||
@SuppressWarnings("unchecked")
|
||||
java.util.Map<String, Object> body = (java.util.Map<String, Object>) r.getEntity();
|
||||
assertThat(body.get("message")).isEqualTo("Format de données invalide dans le JSON");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("JsonMappingException → message spécifique")
|
||||
void mapJsonException_jsonMapping() {
|
||||
Response r = globalExceptionMapper.mapJsonException(new JsonMappingException(null, "mapping"));
|
||||
assertThat(r.getStatus()).isEqualTo(400);
|
||||
@SuppressWarnings("unchecked")
|
||||
java.util.Map<String, Object> body = (java.util.Map<String, Object>) r.getEntity();
|
||||
assertThat(body.get("message")).isEqualTo("Erreur de mapping JSON");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("JsonProcessingException / cas par défaut → Erreur de format JSON")
|
||||
void mapJsonException_jsonProcessing() {
|
||||
Response r = globalExceptionMapper.mapJsonException(new JsonParseException(null, "parse error"));
|
||||
assertThat(r.getStatus()).isEqualTo(400);
|
||||
@SuppressWarnings("unchecked")
|
||||
java.util.Map<String, Object> body = (java.util.Map<String, Object>) r.getEntity();
|
||||
assertThat(body.get("message")).isEqualTo("Erreur de format JSON");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@DisplayName("buildResponse - branches message/details null")
|
||||
class BuildResponseBranches {
|
||||
|
||||
@Test
|
||||
@DisplayName("buildResponse(3 args) avec message null → message = error")
|
||||
void buildResponse_threeArgs_messageNull() {
|
||||
Response r = globalExceptionMapper.mapBadRequestException(new BadRequestException((String) null));
|
||||
@SuppressWarnings("unchecked")
|
||||
java.util.Map<String, Object> body = (java.util.Map<String, Object>) r.getEntity();
|
||||
assertThat(body.get("message")).isEqualTo(body.get("error"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("buildResponse(4 args) avec details null → details = message ou error")
|
||||
void buildResponse_fourArgs_detailsNull() {
|
||||
Response r = globalExceptionMapper.mapJsonException(new JsonParseException(null, "detail"));
|
||||
@SuppressWarnings("unchecked")
|
||||
java.util.Map<String, Object> body = (java.util.Map<String, Object>) r.getEntity();
|
||||
assertThat(body).containsKey("details");
|
||||
assertThat(body.get("details")).isEqualTo("detail");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package dev.lions.unionflow.server.exception;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.quarkus.test.security.TestSecurity;
|
||||
import io.restassured.http.ContentType;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@QuarkusTest
|
||||
class JsonProcessingExceptionMapperTest {
|
||||
|
||||
@Test
|
||||
@TestSecurity(user = "admin@unionflow.com", roles = { "ADMIN" })
|
||||
@DisplayName("JSON invalide (body mal formé) → 400 + message")
|
||||
void toResponse_invalidJson_returns400() {
|
||||
given()
|
||||
.contentType(ContentType.JSON)
|
||||
.body("{ invalid json }")
|
||||
.when()
|
||||
.post("/api/evenements")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body("message", notNullValue())
|
||||
.body("details", notNullValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestSecurity(user = "admin@unionflow.com", roles = { "ADMIN" })
|
||||
@DisplayName("Body vide ou type incorrect → 400")
|
||||
void toResponse_mismatchedInput_returns400() {
|
||||
given()
|
||||
.contentType(ContentType.JSON)
|
||||
.body("[]")
|
||||
.when()
|
||||
.post("/api/evenements")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body("message", anyOf(containsString("JSON"), containsString("format")));
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestSecurity(user = "admin@unionflow.com", roles = { "ADMIN" })
|
||||
@DisplayName("Format de données invalide (type) → 400")
|
||||
void toResponse_invalidFormat_returns400() {
|
||||
given()
|
||||
.contentType(ContentType.JSON)
|
||||
.body("{\"titre\":\"x\",\"capaciteMax\":\"not-a-number\"}")
|
||||
.when()
|
||||
.post("/api/evenements")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body("message", notNullValue());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,206 @@
|
||||
package dev.lions.unionflow.server.integration;
|
||||
|
||||
import dev.lions.unionflow.server.entity.Cotisation;
|
||||
import dev.lions.unionflow.server.entity.Membre;
|
||||
import dev.lions.unionflow.server.entity.Organisation;
|
||||
import dev.lions.unionflow.server.repository.CotisationRepository;
|
||||
import dev.lions.unionflow.server.repository.MembreRepository;
|
||||
import dev.lions.unionflow.server.repository.OrganisationRepository;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.quarkus.test.security.TestSecurity;
|
||||
import io.restassured.http.ContentType;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.transaction.Transactional;
|
||||
import org.junit.jupiter.api.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.UUID;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
|
||||
/**
|
||||
* Tests d'intégration End-to-End pour le workflow des cotisations
|
||||
*
|
||||
* Scénario testé :
|
||||
* 1. Création d'une organisation et d'un membre (prérequis)
|
||||
* 2. Création d'une cotisation
|
||||
* 3. Enregistrement d'un paiement
|
||||
* 4. Consultation de l'historique
|
||||
* 5. Statistiques de cotisations
|
||||
*
|
||||
* @author UnionFlow Team
|
||||
* @version 3.0
|
||||
* @since 2026-01-04
|
||||
*/
|
||||
@QuarkusTest
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||
public class CotisationWorkflowIntegrationTest {
|
||||
|
||||
private static final String BASE_PATH = "/api/cotisations";
|
||||
|
||||
@Inject
|
||||
CotisationRepository cotisationRepository;
|
||||
|
||||
@Inject
|
||||
MembreRepository membreRepository;
|
||||
|
||||
@Inject
|
||||
OrganisationRepository organisationRepository;
|
||||
|
||||
private UUID organisationId;
|
||||
private UUID membreId;
|
||||
private UUID cotisationId;
|
||||
|
||||
@BeforeAll
|
||||
@Transactional
|
||||
void setupTestData() {
|
||||
// Créer organisation
|
||||
Organisation org = Organisation.builder()
|
||||
.nom("Organisation Test E2E Cotisations")
|
||||
.typeOrganisation("ASSOCIATION")
|
||||
.statut("ACTIVE")
|
||||
.email("org-cotisation-e2e-" + System.currentTimeMillis() + "@test.com")
|
||||
.build();
|
||||
org.setDateCreation(LocalDateTime.now());
|
||||
org.setActif(true);
|
||||
organisationRepository.persist(org);
|
||||
organisationId = org.getId();
|
||||
|
||||
// Créer membre
|
||||
Membre membre = Membre.builder()
|
||||
.numeroMembre("UF-" + System.currentTimeMillis())
|
||||
.nom("Test")
|
||||
.prenom("Cotisation")
|
||||
.email("membre-cot-e2e-" + System.currentTimeMillis() + "@test.com")
|
||||
.telephone("+221701234567")
|
||||
.dateNaissance(LocalDate.of(1990, 1, 1))
|
||||
.build();
|
||||
membre.setDateCreation(LocalDateTime.now());
|
||||
membre.setActif(true);
|
||||
membreRepository.persist(membre);
|
||||
membreId = membre.getId();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
@TestSecurity(user = "admin@unionflow.com", roles = { "ADMIN" })
|
||||
@DisplayName("E2E-Cotisation-01: Créer une cotisation pour le membre")
|
||||
void test01_CreerCotisation() {
|
||||
String cotisationJson = String.format("""
|
||||
{
|
||||
"numeroReference": "COT-E2E-%d",
|
||||
"membreId": "%s",
|
||||
"organisationId": "%s",
|
||||
"typeCotisation": "MENSUELLE",
|
||||
"libelle": "Cotisation Mensuelle E2E",
|
||||
"montantDu": 5000.00,
|
||||
"codeDevise": "XOF",
|
||||
"mois": %d,
|
||||
"annee": %d,
|
||||
"dateEcheance": "%s",
|
||||
"statut": "EN_ATTENTE"
|
||||
}
|
||||
""",
|
||||
System.currentTimeMillis(),
|
||||
membreId.toString(),
|
||||
organisationId.toString(),
|
||||
LocalDate.now().getMonthValue(),
|
||||
LocalDate.now().getYear(),
|
||||
LocalDate.now().plusDays(30).toString());
|
||||
|
||||
String idStr = given()
|
||||
.contentType(ContentType.JSON)
|
||||
.body(cotisationJson)
|
||||
.when()
|
||||
.post(BASE_PATH)
|
||||
.then()
|
||||
.statusCode(201)
|
||||
.body("montantDu", equalTo(5000.0f))
|
||||
.body("statut", equalTo("EN_ATTENTE"))
|
||||
.body("id", notNullValue())
|
||||
.extract()
|
||||
.path("id");
|
||||
|
||||
cotisationId = UUID.fromString(idStr);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(2)
|
||||
@TestSecurity(user = "admin@unionflow.com", roles = { "ADMIN" })
|
||||
@DisplayName("E2E-Cotisation-02: Enregistrer un paiement")
|
||||
void test02_EnregistrerPaiement() {
|
||||
String paiementJson = String.format("""
|
||||
{
|
||||
"montantPaye": 5000.00,
|
||||
"datePaiement": "%s",
|
||||
"modePaiement": "ESPECES",
|
||||
"reference": "PAY-E2E-%d"
|
||||
}
|
||||
""",
|
||||
LocalDate.now().toString(),
|
||||
System.currentTimeMillis());
|
||||
|
||||
given()
|
||||
.contentType(ContentType.JSON)
|
||||
.pathParam("id", cotisationId)
|
||||
.body(paiementJson)
|
||||
.when()
|
||||
.put(BASE_PATH + "/{id}/payer")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("statut", equalTo("PAYEE"))
|
||||
.body("montantPaye", equalTo(5000.0f));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(3)
|
||||
@TestSecurity(user = "admin@unionflow.com", roles = { "ADMIN" })
|
||||
@DisplayName("E2E-Cotisation-03: Consulter l'historique du membre")
|
||||
void test03_ConsulterHistorique() {
|
||||
given()
|
||||
.pathParam("membreId", membreId)
|
||||
.when()
|
||||
.get(BASE_PATH + "/membre/{membreId}")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("$", hasSize(greaterThanOrEqualTo(1)))
|
||||
.body("[0].id", equalTo(cotisationId.toString()))
|
||||
.body("[0].statut", equalTo("PAYEE"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(4)
|
||||
@TestSecurity(user = "admin@unionflow.com", roles = { "ADMIN" })
|
||||
@DisplayName("E2E-Cotisation-04: Obtenir les statistiques")
|
||||
void test04_StatistiquesCotisations() {
|
||||
given()
|
||||
.queryParam("annee", LocalDate.now().getYear())
|
||||
.when()
|
||||
.get(BASE_PATH + "/statistiques")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("totalCotisations", greaterThanOrEqualTo(1))
|
||||
.body("totalMontant", greaterThanOrEqualTo(5000.0f));
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
@Transactional
|
||||
void cleanup() {
|
||||
if (cotisationId != null) {
|
||||
cotisationRepository.findByIdOptional(cotisationId)
|
||||
.ifPresent(cot -> cotisationRepository.delete(cot));
|
||||
}
|
||||
if (membreId != null) {
|
||||
membreRepository.findByIdOptional(membreId)
|
||||
.ifPresent(membre -> membreRepository.delete(membre));
|
||||
}
|
||||
if (organisationId != null) {
|
||||
organisationRepository.findByIdOptional(organisationId)
|
||||
.ifPresent(org -> organisationRepository.delete(org));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,205 @@
|
||||
package dev.lions.unionflow.server.integration;
|
||||
|
||||
import dev.lions.unionflow.server.entity.Organisation;
|
||||
import dev.lions.unionflow.server.repository.EvenementRepository;
|
||||
import dev.lions.unionflow.server.repository.OrganisationRepository;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.quarkus.test.security.TestSecurity;
|
||||
import io.restassured.http.ContentType;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.transaction.Transactional;
|
||||
import org.junit.jupiter.api.*;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.UUID;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
|
||||
/**
|
||||
* Tests d'intégration End-to-End pour le workflow des événements
|
||||
*
|
||||
* Scénario testé :
|
||||
* 1. Création d'une organisation (prérequis)
|
||||
* 2. Création d'un événement
|
||||
* 3. Consultation des détails
|
||||
* 4. Modification de l'événement
|
||||
* 5. Liste des événements à venir
|
||||
* 6. Annulation de l'événement
|
||||
*
|
||||
* @author UnionFlow Team
|
||||
* @version 3.0
|
||||
* @since 2026-01-04
|
||||
*/
|
||||
@QuarkusTest
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||
public class EvenementWorkflowIntegrationTest {
|
||||
|
||||
private static final String BASE_PATH = "/api/evenements";
|
||||
|
||||
@Inject
|
||||
EvenementRepository evenementRepository;
|
||||
|
||||
@Inject
|
||||
OrganisationRepository organisationRepository;
|
||||
|
||||
private UUID organisationId;
|
||||
private UUID evenementId;
|
||||
|
||||
@BeforeAll
|
||||
@Transactional
|
||||
void setupOrganisation() {
|
||||
Organisation org = Organisation.builder()
|
||||
.nom("Organisation Test E2E Événements")
|
||||
.typeOrganisation("ASSOCIATION")
|
||||
.statut("ACTIVE")
|
||||
.email("org-event-e2e-" + System.currentTimeMillis() + "@test.com")
|
||||
.build();
|
||||
org.setDateCreation(LocalDateTime.now());
|
||||
org.setActif(true);
|
||||
organisationRepository.persist(org);
|
||||
organisationId = org.getId();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
@TestSecurity(user = "admin@unionflow.com", roles = { "ADMIN" })
|
||||
@DisplayName("E2E-Event-01: Créer un nouvel événement")
|
||||
void test01_CreerEvenement() {
|
||||
LocalDate dateDebut = LocalDate.now().plusDays(7);
|
||||
String eventJson = String.format("""
|
||||
{
|
||||
"titre": "Événement E2E Test",
|
||||
"description": "Description événement test end-to-end",
|
||||
"dateDebut": "%sT10:00:00",
|
||||
"lieu": "Dakar, Sénégal",
|
||||
"typeEvenement": "FORMATION",
|
||||
"statut": "PLANIFIE",
|
||||
"capaciteMax": 50,
|
||||
"prix": 5000.00,
|
||||
"organisation": { "id": "%s", "version": 0 },
|
||||
"inscriptionRequise": true,
|
||||
"visiblePublic": true,
|
||||
"actif": true
|
||||
}
|
||||
""",
|
||||
dateDebut.toString(),
|
||||
organisationId.toString());
|
||||
|
||||
String idStr = given()
|
||||
.contentType(ContentType.JSON)
|
||||
.body(eventJson)
|
||||
.when()
|
||||
.post(BASE_PATH)
|
||||
.then()
|
||||
.statusCode(201)
|
||||
.body("titre", equalTo("Événement E2E Test"))
|
||||
.body("statut", equalTo("PLANIFIE"))
|
||||
.body("id", notNullValue())
|
||||
.extract()
|
||||
.path("id");
|
||||
|
||||
evenementId = UUID.fromString(idStr);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(2)
|
||||
@TestSecurity(user = "admin@unionflow.com", roles = { "ADMIN" })
|
||||
@DisplayName("E2E-Event-02: Consulter les détails de l'événement")
|
||||
void test02_ConsulterEvenement() {
|
||||
given()
|
||||
.pathParam("id", evenementId)
|
||||
.when()
|
||||
.get(BASE_PATH + "/{id}")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("id", equalTo(evenementId.toString()))
|
||||
.body("titre", equalTo("Événement E2E Test"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(3)
|
||||
@TestSecurity(user = "admin@unionflow.com", roles = { "ADMIN" })
|
||||
@DisplayName("E2E-Event-03: Modifier l'événement")
|
||||
void test03_ModifierEvenement() {
|
||||
LocalDate dateDebut = LocalDate.now().plusDays(14);
|
||||
String updateJson = String.format("""
|
||||
{
|
||||
"titre": "Événement E2E Test Modifié",
|
||||
"description": "Description modifiée",
|
||||
"dateDebut": "%sT14:00:00",
|
||||
"lieu": "Abidjan, Côte d'Ivoire",
|
||||
"typeEvenement": "FORMATION",
|
||||
"statut": "CONFIRME",
|
||||
"capaciteMax": 75,
|
||||
"prix": 7500.00,
|
||||
"organisation": { "id": "%s", "version": 0 },
|
||||
"inscriptionRequise": true,
|
||||
"visiblePublic": true,
|
||||
"actif": true
|
||||
}
|
||||
""",
|
||||
dateDebut.toString(),
|
||||
organisationId.toString());
|
||||
|
||||
given()
|
||||
.contentType(ContentType.JSON)
|
||||
.pathParam("id", evenementId)
|
||||
.body(updateJson)
|
||||
.when()
|
||||
.put(BASE_PATH + "/{id}")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("titre", equalTo("Événement E2E Test Modifié"))
|
||||
.body("statut", equalTo("CONFIRME"))
|
||||
.body("capaciteMax", equalTo(75));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(4)
|
||||
@TestSecurity(user = "membre@unionflow.com", roles = { "MEMBRE" })
|
||||
@DisplayName("E2E-Event-04: Lister tous les événements")
|
||||
void test04_ListerEvenements() {
|
||||
given()
|
||||
.queryParam("page", 0)
|
||||
.queryParam("size", 10)
|
||||
.when()
|
||||
.get(BASE_PATH)
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("data", notNullValue())
|
||||
.body("data", hasSize(greaterThanOrEqualTo(1)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(5)
|
||||
@TestSecurity(user = "admin@unionflow.com", roles = { "ADMIN" })
|
||||
@DisplayName("E2E-Event-05: Supprimer l'événement")
|
||||
void test05_SupprimerEvenement() {
|
||||
given()
|
||||
.pathParam("id", evenementId)
|
||||
.when()
|
||||
.delete(BASE_PATH + "/{id}")
|
||||
.then()
|
||||
.statusCode(204);
|
||||
|
||||
// Éviter la tentative de suppression dans cleanup
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
@Transactional
|
||||
void cleanup() {
|
||||
// Supprimer tous les événements de l'organisation de test d'abord
|
||||
if (organisationId != null) {
|
||||
evenementRepository.getEntityManager()
|
||||
.createQuery("DELETE FROM Evenement e WHERE e.organisation.id = :orgId")
|
||||
.setParameter("orgId", organisationId)
|
||||
.executeUpdate();
|
||||
|
||||
organisationRepository.findByIdOptional(organisationId)
|
||||
.ifPresent(org -> organisationRepository.delete(org));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,217 @@
|
||||
package dev.lions.unionflow.server.integration;
|
||||
|
||||
import dev.lions.unionflow.server.entity.Membre;
|
||||
import dev.lions.unionflow.server.entity.Organisation;
|
||||
import dev.lions.unionflow.server.repository.MembreRepository;
|
||||
import dev.lions.unionflow.server.repository.OrganisationRepository;
|
||||
import io.quarkus.test.InjectMock;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.quarkus.test.security.TestSecurity;
|
||||
import io.restassured.http.ContentType;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.transaction.Transactional;
|
||||
import dev.lions.unionflow.server.service.MembreKeycloakSyncService;
|
||||
import org.junit.jupiter.api.*;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.UUID;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
|
||||
/**
|
||||
* Tests d'intégration End-to-End pour le workflow complet d'un membre
|
||||
*
|
||||
* Scénario testé :
|
||||
* 1. Création d'une organisation (prérequis)
|
||||
* 2. Inscription d'un nouveau membre
|
||||
* 3. Consultation du profil
|
||||
* 4. Modification des informations
|
||||
* 5. Recherche du membre
|
||||
* 6. Suspension du membre
|
||||
*
|
||||
* @author UnionFlow Team
|
||||
* @version 3.0
|
||||
* @since 2026-01-04
|
||||
*/
|
||||
@QuarkusTest
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||
public class MembreWorkflowIntegrationTest {
|
||||
|
||||
private static final String BASE_PATH = "/api/membres";
|
||||
private static final String ORG_PATH = "/api/organisations";
|
||||
|
||||
@Inject
|
||||
MembreRepository membreRepository;
|
||||
|
||||
@Inject
|
||||
OrganisationRepository organisationRepository;
|
||||
|
||||
@InjectMock
|
||||
MembreKeycloakSyncService keycloakSyncService;
|
||||
|
||||
private UUID organisationId;
|
||||
private UUID membreId;
|
||||
private String membreEmail;
|
||||
|
||||
@BeforeAll
|
||||
@Transactional
|
||||
void setupOrganisation() {
|
||||
// Créer l'organisation de test
|
||||
Organisation org = Organisation.builder()
|
||||
.nom("Organisation Test E2E Membre")
|
||||
.typeOrganisation("ASSOCIATION")
|
||||
.statut("ACTIVE")
|
||||
.email("org-membre-e2e-" + System.currentTimeMillis() + "@test.com")
|
||||
.build();
|
||||
org.setDateCreation(LocalDateTime.now());
|
||||
org.setActif(true);
|
||||
organisationRepository.persist(org);
|
||||
organisationId = org.getId();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
@TestSecurity(user = "admin@unionflow.com", roles = { "ADMIN" })
|
||||
@DisplayName("E2E-Membre-01: Inscrire un nouveau membre")
|
||||
void test01_InscrireMembre() {
|
||||
membreEmail = "membre-e2e-" + System.currentTimeMillis() + "@test.com";
|
||||
|
||||
String membreJson = String.format("""
|
||||
{
|
||||
"numeroMembre": "UF-E2E-%d",
|
||||
"nom": "Test",
|
||||
"prenom": "Membre",
|
||||
"email": "%s",
|
||||
"telephone": "+221701234567",
|
||||
"dateNaissance": "%s",
|
||||
"dateAdhesion": "%s",
|
||||
"associationId": "%s"
|
||||
}
|
||||
""",
|
||||
System.currentTimeMillis(),
|
||||
membreEmail,
|
||||
LocalDate.of(1990, 1, 1).toString(),
|
||||
LocalDate.now().toString(),
|
||||
organisationId.toString());
|
||||
|
||||
String idStr = given()
|
||||
.contentType(ContentType.JSON)
|
||||
.body(membreJson)
|
||||
.when()
|
||||
.post(BASE_PATH)
|
||||
.then()
|
||||
.statusCode(201)
|
||||
.contentType(ContentType.JSON)
|
||||
.body("nom", equalTo("Test"))
|
||||
.body("prenom", equalTo("Membre"))
|
||||
.body("email", equalTo(membreEmail))
|
||||
.body("id", notNullValue())
|
||||
.extract()
|
||||
.path("id");
|
||||
|
||||
membreId = UUID.fromString(idStr);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(2)
|
||||
@TestSecurity(user = "admin@unionflow.com", roles = { "ADMIN" })
|
||||
@DisplayName("E2E-Membre-02: Consulter le profil du membre")
|
||||
void test02_ConsulterMembre() {
|
||||
given()
|
||||
.pathParam("id", membreId)
|
||||
.when()
|
||||
.get(BASE_PATH + "/{id}")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("id", equalTo(membreId.toString()))
|
||||
.body("nom", equalTo("Test"))
|
||||
.body("email", equalTo(membreEmail));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(3)
|
||||
@TestSecurity(user = "admin@unionflow.com", roles = { "ADMIN" })
|
||||
@DisplayName("E2E-Membre-03: Modifier les informations du membre")
|
||||
void test03_ModifierMembre() {
|
||||
String updateJson = String.format("""
|
||||
{
|
||||
"numeroMembre": "UF-E2E-%d",
|
||||
"nom": "Test Modifié",
|
||||
"prenom": "Membre Modifié",
|
||||
"email": "%s",
|
||||
"telephone": "+221709876543",
|
||||
"dateNaissance": "%s",
|
||||
"dateAdhesion": "%s",
|
||||
"associationId": "%s"
|
||||
}
|
||||
""",
|
||||
System.currentTimeMillis(),
|
||||
membreEmail,
|
||||
LocalDate.of(1990, 1, 1).toString(),
|
||||
LocalDate.now().toString(),
|
||||
organisationId.toString());
|
||||
|
||||
given()
|
||||
.contentType(ContentType.JSON)
|
||||
.pathParam("id", membreId)
|
||||
.body(updateJson)
|
||||
.when()
|
||||
.put(BASE_PATH + "/{id}")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("nom", equalTo("Test Modifié"))
|
||||
.body("prenom", equalTo("Membre Modifié"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(4)
|
||||
@TestSecurity(user = "admin@unionflow.com", roles = { "ADMIN" })
|
||||
@DisplayName("E2E-Membre-04: Lister tous les membres (vérifier présence)")
|
||||
void test04_ListerMembres() {
|
||||
given()
|
||||
.queryParam("page", 0)
|
||||
.queryParam("size", 100)
|
||||
.when()
|
||||
.get(BASE_PATH)
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("data", hasSize(greaterThan(0)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(5)
|
||||
@TestSecurity(user = "admin@unionflow.com", roles = { "ADMIN" })
|
||||
@DisplayName("E2E-Membre-05: Supprimer le membre")
|
||||
void test05_SupprimerMembre() {
|
||||
given()
|
||||
.pathParam("id", membreId)
|
||||
.when()
|
||||
.delete(BASE_PATH + "/{id}")
|
||||
.then()
|
||||
.statusCode(204);
|
||||
|
||||
// Vérifier qu'il est supprimé
|
||||
given()
|
||||
.pathParam("id", membreId)
|
||||
.when()
|
||||
.get(BASE_PATH + "/{id}")
|
||||
.then()
|
||||
.statusCode(404);
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
@Transactional
|
||||
void cleanup() {
|
||||
if (membreId != null) {
|
||||
membreRepository.findByIdOptional(membreId)
|
||||
.ifPresent(membre -> membreRepository.delete(membre));
|
||||
}
|
||||
if (organisationId != null) {
|
||||
organisationRepository.findByIdOptional(organisationId)
|
||||
.ifPresent(org -> organisationRepository.delete(org));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,205 @@
|
||||
package dev.lions.unionflow.server.integration;
|
||||
|
||||
import dev.lions.unionflow.server.entity.Organisation;
|
||||
import dev.lions.unionflow.server.repository.OrganisationRepository;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.quarkus.test.security.TestSecurity;
|
||||
import io.restassured.http.ContentType;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.transaction.Transactional;
|
||||
import org.junit.jupiter.api.*;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
/**
|
||||
* Tests d'intégration End-to-End pour le workflow complet d'une organisation
|
||||
*
|
||||
* Scénario testé :
|
||||
* 1. Création d'une nouvelle organisation
|
||||
* 2. Consultation des détails
|
||||
* 3. Modification des informations
|
||||
* 4. Suspension
|
||||
* 5. Réactivation
|
||||
*
|
||||
* @author UnionFlow Team
|
||||
* @version 3.0
|
||||
* @since 2026-01-04
|
||||
*/
|
||||
@QuarkusTest
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||
public class OrganisationWorkflowIntegrationTest {
|
||||
|
||||
private static final String BASE_PATH = "/api/organisations";
|
||||
|
||||
@Inject
|
||||
OrganisationRepository organisationRepository;
|
||||
|
||||
private UUID organisationId;
|
||||
private String organisationEmail;
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
@TestSecurity(user = "superadmin@unionflow.com", roles = { "SUPER_ADMIN" })
|
||||
@DisplayName("E2E-01: Créer une nouvelle organisation")
|
||||
void test01_CreerOrganisation() {
|
||||
organisationEmail = "org-e2e-" + System.currentTimeMillis() + "@test.com";
|
||||
|
||||
String orgJson = String.format("""
|
||||
{
|
||||
"nom": "Organisation E2E Test",
|
||||
"typeOrganisation": "ASSOCIATION",
|
||||
"statut": "ACTIVE",
|
||||
"email": "%s",
|
||||
"telephone": "+221701234567",
|
||||
"adresse": "123 Rue Test, Dakar",
|
||||
"ville": "Dakar",
|
||||
"pays": "Sénégal"
|
||||
}
|
||||
""", organisationEmail);
|
||||
|
||||
String idStr = given()
|
||||
.contentType(ContentType.JSON)
|
||||
.body(orgJson)
|
||||
.when()
|
||||
.post(BASE_PATH)
|
||||
.then()
|
||||
.statusCode(201)
|
||||
.contentType(ContentType.JSON)
|
||||
.body("nom", equalTo("Organisation E2E Test"))
|
||||
.body("statut", equalTo("ACTIVE"))
|
||||
.body("id", notNullValue())
|
||||
.extract()
|
||||
.path("id");
|
||||
|
||||
organisationId = UUID.fromString(idStr);
|
||||
assertNotNull(organisationId, "L'ID de l'organisation doit être retourné");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(2)
|
||||
@TestSecurity(user = "admin@unionflow.com", roles = { "ADMIN" })
|
||||
@DisplayName("E2E-02: Consulter les détails de l'organisation")
|
||||
void test02_ConsulterOrganisation() {
|
||||
given()
|
||||
.pathParam("id", organisationId)
|
||||
.when()
|
||||
.get(BASE_PATH + "/{id}")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.contentType(ContentType.JSON)
|
||||
.body("id", equalTo(organisationId.toString()))
|
||||
.body("nom", equalTo("Organisation E2E Test"))
|
||||
.body("email", equalTo(organisationEmail));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(3)
|
||||
@TestSecurity(user = "admin@unionflow.com", roles = { "ADMIN" })
|
||||
@DisplayName("E2E-03: Modifier l'organisation")
|
||||
void test03_ModifierOrganisation() {
|
||||
String updateJson = String.format("""
|
||||
{
|
||||
"nom": "Organisation E2E Test Modifiée",
|
||||
"typeOrganisation": "ASSOCIATION",
|
||||
"statut": "ACTIVE",
|
||||
"email": "%s",
|
||||
"telephone": "+221709876543",
|
||||
"adresse": "456 Avenue Nouvelle, Dakar"
|
||||
}
|
||||
""", organisationEmail);
|
||||
|
||||
given()
|
||||
.contentType(ContentType.JSON)
|
||||
.pathParam("id", organisationId)
|
||||
.body(updateJson)
|
||||
.when()
|
||||
.put(BASE_PATH + "/{id}")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("nom", equalTo("Organisation E2E Test Modifiée"))
|
||||
.body("telephone", equalTo("+221709876543"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(4)
|
||||
@TestSecurity(user = "admin@unionflow.com", roles = { "ADMIN" })
|
||||
@DisplayName("E2E-04: Changer le statut à SUSPENDU")
|
||||
void test04_SuspendreOrganisation() {
|
||||
String updateJson = String.format("""
|
||||
{
|
||||
"nom": "Organisation E2E Test Modifiée",
|
||||
"typeOrganisation": "ASSOCIATION",
|
||||
"statut": "SUSPENDUE",
|
||||
"email": "%s",
|
||||
"telephone": "+221709876543"
|
||||
}
|
||||
""", organisationEmail);
|
||||
|
||||
given()
|
||||
.contentType(ContentType.JSON)
|
||||
.pathParam("id", organisationId)
|
||||
.body(updateJson)
|
||||
.when()
|
||||
.put(BASE_PATH + "/{id}")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("statut", equalTo("SUSPENDUE"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(5)
|
||||
@TestSecurity(user = "admin@unionflow.com", roles = { "ADMIN" })
|
||||
@DisplayName("E2E-05: Réactiver en changeant le statut")
|
||||
void test05_ReactiverOrganisation() {
|
||||
String updateJson = String.format("""
|
||||
{
|
||||
"nom": "Organisation E2E Test Modifiée",
|
||||
"typeOrganisation": "ASSOCIATION",
|
||||
"statut": "ACTIVE",
|
||||
"email": "%s",
|
||||
"telephone": "+221709876543"
|
||||
}
|
||||
""", organisationEmail);
|
||||
|
||||
given()
|
||||
.contentType(ContentType.JSON)
|
||||
.pathParam("id", organisationId)
|
||||
.body(updateJson)
|
||||
.when()
|
||||
.put(BASE_PATH + "/{id}")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("statut", equalTo("ACTIVE"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(6)
|
||||
@TestSecurity(user = "admin@unionflow.com", roles = { "ADMIN" })
|
||||
@DisplayName("E2E-06: Lister toutes les organisations (pagination)")
|
||||
void test06_ListerOrganisations() {
|
||||
given()
|
||||
.queryParam("page", 0)
|
||||
.queryParam("size", 10)
|
||||
.when()
|
||||
.get(BASE_PATH)
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("data", notNullValue())
|
||||
.body("data", hasSize(greaterThan(0)))
|
||||
.body("total", greaterThan(0));
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
@Transactional
|
||||
void cleanup() {
|
||||
if (organisationId != null) {
|
||||
organisationRepository.findByIdOptional(organisationId)
|
||||
.ifPresent(org -> organisationRepository.delete(org));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package dev.lions.unionflow.server.mapper;
|
||||
|
||||
import dev.lions.unionflow.server.api.dto.solidarite.response.DemandeAideResponse;
|
||||
import dev.lions.unionflow.server.api.enums.solidarite.StatutAide;
|
||||
import dev.lions.unionflow.server.entity.DemandeAide;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import jakarta.inject.Inject;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@QuarkusTest
|
||||
class DemandeAideMapperTest {
|
||||
|
||||
@Inject
|
||||
DemandeAideMapper mapper;
|
||||
|
||||
@Test
|
||||
@DisplayName("toDTO avec null retourne null")
|
||||
void toDTO_null_returnsNull() {
|
||||
assertThat(mapper.toDTO(null)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toDTO mappe entité vers response")
|
||||
void toDTO_mapsEntityToResponse() {
|
||||
DemandeAide entity = new DemandeAide();
|
||||
entity.setId(UUID.randomUUID());
|
||||
entity.setTitre("Demande test");
|
||||
entity.setDescription("Description");
|
||||
entity.setStatut(StatutAide.EN_ATTENTE);
|
||||
entity.setDemandeur(null);
|
||||
entity.setOrganisation(null);
|
||||
entity.setEvaluateur(null);
|
||||
|
||||
DemandeAideResponse dto = mapper.toDTO(entity);
|
||||
|
||||
assertThat(dto).isNotNull();
|
||||
assertThat(dto.getId()).isEqualTo(entity.getId());
|
||||
assertThat(dto.getTitre()).isEqualTo("Demande test");
|
||||
assertThat(dto.getDescription()).isEqualTo("Description");
|
||||
assertThat(dto.getStatut()).isEqualTo(StatutAide.EN_ATTENTE);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package dev.lions.unionflow.server.mapper.agricole;
|
||||
|
||||
import dev.lions.unionflow.server.api.dto.agricole.CampagneAgricoleDTO;
|
||||
import dev.lions.unionflow.server.api.enums.agricole.StatutCampagneAgricole;
|
||||
import dev.lions.unionflow.server.entity.Organisation;
|
||||
import dev.lions.unionflow.server.entity.agricole.CampagneAgricole;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import jakarta.inject.Inject;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@QuarkusTest
|
||||
class CampagneAgricoleMapperTest {
|
||||
|
||||
@Inject
|
||||
CampagneAgricoleMapper mapper;
|
||||
|
||||
@Test
|
||||
@DisplayName("toDto avec null retourne null")
|
||||
void toDto_null_returnsNull() {
|
||||
assertThat(mapper.toDto(null)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toEntity avec null retourne null")
|
||||
void toEntity_null_returnsNull() {
|
||||
assertThat(mapper.toEntity(null)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toDto mappe entity vers DTO")
|
||||
void toDto_mapsEntityToDto() {
|
||||
UUID orgId = UUID.randomUUID();
|
||||
Organisation org = new Organisation();
|
||||
org.setId(orgId);
|
||||
CampagneAgricole entity = CampagneAgricole.builder()
|
||||
.organisation(org)
|
||||
.designation("Campagne Arachide 2025")
|
||||
.typeCulturePrincipale("Arachide")
|
||||
.surfaceTotaleEstimeeHectares(new BigDecimal("100.5"))
|
||||
.volumePrevisionnelTonnes(new BigDecimal("50"))
|
||||
.volumeReelTonnes(new BigDecimal("48"))
|
||||
.statut(StatutCampagneAgricole.RECOLTE)
|
||||
.build();
|
||||
entity.setId(UUID.randomUUID());
|
||||
|
||||
CampagneAgricoleDTO dto = mapper.toDto(entity);
|
||||
|
||||
assertThat(dto).isNotNull();
|
||||
assertThat(dto.getOrganisationCoopId()).isEqualTo(orgId.toString());
|
||||
assertThat(dto.getDesignation()).isEqualTo("Campagne Arachide 2025");
|
||||
assertThat(dto.getTypeCulturePrincipale()).isEqualTo("Arachide");
|
||||
assertThat(dto.getSurfaceTotaleEstimeeHectares()).isEqualByComparingTo("100.5");
|
||||
assertThat(dto.getStatut()).isEqualTo(StatutCampagneAgricole.RECOLTE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toEntity mappe DTO vers entity")
|
||||
void toEntity_mapsDtoToEntity() {
|
||||
CampagneAgricoleDTO dto = new CampagneAgricoleDTO();
|
||||
dto.setDesignation("Campagne test");
|
||||
dto.setTypeCulturePrincipale("Maïs");
|
||||
dto.setSurfaceTotaleEstimeeHectares(new BigDecimal("200"));
|
||||
dto.setStatut(StatutCampagneAgricole.PREPARATION);
|
||||
|
||||
CampagneAgricole entity = mapper.toEntity(dto);
|
||||
|
||||
assertThat(entity).isNotNull();
|
||||
assertThat(entity.getDesignation()).isEqualTo("Campagne test");
|
||||
assertThat(entity.getTypeCulturePrincipale()).isEqualTo("Maïs");
|
||||
assertThat(entity.getOrganisation()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("updateEntityFromDto met à jour l'entité cible")
|
||||
void updateEntityFromDto_updatesTarget() {
|
||||
CampagneAgricole entity = CampagneAgricole.builder()
|
||||
.designation("Ancienne")
|
||||
.statut(StatutCampagneAgricole.PREPARATION)
|
||||
.build();
|
||||
CampagneAgricoleDTO dto = new CampagneAgricoleDTO();
|
||||
dto.setDesignation("Nouvelle désignation");
|
||||
dto.setStatut(StatutCampagneAgricole.CLOTUREE);
|
||||
|
||||
mapper.updateEntityFromDto(dto, entity);
|
||||
|
||||
assertThat(entity.getDesignation()).isEqualTo("Nouvelle désignation");
|
||||
assertThat(entity.getStatut()).isEqualTo(StatutCampagneAgricole.CLOTUREE);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package dev.lions.unionflow.server.mapper.collectefonds;
|
||||
|
||||
import dev.lions.unionflow.server.api.dto.collectefonds.CampagneCollecteResponse;
|
||||
import dev.lions.unionflow.server.api.enums.collectefonds.StatutCampagneCollecte;
|
||||
import dev.lions.unionflow.server.entity.Organisation;
|
||||
import dev.lions.unionflow.server.entity.collectefonds.CampagneCollecte;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import jakarta.inject.Inject;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@QuarkusTest
|
||||
class CampagneCollecteMapperTest {
|
||||
|
||||
@Inject
|
||||
CampagneCollecteMapper mapper;
|
||||
|
||||
@Test
|
||||
@DisplayName("toDto avec null retourne null")
|
||||
void toDto_null_returnsNull() {
|
||||
assertThat(mapper.toDto(null)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toDto mappe entity vers DTO")
|
||||
void toDto_mapsEntityToDto() {
|
||||
UUID orgId = UUID.randomUUID();
|
||||
Organisation org = new Organisation();
|
||||
org.setId(orgId);
|
||||
CampagneCollecte entity = CampagneCollecte.builder()
|
||||
.organisation(org)
|
||||
.titre("Collecte 2025")
|
||||
.courteDescription("Courte desc")
|
||||
.objectifFinancier(new BigDecimal("1000000"))
|
||||
.statut(StatutCampagneCollecte.EN_COURS)
|
||||
.dateOuverture(LocalDateTime.now())
|
||||
.dateCloturePrevue(LocalDateTime.now().plusMonths(1))
|
||||
.estPublique(true)
|
||||
.build();
|
||||
entity.setId(UUID.randomUUID());
|
||||
|
||||
CampagneCollecteResponse dto = mapper.toDto(entity);
|
||||
|
||||
assertThat(dto).isNotNull();
|
||||
assertThat(dto.getOrganisationId()).isEqualTo(orgId.toString());
|
||||
assertThat(dto.getTitre()).isEqualTo("Collecte 2025");
|
||||
assertThat(dto.getCourteDescription()).isEqualTo("Courte desc");
|
||||
assertThat(dto.getObjectifFinancier()).isEqualByComparingTo("1000000");
|
||||
assertThat(dto.getStatut()).isEqualTo(StatutCampagneCollecte.EN_COURS);
|
||||
assertThat(dto.getEstPublique()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("updateEntityFromDto met à jour l'entité cible")
|
||||
void updateEntityFromDto_updatesTarget() {
|
||||
CampagneCollecte entity = CampagneCollecte.builder()
|
||||
.titre("Ancien titre")
|
||||
.objectifFinancier(BigDecimal.ZERO)
|
||||
.build();
|
||||
CampagneCollecteResponse dto = new CampagneCollecteResponse();
|
||||
dto.setTitre("Nouveau titre");
|
||||
dto.setObjectifFinancier(new BigDecimal("500000"));
|
||||
|
||||
mapper.updateEntityFromDto(dto, entity);
|
||||
|
||||
assertThat(entity.getTitre()).isEqualTo("Nouveau titre");
|
||||
assertThat(entity.getObjectifFinancier()).isEqualByComparingTo("500000");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package dev.lions.unionflow.server.mapper.collectefonds;
|
||||
|
||||
import dev.lions.unionflow.server.api.dto.collectefonds.ContributionCollecteDTO;
|
||||
import dev.lions.unionflow.server.api.enums.wave.StatutTransactionWave;
|
||||
import dev.lions.unionflow.server.entity.Membre;
|
||||
import dev.lions.unionflow.server.entity.collectefonds.CampagneCollecte;
|
||||
import dev.lions.unionflow.server.entity.collectefonds.ContributionCollecte;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import jakarta.inject.Inject;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@QuarkusTest
|
||||
class ContributionCollecteMapperTest {
|
||||
|
||||
@Inject
|
||||
ContributionCollecteMapper mapper;
|
||||
|
||||
@Test
|
||||
@DisplayName("toDto avec null retourne null")
|
||||
void toDto_null_returnsNull() {
|
||||
assertThat(mapper.toDto(null)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toEntity avec null retourne null")
|
||||
void toEntity_null_returnsNull() {
|
||||
assertThat(mapper.toEntity(null)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toDto mappe entity vers DTO")
|
||||
void toDto_mapsEntityToDto() {
|
||||
UUID campagneId = UUID.randomUUID();
|
||||
UUID membreId = UUID.randomUUID();
|
||||
CampagneCollecte campagne = new CampagneCollecte();
|
||||
campagne.setId(campagneId);
|
||||
Membre membre = new Membre();
|
||||
membre.setId(membreId);
|
||||
ContributionCollecte entity = ContributionCollecte.builder()
|
||||
.campagne(campagne)
|
||||
.membreDonateur(membre)
|
||||
.aliasDonateur("Donateur X")
|
||||
.estAnonyme(false)
|
||||
.montantSoutien(new BigDecimal("50000"))
|
||||
.messageSoutien("Soutien")
|
||||
.dateContribution(LocalDateTime.now())
|
||||
.statutPaiement(StatutTransactionWave.REUSSIE)
|
||||
.build();
|
||||
entity.setId(UUID.randomUUID());
|
||||
|
||||
ContributionCollecteDTO dto = mapper.toDto(entity);
|
||||
|
||||
assertThat(dto).isNotNull();
|
||||
assertThat(dto.getCampagneId()).isEqualTo(campagneId.toString());
|
||||
assertThat(dto.getMembreDonateurId()).isEqualTo(membreId.toString());
|
||||
assertThat(dto.getAliasDonateur()).isEqualTo("Donateur X");
|
||||
assertThat(dto.getMontantSoutien()).isEqualByComparingTo("50000");
|
||||
assertThat(dto.getStatutPaiement()).isEqualTo(StatutTransactionWave.REUSSIE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toEntity mappe DTO vers entity")
|
||||
void toEntity_mapsDtoToEntity() {
|
||||
ContributionCollecteDTO dto = new ContributionCollecteDTO();
|
||||
dto.setAliasDonateur("Alias");
|
||||
dto.setEstAnonyme(true);
|
||||
dto.setMontantSoutien(new BigDecimal("10000"));
|
||||
dto.setMessageSoutien("Message");
|
||||
|
||||
ContributionCollecte entity = mapper.toEntity(dto);
|
||||
|
||||
assertThat(entity).isNotNull();
|
||||
assertThat(entity.getAliasDonateur()).isEqualTo("Alias");
|
||||
assertThat(entity.getMontantSoutien()).isEqualByComparingTo("10000");
|
||||
assertThat(entity.getCampagne()).isNull();
|
||||
assertThat(entity.getMembreDonateur()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("updateEntityFromDto met à jour l'entité cible")
|
||||
void updateEntityFromDto_updatesTarget() {
|
||||
ContributionCollecte entity = ContributionCollecte.builder()
|
||||
.aliasDonateur("Ancien")
|
||||
.montantSoutien(BigDecimal.ONE)
|
||||
.build();
|
||||
ContributionCollecteDTO dto = new ContributionCollecteDTO();
|
||||
dto.setAliasDonateur("Nouveau");
|
||||
dto.setMontantSoutien(new BigDecimal("25000"));
|
||||
|
||||
mapper.updateEntityFromDto(dto, entity);
|
||||
|
||||
assertThat(entity.getAliasDonateur()).isEqualTo("Nouveau");
|
||||
assertThat(entity.getMontantSoutien()).isEqualByComparingTo("25000");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package dev.lions.unionflow.server.mapper.culte;
|
||||
|
||||
import dev.lions.unionflow.server.api.dto.culte.DonReligieuxDTO;
|
||||
import dev.lions.unionflow.server.api.enums.culte.TypeDonReligieux;
|
||||
import dev.lions.unionflow.server.entity.Organisation;
|
||||
import dev.lions.unionflow.server.entity.culte.DonReligieux;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import jakarta.inject.Inject;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@QuarkusTest
|
||||
class DonReligieuxMapperTest {
|
||||
|
||||
@Inject
|
||||
DonReligieuxMapper mapper;
|
||||
|
||||
@Test
|
||||
@DisplayName("toDto avec null retourne null")
|
||||
void toDto_null_returnsNull() {
|
||||
assertThat(mapper.toDto(null)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toEntity avec null retourne null")
|
||||
void toEntity_null_returnsNull() {
|
||||
assertThat(mapper.toEntity(null)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toDto mappe entity vers DTO")
|
||||
void toDto_mapsEntityToDto() {
|
||||
UUID instId = UUID.randomUUID();
|
||||
Organisation inst = new Organisation();
|
||||
inst.setId(instId);
|
||||
DonReligieux entity = DonReligieux.builder()
|
||||
.institution(inst)
|
||||
.fidele(null)
|
||||
.typeDon(TypeDonReligieux.QUETE_ORDINAIRE)
|
||||
.montant(BigDecimal.TEN)
|
||||
.build();
|
||||
entity.setId(UUID.randomUUID());
|
||||
|
||||
DonReligieuxDTO dto = mapper.toDto(entity);
|
||||
|
||||
assertThat(dto).isNotNull();
|
||||
assertThat(dto.getTypeDon()).isEqualTo(TypeDonReligieux.QUETE_ORDINAIRE);
|
||||
assertThat(dto.getMontant()).isEqualByComparingTo(BigDecimal.TEN);
|
||||
assertThat(dto.getInstitutionId()).isEqualTo(instId.toString());
|
||||
assertThat(dto.getFideleId()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toEntity mappe DTO vers entity")
|
||||
void toEntity_mapsDtoToEntity() {
|
||||
DonReligieuxDTO dto = new DonReligieuxDTO();
|
||||
dto.setTypeDon(TypeDonReligieux.DIME);
|
||||
dto.setMontant(BigDecimal.valueOf(100));
|
||||
|
||||
DonReligieux entity = mapper.toEntity(dto);
|
||||
|
||||
assertThat(entity).isNotNull();
|
||||
assertThat(entity.getTypeDon()).isEqualTo(TypeDonReligieux.DIME);
|
||||
assertThat(entity.getMontant()).isEqualByComparingTo(BigDecimal.valueOf(100));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package dev.lions.unionflow.server.mapper.gouvernance;
|
||||
|
||||
import dev.lions.unionflow.server.api.dto.gouvernance.EchelonOrganigrammeDTO;
|
||||
import dev.lions.unionflow.server.api.enums.gouvernance.NiveauEchelon;
|
||||
import dev.lions.unionflow.server.entity.Organisation;
|
||||
import dev.lions.unionflow.server.entity.gouvernance.EchelonOrganigramme;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import jakarta.inject.Inject;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@QuarkusTest
|
||||
class EchelonOrganigrammeMapperTest {
|
||||
|
||||
@Inject
|
||||
EchelonOrganigrammeMapper mapper;
|
||||
|
||||
@Test
|
||||
@DisplayName("toDto avec null retourne null")
|
||||
void toDto_null_returnsNull() {
|
||||
assertThat(mapper.toDto(null)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toEntity avec null retourne null")
|
||||
void toEntity_null_returnsNull() {
|
||||
assertThat(mapper.toEntity(null)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toDto mappe entity vers DTO")
|
||||
void toDto_mapsEntityToDto() {
|
||||
UUID orgId = UUID.randomUUID();
|
||||
Organisation org = new Organisation();
|
||||
org.setId(orgId);
|
||||
EchelonOrganigramme entity = EchelonOrganigramme.builder()
|
||||
.organisation(org)
|
||||
.echelonParent(null)
|
||||
.niveau(NiveauEchelon.NATIONAL)
|
||||
.designation("Bureau national")
|
||||
.zoneGeographiqueOuDelegation("Zone A")
|
||||
.build();
|
||||
entity.setId(UUID.randomUUID());
|
||||
|
||||
EchelonOrganigrammeDTO dto = mapper.toDto(entity);
|
||||
|
||||
assertThat(dto).isNotNull();
|
||||
assertThat(dto.getDesignation()).isEqualTo("Bureau national");
|
||||
assertThat(dto.getNiveau()).isEqualTo(NiveauEchelon.NATIONAL);
|
||||
assertThat(dto.getZoneGeographiqueOuDelegation()).isEqualTo("Zone A");
|
||||
assertThat(dto.getOrganisationId()).isEqualTo(orgId.toString());
|
||||
assertThat(dto.getEchelonParentId()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toEntity mappe DTO vers entity (champs principaux)")
|
||||
void toEntity_mapsDtoToEntity() {
|
||||
EchelonOrganigrammeDTO dto = new EchelonOrganigrammeDTO();
|
||||
dto.setDesignation("Échelon test");
|
||||
dto.setNiveau(NiveauEchelon.SIEGE_MONDIAL);
|
||||
dto.setZoneGeographiqueOuDelegation("Monde");
|
||||
|
||||
EchelonOrganigramme entity = mapper.toEntity(dto);
|
||||
|
||||
assertThat(entity).isNotNull();
|
||||
assertThat(entity.getDesignation()).isEqualTo("Échelon test");
|
||||
assertThat(entity.getNiveau()).isEqualTo(NiveauEchelon.SIEGE_MONDIAL);
|
||||
assertThat(entity.getZoneGeographiqueOuDelegation()).isEqualTo("Monde");
|
||||
assertThat(entity.getOrganisation()).isNull();
|
||||
assertThat(entity.getEchelonParent()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("updateEntityFromDto met à jour l'entité cible")
|
||||
void updateEntityFromDto_updatesTarget() {
|
||||
EchelonOrganigramme entity = EchelonOrganigramme.builder()
|
||||
.designation("Ancienne")
|
||||
.niveau(NiveauEchelon.NATIONAL)
|
||||
.build();
|
||||
EchelonOrganigrammeDTO dto = new EchelonOrganigrammeDTO();
|
||||
dto.setDesignation("Nouvelle désignation");
|
||||
dto.setNiveau(NiveauEchelon.SIEGE_MONDIAL);
|
||||
|
||||
mapper.updateEntityFromDto(dto, entity);
|
||||
|
||||
assertThat(entity.getDesignation()).isEqualTo("Nouvelle désignation");
|
||||
assertThat(entity.getNiveau()).isEqualTo(NiveauEchelon.SIEGE_MONDIAL);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
package dev.lions.unionflow.server.mapper.mutuelle.credit;
|
||||
|
||||
import dev.lions.unionflow.server.api.dto.mutuelle.credit.DemandeCreditRequest;
|
||||
import dev.lions.unionflow.server.api.dto.mutuelle.credit.DemandeCreditResponse;
|
||||
import dev.lions.unionflow.server.api.enums.mutuelle.credit.TypeCredit;
|
||||
import dev.lions.unionflow.server.entity.Membre;
|
||||
import dev.lions.unionflow.server.entity.mutuelle.epargne.CompteEpargne;
|
||||
import dev.lions.unionflow.server.entity.mutuelle.credit.DemandeCredit;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import jakarta.inject.Inject;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Collections;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@QuarkusTest
|
||||
class DemandeCreditMapperTest {
|
||||
|
||||
@Inject
|
||||
DemandeCreditMapper mapper;
|
||||
|
||||
@Test
|
||||
@DisplayName("toDto avec null retourne null")
|
||||
void toDto_null_returnsNull() {
|
||||
assertThat(mapper.toDto(null)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toEntity avec null retourne null")
|
||||
void toEntity_null_returnsNull() {
|
||||
assertThat(mapper.toEntity(null)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toDto mappe entity vers DTO")
|
||||
void toDto_mapsEntityToDto() {
|
||||
UUID membreId = UUID.randomUUID();
|
||||
UUID compteId = UUID.randomUUID();
|
||||
Membre membre = new Membre();
|
||||
membre.setId(membreId);
|
||||
CompteEpargne compte = new CompteEpargne();
|
||||
compte.setId(compteId);
|
||||
DemandeCredit entity = DemandeCredit.builder()
|
||||
.membre(membre)
|
||||
.compteLie(compte)
|
||||
.typeCredit(TypeCredit.CONSOMMATION)
|
||||
.montantDemande(new BigDecimal("500000"))
|
||||
.dureeMoisDemande(12)
|
||||
.justificationDetaillee("Projet")
|
||||
.echeancier(Collections.emptyList())
|
||||
.build();
|
||||
entity.setId(UUID.randomUUID());
|
||||
|
||||
DemandeCreditResponse dto = mapper.toDto(entity);
|
||||
|
||||
assertThat(dto).isNotNull();
|
||||
assertThat(dto.getMembreId()).isEqualTo(membreId.toString());
|
||||
assertThat(dto.getCompteLieId()).isEqualTo(compteId.toString());
|
||||
assertThat(dto.getTypeCredit()).isEqualTo(TypeCredit.CONSOMMATION);
|
||||
assertThat(dto.getMontantDemande()).isEqualByComparingTo("500000");
|
||||
assertThat(dto.getDureeMoisDemande()).isEqualTo(12);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toEntity mappe Request vers entity (dureeMois -> dureeMoisDemande)")
|
||||
void toEntity_mapsRequestToEntity() {
|
||||
DemandeCreditRequest request = DemandeCreditRequest.builder()
|
||||
.membreId(UUID.randomUUID().toString())
|
||||
.typeCredit(TypeCredit.CONSOMMATION)
|
||||
.montantDemande(new BigDecimal("300000"))
|
||||
.dureeMois(24)
|
||||
.compteLieId(UUID.randomUUID().toString())
|
||||
.justificationDetaillee("Projet détaillé")
|
||||
.garantiesProposees(Collections.emptyList())
|
||||
.build();
|
||||
|
||||
DemandeCredit entity = mapper.toEntity(request);
|
||||
|
||||
assertThat(entity).isNotNull();
|
||||
assertThat(entity.getTypeCredit()).isEqualTo(TypeCredit.CONSOMMATION);
|
||||
assertThat(entity.getMontantDemande()).isEqualByComparingTo("300000");
|
||||
assertThat(entity.getDureeMoisDemande()).isEqualTo(24);
|
||||
assertThat(entity.getJustificationDetaillee()).isEqualTo("Projet détaillé");
|
||||
assertThat(entity.getMembre()).isNull();
|
||||
assertThat(entity.getCompteLie()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("updateEntityFromDto met à jour l'entité cible")
|
||||
void updateEntityFromDto_updatesTarget() {
|
||||
DemandeCredit entity = DemandeCredit.builder()
|
||||
.typeCredit(TypeCredit.CONSOMMATION)
|
||||
.montantDemande(BigDecimal.ONE)
|
||||
.dureeMoisDemande(6)
|
||||
.build();
|
||||
DemandeCreditRequest request = DemandeCreditRequest.builder()
|
||||
.membreId(UUID.randomUUID().toString())
|
||||
.typeCredit(TypeCredit.PROFESSIONNEL)
|
||||
.montantDemande(new BigDecimal("200000"))
|
||||
.dureeMois(18)
|
||||
.justificationDetaillee("Nouvelle justification")
|
||||
.build();
|
||||
|
||||
mapper.updateEntityFromDto(request, entity);
|
||||
|
||||
assertThat(entity.getTypeCredit()).isEqualTo(TypeCredit.PROFESSIONNEL);
|
||||
assertThat(entity.getMontantDemande()).isEqualByComparingTo("200000");
|
||||
assertThat(entity.getJustificationDetaillee()).isEqualTo("Nouvelle justification");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package dev.lions.unionflow.server.mapper.mutuelle.credit;
|
||||
|
||||
import dev.lions.unionflow.server.api.dto.mutuelle.credit.EcheanceCreditDTO;
|
||||
import dev.lions.unionflow.server.api.enums.mutuelle.credit.StatutEcheanceCredit;
|
||||
import dev.lions.unionflow.server.entity.mutuelle.credit.DemandeCredit;
|
||||
import dev.lions.unionflow.server.entity.mutuelle.credit.EcheanceCredit;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import jakarta.inject.Inject;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@QuarkusTest
|
||||
class EcheanceCreditMapperTest {
|
||||
|
||||
@Inject
|
||||
EcheanceCreditMapper mapper;
|
||||
|
||||
@Test
|
||||
@DisplayName("toDto avec null retourne null")
|
||||
void toDto_null_returnsNull() {
|
||||
assertThat(mapper.toDto(null)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toEntity avec null retourne null")
|
||||
void toEntity_null_returnsNull() {
|
||||
assertThat(mapper.toEntity(null)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toDto mappe entity vers DTO")
|
||||
void toDto_mapsEntityToDto() {
|
||||
UUID demandeId = UUID.randomUUID();
|
||||
DemandeCredit demande = new DemandeCredit();
|
||||
demande.setId(demandeId);
|
||||
EcheanceCredit entity = EcheanceCredit.builder()
|
||||
.demandeCredit(demande)
|
||||
.ordre(1)
|
||||
.dateEcheancePrevue(LocalDate.now().plusMonths(1))
|
||||
.datePaiementEffectif(null)
|
||||
.capitalAmorti(new BigDecimal("10000"))
|
||||
.interetsDeLaPeriode(new BigDecimal("500"))
|
||||
.montantTotalExigible(new BigDecimal("10500"))
|
||||
.capitalRestantDu(new BigDecimal("90000"))
|
||||
.statut(StatutEcheanceCredit.IMPAYEE)
|
||||
.build();
|
||||
entity.setId(UUID.randomUUID());
|
||||
|
||||
EcheanceCreditDTO dto = mapper.toDto(entity);
|
||||
|
||||
assertThat(dto).isNotNull();
|
||||
assertThat(dto.getDemandeCreditId()).isEqualTo(demandeId.toString());
|
||||
assertThat(dto.getOrdre()).isEqualTo(1);
|
||||
assertThat(dto.getCapitalAmorti()).isEqualByComparingTo("10000");
|
||||
assertThat(dto.getStatut()).isEqualTo(StatutEcheanceCredit.IMPAYEE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toEntity mappe DTO vers entity")
|
||||
void toEntity_mapsDtoToEntity() {
|
||||
EcheanceCreditDTO dto = new EcheanceCreditDTO();
|
||||
dto.setOrdre(2);
|
||||
dto.setDateEcheancePrevue(LocalDate.now().plusMonths(2));
|
||||
dto.setCapitalAmorti(new BigDecimal("10000"));
|
||||
dto.setInteretsDeLaPeriode(new BigDecimal("400"));
|
||||
dto.setMontantTotalExigible(new BigDecimal("10400"));
|
||||
|
||||
EcheanceCredit entity = mapper.toEntity(dto);
|
||||
|
||||
assertThat(entity).isNotNull();
|
||||
assertThat(entity.getOrdre()).isEqualTo(2);
|
||||
assertThat(entity.getCapitalAmorti()).isEqualByComparingTo("10000");
|
||||
assertThat(entity.getDemandeCredit()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("updateEntityFromDto met à jour l'entité cible")
|
||||
void updateEntityFromDto_updatesTarget() {
|
||||
EcheanceCredit entity = EcheanceCredit.builder()
|
||||
.ordre(1)
|
||||
.statut(StatutEcheanceCredit.IMPAYEE)
|
||||
.build();
|
||||
EcheanceCreditDTO dto = new EcheanceCreditDTO();
|
||||
dto.setOrdre(2);
|
||||
dto.setStatut(StatutEcheanceCredit.PAYEE);
|
||||
|
||||
mapper.updateEntityFromDto(dto, entity);
|
||||
|
||||
assertThat(entity.getOrdre()).isEqualTo(2);
|
||||
assertThat(entity.getStatut()).isEqualTo(StatutEcheanceCredit.PAYEE);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package dev.lions.unionflow.server.mapper.mutuelle.credit;
|
||||
|
||||
import dev.lions.unionflow.server.api.dto.mutuelle.credit.GarantieDemandeDTO;
|
||||
import dev.lions.unionflow.server.api.enums.mutuelle.credit.TypeGarantie;
|
||||
import dev.lions.unionflow.server.entity.mutuelle.credit.DemandeCredit;
|
||||
import dev.lions.unionflow.server.entity.mutuelle.credit.GarantieDemande;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import jakarta.inject.Inject;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@QuarkusTest
|
||||
class GarantieDemandeMapperTest {
|
||||
|
||||
@Inject
|
||||
GarantieDemandeMapper mapper;
|
||||
|
||||
@Test
|
||||
@DisplayName("toDto avec null retourne null")
|
||||
void toDto_null_returnsNull() {
|
||||
assertThat(mapper.toDto(null)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toEntity avec null retourne null")
|
||||
void toEntity_null_returnsNull() {
|
||||
assertThat(mapper.toEntity(null)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toDto mappe entity vers DTO")
|
||||
void toDto_mapsEntityToDto() {
|
||||
GarantieDemande entity = GarantieDemande.builder()
|
||||
.typeGarantie(TypeGarantie.CAUTION_SOLIDAIRE)
|
||||
.valeurEstimee(new BigDecimal("500000"))
|
||||
.referenceOuDescription("Membre X - Caution")
|
||||
.documentPreuveId("doc-uuid")
|
||||
.build();
|
||||
entity.setId(UUID.randomUUID());
|
||||
|
||||
GarantieDemandeDTO dto = mapper.toDto(entity);
|
||||
|
||||
assertThat(dto).isNotNull();
|
||||
assertThat(dto.getTypeGarantie()).isEqualTo(TypeGarantie.CAUTION_SOLIDAIRE);
|
||||
assertThat(dto.getValeurEstimee()).isEqualByComparingTo("500000");
|
||||
assertThat(dto.getReferenceOuDescription()).isEqualTo("Membre X - Caution");
|
||||
assertThat(dto.getDocumentPreuveId()).isEqualTo("doc-uuid");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toEntity mappe DTO vers entity")
|
||||
void toEntity_mapsDtoToEntity() {
|
||||
GarantieDemandeDTO dto = new GarantieDemandeDTO();
|
||||
dto.setTypeGarantie(TypeGarantie.EPARGNE_BLOQUEE);
|
||||
dto.setValeurEstimee(new BigDecimal("1000000"));
|
||||
dto.setReferenceOuDescription("Titre foncier SN 123");
|
||||
dto.setDocumentPreuveId("doc-id");
|
||||
|
||||
GarantieDemande entity = mapper.toEntity(dto);
|
||||
|
||||
assertThat(entity).isNotNull();
|
||||
assertThat(entity.getTypeGarantie()).isEqualTo(TypeGarantie.EPARGNE_BLOQUEE);
|
||||
assertThat(entity.getReferenceOuDescription()).isEqualTo("Titre foncier SN 123");
|
||||
assertThat(entity.getDemandeCredit()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("updateEntityFromDto met à jour l'entité cible")
|
||||
void updateEntityFromDto_updatesTarget() {
|
||||
GarantieDemande entity = GarantieDemande.builder()
|
||||
.typeGarantie(TypeGarantie.CAUTION_SOLIDAIRE)
|
||||
.referenceOuDescription("Ancienne")
|
||||
.build();
|
||||
GarantieDemandeDTO dto = new GarantieDemandeDTO();
|
||||
dto.setTypeGarantie(TypeGarantie.EPARGNE_BLOQUEE);
|
||||
dto.setReferenceOuDescription("Nouvelle référence");
|
||||
|
||||
mapper.updateEntityFromDto(dto, entity);
|
||||
|
||||
assertThat(entity.getTypeGarantie()).isEqualTo(TypeGarantie.EPARGNE_BLOQUEE);
|
||||
assertThat(entity.getReferenceOuDescription()).isEqualTo("Nouvelle référence");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package dev.lions.unionflow.server.mapper.mutuelle.epargne;
|
||||
|
||||
import dev.lions.unionflow.server.api.dto.mutuelle.epargne.CompteEpargneRequest;
|
||||
import dev.lions.unionflow.server.api.dto.mutuelle.epargne.CompteEpargneResponse;
|
||||
import dev.lions.unionflow.server.api.enums.mutuelle.epargne.StatutCompteEpargne;
|
||||
import dev.lions.unionflow.server.api.enums.mutuelle.epargne.TypeCompteEpargne;
|
||||
import dev.lions.unionflow.server.entity.Membre;
|
||||
import dev.lions.unionflow.server.entity.Organisation;
|
||||
import dev.lions.unionflow.server.entity.mutuelle.epargne.CompteEpargne;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import jakarta.inject.Inject;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@QuarkusTest
|
||||
class CompteEpargneMapperTest {
|
||||
|
||||
@Inject
|
||||
CompteEpargneMapper mapper;
|
||||
|
||||
@Test
|
||||
@DisplayName("toDto avec null retourne null")
|
||||
void toDto_null_returnsNull() {
|
||||
assertThat(mapper.toDto(null)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toEntity avec null retourne null")
|
||||
void toEntity_null_returnsNull() {
|
||||
assertThat(mapper.toEntity(null)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toDto mappe entity vers DTO")
|
||||
void toDto_mapsEntityToDto() {
|
||||
UUID membreId = UUID.randomUUID();
|
||||
UUID orgId = UUID.randomUUID();
|
||||
Membre membre = new Membre();
|
||||
membre.setId(membreId);
|
||||
Organisation org = new Organisation();
|
||||
org.setId(orgId);
|
||||
CompteEpargne entity = CompteEpargne.builder()
|
||||
.membre(membre)
|
||||
.organisation(org)
|
||||
.numeroCompte("MEC-00123")
|
||||
.typeCompte(TypeCompteEpargne.EPARGNE_LIBRE)
|
||||
.soldeActuel(new BigDecimal("100000"))
|
||||
.soldeBloque(BigDecimal.ZERO)
|
||||
.statut(StatutCompteEpargne.ACTIF)
|
||||
.dateOuverture(LocalDate.now())
|
||||
.description("Compte principal")
|
||||
.build();
|
||||
entity.setId(UUID.randomUUID());
|
||||
|
||||
CompteEpargneResponse dto = mapper.toDto(entity);
|
||||
|
||||
assertThat(dto).isNotNull();
|
||||
assertThat(dto.getMembreId()).isEqualTo(membreId.toString());
|
||||
assertThat(dto.getOrganisationId()).isEqualTo(orgId.toString());
|
||||
assertThat(dto.getNumeroCompte()).isEqualTo("MEC-00123");
|
||||
assertThat(dto.getTypeCompte()).isEqualTo(TypeCompteEpargne.EPARGNE_LIBRE);
|
||||
assertThat(dto.getSoldeActuel()).isEqualByComparingTo("100000");
|
||||
assertThat(dto.getStatut()).isEqualTo(StatutCompteEpargne.ACTIF);
|
||||
assertThat(dto.getDescription()).isEqualTo("Compte principal");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toEntity mappe Request vers entity (notesOuverture -> description)")
|
||||
void toEntity_mapsRequestToEntity() {
|
||||
CompteEpargneRequest request = new CompteEpargneRequest();
|
||||
request.setMembreId(UUID.randomUUID().toString());
|
||||
request.setOrganisationId(UUID.randomUUID().toString());
|
||||
request.setTypeCompte(TypeCompteEpargne.EPARGNE_LIBRE);
|
||||
request.setNotesOuverture("Notes à l'ouverture");
|
||||
|
||||
CompteEpargne entity = mapper.toEntity(request);
|
||||
|
||||
assertThat(entity).isNotNull();
|
||||
assertThat(entity.getTypeCompte()).isEqualTo(TypeCompteEpargne.EPARGNE_LIBRE);
|
||||
assertThat(entity.getDescription()).isEqualTo("Notes à l'ouverture");
|
||||
assertThat(entity.getMembre()).isNull();
|
||||
assertThat(entity.getOrganisation()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("updateEntityFromDto met à jour l'entité cible")
|
||||
void updateEntityFromDto_updatesTarget() {
|
||||
CompteEpargne entity = CompteEpargne.builder()
|
||||
.typeCompte(TypeCompteEpargne.EPARGNE_LIBRE)
|
||||
.description("Ancienne")
|
||||
.build();
|
||||
CompteEpargneRequest request = new CompteEpargneRequest();
|
||||
request.setMembreId(UUID.randomUUID().toString());
|
||||
request.setOrganisationId(UUID.randomUUID().toString());
|
||||
request.setTypeCompte(TypeCompteEpargne.EPARGNE_BLOQUEE);
|
||||
request.setNotesOuverture("Nouvelles notes");
|
||||
|
||||
mapper.updateEntityFromDto(request, entity);
|
||||
|
||||
assertThat(entity.getTypeCompte()).isEqualTo(TypeCompteEpargne.EPARGNE_BLOQUEE);
|
||||
assertThat(entity.getDescription()).isEqualTo("Nouvelles notes");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
package dev.lions.unionflow.server.mapper.mutuelle.epargne;
|
||||
|
||||
import dev.lions.unionflow.server.api.dto.mutuelle.epargne.TransactionEpargneRequest;
|
||||
import dev.lions.unionflow.server.api.dto.mutuelle.epargne.TransactionEpargneResponse;
|
||||
import dev.lions.unionflow.server.api.enums.mutuelle.epargne.TypeTransactionEpargne;
|
||||
import dev.lions.unionflow.server.api.enums.wave.StatutTransactionWave;
|
||||
import dev.lions.unionflow.server.entity.mutuelle.epargne.CompteEpargne;
|
||||
import dev.lions.unionflow.server.entity.mutuelle.epargne.TransactionEpargne;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import jakarta.inject.Inject;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@QuarkusTest
|
||||
class TransactionEpargneMapperTest {
|
||||
|
||||
@Inject
|
||||
TransactionEpargneMapper mapper;
|
||||
|
||||
@Test
|
||||
@DisplayName("toDto avec null retourne null")
|
||||
void toDto_null_returnsNull() {
|
||||
assertThat(mapper.toDto(null)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toEntity avec null retourne null")
|
||||
void toEntity_null_returnsNull() {
|
||||
assertThat(mapper.toEntity(null)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toDto mappe entity vers DTO")
|
||||
void toDto_mapsEntityToDto() {
|
||||
UUID compteId = UUID.randomUUID();
|
||||
CompteEpargne compte = new CompteEpargne();
|
||||
compte.setId(compteId);
|
||||
TransactionEpargne entity = TransactionEpargne.builder()
|
||||
.compte(compte)
|
||||
.type(TypeTransactionEpargne.DEPOT)
|
||||
.montant(new BigDecimal("50000"))
|
||||
.soldeAvant(new BigDecimal("100000"))
|
||||
.soldeApres(new BigDecimal("150000"))
|
||||
.motif("Dépôt mensuel")
|
||||
.dateTransaction(LocalDateTime.now())
|
||||
.statutExecution(StatutTransactionWave.REUSSIE)
|
||||
.build();
|
||||
entity.setId(UUID.randomUUID());
|
||||
|
||||
TransactionEpargneResponse dto = mapper.toDto(entity);
|
||||
|
||||
assertThat(dto).isNotNull();
|
||||
assertThat(dto.getCompteId()).isEqualTo(compteId.toString());
|
||||
assertThat(dto.getType()).isEqualTo(TypeTransactionEpargne.DEPOT);
|
||||
assertThat(dto.getMontant()).isEqualByComparingTo("50000");
|
||||
assertThat(dto.getMotif()).isEqualTo("Dépôt mensuel");
|
||||
assertThat(dto.getStatutExecution()).isEqualTo(StatutTransactionWave.REUSSIE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toEntity mappe Request vers entity (typeTransaction -> type)")
|
||||
void toEntity_mapsRequestToEntity() {
|
||||
TransactionEpargneRequest request = TransactionEpargneRequest.builder()
|
||||
.compteId(UUID.randomUUID().toString())
|
||||
.typeTransaction(TypeTransactionEpargne.RETRAIT)
|
||||
.montant(new BigDecimal("25000"))
|
||||
.motif("Retrait")
|
||||
.build();
|
||||
|
||||
TransactionEpargne entity = mapper.toEntity(request);
|
||||
|
||||
assertThat(entity).isNotNull();
|
||||
assertThat(entity.getType()).isEqualTo(TypeTransactionEpargne.RETRAIT);
|
||||
assertThat(entity.getMontant()).isEqualByComparingTo("25000");
|
||||
assertThat(entity.getMotif()).isEqualTo("Retrait");
|
||||
assertThat(entity.getCompte()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("updateEntityFromDto met à jour l'entité cible")
|
||||
void updateEntityFromDto_updatesTarget() {
|
||||
TransactionEpargne entity = TransactionEpargne.builder()
|
||||
.type(TypeTransactionEpargne.DEPOT)
|
||||
.montant(BigDecimal.ONE)
|
||||
.build();
|
||||
TransactionEpargneRequest request = TransactionEpargneRequest.builder()
|
||||
.compteId(UUID.randomUUID().toString())
|
||||
.typeTransaction(TypeTransactionEpargne.TRANSFERT_SORTANT)
|
||||
.montant(new BigDecimal("75000"))
|
||||
.motif("Virement")
|
||||
.build();
|
||||
|
||||
mapper.updateEntityFromDto(request, entity);
|
||||
|
||||
assertThat(entity.getType()).isEqualTo(TypeTransactionEpargne.TRANSFERT_SORTANT);
|
||||
assertThat(entity.getMontant()).isEqualByComparingTo("75000");
|
||||
assertThat(entity.getMotif()).isEqualTo("Virement");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package dev.lions.unionflow.server.mapper.ong;
|
||||
|
||||
import dev.lions.unionflow.server.api.dto.ong.ProjetOngDTO;
|
||||
import dev.lions.unionflow.server.api.enums.ong.StatutProjetOng;
|
||||
import dev.lions.unionflow.server.entity.Organisation;
|
||||
import dev.lions.unionflow.server.entity.ong.ProjetOng;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import jakarta.inject.Inject;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@QuarkusTest
|
||||
class ProjetOngMapperTest {
|
||||
|
||||
@Inject
|
||||
ProjetOngMapper mapper;
|
||||
|
||||
@Test
|
||||
@DisplayName("toDto avec null retourne null")
|
||||
void toDto_null_returnsNull() {
|
||||
assertThat(mapper.toDto(null)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toEntity avec null retourne null")
|
||||
void toEntity_null_returnsNull() {
|
||||
assertThat(mapper.toEntity(null)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toDto mappe entity vers DTO")
|
||||
void toDto_mapsEntityToDto() {
|
||||
UUID orgId = UUID.randomUUID();
|
||||
Organisation org = new Organisation();
|
||||
org.setId(orgId);
|
||||
ProjetOng entity = ProjetOng.builder()
|
||||
.organisation(org)
|
||||
.nomProjet("Projet santé")
|
||||
.statut(StatutProjetOng.EN_ETUDE)
|
||||
.build();
|
||||
entity.setId(UUID.randomUUID());
|
||||
|
||||
ProjetOngDTO dto = mapper.toDto(entity);
|
||||
|
||||
assertThat(dto).isNotNull();
|
||||
assertThat(dto.getOrganisationId()).isEqualTo(orgId.toString());
|
||||
assertThat(dto.getNomProjet()).isEqualTo("Projet santé");
|
||||
assertThat(dto.getStatut()).isEqualTo(StatutProjetOng.EN_ETUDE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toEntity mappe DTO vers entity (champs non ignorés)")
|
||||
void toEntity_mapsDtoToEntity() {
|
||||
ProjetOngDTO dto = new ProjetOngDTO();
|
||||
dto.setNomProjet("Projet test");
|
||||
dto.setDescriptionMandat("Description");
|
||||
dto.setZoneGeographiqueIntervention("Afrique");
|
||||
|
||||
ProjetOng entity = mapper.toEntity(dto);
|
||||
|
||||
assertThat(entity).isNotNull();
|
||||
assertThat(entity.getNomProjet()).isEqualTo("Projet test");
|
||||
assertThat(entity.getDescriptionMandat()).isEqualTo("Description");
|
||||
assertThat(entity.getZoneGeographiqueIntervention()).isEqualTo("Afrique");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package dev.lions.unionflow.server.mapper.registre;
|
||||
|
||||
import dev.lions.unionflow.server.api.dto.registre.AgrementProfessionnelDTO;
|
||||
import dev.lions.unionflow.server.api.enums.registre.StatutAgrement;
|
||||
import dev.lions.unionflow.server.entity.Membre;
|
||||
import dev.lions.unionflow.server.entity.Organisation;
|
||||
import dev.lions.unionflow.server.entity.registre.AgrementProfessionnel;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import jakarta.inject.Inject;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@QuarkusTest
|
||||
class AgrementProfessionnelMapperTest {
|
||||
|
||||
@Inject
|
||||
AgrementProfessionnelMapper mapper;
|
||||
|
||||
@Test
|
||||
@DisplayName("toDto avec null retourne null")
|
||||
void toDto_null_returnsNull() {
|
||||
assertThat(mapper.toDto(null)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toEntity avec null retourne null")
|
||||
void toEntity_null_returnsNull() {
|
||||
assertThat(mapper.toEntity(null)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toDto mappe entity vers DTO")
|
||||
void toDto_mapsEntityToDto() {
|
||||
UUID membreId = UUID.randomUUID();
|
||||
UUID orgId = UUID.randomUUID();
|
||||
Membre m = new Membre();
|
||||
m.setId(membreId);
|
||||
Organisation o = new Organisation();
|
||||
o.setId(orgId);
|
||||
AgrementProfessionnel entity = AgrementProfessionnel.builder()
|
||||
.membre(m)
|
||||
.organisation(o)
|
||||
.statut(StatutAgrement.VALIDE)
|
||||
.secteurOuOrdre("Santé")
|
||||
.build();
|
||||
entity.setId(UUID.randomUUID());
|
||||
|
||||
AgrementProfessionnelDTO dto = mapper.toDto(entity);
|
||||
|
||||
assertThat(dto).isNotNull();
|
||||
assertThat(dto.getMembreId()).isEqualTo(membreId.toString());
|
||||
assertThat(dto.getOrganisationId()).isEqualTo(orgId.toString());
|
||||
assertThat(dto.getStatut()).isEqualTo(StatutAgrement.VALIDE);
|
||||
assertThat(dto.getSecteurOuOrdre()).isEqualTo("Santé");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toEntity mappe DTO vers entity")
|
||||
void toEntity_mapsDtoToEntity() {
|
||||
AgrementProfessionnelDTO dto = new AgrementProfessionnelDTO();
|
||||
dto.setStatut(StatutAgrement.PROVISOIRE);
|
||||
dto.setSecteurOuOrdre("Juridique");
|
||||
|
||||
AgrementProfessionnel entity = mapper.toEntity(dto);
|
||||
|
||||
assertThat(entity).isNotNull();
|
||||
assertThat(entity.getStatut()).isEqualTo(StatutAgrement.PROVISOIRE);
|
||||
assertThat(entity.getSecteurOuOrdre()).isEqualTo("Juridique");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
package dev.lions.unionflow.server.mapper.tontine;
|
||||
|
||||
import dev.lions.unionflow.server.api.dto.tontine.TontineRequest;
|
||||
import dev.lions.unionflow.server.api.dto.tontine.TontineResponse;
|
||||
import dev.lions.unionflow.server.api.enums.tontine.FrequenceTour;
|
||||
import dev.lions.unionflow.server.api.enums.tontine.TypeTontine;
|
||||
import dev.lions.unionflow.server.entity.Organisation;
|
||||
import dev.lions.unionflow.server.entity.tontine.Tontine;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import jakarta.inject.Inject;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Collections;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@QuarkusTest
|
||||
class TontineMapperTest {
|
||||
|
||||
@Inject
|
||||
TontineMapper mapper;
|
||||
|
||||
@Test
|
||||
@DisplayName("toDto avec null retourne null")
|
||||
void toDto_null_returnsNull() {
|
||||
assertThat(mapper.toDto(null)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toEntity avec null retourne null")
|
||||
void toEntity_null_returnsNull() {
|
||||
assertThat(mapper.toEntity(null)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toDto mappe entity vers DTO")
|
||||
void toDto_mapsEntityToDto() {
|
||||
UUID orgId = UUID.randomUUID();
|
||||
Organisation org = new Organisation();
|
||||
org.setId(orgId);
|
||||
Tontine entity = Tontine.builder()
|
||||
.organisation(org)
|
||||
.nom("Tontine 2025")
|
||||
.description("Description")
|
||||
.typeTontine(TypeTontine.ROTATIVE_CLASSIQUE)
|
||||
.frequence(FrequenceTour.MENSUELLE)
|
||||
.montantMiseParTour(new BigDecimal("10000"))
|
||||
.limiteParticipants(20)
|
||||
.calendrierTours(Collections.emptyList())
|
||||
.build();
|
||||
entity.setId(UUID.randomUUID());
|
||||
|
||||
TontineResponse dto = mapper.toDto(entity);
|
||||
|
||||
assertThat(dto).isNotNull();
|
||||
assertThat(dto.getOrganisationId()).isEqualTo(orgId.toString());
|
||||
assertThat(dto.getNom()).isEqualTo("Tontine 2025");
|
||||
assertThat(dto.getDescription()).isEqualTo("Description");
|
||||
assertThat(dto.getTypeTontine()).isEqualTo(TypeTontine.ROTATIVE_CLASSIQUE);
|
||||
assertThat(dto.getFrequence()).isEqualTo(FrequenceTour.MENSUELLE);
|
||||
assertThat(dto.getMontantMiseParTour()).isEqualByComparingTo("10000");
|
||||
assertThat(dto.getLimiteParticipants()).isEqualTo(20);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toEntity mappe Request vers entity")
|
||||
void toEntity_mapsRequestToEntity() {
|
||||
TontineRequest request = TontineRequest.builder()
|
||||
.nom("Tontine test")
|
||||
.description("Desc")
|
||||
.organisationId(UUID.randomUUID().toString())
|
||||
.typeTontine(TypeTontine.ROTATIVE_CLASSIQUE)
|
||||
.frequence(FrequenceTour.HEBDOMADAIRE)
|
||||
.dateDebutPrevue(LocalDate.now().plusDays(7))
|
||||
.montantMiseParTour(new BigDecimal("5000"))
|
||||
.limiteParticipants(10)
|
||||
.build();
|
||||
|
||||
Tontine entity = mapper.toEntity(request);
|
||||
|
||||
assertThat(entity).isNotNull();
|
||||
assertThat(entity.getNom()).isEqualTo("Tontine test");
|
||||
assertThat(entity.getTypeTontine()).isEqualTo(TypeTontine.ROTATIVE_CLASSIQUE);
|
||||
assertThat(entity.getFrequence()).isEqualTo(FrequenceTour.HEBDOMADAIRE);
|
||||
assertThat(entity.getOrganisation()).isNull();
|
||||
assertThat(entity.getCalendrierTours()).isNotNull().isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("updateEntityFromDto met à jour l'entité cible")
|
||||
void updateEntityFromDto_updatesTarget() {
|
||||
Tontine entity = Tontine.builder()
|
||||
.nom("Ancienne")
|
||||
.montantMiseParTour(BigDecimal.ZERO)
|
||||
.build();
|
||||
TontineRequest request = TontineRequest.builder()
|
||||
.nom("Nouvelle tontine")
|
||||
.organisationId(UUID.randomUUID().toString())
|
||||
.typeTontine(TypeTontine.ROTATIVE_CLASSIQUE)
|
||||
.frequence(FrequenceTour.MENSUELLE)
|
||||
.dateDebutPrevue(LocalDate.now())
|
||||
.montantMiseParTour(new BigDecimal("15000"))
|
||||
.limiteParticipants(15)
|
||||
.build();
|
||||
|
||||
mapper.updateEntityFromDto(request, entity);
|
||||
|
||||
assertThat(entity.getNom()).isEqualTo("Nouvelle tontine");
|
||||
assertThat(entity.getMontantMiseParTour()).isEqualByComparingTo("15000");
|
||||
assertThat(entity.getLimiteParticipants()).isEqualTo(15);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package dev.lions.unionflow.server.mapper.tontine;
|
||||
|
||||
import dev.lions.unionflow.server.api.dto.tontine.TourTontineDTO;
|
||||
import dev.lions.unionflow.server.entity.Membre;
|
||||
import dev.lions.unionflow.server.entity.tontine.Tontine;
|
||||
import dev.lions.unionflow.server.entity.tontine.TourTontine;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import jakarta.inject.Inject;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@QuarkusTest
|
||||
class TourTontineMapperTest {
|
||||
|
||||
@Inject
|
||||
TourTontineMapper mapper;
|
||||
|
||||
@Test
|
||||
@DisplayName("toDto avec null retourne null")
|
||||
void toDto_null_returnsNull() {
|
||||
assertThat(mapper.toDto(null)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toEntity avec null retourne null")
|
||||
void toEntity_null_returnsNull() {
|
||||
assertThat(mapper.toEntity(null)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toDto mappe entity vers DTO")
|
||||
void toDto_mapsEntityToDto() {
|
||||
UUID tontineId = UUID.randomUUID();
|
||||
UUID membreId = UUID.randomUUID();
|
||||
Tontine tontine = new Tontine();
|
||||
tontine.setId(tontineId);
|
||||
Membre membre = new Membre();
|
||||
membre.setId(membreId);
|
||||
TourTontine entity = TourTontine.builder()
|
||||
.tontine(tontine)
|
||||
.membreBeneficiaire(membre)
|
||||
.ordreTour(1)
|
||||
.dateOuvertureCotisations(LocalDate.now())
|
||||
.dateTirageOuRemise(LocalDate.now().plusDays(7))
|
||||
.montantCible(new BigDecimal("100000"))
|
||||
.cagnotteCollectee(new BigDecimal("50000"))
|
||||
.statutInterne("EN_COURS")
|
||||
.build();
|
||||
entity.setId(UUID.randomUUID());
|
||||
|
||||
TourTontineDTO dto = mapper.toDto(entity);
|
||||
|
||||
assertThat(dto).isNotNull();
|
||||
assertThat(dto.getTontineId()).isEqualTo(tontineId.toString());
|
||||
assertThat(dto.getMembreBeneficiaireId()).isEqualTo(membreId.toString());
|
||||
assertThat(dto.getOrdreTour()).isEqualTo(1);
|
||||
assertThat(dto.getStatutInterne()).isEqualTo("EN_COURS");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toEntity mappe DTO vers entity")
|
||||
void toEntity_mapsDtoToEntity() {
|
||||
TourTontineDTO dto = new TourTontineDTO();
|
||||
dto.setOrdreTour(2);
|
||||
dto.setDateOuvertureCotisations(LocalDate.now());
|
||||
dto.setMontantCible(new BigDecimal("200000"));
|
||||
dto.setStatutInterne("A_VENIR");
|
||||
|
||||
TourTontine entity = mapper.toEntity(dto);
|
||||
|
||||
assertThat(entity).isNotNull();
|
||||
assertThat(entity.getOrdreTour()).isEqualTo(2);
|
||||
assertThat(entity.getMontantCible()).isEqualByComparingTo("200000");
|
||||
assertThat(entity.getTontine()).isNull();
|
||||
assertThat(entity.getMembreBeneficiaire()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("updateEntityFromDto met à jour l'entité cible")
|
||||
void updateEntityFromDto_updatesTarget() {
|
||||
TourTontine entity = TourTontine.builder()
|
||||
.ordreTour(1)
|
||||
.statutInterne("A_VENIR")
|
||||
.build();
|
||||
TourTontineDTO dto = new TourTontineDTO();
|
||||
dto.setOrdreTour(3);
|
||||
dto.setStatutInterne("CLOTURE");
|
||||
|
||||
mapper.updateEntityFromDto(dto, entity);
|
||||
|
||||
assertThat(entity.getOrdreTour()).isEqualTo(3);
|
||||
assertThat(entity.getStatutInterne()).isEqualTo("CLOTURE");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
package dev.lions.unionflow.server.mapper.vote;
|
||||
|
||||
import dev.lions.unionflow.server.api.dto.vote.CampagneVoteRequest;
|
||||
import dev.lions.unionflow.server.api.dto.vote.CampagneVoteResponse;
|
||||
import dev.lions.unionflow.server.api.enums.vote.ModeScrutin;
|
||||
import dev.lions.unionflow.server.api.enums.vote.TypeVote;
|
||||
import dev.lions.unionflow.server.entity.Organisation;
|
||||
import dev.lions.unionflow.server.entity.vote.CampagneVote;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import jakarta.inject.Inject;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collections;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@QuarkusTest
|
||||
class CampagneVoteMapperTest {
|
||||
|
||||
@Inject
|
||||
CampagneVoteMapper mapper;
|
||||
|
||||
@Test
|
||||
@DisplayName("toDto avec null retourne null")
|
||||
void toDto_null_returnsNull() {
|
||||
assertThat(mapper.toDto(null)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toEntity avec null retourne null")
|
||||
void toEntity_null_returnsNull() {
|
||||
assertThat(mapper.toEntity(null)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toDto mappe entity vers DTO")
|
||||
void toDto_mapsEntityToDto() {
|
||||
UUID orgId = UUID.randomUUID();
|
||||
Organisation org = new Organisation();
|
||||
org.setId(orgId);
|
||||
CampagneVote entity = CampagneVote.builder()
|
||||
.organisation(org)
|
||||
.titre("Élection bureau 2025")
|
||||
.descriptionOuResolution("Résolution")
|
||||
.typeVote(TypeVote.ELECTION_BUREAU)
|
||||
.modeScrutin(ModeScrutin.MAJORITAIRE_UN_TOUR)
|
||||
.dateOuverture(LocalDateTime.now().plusDays(1))
|
||||
.dateFermeture(LocalDateTime.now().plusDays(2))
|
||||
.restreindreMembresAJour(true)
|
||||
.autoriserVoteBlanc(true)
|
||||
.candidats(Collections.emptyList())
|
||||
.build();
|
||||
entity.setId(UUID.randomUUID());
|
||||
|
||||
CampagneVoteResponse dto = mapper.toDto(entity);
|
||||
|
||||
assertThat(dto).isNotNull();
|
||||
assertThat(dto.getOrganisationId()).isEqualTo(orgId.toString());
|
||||
assertThat(dto.getTitre()).isEqualTo("Élection bureau 2025");
|
||||
assertThat(dto.getDescriptionOuResolution()).isEqualTo("Résolution");
|
||||
assertThat(dto.getTypeVote()).isEqualTo(TypeVote.ELECTION_BUREAU);
|
||||
assertThat(dto.getModeScrutin()).isEqualTo(ModeScrutin.MAJORITAIRE_UN_TOUR);
|
||||
assertThat(dto.getRestreindreMembresAJour()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toEntity mappe Request vers entity")
|
||||
void toEntity_mapsRequestToEntity() {
|
||||
CampagneVoteRequest request = CampagneVoteRequest.builder()
|
||||
.titre("Vote test")
|
||||
.descriptionOuResolution("Desc")
|
||||
.organisationId(UUID.randomUUID().toString())
|
||||
.typeVote(TypeVote.REFERENDUM)
|
||||
.modeScrutin(ModeScrutin.BUREAU_CONSENSUEL)
|
||||
.dateOuverture(LocalDateTime.now().plusDays(1))
|
||||
.dateFermeture(LocalDateTime.now().plusDays(2))
|
||||
.restreindreMembresAJour(false)
|
||||
.autoriserVoteBlanc(true)
|
||||
.build();
|
||||
|
||||
CampagneVote entity = mapper.toEntity(request);
|
||||
|
||||
assertThat(entity).isNotNull();
|
||||
assertThat(entity.getTitre()).isEqualTo("Vote test");
|
||||
assertThat(entity.getDescriptionOuResolution()).isEqualTo("Desc");
|
||||
assertThat(entity.getTypeVote()).isEqualTo(TypeVote.REFERENDUM);
|
||||
assertThat(entity.getOrganisation()).isNull();
|
||||
assertThat(entity.getCandidats()).isNotNull().isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("updateEntityFromDto met à jour l'entité cible")
|
||||
void updateEntityFromDto_updatesTarget() {
|
||||
CampagneVote entity = CampagneVote.builder()
|
||||
.titre("Ancien")
|
||||
.typeVote(TypeVote.ELECTION_BUREAU)
|
||||
.build();
|
||||
CampagneVoteRequest request = CampagneVoteRequest.builder()
|
||||
.titre("Nouveau titre")
|
||||
.organisationId(UUID.randomUUID().toString())
|
||||
.typeVote(TypeVote.REFERENDUM)
|
||||
.modeScrutin(ModeScrutin.MAJORITAIRE_UN_TOUR)
|
||||
.dateOuverture(LocalDateTime.now().plusDays(1))
|
||||
.dateFermeture(LocalDateTime.now().plusDays(2))
|
||||
.build();
|
||||
|
||||
mapper.updateEntityFromDto(request, entity);
|
||||
|
||||
assertThat(entity.getTitre()).isEqualTo("Nouveau titre");
|
||||
assertThat(entity.getTypeVote()).isEqualTo(TypeVote.REFERENDUM);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package dev.lions.unionflow.server.mapper.vote;
|
||||
|
||||
import dev.lions.unionflow.server.api.dto.vote.CandidatDTO;
|
||||
import dev.lions.unionflow.server.entity.vote.CampagneVote;
|
||||
import dev.lions.unionflow.server.entity.vote.Candidat;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import jakarta.inject.Inject;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@QuarkusTest
|
||||
class CandidatMapperTest {
|
||||
|
||||
@Inject
|
||||
CandidatMapper mapper;
|
||||
|
||||
@Test
|
||||
@DisplayName("toDto avec null retourne null")
|
||||
void toDto_null_returnsNull() {
|
||||
assertThat(mapper.toDto(null)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toEntity avec null retourne null")
|
||||
void toEntity_null_returnsNull() {
|
||||
assertThat(mapper.toEntity(null)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toDto mappe entity vers DTO")
|
||||
void toDto_mapsEntityToDto() {
|
||||
UUID campagneId = UUID.randomUUID();
|
||||
CampagneVote campagne = new CampagneVote();
|
||||
campagne.setId(campagneId);
|
||||
Candidat entity = Candidat.builder()
|
||||
.campagneVote(campagne)
|
||||
.nomCandidatureOuChoix("Liste A")
|
||||
.membreIdAssocie(null)
|
||||
.professionDeFoi("Programme")
|
||||
.photoUrl("https://photo")
|
||||
.nombreDeVoix(10)
|
||||
.pourcentageObtenu(new BigDecimal("25.5"))
|
||||
.build();
|
||||
entity.setId(UUID.randomUUID());
|
||||
|
||||
CandidatDTO dto = mapper.toDto(entity);
|
||||
|
||||
assertThat(dto).isNotNull();
|
||||
assertThat(dto.getCampagneVoteId()).isEqualTo(campagneId.toString());
|
||||
assertThat(dto.getNomCandidatureOuChoix()).isEqualTo("Liste A");
|
||||
assertThat(dto.getProfessionDeFoi()).isEqualTo("Programme");
|
||||
assertThat(dto.getPhotoUrl()).isEqualTo("https://photo");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toEntity mappe DTO vers entity")
|
||||
void toEntity_mapsDtoToEntity() {
|
||||
CandidatDTO dto = new CandidatDTO();
|
||||
dto.setNomCandidatureOuChoix("OUI");
|
||||
dto.setMembreIdAssocie("membre-uuid");
|
||||
dto.setProfessionDeFoi("Foi");
|
||||
|
||||
Candidat entity = mapper.toEntity(dto);
|
||||
|
||||
assertThat(entity).isNotNull();
|
||||
assertThat(entity.getNomCandidatureOuChoix()).isEqualTo("OUI");
|
||||
assertThat(entity.getMembreIdAssocie()).isEqualTo("membre-uuid");
|
||||
assertThat(entity.getCampagneVote()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("updateEntityFromDto met à jour l'entité cible")
|
||||
void updateEntityFromDto_updatesTarget() {
|
||||
Candidat entity = Candidat.builder()
|
||||
.nomCandidatureOuChoix("Ancien")
|
||||
.build();
|
||||
CandidatDTO dto = new CandidatDTO();
|
||||
dto.setNomCandidatureOuChoix("Nouveau choix");
|
||||
|
||||
mapper.updateEntityFromDto(dto, entity);
|
||||
|
||||
assertThat(entity.getNomCandidatureOuChoix()).isEqualTo("Nouveau choix");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
package dev.lions.unionflow.server.repository;
|
||||
|
||||
import dev.lions.unionflow.server.entity.DemandeAdhesion;
|
||||
import dev.lions.unionflow.server.entity.Membre;
|
||||
import dev.lions.unionflow.server.entity.Organisation;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.quarkus.test.TestTransaction;
|
||||
import jakarta.inject.Inject;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@QuarkusTest
|
||||
class AdhesionRepositoryTest {
|
||||
|
||||
@Inject
|
||||
AdhesionRepository adhesionRepository;
|
||||
@Inject
|
||||
OrganisationRepository organisationRepository;
|
||||
@Inject
|
||||
MembreRepository membreRepository;
|
||||
|
||||
private Organisation newOrganisation() {
|
||||
Organisation o = new Organisation();
|
||||
o.setNom("Org Adhesion");
|
||||
o.setTypeOrganisation("ASSOCIATION");
|
||||
o.setStatut("ACTIVE");
|
||||
o.setEmail("adh-org-" + UUID.randomUUID() + "@test.com");
|
||||
o.setActif(true);
|
||||
organisationRepository.persist(o);
|
||||
return o;
|
||||
}
|
||||
|
||||
private Membre newMembre() {
|
||||
Membre m = new Membre();
|
||||
m.setNumeroMembre("ADH-" + UUID.randomUUID().toString().substring(0, 8));
|
||||
m.setPrenom("Test");
|
||||
m.setNom("User");
|
||||
m.setEmail("adh-membre-" + UUID.randomUUID() + "@test.com");
|
||||
m.setDateNaissance(java.time.LocalDate.of(1990, 1, 1));
|
||||
m.setActif(true);
|
||||
membreRepository.persist(m);
|
||||
return m;
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findByNumeroReference retourne empty pour référence inexistante")
|
||||
void findByNumeroReference_inexistant_returnsEmpty() {
|
||||
Optional<DemandeAdhesion> opt = adhesionRepository.findByNumeroReference("REF-" + UUID.randomUUID());
|
||||
assertThat(opt).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findByMembreId retourne une liste")
|
||||
void findByMembreId_returnsList() {
|
||||
List<DemandeAdhesion> list = adhesionRepository.findByMembreId(UUID.randomUUID());
|
||||
assertThat(list).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findByOrganisationId retourne une liste")
|
||||
void findByOrganisationId_returnsList() {
|
||||
List<DemandeAdhesion> list = adhesionRepository.findByOrganisationId(UUID.randomUUID());
|
||||
assertThat(list).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findByStatut retourne une liste")
|
||||
void findByStatut_returnsList() {
|
||||
List<DemandeAdhesion> list = adhesionRepository.findByStatut("EN_ATTENTE");
|
||||
assertThat(list).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findEnAttente retourne une liste")
|
||||
void findEnAttente_returnsList() {
|
||||
List<DemandeAdhesion> list = adhesionRepository.findEnAttente();
|
||||
assertThat(list).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findApprouveesEnAttentePaiement retourne une liste")
|
||||
void findApprouveesEnAttentePaiement_returnsList() {
|
||||
List<DemandeAdhesion> list = adhesionRepository.findApprouveesEnAttentePaiement();
|
||||
assertThat(list).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("persist puis findById et findByNumeroReference retrouvent la demande")
|
||||
void persist_thenFind_findsDemande() {
|
||||
Organisation org = newOrganisation();
|
||||
Membre membre = newMembre();
|
||||
String ref = "DA-" + UUID.randomUUID().toString().substring(0, 8);
|
||||
DemandeAdhesion d = DemandeAdhesion.builder()
|
||||
.numeroReference(ref)
|
||||
.utilisateur(membre)
|
||||
.organisation(org)
|
||||
.statut("EN_ATTENTE")
|
||||
.build();
|
||||
adhesionRepository.persist(d);
|
||||
assertThat(d.getId()).isNotNull();
|
||||
DemandeAdhesion found = adhesionRepository.findById(d.getId());
|
||||
assertThat(found).isNotNull();
|
||||
Optional<DemandeAdhesion> byRef = adhesionRepository.findByNumeroReference(ref);
|
||||
assertThat(byRef).isPresent();
|
||||
assertThat(byRef.get().getNumeroReference()).isEqualTo(ref);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package dev.lions.unionflow.server.repository;
|
||||
|
||||
import dev.lions.unionflow.server.entity.Adresse;
|
||||
import dev.lions.unionflow.server.entity.Organisation;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.quarkus.test.TestTransaction;
|
||||
import jakarta.inject.Inject;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@QuarkusTest
|
||||
class AdresseRepositoryTest {
|
||||
|
||||
@Inject
|
||||
AdresseRepository adresseRepository;
|
||||
@Inject
|
||||
OrganisationRepository organisationRepository;
|
||||
|
||||
private Organisation newOrganisation() {
|
||||
Organisation o = new Organisation();
|
||||
o.setNom("Org Adresse");
|
||||
o.setTypeOrganisation("ASSOCIATION");
|
||||
o.setStatut("ACTIVE");
|
||||
o.setEmail("adresse-" + UUID.randomUUID() + "@test.com");
|
||||
o.setActif(true);
|
||||
organisationRepository.persist(o);
|
||||
return o;
|
||||
}
|
||||
|
||||
private Adresse newAdresse(Organisation org) {
|
||||
Adresse a = new Adresse();
|
||||
a.setTypeAdresse("SIEGE");
|
||||
a.setAdresse("1 rue Test");
|
||||
a.setVille("Paris");
|
||||
a.setCodePostal("75001");
|
||||
a.setPays("France");
|
||||
a.setPrincipale(true);
|
||||
a.setOrganisation(org);
|
||||
return a;
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("persist puis findAdresseById retrouve l'adresse")
|
||||
void persist_thenFindAdresseById_findsAdresse() {
|
||||
Organisation org = newOrganisation();
|
||||
Adresse a = newAdresse(org);
|
||||
adresseRepository.persist(a);
|
||||
assertThat(a.getId()).isNotNull();
|
||||
Optional<Adresse> found = adresseRepository.findAdresseById(a.getId());
|
||||
assertThat(found).isPresent();
|
||||
assertThat(found.get().getAdresse()).isEqualTo("1 rue Test");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findAdresseById retourne empty pour UUID inexistant")
|
||||
void findAdresseById_inexistant_returnsEmpty() {
|
||||
Optional<Adresse> found = adresseRepository.findAdresseById(UUID.randomUUID());
|
||||
assertThat(found).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findByOrganisationId retourne une liste")
|
||||
void findByOrganisationId_returnsList() {
|
||||
Organisation org = newOrganisation();
|
||||
List<Adresse> list = adresseRepository.findByOrganisationId(org.getId());
|
||||
assertThat(list).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findByMembreId retourne une liste (vide si pas de membre)")
|
||||
void findByMembreId_returnsList() {
|
||||
List<Adresse> list = adresseRepository.findByMembreId(UUID.randomUUID());
|
||||
assertThat(list).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("listAll et count cohérents")
|
||||
void listAll_count_consistent() {
|
||||
List<Adresse> all = adresseRepository.listAll();
|
||||
long count = adresseRepository.count();
|
||||
assertThat((long) all.size()).isEqualTo(count);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package dev.lions.unionflow.server.repository;
|
||||
|
||||
import dev.lions.unionflow.server.api.enums.audit.PorteeAudit;
|
||||
import dev.lions.unionflow.server.entity.AuditLog;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.quarkus.test.TestTransaction;
|
||||
import jakarta.inject.Inject;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@QuarkusTest
|
||||
class AuditLogRepositoryTest {
|
||||
|
||||
@Inject
|
||||
AuditLogRepository auditLogRepository;
|
||||
|
||||
private static AuditLog newAuditLog() {
|
||||
AuditLog a = new AuditLog();
|
||||
a.setTypeAction("CREATE");
|
||||
a.setSeverite("INFO");
|
||||
a.setUtilisateur("test@test.com");
|
||||
a.setModule("TEST");
|
||||
a.setDescription("Test audit");
|
||||
a.setPortee(PorteeAudit.PLATEFORME);
|
||||
return a;
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("persist puis findById retrouve le log")
|
||||
void persist_thenFindById_findsLog() {
|
||||
AuditLog log = newAuditLog();
|
||||
auditLogRepository.persist(log);
|
||||
assertThat(log.getId()).isNotNull();
|
||||
AuditLog found = auditLogRepository.findById(log.getId());
|
||||
assertThat(found).isNotNull();
|
||||
assertThat(found.getTypeAction()).isEqualTo("CREATE");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findById retourne null pour UUID inexistant")
|
||||
void findById_inexistant_returnsNull() {
|
||||
assertThat(auditLogRepository.findById(UUID.randomUUID())).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("listAll retourne une liste")
|
||||
void listAll_returnsList() {
|
||||
List<AuditLog> list = auditLogRepository.listAll();
|
||||
assertThat(list).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("count retourne un nombre >= 0")
|
||||
void count_returnsNonNegative() {
|
||||
assertThat(auditLogRepository.count()).isGreaterThanOrEqualTo(0L);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("deleteById supprime le log")
|
||||
void deleteById_removesLog() {
|
||||
AuditLog log = newAuditLog();
|
||||
auditLogRepository.persist(log);
|
||||
UUID id = log.getId();
|
||||
boolean deleted = auditLogRepository.deleteById(id);
|
||||
assertThat(deleted).isTrue();
|
||||
assertThat(auditLogRepository.findById(id)).isNull();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
package dev.lions.unionflow.server.repository;
|
||||
|
||||
import dev.lions.unionflow.server.entity.Organisation;
|
||||
import io.quarkus.panache.common.Page;
|
||||
import io.quarkus.panache.common.Sort;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.quarkus.test.TestTransaction;
|
||||
import jakarta.inject.Inject;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Teste les méthodes héritées de BaseRepository via OrganisationRepository.
|
||||
* BaseRepository est abstrait, donc on s'appuie sur une implémentation concrète.
|
||||
*/
|
||||
@QuarkusTest
|
||||
class BaseRepositoryTest {
|
||||
|
||||
@Inject
|
||||
OrganisationRepository organisationRepository;
|
||||
|
||||
private static Organisation newOrganisation(String email) {
|
||||
Organisation o = new Organisation();
|
||||
o.setNom("Org Test");
|
||||
o.setTypeOrganisation("ASSOCIATION");
|
||||
o.setStatut("ACTIVE");
|
||||
o.setEmail(email);
|
||||
o.setActif(true);
|
||||
return o;
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findById retourne null pour UUID inexistant")
|
||||
void findById_inexistant_returnsNull() {
|
||||
Organisation found = organisationRepository.findById(UUID.randomUUID());
|
||||
assertThat(found).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findByIdOptional retourne empty pour UUID inexistant")
|
||||
void findByIdOptional_inexistant_returnsEmpty() {
|
||||
Optional<Organisation> opt = organisationRepository.findByIdOptional(UUID.randomUUID());
|
||||
assertThat(opt).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("persist puis findById retrouve l'entité")
|
||||
void persist_thenFindById_findsEntity() {
|
||||
Organisation o = newOrganisation("base-repo-" + UUID.randomUUID() + "@test.com");
|
||||
organisationRepository.persist(o);
|
||||
assertThat(o.getId()).isNotNull();
|
||||
Organisation found = organisationRepository.findById(o.getId());
|
||||
assertThat(found).isNotNull();
|
||||
assertThat(found.getEmail()).isEqualTo(o.getEmail());
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findByIdOptional retrouve l'entité persistée")
|
||||
void findByIdOptional_findsPersisted() {
|
||||
Organisation o = newOrganisation("opt-" + UUID.randomUUID() + "@test.com");
|
||||
organisationRepository.persist(o);
|
||||
Optional<Organisation> opt = organisationRepository.findByIdOptional(o.getId());
|
||||
assertThat(opt).isPresent();
|
||||
assertThat(opt.get().getNom()).isEqualTo(o.getNom());
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("update modifie l'entité")
|
||||
void update_modifiesEntity() {
|
||||
Organisation o = newOrganisation("upd-" + UUID.randomUUID() + "@test.com");
|
||||
organisationRepository.persist(o);
|
||||
o.setNom("Nom modifié");
|
||||
organisationRepository.update(o);
|
||||
Organisation found = organisationRepository.findById(o.getId());
|
||||
assertThat(found).isNotNull();
|
||||
assertThat(found.getNom()).isEqualTo("Nom modifié");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("delete supprime l'entité")
|
||||
void delete_removesEntity() {
|
||||
Organisation o = newOrganisation("del-" + UUID.randomUUID() + "@test.com");
|
||||
organisationRepository.persist(o);
|
||||
UUID id = o.getId();
|
||||
organisationRepository.delete(o);
|
||||
assertThat(organisationRepository.findById(id)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("deleteById retourne true et supprime quand l'entité existe")
|
||||
void deleteById_existing_returnsTrueAndRemoves() {
|
||||
Organisation o = newOrganisation("delid-" + UUID.randomUUID() + "@test.com");
|
||||
organisationRepository.persist(o);
|
||||
UUID id = o.getId();
|
||||
boolean deleted = organisationRepository.deleteById(id);
|
||||
assertThat(deleted).isTrue();
|
||||
assertThat(organisationRepository.findById(id)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("deleteById retourne false quand l'entité n'existe pas")
|
||||
void deleteById_inexistant_returnsFalse() {
|
||||
boolean deleted = organisationRepository.deleteById(UUID.randomUUID());
|
||||
assertThat(deleted).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("listAll retourne une liste (éventuellement vide)")
|
||||
void listAll_returnsList() {
|
||||
List<Organisation> all = organisationRepository.listAll();
|
||||
assertThat(all).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findAll avec Page et Sort null retourne une liste paginée")
|
||||
void findAll_pageAndSortNull_returnsPagedList() {
|
||||
Page page = new Page(0, 10);
|
||||
List<Organisation> list = organisationRepository.findAll(page, null);
|
||||
assertThat(list).isNotNull();
|
||||
assertThat(list.size()).isLessThanOrEqualTo(10);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findAll avec Page et Sort par nom retourne une liste triée")
|
||||
void findAll_pageAndSort_returnsSortedList() {
|
||||
Page page = new Page(0, 10);
|
||||
Sort sort = Sort.by("nom").ascending();
|
||||
List<Organisation> list = organisationRepository.findAll(page, sort);
|
||||
assertThat(list).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("count retourne un nombre >= 0")
|
||||
void count_returnsNonNegative() {
|
||||
long n = organisationRepository.count();
|
||||
assertThat(n).isGreaterThanOrEqualTo(0L);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("existsById retourne false pour UUID inexistant")
|
||||
void existsById_inexistant_returnsFalse() {
|
||||
boolean exists = organisationRepository.existsById(UUID.randomUUID());
|
||||
assertThat(exists).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("existsById retourne true après persist")
|
||||
void existsById_afterPersist_returnsTrue() {
|
||||
Organisation o = newOrganisation("exists-" + UUID.randomUUID() + "@test.com");
|
||||
organisationRepository.persist(o);
|
||||
assertThat(organisationRepository.existsById(o.getId())).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("getEntityManager retourne un EntityManager non null")
|
||||
void getEntityManager_returnsNonNull() {
|
||||
assertThat(organisationRepository.getEntityManager()).isNotNull();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package dev.lions.unionflow.server.repository;
|
||||
|
||||
import dev.lions.unionflow.server.api.enums.comptabilite.TypeCompteComptable;
|
||||
import dev.lions.unionflow.server.entity.CompteComptable;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.quarkus.test.TestTransaction;
|
||||
import jakarta.inject.Inject;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@QuarkusTest
|
||||
class CompteComptableRepositoryTest {
|
||||
|
||||
@Inject
|
||||
CompteComptableRepository compteComptableRepository;
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findById retourne null pour UUID inexistant")
|
||||
void findById_inexistant_returnsNull() {
|
||||
assertThat(compteComptableRepository.findById(UUID.randomUUID())).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findCompteComptableById retourne empty pour UUID inexistant")
|
||||
void findCompteComptableById_inexistant_returnsEmpty() {
|
||||
Optional<CompteComptable> opt = compteComptableRepository.findCompteComptableById(UUID.randomUUID());
|
||||
assertThat(opt).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findByNumeroCompte retourne empty pour numéro inexistant")
|
||||
void findByNumeroCompte_inexistant_returnsEmpty() {
|
||||
Optional<CompteComptable> opt = compteComptableRepository.findByNumeroCompte("999999");
|
||||
assertThat(opt).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("listAll retourne une liste")
|
||||
void listAll_returnsList() {
|
||||
List<CompteComptable> list = compteComptableRepository.listAll();
|
||||
assertThat(list).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("count retourne un nombre >= 0")
|
||||
void count_returnsNonNegative() {
|
||||
assertThat(compteComptableRepository.count()).isGreaterThanOrEqualTo(0L);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findByType retourne une liste")
|
||||
void findByType_returnsList() {
|
||||
List<CompteComptable> list = compteComptableRepository.findByType(TypeCompteComptable.TRESORERIE);
|
||||
assertThat(list).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findAllActifs retourne une liste")
|
||||
void findAllActifs_returnsList() {
|
||||
List<CompteComptable> list = compteComptableRepository.findAllActifs();
|
||||
assertThat(list).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findComptesTresorerie retourne une liste")
|
||||
void findComptesTresorerie_returnsList() {
|
||||
List<CompteComptable> list = compteComptableRepository.findComptesTresorerie();
|
||||
assertThat(list).isNotNull();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package dev.lions.unionflow.server.repository;
|
||||
|
||||
import dev.lions.unionflow.server.entity.CompteWave;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.quarkus.test.TestTransaction;
|
||||
import jakarta.inject.Inject;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@QuarkusTest
|
||||
class CompteWaveRepositoryTest {
|
||||
|
||||
@Inject
|
||||
CompteWaveRepository compteWaveRepository;
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findById retourne null pour UUID inexistant")
|
||||
void findById_inexistant_returnsNull() {
|
||||
assertThat(compteWaveRepository.findById(UUID.randomUUID())).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findCompteWaveById retourne empty pour UUID inexistant")
|
||||
void findCompteWaveById_inexistant_returnsEmpty() {
|
||||
Optional<CompteWave> opt = compteWaveRepository.findCompteWaveById(UUID.randomUUID());
|
||||
assertThat(opt).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findByNumeroTelephone retourne empty pour numéro inexistant")
|
||||
void findByNumeroTelephone_inexistant_returnsEmpty() {
|
||||
Optional<CompteWave> opt = compteWaveRepository.findByNumeroTelephone("+22100000000");
|
||||
assertThat(opt).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("listAll retourne une liste")
|
||||
void listAll_returnsList() {
|
||||
List<CompteWave> list = compteWaveRepository.listAll();
|
||||
assertThat(list).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("count retourne un nombre >= 0")
|
||||
void count_returnsNonNegative() {
|
||||
assertThat(compteWaveRepository.count()).isGreaterThanOrEqualTo(0L);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findByOrganisationId retourne une liste")
|
||||
void findByOrganisationId_returnsList() {
|
||||
List<CompteWave> list = compteWaveRepository.findByOrganisationId(UUID.randomUUID());
|
||||
assertThat(list).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findComptesVerifies retourne une liste")
|
||||
void findComptesVerifies_returnsList() {
|
||||
List<CompteWave> list = compteWaveRepository.findComptesVerifies();
|
||||
assertThat(list).isNotNull();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package dev.lions.unionflow.server.repository;
|
||||
|
||||
import dev.lions.unionflow.server.entity.Configuration;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.quarkus.test.TestTransaction;
|
||||
import jakarta.inject.Inject;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@QuarkusTest
|
||||
class ConfigurationRepositoryTest {
|
||||
|
||||
@Inject
|
||||
ConfigurationRepository configurationRepository;
|
||||
|
||||
private static Configuration newConfig(String cle, String categorie) {
|
||||
Configuration c = new Configuration();
|
||||
c.setCle(cle);
|
||||
c.setValeur("valeur");
|
||||
c.setCategorie(categorie);
|
||||
c.setActif(true);
|
||||
c.setVisible(true);
|
||||
return c;
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("persist puis findById retrouve la configuration")
|
||||
void persist_thenFindById_findsConfig() {
|
||||
String cle = "test.cle." + UUID.randomUUID();
|
||||
Configuration c = newConfig(cle, "SYSTEME");
|
||||
configurationRepository.persist(c);
|
||||
assertThat(c.getId()).isNotNull();
|
||||
Configuration found = configurationRepository.findById(c.getId());
|
||||
assertThat(found).isNotNull();
|
||||
assertThat(found.getCle()).isEqualTo(cle);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findByCle retrouve par clé")
|
||||
void findByCle_findsByKey() {
|
||||
String cle = "test.bycle." + UUID.randomUUID();
|
||||
Configuration c = newConfig(cle, "SYSTEME");
|
||||
configurationRepository.persist(c);
|
||||
Optional<Configuration> opt = configurationRepository.findByCle(cle);
|
||||
assertThat(opt).isPresent();
|
||||
assertThat(opt.get().getCle()).isEqualTo(cle);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findByCle retourne empty pour clé inexistante")
|
||||
void findByCle_inexistant_returnsEmpty() {
|
||||
Optional<Configuration> opt = configurationRepository.findByCle("cle.inexistante." + UUID.randomUUID());
|
||||
assertThat(opt).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findAllActives retourne une liste")
|
||||
void findAllActives_returnsList() {
|
||||
List<Configuration> list = configurationRepository.findAllActives();
|
||||
assertThat(list).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findByCategorie retourne une liste (éventuellement vide)")
|
||||
void findByCategorie_returnsList() {
|
||||
List<Configuration> list = configurationRepository.findByCategorie("SYSTEME");
|
||||
assertThat(list).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findVisibles retourne une liste")
|
||||
void findVisibles_returnsList() {
|
||||
List<Configuration> list = configurationRepository.findVisibles();
|
||||
assertThat(list).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("listAll et count cohérents")
|
||||
void listAll_count_consistent() {
|
||||
List<Configuration> all = configurationRepository.listAll();
|
||||
long count = configurationRepository.count();
|
||||
assertThat((long) all.size()).isEqualTo(count);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package dev.lions.unionflow.server.repository;
|
||||
|
||||
import dev.lions.unionflow.server.entity.ConfigurationWave;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.quarkus.test.TestTransaction;
|
||||
import jakarta.inject.Inject;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@QuarkusTest
|
||||
class ConfigurationWaveRepositoryTest {
|
||||
|
||||
@Inject
|
||||
ConfigurationWaveRepository configurationWaveRepository;
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findById retourne null pour UUID inexistant")
|
||||
void findById_inexistant_returnsNull() {
|
||||
assertThat(configurationWaveRepository.findById(UUID.randomUUID())).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findConfigurationWaveById retourne empty pour UUID inexistant")
|
||||
void findConfigurationWaveById_inexistant_returnsEmpty() {
|
||||
Optional<ConfigurationWave> opt = configurationWaveRepository.findConfigurationWaveById(UUID.randomUUID());
|
||||
assertThat(opt).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findByCle retourne empty pour clé inexistante")
|
||||
void findByCle_inexistant_returnsEmpty() {
|
||||
Optional<ConfigurationWave> opt = configurationWaveRepository.findByCle("cle-" + UUID.randomUUID());
|
||||
assertThat(opt).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("listAll retourne une liste")
|
||||
void listAll_returnsList() {
|
||||
List<ConfigurationWave> list = configurationWaveRepository.listAll();
|
||||
assertThat(list).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("count retourne un nombre >= 0")
|
||||
void count_returnsNonNegative() {
|
||||
assertThat(configurationWaveRepository.count()).isGreaterThanOrEqualTo(0L);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findByEnvironnement retourne une liste")
|
||||
void findByEnvironnement_returnsList() {
|
||||
List<ConfigurationWave> list = configurationWaveRepository.findByEnvironnement("SANDBOX");
|
||||
assertThat(list).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findAllActives retourne une liste")
|
||||
void findAllActives_returnsList() {
|
||||
List<ConfigurationWave> list = configurationWaveRepository.findAllActives();
|
||||
assertThat(list).isNotNull();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
package dev.lions.unionflow.server.repository;
|
||||
|
||||
import dev.lions.unionflow.server.entity.Cotisation;
|
||||
import dev.lions.unionflow.server.entity.Membre;
|
||||
import dev.lions.unionflow.server.entity.Organisation;
|
||||
import io.quarkus.panache.common.Page;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.quarkus.test.TestTransaction;
|
||||
import jakarta.inject.Inject;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@QuarkusTest
|
||||
class CotisationRepositoryTest {
|
||||
|
||||
@Inject
|
||||
CotisationRepository cotisationRepository;
|
||||
@Inject
|
||||
OrganisationRepository organisationRepository;
|
||||
@Inject
|
||||
MembreRepository membreRepository;
|
||||
|
||||
private Organisation newOrganisation() {
|
||||
Organisation o = new Organisation();
|
||||
o.setNom("Org Cotisation");
|
||||
o.setTypeOrganisation("ASSOCIATION");
|
||||
o.setStatut("ACTIVE");
|
||||
o.setEmail("cot-org-" + UUID.randomUUID() + "@test.com");
|
||||
o.setActif(true);
|
||||
organisationRepository.persist(o);
|
||||
return o;
|
||||
}
|
||||
|
||||
private Membre newMembre() {
|
||||
Membre m = new Membre();
|
||||
m.setNumeroMembre("C-" + UUID.randomUUID().toString().substring(0, 8));
|
||||
m.setPrenom("Test");
|
||||
m.setNom("User");
|
||||
m.setEmail("cot-membre-" + UUID.randomUUID() + "@test.com");
|
||||
m.setDateNaissance(LocalDate.of(1990, 1, 1));
|
||||
m.setActif(true);
|
||||
membreRepository.persist(m);
|
||||
return m;
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findByNumeroReference retourne empty pour référence inexistante")
|
||||
void findByNumeroReference_inexistant_returnsEmpty() {
|
||||
Optional<Cotisation> opt = cotisationRepository.findByNumeroReference("REF-" + UUID.randomUUID());
|
||||
assertThat(opt).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findByMembreId avec pagination retourne une liste")
|
||||
void findByMembreId_returnsList() {
|
||||
Page page = new Page(0, 10);
|
||||
List<Cotisation> list = cotisationRepository.findByMembreId(UUID.randomUUID(), page, null);
|
||||
assertThat(list).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findByStatut retourne une liste")
|
||||
void findByStatut_returnsList() {
|
||||
Page page = new Page(0, 10);
|
||||
List<Cotisation> list = cotisationRepository.findByStatut("EN_ATTENTE", page);
|
||||
assertThat(list).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findCotisationsEnRetard retourne une liste")
|
||||
void findCotisationsEnRetard_returnsList() {
|
||||
Page page = new Page(0, 10);
|
||||
List<Cotisation> list = cotisationRepository.findCotisationsEnRetard(LocalDate.now(), page);
|
||||
assertThat(list).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findByPeriode avec année retourne une liste")
|
||||
void findByPeriode_returnsList() {
|
||||
Page page = new Page(0, 10);
|
||||
List<Cotisation> list = cotisationRepository.findByPeriode(LocalDate.now().getYear(), null, page);
|
||||
assertThat(list).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("rechercheAvancee sans filtres retourne une liste")
|
||||
void rechercheAvancee_returnsList() {
|
||||
Page page = new Page(0, 10);
|
||||
List<Cotisation> list = cotisationRepository.rechercheAvancee(null, null, null, null, null, page);
|
||||
assertThat(list).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("calculerTotalMontantDu retourne zéro pour membre sans cotisation")
|
||||
void calculerTotalMontantDu_returnsZero() {
|
||||
BigDecimal total = cotisationRepository.calculerTotalMontantDu(UUID.randomUUID());
|
||||
assertThat(total).isEqualByComparingTo(BigDecimal.ZERO);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("compterParStatut retourne un nombre >= 0")
|
||||
void compterParStatut_returnsNonNegative() {
|
||||
long n = cotisationRepository.compterParStatut("PAYEE");
|
||||
assertThat(n).isGreaterThanOrEqualTo(0L);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("sommeMontantDu retourne un BigDecimal")
|
||||
void sommeMontantDu_returnsBigDecimal() {
|
||||
BigDecimal sum = cotisationRepository.sommeMontantDu();
|
||||
assertThat(sum).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("getStatistiquesPeriode retourne une map avec les clés attendues")
|
||||
void getStatistiquesPeriode_returnsMap() {
|
||||
int annee = LocalDate.now().getYear();
|
||||
Map<String, Object> stats = cotisationRepository.getStatistiquesPeriode(annee, null);
|
||||
assertThat(stats).containsKeys("totalCotisations", "montantTotal", "montantPaye", "cotisationsPayees", "tauxPaiement");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("persist puis findByNumeroReference retrouve la cotisation")
|
||||
void persist_thenFindByNumeroReference_findsCotisation() {
|
||||
Organisation org = newOrganisation();
|
||||
Membre membre = newMembre();
|
||||
String ref = "COT-TEST-" + UUID.randomUUID().toString().substring(0, 8);
|
||||
Cotisation c = Cotisation.builder()
|
||||
.numeroReference(ref)
|
||||
.membre(membre)
|
||||
.organisation(org)
|
||||
.typeCotisation("ANNUELLE")
|
||||
.libelle("Cotisation test")
|
||||
.montantDu(BigDecimal.valueOf(5000))
|
||||
.codeDevise("XOF")
|
||||
.statut("EN_ATTENTE")
|
||||
.annee(LocalDate.now().getYear())
|
||||
.mois(LocalDate.now().getMonthValue())
|
||||
.dateEcheance(LocalDate.now().plusMonths(1))
|
||||
.build();
|
||||
cotisationRepository.persist(c);
|
||||
Optional<Cotisation> found = cotisationRepository.findByNumeroReference(ref);
|
||||
assertThat(found).isPresent();
|
||||
assertThat(found.get().getNumeroReference()).isEqualTo(ref);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
package dev.lions.unionflow.server.repository;
|
||||
|
||||
import dev.lions.unionflow.server.api.enums.solidarite.StatutAide;
|
||||
import dev.lions.unionflow.server.api.enums.solidarite.TypeAide;
|
||||
import dev.lions.unionflow.server.entity.DemandeAide;
|
||||
import dev.lions.unionflow.server.entity.Membre;
|
||||
import dev.lions.unionflow.server.entity.Organisation;
|
||||
import io.quarkus.panache.common.Page;
|
||||
import io.quarkus.panache.common.Sort;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.quarkus.test.TestTransaction;
|
||||
import jakarta.inject.Inject;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@QuarkusTest
|
||||
class DemandeAideRepositoryTest {
|
||||
|
||||
@Inject
|
||||
DemandeAideRepository demandeAideRepository;
|
||||
@Inject
|
||||
OrganisationRepository organisationRepository;
|
||||
@Inject
|
||||
MembreRepository membreRepository;
|
||||
|
||||
private Organisation newOrganisation() {
|
||||
Organisation o = new Organisation();
|
||||
o.setNom("Org DemandeAide");
|
||||
o.setTypeOrganisation("ASSOCIATION");
|
||||
o.setStatut("ACTIVE");
|
||||
o.setEmail("da-org-" + UUID.randomUUID() + "@test.com");
|
||||
o.setActif(true);
|
||||
organisationRepository.persist(o);
|
||||
return o;
|
||||
}
|
||||
|
||||
private Membre newMembre() {
|
||||
Membre m = new Membre();
|
||||
m.setNumeroMembre("M-" + UUID.randomUUID().toString().substring(0, 8));
|
||||
m.setPrenom("Test");
|
||||
m.setNom("User");
|
||||
m.setEmail("da-membre-" + UUID.randomUUID() + "@test.com");
|
||||
m.setDateNaissance(java.time.LocalDate.of(1990, 1, 1));
|
||||
m.setActif(true);
|
||||
membreRepository.persist(m);
|
||||
return m;
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findByOrganisationId retourne une liste")
|
||||
void findByOrganisationId_returnsList() {
|
||||
List<DemandeAide> list = demandeAideRepository.findByOrganisationId(UUID.randomUUID());
|
||||
assertThat(list).isNotNull();
|
||||
assertThat(list).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findByOrganisationId avec pagination retourne une liste")
|
||||
void findByOrganisationId_paged_returnsList() {
|
||||
Page page = new Page(0, 10);
|
||||
List<DemandeAide> list = demandeAideRepository.findByOrganisationId(UUID.randomUUID(), page, null);
|
||||
assertThat(list).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findByStatut avec enum retourne une liste")
|
||||
void findByStatut_returnsList() {
|
||||
List<DemandeAide> list = demandeAideRepository.findByStatut(StatutAide.EN_ATTENTE);
|
||||
assertThat(list).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findByTypeAide retourne une liste")
|
||||
void findByTypeAide_returnsList() {
|
||||
List<DemandeAide> list = demandeAideRepository.findByTypeAide(TypeAide.AIDE_FINANCIERE_URGENTE);
|
||||
assertThat(list).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findUrgentes retourne une liste")
|
||||
void findUrgentes_returnsList() {
|
||||
List<DemandeAide> list = demandeAideRepository.findUrgentes();
|
||||
assertThat(list).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findRecentes retourne une liste")
|
||||
void findRecentes_returnsList() {
|
||||
List<DemandeAide> list = demandeAideRepository.findRecentes();
|
||||
assertThat(list).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("count retourne un nombre >= 0")
|
||||
void count_returnsNonNegative() {
|
||||
long n = demandeAideRepository.count();
|
||||
assertThat(n).isGreaterThanOrEqualTo(0L);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findByPeriode retourne une liste")
|
||||
void findByPeriode_returnsList() {
|
||||
LocalDateTime debut = LocalDateTime.now().minusDays(30);
|
||||
LocalDateTime fin = LocalDateTime.now();
|
||||
List<DemandeAide> list = demandeAideRepository.findByPeriode(debut, fin);
|
||||
assertThat(list).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("sumMontantDemandeByOrganisationId retourne empty quand aucun montant")
|
||||
void sumMontantDemandeByOrganisationId_empty_returnsEmpty() {
|
||||
Optional<BigDecimal> sum = demandeAideRepository.sumMontantDemandeByOrganisationId(UUID.randomUUID());
|
||||
assertThat(sum).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("persist puis findById retrouve la demande")
|
||||
void persist_thenFindById_findsDemande() {
|
||||
Organisation org = newOrganisation();
|
||||
Membre membre = newMembre();
|
||||
DemandeAide d = DemandeAide.builder()
|
||||
.titre("Test aide")
|
||||
.description("Description")
|
||||
.typeAide(TypeAide.AIDE_COTISATION)
|
||||
.statut(StatutAide.EN_ATTENTE)
|
||||
.montantDemande(BigDecimal.valueOf(1000))
|
||||
.dateDemande(LocalDateTime.now())
|
||||
.demandeur(membre)
|
||||
.organisation(org)
|
||||
.urgence(false)
|
||||
.build();
|
||||
demandeAideRepository.persist(d);
|
||||
assertThat(d.getId()).isNotNull();
|
||||
DemandeAide found = demandeAideRepository.findById(d.getId());
|
||||
assertThat(found).isNotNull();
|
||||
assertThat(found.getTitre()).isEqualTo("Test aide");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package dev.lions.unionflow.server.repository;
|
||||
|
||||
import dev.lions.unionflow.server.api.enums.document.TypeDocument;
|
||||
import dev.lions.unionflow.server.entity.Document;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.quarkus.test.TestTransaction;
|
||||
import jakarta.inject.Inject;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@QuarkusTest
|
||||
class DocumentRepositoryTest {
|
||||
|
||||
@Inject
|
||||
DocumentRepository documentRepository;
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findById retourne null pour UUID inexistant")
|
||||
void findById_inexistant_returnsNull() {
|
||||
assertThat(documentRepository.findById(UUID.randomUUID())).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findDocumentById retourne empty pour UUID inexistant")
|
||||
void findDocumentById_inexistant_returnsEmpty() {
|
||||
Optional<Document> opt = documentRepository.findDocumentById(UUID.randomUUID());
|
||||
assertThat(opt).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findByHashMd5 retourne empty pour hash inexistant")
|
||||
void findByHashMd5_inexistant_returnsEmpty() {
|
||||
Optional<Document> opt = documentRepository.findByHashMd5("hash-" + UUID.randomUUID());
|
||||
assertThat(opt).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("listAll retourne une liste")
|
||||
void listAll_returnsList() {
|
||||
List<Document> list = documentRepository.listAll();
|
||||
assertThat(list).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("count retourne un nombre >= 0")
|
||||
void count_returnsNonNegative() {
|
||||
assertThat(documentRepository.count()).isGreaterThanOrEqualTo(0L);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findByType retourne une liste")
|
||||
void findByType_returnsList() {
|
||||
List<Document> list = documentRepository.findByType(TypeDocument.FACTURE);
|
||||
assertThat(list).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findAllActifs retourne une liste")
|
||||
void findAllActifs_returnsList() {
|
||||
List<Document> list = documentRepository.findAllActifs();
|
||||
assertThat(list).isNotNull();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package dev.lions.unionflow.server.repository;
|
||||
|
||||
import dev.lions.unionflow.server.entity.EcritureComptable;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.quarkus.test.TestTransaction;
|
||||
import jakarta.inject.Inject;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@QuarkusTest
|
||||
class EcritureComptableRepositoryTest {
|
||||
|
||||
@Inject
|
||||
EcritureComptableRepository ecritureComptableRepository;
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findById retourne null pour UUID inexistant")
|
||||
void findById_inexistant_returnsNull() {
|
||||
assertThat(ecritureComptableRepository.findById(UUID.randomUUID())).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findEcritureComptableById retourne empty pour UUID inexistant")
|
||||
void findEcritureComptableById_inexistant_returnsEmpty() {
|
||||
Optional<EcritureComptable> opt = ecritureComptableRepository.findEcritureComptableById(UUID.randomUUID());
|
||||
assertThat(opt).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findByNumeroPiece retourne empty pour numéro inexistant")
|
||||
void findByNumeroPiece_inexistant_returnsEmpty() {
|
||||
Optional<EcritureComptable> opt = ecritureComptableRepository.findByNumeroPiece("PIECE-" + UUID.randomUUID());
|
||||
assertThat(opt).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("listAll retourne une liste")
|
||||
void listAll_returnsList() {
|
||||
List<EcritureComptable> list = ecritureComptableRepository.listAll();
|
||||
assertThat(list).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("count retourne un nombre >= 0")
|
||||
void count_returnsNonNegative() {
|
||||
assertThat(ecritureComptableRepository.count()).isGreaterThanOrEqualTo(0L);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findByJournalId retourne une liste")
|
||||
void findByJournalId_returnsList() {
|
||||
List<EcritureComptable> list = ecritureComptableRepository.findByJournalId(UUID.randomUUID());
|
||||
assertThat(list).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findByPeriode retourne une liste")
|
||||
void findByPeriode_returnsList() {
|
||||
LocalDate debut = LocalDate.now().minusMonths(1);
|
||||
LocalDate fin = LocalDate.now();
|
||||
List<EcritureComptable> list = ecritureComptableRepository.findByPeriode(debut, fin);
|
||||
assertThat(list).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findNonPointees retourne une liste")
|
||||
void findNonPointees_returnsList() {
|
||||
List<EcritureComptable> list = ecritureComptableRepository.findNonPointees();
|
||||
assertThat(list).isNotNull();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
package dev.lions.unionflow.server.repository;
|
||||
|
||||
import dev.lions.unionflow.server.entity.Evenement;
|
||||
import dev.lions.unionflow.server.entity.Organisation;
|
||||
import io.quarkus.panache.common.Page;
|
||||
import io.quarkus.panache.common.Sort;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.quarkus.test.TestTransaction;
|
||||
import jakarta.inject.Inject;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@QuarkusTest
|
||||
class EvenementRepositoryTest {
|
||||
|
||||
@Inject
|
||||
EvenementRepository evenementRepository;
|
||||
@Inject
|
||||
OrganisationRepository organisationRepository;
|
||||
|
||||
private Organisation newOrganisation() {
|
||||
Organisation o = new Organisation();
|
||||
o.setNom("Org Evenement");
|
||||
o.setTypeOrganisation("ASSOCIATION");
|
||||
o.setStatut("ACTIVE");
|
||||
o.setEmail("evt-org-" + UUID.randomUUID() + "@test.com");
|
||||
o.setActif(true);
|
||||
organisationRepository.persist(o);
|
||||
return o;
|
||||
}
|
||||
|
||||
private Evenement newEvenement(Organisation org) {
|
||||
Evenement e = new Evenement();
|
||||
e.setTitre("Événement test");
|
||||
e.setDescription("Description");
|
||||
e.setDateDebut(LocalDateTime.now().plusDays(1));
|
||||
e.setStatut("PLANIFIE");
|
||||
e.setTypeEvenement("REUNION");
|
||||
e.setOrganisation(org);
|
||||
e.setActif(true);
|
||||
e.setVisiblePublic(true);
|
||||
return e;
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findByTitre retourne empty pour titre inexistant")
|
||||
void findByTitre_inexistant_returnsEmpty() {
|
||||
Optional<Evenement> opt = evenementRepository.findByTitre("Titre inexistant " + UUID.randomUUID());
|
||||
assertThat(opt).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findAllActifs retourne une liste")
|
||||
void findAllActifs_returnsList() {
|
||||
List<Evenement> list = evenementRepository.findAllActifs();
|
||||
assertThat(list).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("countActifs retourne un nombre >= 0")
|
||||
void countActifs_returnsNonNegative() {
|
||||
assertThat(evenementRepository.countActifs()).isGreaterThanOrEqualTo(0L);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findByStatut retourne une liste")
|
||||
void findByStatut_returnsList() {
|
||||
List<Evenement> list = evenementRepository.findByStatut("PLANIFIE");
|
||||
assertThat(list).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findByOrganisation retourne une liste")
|
||||
void findByOrganisation_returnsList() {
|
||||
List<Evenement> list = evenementRepository.findByOrganisation(UUID.randomUUID());
|
||||
assertThat(list).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findEvenementsAVenir retourne une liste")
|
||||
void findEvenementsAVenir_returnsList() {
|
||||
List<Evenement> list = evenementRepository.findEvenementsAVenir();
|
||||
assertThat(list).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("findEvenementsPublics retourne une liste")
|
||||
void findEvenementsPublics_returnsList() {
|
||||
List<Evenement> list = evenementRepository.findEvenementsPublics();
|
||||
assertThat(list).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("getStatistiques retourne une map avec des clés attendues")
|
||||
void getStatistiques_returnsMap() {
|
||||
Map<String, Long> stats = evenementRepository.getStatistiques();
|
||||
assertThat(stats).containsKeys("total", "actifs", "inactifs", "aVenir", "enCours", "passes", "publics", "avecInscription");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("rechercheAvancee avec tous critères null retourne une liste")
|
||||
void rechercheAvancee_returnsList() {
|
||||
Page page = new Page(0, 10);
|
||||
List<Evenement> list = evenementRepository.rechercheAvancee(
|
||||
null, null, null, null, null,
|
||||
null, null, null, null, null,
|
||||
page, null);
|
||||
assertThat(list).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestTransaction
|
||||
@DisplayName("persist puis findById et findByTitre retrouvent l'événement")
|
||||
void persist_thenFind_findsEvenement() {
|
||||
Organisation org = newOrganisation();
|
||||
Evenement e = newEvenement(org);
|
||||
evenementRepository.persist(e);
|
||||
assertThat(e.getId()).isNotNull();
|
||||
Evenement found = evenementRepository.findById(e.getId());
|
||||
assertThat(found).isNotNull();
|
||||
assertThat(found.getTitre()).isEqualTo("Événement test");
|
||||
Optional<Evenement> byTitre = evenementRepository.findByTitre("Événement test");
|
||||
assertThat(byTitre).isPresent();
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user