use of org.alfresco.event.sdk.model.v1.model.PeerAssociationResource in project alfresco-java-sdk by Alfresco.
the class NodeTypeFilterTest method should_testFalse_when_noNodeEventIsSent.
@Test
public void should_testFalse_when_noNodeEventIsSent() {
final PeerAssociationResource peerAssociationResource = new PeerAssociationResource("source-id", "target-id", "test:other");
final EventData<PeerAssociationResource> eventData = EventData.<PeerAssociationResource>builder().setResource(peerAssociationResource).build();
final RepoEvent<? extends DataAttributes<? extends Resource>> repoEvent = RepoEvent.<EventData<PeerAssociationResource>>builder().setData(eventData).build();
final boolean result = nodeTypeFilter.test((RepoEvent<DataAttributes<Resource>>) repoEvent);
assertThat(result).isFalse();
}
use of org.alfresco.event.sdk.model.v1.model.PeerAssociationResource in project alfresco-java-sdk by Alfresco.
the class AssocTypeFilterTest method should_testTrue_when_assocEventWithCorrespondingAssocTypeIsSent.
@Test
public void should_testTrue_when_assocEventWithCorrespondingAssocTypeIsSent() {
final PeerAssociationResource peerAssociationResource = new PeerAssociationResource("source-id", "target-id", TEST_ASSOC_TYPE);
final EventData<PeerAssociationResource> eventData = EventData.<PeerAssociationResource>builder().setResource(peerAssociationResource).build();
final RepoEvent<? extends DataAttributes<? extends Resource>> repoEvent = RepoEvent.<EventData<PeerAssociationResource>>builder().setData(eventData).build();
final boolean result = assocTypeFilter.test((RepoEvent<DataAttributes<Resource>>) repoEvent);
assertThat(result).isTrue();
}
use of org.alfresco.event.sdk.model.v1.model.PeerAssociationResource in project alfresco-repository by Alfresco.
the class PeerAssociationEventConsolidator method getRepoEvent.
/**
* Builds and returns the {@link RepoEvent} instance.
*
* @param eventInfo the object holding the event information
* @return the {@link RepoEvent} instance
*/
public RepoEvent<DataAttributes<PeerAssociationResource>> getRepoEvent(EventInfo eventInfo) {
EventType eventType = getDerivedEvent();
DataAttributes<PeerAssociationResource> eventData = buildEventData(eventInfo, resource);
return RepoEvent.<DataAttributes<PeerAssociationResource>>builder().setId(eventInfo.getId()).setSource(eventInfo.getSource()).setTime(eventInfo.getTimestamp()).setType(eventType.getType()).setData(eventData).setDataschema(EventJSONSchema.getSchemaV1(eventType)).build();
}
use of org.alfresco.event.sdk.model.v1.model.PeerAssociationResource in project alfresco-repository by Alfresco.
the class AbstractContextAwareRepoEvent method getPeerAssocResource.
protected <D extends DataAttributes<PeerAssociationResource>> PeerAssociationResource getPeerAssocResource(RepoEvent<D> repoEvent) {
assertNotNull(repoEvent);
D eventData = repoEvent.getData();
assertNotNull(eventData);
PeerAssociationResource resource = eventData.getResource();
assertNotNull(resource);
return resource;
}
use of org.alfresco.event.sdk.model.v1.model.PeerAssociationResource in project alfresco-repository by Alfresco.
the class PeerAssociationRepoEventIT method testAddMultiplePeerAssociationDifferentTransaction.
@Test
public void testAddMultiplePeerAssociationDifferentTransaction() {
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);
return null;
});
retryingTransactionHelper.doInTransaction(() -> {
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());
assertEquals("Wrong source", content1NodeRef.getId(), getPeerAssocResource(peerAssocRepoEvent.get(0)).getSource().getId());
assertEquals("Wrong target", content2NodeRef.getId(), getPeerAssocResource(peerAssocRepoEvent.get(0)).getTarget().getId());
assertEquals("Wrong assoc type", "cm:original", getPeerAssocResource(peerAssocRepoEvent.get(0)).getAssocType());
assertEquals("Wrong source", content3NodeRef.getId(), getPeerAssocResource(peerAssocRepoEvent.get(1)).getSource().getId());
assertEquals("Wrong target", content2NodeRef.getId(), getPeerAssocResource(peerAssocRepoEvent.get(1)).getTarget().getId());
assertEquals("Wrong assoc type", "cm:original", getPeerAssocResource(peerAssocRepoEvent.get(1)).getAssocType());
}
Aggregations