use of org.alfresco.repo.event.v1.model.NodeResource in project alfresco-repository by Alfresco.
the class ChildAssociationRepoEventIT method testOneChildMultipleParentsDifferentTransaction.
@Test
public void testOneChildMultipleParentsDifferentTransaction() {
final NodeRef parent1NodeRef = createNode(ContentModel.TYPE_FOLDER);
final NodeRef parent2NodeRef = createNode(ContentModel.TYPE_FOLDER);
final NodeRef parent3NodeRef = createNode(ContentModel.TYPE_FOLDER);
final NodeRef childNodeRef = createNode(ContentModel.TYPE_CONTENT);
List<NodeRef> parents = Arrays.asList(parent1NodeRef, parent2NodeRef, parent3NodeRef);
checkNumOfEvents(4);
RepoEvent<EventData<NodeResource>> resultRepoEvent = getRepoEventWithoutWait(1);
assertEquals("Wrong repo event type.", EventType.NODE_CREATED.getType(), resultRepoEvent.getType());
resultRepoEvent = getRepoEventWithoutWait(2);
assertEquals("Wrong repo event type.", EventType.NODE_CREATED.getType(), resultRepoEvent.getType());
resultRepoEvent = getRepoEventWithoutWait(3);
assertEquals("Wrong repo event type.", EventType.NODE_CREATED.getType(), resultRepoEvent.getType());
resultRepoEvent = getRepoEventWithoutWait(4);
assertEquals("Wrong repo event type.", EventType.NODE_CREATED.getType(), resultRepoEvent.getType());
for (NodeRef parent : parents) {
retryingTransactionHelper.doInTransaction(() -> nodeService.addChild(parent, childNodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName(TEST_NAMESPACE, GUID.generate())));
}
retryingTransactionHelper.doInTransaction(() -> {
List<ChildAssociationRef> childAssocParent1 = nodeService.getChildAssocs(parent1NodeRef);
List<ChildAssociationRef> childAssocParent2 = nodeService.getChildAssocs(parent2NodeRef);
List<ChildAssociationRef> childAssocParent3 = nodeService.getChildAssocs(parent3NodeRef);
assertEquals(1, childAssocParent1.size());
assertEquals(1, childAssocParent2.size());
assertEquals(1, childAssocParent3.size());
return null;
});
checkNumOfEvents(7);
// 3 assoc.child.Created events should be created
List<RepoEvent<EventData<ChildAssociationResource>>> childAssocEvents = getFilteredEvents(EventType.CHILD_ASSOC_CREATED);
assertEquals("Wrong association events number", 3, childAssocEvents.size());
assertEquals(parent1NodeRef.getId(), getChildAssocResource(childAssocEvents.get(0)).getParent().getId());
assertEquals(childNodeRef.getId(), getChildAssocResource(childAssocEvents.get(0)).getChild().getId());
assertEquals("cm:contains", getChildAssocResource(childAssocEvents.get(0)).getAssocType());
assertEquals(parent2NodeRef.getId(), getChildAssocResource(childAssocEvents.get(1)).getParent().getId());
assertEquals(childNodeRef.getId(), getChildAssocResource(childAssocEvents.get(1)).getChild().getId());
assertEquals("cm:contains", getChildAssocResource(childAssocEvents.get(1)).getAssocType());
assertEquals(parent3NodeRef.getId(), getChildAssocResource(childAssocEvents.get(2)).getParent().getId());
assertEquals(childNodeRef.getId(), getChildAssocResource(childAssocEvents.get(2)).getChild().getId());
assertEquals("cm:contains", getChildAssocResource(childAssocEvents.get(2)).getAssocType());
}
Aggregations