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