person.setLastName(getName() + " #" + i);
person = pCtrl.update(person);
participants.add(person);
}
Communication com = new Communication();
com.setIdCommunication(TEST_ID_COMPLETED);
com.setActionToBeConducted(getName());
com.setDateCommunication(new Date());
com.setDateOfCompletion(new Date());
com.setMedia("test");
com.setTopic(getName());
com = comCtrl.update(com);
com = comCtrl.updateParticipants(com, participants);
assertEquals(10, com.getParticipants().size());
Person person;
for(int i=0; i < 10; i++) {
person = pCtrl.read(TEST_ID_CONTACT1 + i);
assertTrue(person.getParticipate().contains(com));
}
//try to remove one participant and check if the relation is updated for both side
participants = new ArrayList(com.getParticipants());
person = pCtrl.read(TEST_ID_CONTACT1);
assertTrue(participants.remove(person));
com = comCtrl.updateParticipants(com, participants);
// check the removed participant doesn't contain the communication
person = pCtrl.read(person.getIdContact());
assertFalse(person.getParticipate().contains(com));
//check new list size
assertEquals(9, com.getParticipants().size());
}