Commit a1d0a9ed authored by Mathieu Gicquel's avatar Mathieu Gicquel
Browse files

Test Participants association - Fix #19

parent af1a8c38
......@@ -47,15 +47,15 @@ public class ProjectTest {
this.project.addTask(t1);
assertEquals(this.project,t1.getProjectReference().get());
assertEquals(this.project,t1.getProjectContainer());
assertEquals(this.project, t1.getProjectReference().get());
assertEquals(this.project, t1.getProjectContainer());
this.project.addTask(t2);
assertEquals(this.project,t2.getProjectReference().get());
assertEquals(this.project,t2.getProjectContainer());
assertEquals(this.project,t1.getProjectReference().get());
assertEquals(this.project, t2.getProjectReference().get());
assertEquals(this.project, t2.getProjectContainer());
assertEquals(this.project, t1.getProjectReference().get());
assertEquals(2,this.project.getTaskReference().size());
assertEquals(2, this.project.getTaskReference().size());
t1.getProjectReference().unset();
......@@ -79,7 +79,7 @@ public class ProjectTest {
this.project.deleteAllTasks();
assertEquals(0,this.project.getTaskReference().size());
assertEquals(0, this.project.getTaskReference().size());
}
@Test
......@@ -108,8 +108,8 @@ public class ProjectTest {
assertTrue(this.project.getTasksList().contains(t3));
assertTrue(this.project.getTasksList().contains(t4));
assertEquals(this.project,t3.getProjectContainer());
assertEquals(this.project,t4.getProjectContainer());
assertEquals(this.project, t3.getProjectContainer());
assertEquals(this.project, t4.getProjectContainer());
}
@Test
......@@ -119,13 +119,37 @@ public class ProjectTest {
this.project.setCreator(u1);
assertEquals(u1,this.project.getCreator());
assertEquals(u1, this.project.getCreator());
this.project.setCreator(u2);
assertEquals(u2,this.project.getCreator());
assertEquals(u2, this.project.getCreator());
}
@Test
public void testParticipantAssociation() {
IParticipant u1 = new Utilisateur();
IParticipant u2 = new Utilisateur();
IParticipant u3 = new Utilisateur();
List<IParticipant> participants = new ArrayList<>();
participants.add(u1);
participants.add(u2);
this.project.setParticipantsList(participants);
}
assertTrue(this.project.getParticipantsList().contains(u1));
assertTrue(this.project.getParticipantsList().contains(u2));
assertTrue(u2.getProjectReference().contains(this.project));
List<IParticipant> participants2 = new ArrayList<>();
participants2.add(u3);
this.project.setParticipantsList(participants2);
assertFalse(this.project.getParticipantsList().contains(u1));
assertTrue(this.project.getParticipantsList().contains(u3));
assertFalse(u2.getProjectReference().contains(this.project));
}
}
\ No newline at end of file
package fr.alma.gtd.server.main.donnees;
import fr.alma.gtd.server.core.IProject;
import fr.alma.gtd.server.persistence.data.Idea;
import fr.alma.gtd.server.persistence.data.Utilisateur;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import static junit.framework.Assert.*;
......@@ -49,5 +52,33 @@ public class UserTest {
}
@Test
public void testProjectAssociation() {
Project p1 = new Project();
Project p2 = new Project();
List<IProject> projects1 = new ArrayList<>();
projects1.add(p1);
this.user.setProjetsAssocies(projects1);
assertTrue(this.user.getProjetsAssocies().contains(p1));
assertTrue(p1.getParticipantsList().contains(this.user));
assertFalse(this.user.getProjetsAssocies().contains(p2));
assertFalse(p2.getParticipantsList().contains(this.user));
List<IProject> projects2 = new ArrayList<>();
projects2.add(p2);
this.user.setProjetsAssocies(projects2);
assertFalse(this.user.getProjetsAssocies().contains(p1));
assertFalse(p1.getParticipantsList().contains(this.user));
assertTrue(this.user.getProjetsAssocies().contains(p2));
assertTrue(p2.getParticipantsList().contains(this.user));
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment