Search in sources :

Example 6 with PeerAssociationResource

use of org.alfresco.repo.event.v1.model.PeerAssociationResource 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());
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) RepoEvent(org.alfresco.repo.event.v1.model.RepoEvent) PeerAssociationResource(org.alfresco.repo.event.v1.model.PeerAssociationResource) EventData(org.alfresco.repo.event.v1.model.EventData) AssociationRef(org.alfresco.service.cmr.repository.AssociationRef) Test(org.junit.Test)

Aggregations

PeerAssociationResource (org.alfresco.repo.event.v1.model.PeerAssociationResource)6 EventData (org.alfresco.repo.event.v1.model.EventData)4 AssociationRef (org.alfresco.service.cmr.repository.AssociationRef)4 NodeRef (org.alfresco.service.cmr.repository.NodeRef)4 Test (org.junit.Test)4 RepoEvent (org.alfresco.repo.event.v1.model.RepoEvent)2 EventType (org.alfresco.repo.event.v1.model.EventType)1 GUID (org.alfresco.util.GUID)1