Sync: code local unifié
Synchronisation du code source local (fait foi). Signed-off-by: lions dev Team
This commit is contained in:
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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user