use of com.ibm.watson.discovery.v1.model.EventData 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());
}
use of com.ibm.watson.discovery.v1.model.EventData in project alfresco-repository by Alfresco.
the class PeerAssociationRepoEventIT method testAddAndRemovePeerAssociationSameTransaction.
@Test
public void testAddAndRemovePeerAssociationSameTransaction() {
final NodeRef content1NodeRef = createNode(ContentModel.TYPE_CONTENT);
final NodeRef content2NodeRef = createNode(ContentModel.TYPE_CONTENT);
checkNumOfEvents(2);
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());
// Create peer association
retryingTransactionHelper.doInTransaction(() -> {
nodeService.createAssociation(content1NodeRef, content2NodeRef, ContentModel.ASSOC_ORIGINAL);
nodeService.removeAssociation(content1NodeRef, content2NodeRef, ContentModel.ASSOC_ORIGINAL);
return null;
});
List<AssociationRef> peerAssociationRefs = retryingTransactionHelper.doInTransaction(() -> nodeService.getSourceAssocs(content2NodeRef, ContentModel.ASSOC_ORIGINAL));
assertEquals(0, peerAssociationRefs.size());
checkNumOfEvents(2);
}
use of com.ibm.watson.discovery.v1.model.EventData in project alfresco-repository by Alfresco.
the class PeerAssociationRepoEventIT method testAddPeerAssociation.
@Test
public void testAddPeerAssociation() {
final NodeRef content1NodeRef = createNode(ContentModel.TYPE_CONTENT);
final NodeRef content2NodeRef = createNode(ContentModel.TYPE_CONTENT);
checkNumOfEvents(2);
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());
retryingTransactionHelper.doInTransaction(() -> nodeService.createAssociation(content1NodeRef, content2NodeRef, ContentModel.ASSOC_ORIGINAL));
List<AssociationRef> peerAssociationRefs = retryingTransactionHelper.doInTransaction(() -> nodeService.getSourceAssocs(content2NodeRef, ContentModel.ASSOC_ORIGINAL));
assertEquals(1, peerAssociationRefs.size());
checkNumOfEvents(4);
final RepoEvent<EventData<PeerAssociationResource>> peerAssocRepoEvent = getFilteredEvent(EventType.PEER_ASSOC_CREATED, 0);
assertEquals("Wrong repo event type.", EventType.PEER_ASSOC_CREATED.getType(), peerAssocRepoEvent.getType());
assertNotNull("Repo event ID is not available. ", peerAssocRepoEvent.getId());
assertNotNull("Source is not available", peerAssocRepoEvent.getSource());
assertEquals("Repo event source is not available. ", "/" + descriptorService.getCurrentRepositoryDescriptor().getId(), peerAssocRepoEvent.getSource().toString());
assertNotNull("Repo event creation time is not available. ", peerAssocRepoEvent.getTime());
assertEquals("Repo event datacontenttype", "application/json", peerAssocRepoEvent.getDatacontenttype());
assertNotNull(peerAssocRepoEvent.getDataschema());
assertEquals(EventJSONSchema.PEER_ASSOC_CREATED_V1.getSchema(), peerAssocRepoEvent.getDataschema());
final EventData<PeerAssociationResource> nodeResourceEventData = getEventData(peerAssocRepoEvent);
// EventData attributes
assertNotNull("Event data group ID is not available. ", nodeResourceEventData.getEventGroupId());
assertNull("resourceBefore property is not available", nodeResourceEventData.getResourceBefore());
final PeerAssociationResource peerAssociationResource = getPeerAssocResource(peerAssocRepoEvent);
assertEquals("Wrong source", content1NodeRef.getId(), peerAssociationResource.getSource().getId());
assertEquals("Wrong target", content2NodeRef.getId(), peerAssociationResource.getTarget().getId());
assertEquals("Wrong assoc type", "cm:original", peerAssociationResource.getAssocType());
}
use of com.ibm.watson.discovery.v1.model.EventData in project alfresco-repository by Alfresco.
the class PeerAssociationRepoEventIT method testAddMultiplePeerAssociationSameTransaction.
@Test
public void testAddMultiplePeerAssociationSameTransaction() {
final NodeRef content1NodeRef = createNode(ContentModel.TYPE_CONTENT);
final NodeRef content2NodeRef = createNode(ContentModel.TYPE_CONTENT);
final NodeRef content3NodeRef = createNode(ContentModel.TYPE_CONTENT);
checkNumOfEvents(3);
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());
retryingTransactionHelper.doInTransaction(() -> {
nodeService.createAssociation(content1NodeRef, content2NodeRef, ContentModel.ASSOC_ORIGINAL);
nodeService.createAssociation(content3NodeRef, content2NodeRef, ContentModel.ASSOC_ORIGINAL);
return null;
});
List<AssociationRef> peerAssociationRefs = retryingTransactionHelper.doInTransaction(() -> nodeService.getSourceAssocs(content2NodeRef, ContentModel.ASSOC_ORIGINAL));
assertEquals(2, peerAssociationRefs.size());
checkNumOfEvents(7);
List<RepoEvent<EventData<PeerAssociationResource>>> peerAssocRepoEvent = getFilteredEvents(EventType.PEER_ASSOC_CREATED);
// we should have 2 assoc.peer.Created events
assertEquals("Wrong association events number", 2, peerAssocRepoEvent.size());
}
use of com.ibm.watson.discovery.v1.model.EventData in project alfresco-repository by Alfresco.
the class UpdateRepoEventIT method testUpdateNodeType.
@Test
public void testUpdateNodeType() {
final NodeRef nodeRef = createNode(ContentModel.TYPE_CONTENT);
// old node's type
assertEquals("Created node does not have the correct type", ContentModel.TYPE_CONTENT, nodeService.getType(nodeRef));
// node.Created event should be generated
RepoEvent<EventData<NodeResource>> resultRepoEvent = getRepoEvent(1);
assertEquals("Wrong repo event type.", EventType.NODE_CREATED.getType(), resultRepoEvent.getType());
NodeResource nodeResource = getNodeResource(resultRepoEvent);
assertEquals("cm:content node type was not found", "cm:content", nodeResource.getNodeType());
retryingTransactionHelper.doInTransaction(() -> {
nodeService.setType(nodeRef, ContentModel.TYPE_FOLDER);
// new node's type
assertEquals("Wrong node type", ContentModel.TYPE_FOLDER, nodeService.getType(nodeRef));
return null;
});
// we should have 2 events, node.Created and node.Updated
checkNumOfEvents(2);
resultRepoEvent = getRepoEvent(2);
assertEquals("Wrong repo event type.", EventType.NODE_UPDATED.getType(), resultRepoEvent.getType());
nodeResource = getNodeResource(resultRepoEvent);
assertEquals("Incorrect node type was found", "cm:folder", nodeResource.getNodeType());
NodeResource resourceBefore = getNodeResourceBefore(2);
assertEquals("Incorrect node type was found", "cm:content", resourceBefore.getNodeType());
// assertNotNull(resourceBefore.getModifiedAt()); uncomment this when the issue will be fixed
assertNull(resourceBefore.getId());
assertNull(resourceBefore.getContent());
assertNull(resourceBefore.isFile());
assertNull(resourceBefore.isFolder());
assertNull(resourceBefore.getModifiedByUser());
assertNull(resourceBefore.getCreatedAt());
assertNull(resourceBefore.getCreatedByUser());
assertNull(resourceBefore.getProperties());
assertNull(resourceBefore.getAspectNames());
assertNull(resourceBefore.getPrimaryHierarchy());
}
Aggregations