task2.addAttachment(att3);
persist(task2);
UserRoles ur = new UserRoles("niko",
new String[] { "examples\\employee" });
final TaskFetcher taskFetcher = new TaskFetcher(em);
// test task1 has two attachments
String query = "(T._id = '" + task1.getID() + "')";
Task[] t2 = taskFetcher.fetchAvailableTasks(ur, PATask.class, query);
Assert.assertTrue(t2[0] instanceof PATask);
PATask t = (PATask) t2[0];
Collection<Attachment> atts = t.getAttachments();
Assert.assertEquals(2, atts.size());
// test the two attachments are different
Iterator<Attachment> iter = atts.iterator();
Attachment a1 = iter.next();
Attachment a2 = iter.next();
Assert.assertNotSame(a1.getPayloadURL(), a2.getPayloadURL());
// test task2 has one attachment
query = "(T._id = '" + task2.getID() + "')";
t2 = taskFetcher.fetchAvailableTasks(ur, PATask.class, query);
Assert.assertTrue(t2[0] instanceof PATask);
t = (PATask) t2[0];
Assert.assertEquals(1, t.getAttachments().size());
// task2 attachments are not the same as task1