boolean found1 = false;
boolean found2 = false;
ContactController instance = new ContactController();
Contact contact = instance.read(testPersons.get(0).getIdContact());
Document doc1 = new Document();
doc1.setContact(contact);
doc1.setDocumentType("Test1");
doc1.setTitle(getName());
Document doc2 = new Document();
doc2.setContact(contact);
doc2.setDocumentType("Test2");
doc2.setTitle(getName());
doc1 = instance.addDocument(doc1);
doc2 = instance.addDocument(doc2);
assertEquals(contact, doc1.getContact());
assertEquals(contact, doc2.getContact());
for(Document aDoc : doc2.getContact().getDocumentLinks()) {
if (aDoc.getTitle().equals(getName())
&& aDoc.getDocumentType().equals("Test1")) {
found1 = true;
}
if (aDoc.getTitle().equals(getName())
&& aDoc.getDocumentType().equals("Test2")) {
found2 = true;
}
}
assertTrue("The added 1rst test document is not found", found1);
assertTrue("The added 2nd test document is not found", found2);
//check if donations can be read
DocumentController documentCtrl = new DocumentController();
assertNotNull(documentCtrl.read(doc1.getIdDocument()));
assertNotNull(documentCtrl.read(doc2.getIdDocument()));
//check update an existing donation
doc1.setDocumentType("Test3");
instance.addDocument(doc1);
assertEquals("Test3", documentCtrl.read(doc1.getIdDocument()).getDocumentType());