mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-01 14:41:46 +00:00
ACS-5471: Secondary path support (#2213)
* ACS-5471: Secondary path support * ACS-5471: Secondary path support * ACS-5471: Secondary path support * ACS-5471: Secondary path support * ACS-5471: Secondary path support * ACS-5471: Secondary path support * ACS-5471: Secondary path support * ACS-5471: Secondary path support - fixed test method name * ACS-5471: Secondary path support - trying to fix failing on CI DispositionScheduleLinkedRecordsTest * ACS-5471: Secondary path support - trying to fix failing on CI DispositionScheduleLinkedRecordsTest * ACS-5471: Secondary path support - trying to fix failing CI due to DispositionScheduleLinkedRecordsTest * ACS-5471: Test adjustment to follow same behavior as introduced by ACS-5325 * ACS-5471: Fixing docker issues --------- Co-authored-by: mpichura <maciej.pichura@hyland.com>
This commit is contained in:
committed by
GitHub
parent
c157780dcb
commit
395d7ded57
@@ -28,6 +28,7 @@ package org.alfresco.repo.event2;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.event.v1.model.ChildAssociationResource;
|
||||
@@ -64,12 +65,11 @@ public class ChildAssociationRepoEventIT extends AbstractContextAwareRepoEvent
|
||||
assertEquals("Wrong repo event type.", EventType.NODE_CREATED.getType(),
|
||||
resultRepoEvent.getType());
|
||||
|
||||
retryingTransactionHelper.doInTransaction(() ->
|
||||
nodeService.addChild(
|
||||
parentNodeRef,
|
||||
childNodeRef,
|
||||
ContentModel.ASSOC_CONTAINS,
|
||||
QName.createQName(TEST_NAMESPACE, assocLocalName)));
|
||||
retryingTransactionHelper.doInTransaction(() -> nodeService.addChild(
|
||||
parentNodeRef,
|
||||
childNodeRef,
|
||||
ContentModel.ASSOC_CONTAINS,
|
||||
QName.createQName(TEST_NAMESPACE, assocLocalName)));
|
||||
|
||||
List<ChildAssociationRef> childAssociationRefs = retryingTransactionHelper.doInTransaction(() ->
|
||||
nodeService.getChildAssocs(parentNodeRef));
|
||||
@@ -79,8 +79,30 @@ public class ChildAssociationRepoEventIT extends AbstractContextAwareRepoEvent
|
||||
|
||||
checkNumOfEvents(4);
|
||||
|
||||
final RepoEvent<EventData<ChildAssociationResource>> childAssocRepoEvent = getFilteredEvent(EventType.CHILD_ASSOC_CREATED, 0);
|
||||
// node event
|
||||
final RepoEvent<EventData<NodeResource>> nodeRepoEvent = getRepoEventWithoutWait(3);
|
||||
assertEquals("Wrong repo event type.", EventType.NODE_UPDATED.getType(), nodeRepoEvent.getType());
|
||||
assertNotNull("Repo event ID is not available.", nodeRepoEvent.getId());
|
||||
assertNotNull("Source is not available", nodeRepoEvent.getSource());
|
||||
assertEquals("Repo event source is not available.",
|
||||
"/" + descriptorService.getCurrentRepositoryDescriptor().getId(),
|
||||
nodeRepoEvent.getSource().toString());
|
||||
assertNotNull("Repo event creation time is not available.", nodeRepoEvent.getTime());
|
||||
assertEquals("Invalid repo event datacontenttype", "application/json",
|
||||
nodeRepoEvent.getDatacontenttype());
|
||||
assertNotNull(nodeRepoEvent.getDataschema());
|
||||
assertEquals(EventJSONSchema.NODE_UPDATED_V1.getSchema(), nodeRepoEvent.getDataschema());
|
||||
|
||||
final EventData<NodeResource> nodeResourceEventData = getEventData(nodeRepoEvent);
|
||||
assertNotNull("Event data group ID is not available. ", nodeResourceEventData.getEventGroupId());
|
||||
assertNotNull("resourceBefore property is not available", nodeResourceEventData.getResourceBefore());
|
||||
|
||||
final NodeResource nodeResource = getNodeResource(nodeRepoEvent);
|
||||
final NodeResource nodeResourceBefore = getNodeResourceBefore(nodeRepoEvent);
|
||||
assertNotSame("Secondary parents actual and earlier state should differ", nodeResource.getSecondaryParents(), nodeResourceBefore.getSecondaryParents());
|
||||
|
||||
// child association event
|
||||
final RepoEvent<EventData<ChildAssociationResource>> childAssocRepoEvent = getFilteredEvent(EventType.CHILD_ASSOC_CREATED, 0);
|
||||
assertEquals("Wrong repo event type.", EventType.CHILD_ASSOC_CREATED.getType(), childAssocRepoEvent.getType());
|
||||
assertNotNull("Repo event ID is not available.", childAssocRepoEvent.getId());
|
||||
assertNotNull("Source is not available", childAssocRepoEvent.getSource());
|
||||
@@ -93,16 +115,18 @@ public class ChildAssociationRepoEventIT extends AbstractContextAwareRepoEvent
|
||||
assertNotNull(childAssocRepoEvent.getDataschema());
|
||||
assertEquals(EventJSONSchema.CHILD_ASSOC_CREATED_V1.getSchema(), childAssocRepoEvent.getDataschema());
|
||||
|
||||
final EventData<ChildAssociationResource> nodeResourceEventData = getEventData(childAssocRepoEvent);
|
||||
// EventData attributes
|
||||
assertNotNull("Event data group ID is not available. ", nodeResourceEventData.getEventGroupId());
|
||||
assertNull("resourceBefore property is not available", nodeResourceEventData.getResourceBefore());
|
||||
final EventData<ChildAssociationResource> childAssocResourceEventData = getEventData(childAssocRepoEvent);
|
||||
assertNotNull("Event data group ID is not available. ", childAssocResourceEventData.getEventGroupId());
|
||||
assertNull("resourceBefore property is not available", childAssocResourceEventData.getResourceBefore());
|
||||
|
||||
final ChildAssociationResource childAssociationResource = getChildAssocResource(childAssocRepoEvent);
|
||||
assertEquals("Wrong parent", parentNodeRef.getId(), childAssociationResource.getParent().getId());
|
||||
assertEquals("Wrong child", childNodeRef.getId(), childAssociationResource.getChild().getId());
|
||||
assertEquals("Wrong assoc type", "cm:contains", childAssociationResource.getAssocType());
|
||||
assertEquals("Wrong assoc name", "ce:" + assocLocalName, childAssociationResource.getAssocQName());
|
||||
|
||||
assertEquals("Node and child association events should have same eventGroupId", nodeResourceEventData.getEventGroupId(), childAssocResourceEventData.getEventGroupId());
|
||||
assertTrue("Wrong node's secondary parents", nodeResource.getSecondaryParents().contains(childAssociationResource.getParent().getId()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -143,8 +167,30 @@ public class ChildAssociationRepoEventIT extends AbstractContextAwareRepoEvent
|
||||
|
||||
checkNumOfEvents(6);
|
||||
|
||||
final RepoEvent<EventData<ChildAssociationResource>> childAssocRepoEvent = getFilteredEvent(EventType.CHILD_ASSOC_DELETED, 0);
|
||||
// node repo event
|
||||
final RepoEvent<EventData<NodeResource>> nodeRepoEvent = getRepoEventWithoutWait(5);
|
||||
assertEquals("Wrong repo event type.", EventType.NODE_UPDATED.getType(), nodeRepoEvent.getType());
|
||||
assertNotNull("Repo event ID is not available.", nodeRepoEvent.getId());
|
||||
assertNotNull("Source is not available", nodeRepoEvent.getSource());
|
||||
assertEquals("Repo event source is not available.",
|
||||
"/" + descriptorService.getCurrentRepositoryDescriptor().getId(),
|
||||
nodeRepoEvent.getSource().toString());
|
||||
assertNotNull("Repo event creation time is not available.", nodeRepoEvent.getTime());
|
||||
assertEquals("Invalid repo event datacontenttype", "application/json",
|
||||
nodeRepoEvent.getDatacontenttype());
|
||||
assertNotNull(nodeRepoEvent.getDataschema());
|
||||
assertEquals(EventJSONSchema.NODE_UPDATED_V1.getSchema(), nodeRepoEvent.getDataschema());
|
||||
|
||||
final EventData<NodeResource> nodeResourceEventData = getEventData(nodeRepoEvent);
|
||||
assertNotNull("Event data group ID is not available. ", nodeResourceEventData.getEventGroupId());
|
||||
assertNotNull("resourceBefore property is not available", nodeResourceEventData.getResourceBefore());
|
||||
|
||||
final NodeResource nodeResource = getNodeResource(nodeRepoEvent);
|
||||
final NodeResource nodeResourceBefore = getNodeResourceBefore(nodeRepoEvent);
|
||||
assertNotSame("Secondary parents actual and earlier state should differ", nodeResource.getSecondaryParents(), nodeResourceBefore.getSecondaryParents());
|
||||
|
||||
// child association repo event
|
||||
final RepoEvent<EventData<ChildAssociationResource>> childAssocRepoEvent = getFilteredEvent(EventType.CHILD_ASSOC_DELETED, 0);
|
||||
assertEquals("Wrong repo event type.", EventType.CHILD_ASSOC_DELETED.getType(), childAssocRepoEvent.getType());
|
||||
assertNotNull("Repo event ID is not available. ", childAssocRepoEvent.getId());
|
||||
assertNotNull("Source is not available", childAssocRepoEvent.getSource());
|
||||
@@ -156,15 +202,17 @@ public class ChildAssociationRepoEventIT extends AbstractContextAwareRepoEvent
|
||||
assertNotNull(childAssocRepoEvent.getDataschema());
|
||||
assertEquals(EventJSONSchema.CHILD_ASSOC_DELETED_V1.getSchema(), childAssocRepoEvent.getDataschema());
|
||||
|
||||
final EventData<ChildAssociationResource> nodeResourceEventData = getEventData(childAssocRepoEvent);
|
||||
// EventData attributes
|
||||
assertNotNull("Event data group ID is not available. ", nodeResourceEventData.getEventGroupId());
|
||||
assertNull("resourceBefore property is not available", nodeResourceEventData.getResourceBefore());
|
||||
final EventData<ChildAssociationResource> childAssocResourceEventData = getEventData(childAssocRepoEvent);
|
||||
assertNotNull("Event data group ID is not available. ", childAssocResourceEventData.getEventGroupId());
|
||||
assertNull("resourceBefore property is not available", childAssocResourceEventData.getResourceBefore());
|
||||
|
||||
final ChildAssociationResource childAssociationResource = getChildAssocResource(childAssocRepoEvent);
|
||||
assertEquals("Wrong parent", parentNodeRef.getId(), childAssociationResource.getParent().getId());
|
||||
assertEquals("Wrong child", childNodeRef.getId(), childAssociationResource.getChild().getId());
|
||||
assertEquals("Wrong assoc type", "cm:contains", childAssociationResource.getAssocType());
|
||||
|
||||
assertEquals("Node and child association events should have same eventGroupId", nodeResourceEventData.getEventGroupId(), childAssocResourceEventData.getEventGroupId());
|
||||
assertTrue("Wrong node's secondary parents", nodeResourceBefore.getSecondaryParents().contains(childAssociationResource.getParent().getId()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -179,17 +227,10 @@ public class ChildAssociationRepoEventIT extends AbstractContextAwareRepoEvent
|
||||
|
||||
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());
|
||||
IntStream.of(1, 2, 3, 4).forEach(i -> {
|
||||
RepoEvent<EventData<NodeResource>> resultRepoEvent = getRepoEventWithoutWait(i);
|
||||
assertEquals("Wrong repo event type.", EventType.NODE_CREATED.getType(), resultRepoEvent.getType());
|
||||
});
|
||||
|
||||
retryingTransactionHelper.doInTransaction(() ->
|
||||
nodeService.addChild(
|
||||
@@ -213,11 +254,14 @@ public class ChildAssociationRepoEventIT extends AbstractContextAwareRepoEvent
|
||||
});
|
||||
|
||||
checkNumOfEvents(8);
|
||||
|
||||
// 3 assoc.child.Created events should be created
|
||||
|
||||
// 1 node.Updated events should be created
|
||||
List<RepoEvent<EventData<NodeResource>>> nodeUpdateEvent = getFilteredEvents(EventType.NODE_UPDATED);
|
||||
assertEquals("Wrong association events number", 1, nodeUpdateEvent.size());
|
||||
|
||||
// 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("Wrong association events number", 3, childAssocEvents.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -231,17 +275,10 @@ public class ChildAssociationRepoEventIT extends AbstractContextAwareRepoEvent
|
||||
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(1);
|
||||
assertEquals("Wrong repo event type.", EventType.NODE_CREATED.getType(), resultRepoEvent.getType());
|
||||
|
||||
resultRepoEvent = getRepoEventWithoutWait(1);
|
||||
assertEquals("Wrong repo event type.", EventType.NODE_CREATED.getType(), resultRepoEvent.getType());
|
||||
|
||||
resultRepoEvent = getRepoEventWithoutWait(1);
|
||||
assertEquals("Wrong repo event type.", EventType.NODE_CREATED.getType(), resultRepoEvent.getType());
|
||||
IntStream.of(1, 2, 3, 4).forEach(i -> {
|
||||
RepoEvent<EventData<NodeResource>> resultRepoEvent = getRepoEventWithoutWait(i);
|
||||
assertEquals("Wrong repo event type.", EventType.NODE_CREATED.getType(), resultRepoEvent.getType());
|
||||
});
|
||||
|
||||
retryingTransactionHelper.doInTransaction(() -> {
|
||||
for (NodeRef parent : parents)
|
||||
@@ -269,9 +306,13 @@ public class ChildAssociationRepoEventIT extends AbstractContextAwareRepoEvent
|
||||
});
|
||||
|
||||
checkNumOfEvents(8);
|
||||
|
||||
RepoEvent<EventData<NodeResource>> resultRepoEvent = getRepoEventWithoutWait(5);
|
||||
assertEquals("Wrong repo event type.", EventType.NODE_UPDATED.getType(), resultRepoEvent.getType());
|
||||
|
||||
// 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("Wrong association events number", 3, childAssocEvents.size());
|
||||
|
||||
// All events in the transaction should have the same eventGroupId
|
||||
String assocEventGroupID1 = getEventData(childAssocEvents.get(0)).getEventGroupId();
|
||||
@@ -294,17 +335,10 @@ public class ChildAssociationRepoEventIT extends AbstractContextAwareRepoEvent
|
||||
|
||||
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());
|
||||
IntStream.of(1, 2, 3, 4).forEach(i -> {
|
||||
RepoEvent<EventData<NodeResource>> resultRepoEvent = getRepoEventWithoutWait(i);
|
||||
assertEquals("Wrong repo event type.", EventType.NODE_CREATED.getType(), resultRepoEvent.getType());
|
||||
});
|
||||
|
||||
for (NodeRef parent : parents)
|
||||
{
|
||||
@@ -331,9 +365,14 @@ public class ChildAssociationRepoEventIT extends AbstractContextAwareRepoEvent
|
||||
});
|
||||
|
||||
checkNumOfEvents(10);
|
||||
|
||||
// 3 node.Updated events should be created
|
||||
List<RepoEvent<EventData<ChildAssociationResource>>> nodeUpdateEvents = getFilteredEvents(EventType.NODE_UPDATED);
|
||||
assertEquals("Wrong node update events number", 3, nodeUpdateEvents.size());
|
||||
|
||||
// 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("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());
|
||||
@@ -360,17 +399,10 @@ public class ChildAssociationRepoEventIT extends AbstractContextAwareRepoEvent
|
||||
|
||||
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());
|
||||
IntStream.of(1, 2, 3, 4).forEach(i -> {
|
||||
RepoEvent<EventData<NodeResource>> resultRepoEvent = getRepoEventWithoutWait(i);
|
||||
assertEquals("Wrong repo event type.", EventType.NODE_CREATED.getType(), resultRepoEvent.getType());
|
||||
});
|
||||
|
||||
retryingTransactionHelper.doInTransaction(() -> {
|
||||
for (NodeRef child : children)
|
||||
@@ -389,9 +421,14 @@ public class ChildAssociationRepoEventIT extends AbstractContextAwareRepoEvent
|
||||
});
|
||||
|
||||
checkNumOfEvents(10);
|
||||
|
||||
// 3 node.Updated events should be created
|
||||
List<RepoEvent<EventData<ChildAssociationResource>>> nodeUpdateEvents = getFilteredEvents(EventType.NODE_UPDATED);
|
||||
assertEquals("Wrong node update events number", 3, nodeUpdateEvents.size());
|
||||
|
||||
// 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("Wrong association events number", 3, childAssocEvents.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -406,17 +443,10 @@ public class ChildAssociationRepoEventIT extends AbstractContextAwareRepoEvent
|
||||
|
||||
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());
|
||||
IntStream.of(1, 2, 3, 4).forEach(i -> {
|
||||
RepoEvent<EventData<NodeResource>> resultRepoEvent = getRepoEventWithoutWait(i);
|
||||
assertEquals("Wrong repo event type.", EventType.NODE_CREATED.getType(), resultRepoEvent.getType());
|
||||
});
|
||||
|
||||
for (NodeRef child : children)
|
||||
{
|
||||
@@ -433,9 +463,14 @@ public class ChildAssociationRepoEventIT extends AbstractContextAwareRepoEvent
|
||||
});
|
||||
|
||||
checkNumOfEvents(10);
|
||||
|
||||
// 3 node.Updated events should be created
|
||||
List<RepoEvent<EventData<ChildAssociationResource>>> nodeUpdateEvents = getFilteredEvents(EventType.NODE_UPDATED);
|
||||
assertEquals("Wrong node update events number", 3, nodeUpdateEvents.size());
|
||||
|
||||
// 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("Wrong association events number", 3, childAssocEvents.size());
|
||||
|
||||
assertEquals(parentNodeRef.getId(), getChildAssocResource(childAssocEvents.get(0)).getParent().getId());
|
||||
assertEquals(child1NodeRef.getId(), getChildAssocResource(childAssocEvents.get(0)).getChild().getId());
|
||||
@@ -462,17 +497,10 @@ public class ChildAssociationRepoEventIT extends AbstractContextAwareRepoEvent
|
||||
|
||||
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());
|
||||
IntStream.of(1, 2, 3, 4).forEach(i -> {
|
||||
RepoEvent<EventData<NodeResource>> resultRepoEvent = getRepoEventWithoutWait(i);
|
||||
assertEquals("Wrong repo event type.", EventType.NODE_CREATED.getType(), resultRepoEvent.getType());
|
||||
});
|
||||
|
||||
retryingTransactionHelper.doInTransaction(() ->
|
||||
nodeService.addChild(parents, childNodeRef, ContentModel.ASSOC_CONTAINS,
|
||||
@@ -503,13 +531,17 @@ public class ChildAssociationRepoEventIT extends AbstractContextAwareRepoEvent
|
||||
|
||||
checkNumOfEvents(12);
|
||||
|
||||
// 2 node.Updated events should be created
|
||||
List<RepoEvent<EventData<ChildAssociationResource>>> nodeUpdateEvents = getFilteredEvents(EventType.NODE_UPDATED);
|
||||
assertEquals("Wrong node update events number", 2, nodeUpdateEvents.size());
|
||||
|
||||
// 3 assoc.child.Deleted events should be created
|
||||
List<RepoEvent<EventData<ChildAssociationResource>>> childAssocEvents = getFilteredEvents(EventType.CHILD_ASSOC_DELETED);
|
||||
assertEquals("Wrong association events number",3, childAssocEvents.size());
|
||||
assertEquals("Wrong association events number", 3, childAssocEvents.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteAssociationOneParentMultipleChildrenDifferentTransactions()
|
||||
public void testDeleteAssociationMultipleParentOneChildrenDifferentTransactions()
|
||||
{
|
||||
final NodeRef parent1NodeRef = createNode(ContentModel.TYPE_FOLDER);
|
||||
final NodeRef parent2NodeRef = createNode(ContentModel.TYPE_FOLDER);
|
||||
@@ -520,17 +552,10 @@ public class ChildAssociationRepoEventIT extends AbstractContextAwareRepoEvent
|
||||
|
||||
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());
|
||||
IntStream.of(1, 2, 3, 4).forEach(i -> {
|
||||
RepoEvent<EventData<NodeResource>> resultRepoEvent = getRepoEventWithoutWait(i);
|
||||
assertEquals("Wrong repo event type.", EventType.NODE_CREATED.getType(), resultRepoEvent.getType());
|
||||
});
|
||||
|
||||
retryingTransactionHelper.doInTransaction(() ->
|
||||
nodeService.addChild(parents, childNodeRef, ContentModel.ASSOC_CONTAINS,
|
||||
@@ -588,17 +613,10 @@ public class ChildAssociationRepoEventIT extends AbstractContextAwareRepoEvent
|
||||
|
||||
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());
|
||||
IntStream.of(1, 2, 3, 4).forEach(i -> {
|
||||
RepoEvent<EventData<NodeResource>> resultRepoEvent = getRepoEventWithoutWait(i);
|
||||
assertEquals("Wrong repo event type.", EventType.NODE_CREATED.getType(), resultRepoEvent.getType());
|
||||
});
|
||||
|
||||
retryingTransactionHelper.doInTransaction(() -> {
|
||||
for (NodeRef child : children)
|
||||
@@ -621,9 +639,13 @@ public class ChildAssociationRepoEventIT extends AbstractContextAwareRepoEvent
|
||||
|
||||
checkNumOfEvents(17);
|
||||
|
||||
// 6 node.Updated events should be created
|
||||
List<RepoEvent<EventData<ChildAssociationResource>>> nodeUpdateEvents = getFilteredEvents(EventType.NODE_UPDATED);
|
||||
assertEquals("Wrong node update events number", 6, nodeUpdateEvents.size());
|
||||
|
||||
// 3 assoc.child.Deleted events should be created
|
||||
List<RepoEvent<EventData<ChildAssociationResource>>> childAssocEvents = getFilteredEvents(EventType.CHILD_ASSOC_DELETED);
|
||||
assertEquals("Wrong association events number",3, childAssocEvents.size());
|
||||
assertEquals("Wrong association events number", 3, childAssocEvents.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -638,17 +660,10 @@ public class ChildAssociationRepoEventIT extends AbstractContextAwareRepoEvent
|
||||
|
||||
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());
|
||||
IntStream.of(1, 2, 3, 4).forEach(i -> {
|
||||
RepoEvent<EventData<NodeResource>> resultRepoEvent = getRepoEventWithoutWait(i);
|
||||
assertEquals("Wrong repo event type.", EventType.NODE_CREATED.getType(), resultRepoEvent.getType());
|
||||
});
|
||||
|
||||
retryingTransactionHelper.doInTransaction(() ->
|
||||
nodeService.addChild(parents, childNodeRef, ContentModel.ASSOC_CONTAINS,
|
||||
@@ -672,9 +687,13 @@ public class ChildAssociationRepoEventIT extends AbstractContextAwareRepoEvent
|
||||
|
||||
checkNumOfEvents(12);
|
||||
|
||||
// 2 node.Updated events should be created
|
||||
List<RepoEvent<EventData<ChildAssociationResource>>> nodeUpdateEvents = getFilteredEvents(EventType.NODE_UPDATED);
|
||||
assertEquals("Wrong node update events number", 2, nodeUpdateEvents.size());
|
||||
|
||||
// 3 assoc.child.Deleted events should be created
|
||||
List<RepoEvent<EventData<ChildAssociationResource>>> childAssocEvents = getFilteredEvents(EventType.CHILD_ASSOC_DELETED);
|
||||
assertEquals("Wrong association events number",3, childAssocEvents.size());
|
||||
assertEquals("Wrong association events number", 3, childAssocEvents.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -685,11 +704,10 @@ public class ChildAssociationRepoEventIT extends AbstractContextAwareRepoEvent
|
||||
|
||||
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());
|
||||
IntStream.of(1, 2).forEach(i -> {
|
||||
RepoEvent<EventData<NodeResource>> resultRepoEvent = getRepoEventWithoutWait(i);
|
||||
assertEquals("Wrong repo event type.", EventType.NODE_CREATED.getType(), resultRepoEvent.getType());
|
||||
});
|
||||
|
||||
retryingTransactionHelper.doInTransaction(() ->
|
||||
{
|
||||
@@ -712,10 +730,10 @@ public class ChildAssociationRepoEventIT extends AbstractContextAwareRepoEvent
|
||||
|
||||
// Check the node events occur before the child association event
|
||||
List<RepoEvent<?>> repoEvents = getRepoEventsContainer().getEvents();
|
||||
assertEquals("org.alfresco.event.node.Created", repoEvents.get(0).getType());
|
||||
assertEquals("org.alfresco.event.node.Created", repoEvents.get(1).getType());
|
||||
assertEquals("org.alfresco.event.node.Updated", repoEvents.get(2).getType());
|
||||
assertEquals("org.alfresco.event.node.Updated", repoEvents.get(3).getType());
|
||||
assertEquals("org.alfresco.event.assoc.child.Created", repoEvents.get(4).getType());
|
||||
assertEquals(EventType.NODE_CREATED.getType(), repoEvents.get(0).getType());
|
||||
assertEquals(EventType.NODE_CREATED.getType(), repoEvents.get(1).getType());
|
||||
assertEquals(EventType.NODE_UPDATED.getType(), repoEvents.get(2).getType());
|
||||
assertEquals(EventType.NODE_UPDATED.getType(), repoEvents.get(3).getType());
|
||||
assertEquals(EventType.CHILD_ASSOC_CREATED.getType(), repoEvents.get(4).getType());
|
||||
}
|
||||
}
|
||||
|
@@ -27,24 +27,38 @@ package org.alfresco.repo.event2;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.event.v1.model.EventType;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class EventConsolidatorUnitTest
|
||||
{
|
||||
private NodeResourceHelper nodeResourceHelper = mock(NodeResourceHelper.class);
|
||||
|
||||
private final NodeResourceHelper nodeResourceHelper = mock(NodeResourceHelper.class);
|
||||
private NodeEventConsolidator eventConsolidator;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception
|
||||
{
|
||||
eventConsolidator = new NodeEventConsolidator(nodeResourceHelper);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetMappedAspectsBeforeRemovedAndAddedEmpty()
|
||||
{
|
||||
NodeEventConsolidator eventConsolidator = new NodeEventConsolidator(nodeResourceHelper);
|
||||
|
||||
Set<String> currentAspects = new HashSet<>();
|
||||
currentAspects.add("cm:geographic");
|
||||
currentAspects.add("cm:auditable");
|
||||
@@ -57,7 +71,6 @@ public class EventConsolidatorUnitTest
|
||||
@Test
|
||||
public void testGetMappedAspectsBefore_AspectRemoved()
|
||||
{
|
||||
NodeEventConsolidator eventConsolidator = new NodeEventConsolidator(nodeResourceHelper);
|
||||
eventConsolidator.addAspect(ContentModel.ASSOC_CONTAINS);
|
||||
|
||||
Set<String> currentAspects = new HashSet<>();
|
||||
@@ -79,7 +92,6 @@ public class EventConsolidatorUnitTest
|
||||
@Test
|
||||
public void testGetMappedAspectsBefore_AspectAdded()
|
||||
{
|
||||
NodeEventConsolidator eventConsolidator = new NodeEventConsolidator(nodeResourceHelper);
|
||||
eventConsolidator.addAspect(ContentModel.ASSOC_CONTAINS);
|
||||
|
||||
Set<String> currentAspects = new HashSet<>();
|
||||
@@ -102,7 +114,6 @@ public class EventConsolidatorUnitTest
|
||||
@Test
|
||||
public void testGetMappedAspectsBefore_AspectAddedAndRemoved()
|
||||
{
|
||||
NodeEventConsolidator eventConsolidator = new NodeEventConsolidator(nodeResourceHelper);
|
||||
eventConsolidator.addAspect(ContentModel.ASSOC_CONTAINS);
|
||||
|
||||
Set<String> currentAspects = new HashSet<>();
|
||||
@@ -125,7 +136,6 @@ public class EventConsolidatorUnitTest
|
||||
@Test
|
||||
public void testGetMappedAspectsBefore_AspectRemovedAndAdded()
|
||||
{
|
||||
NodeEventConsolidator eventConsolidator = new NodeEventConsolidator(nodeResourceHelper);
|
||||
eventConsolidator.addAspect(ContentModel.ASSOC_CONTAINS);
|
||||
eventConsolidator.removeAspect(ContentModel.ASSOC_CONTAINS);
|
||||
|
||||
@@ -150,8 +160,6 @@ public class EventConsolidatorUnitTest
|
||||
@Test
|
||||
public void testGetMappedAspectsBefore_AspectAddedTwiceRemovedOnce()
|
||||
{
|
||||
NodeEventConsolidator eventConsolidator = new NodeEventConsolidator(nodeResourceHelper);
|
||||
|
||||
eventConsolidator.addAspect(ContentModel.ASSOC_CONTAINS);
|
||||
eventConsolidator.addAspect(ContentModel.ASSOC_CONTAINS);
|
||||
|
||||
@@ -178,8 +186,6 @@ public class EventConsolidatorUnitTest
|
||||
@Test
|
||||
public void testGetMappedAspectsBefore_AspectRemovedTwiceAddedOnce()
|
||||
{
|
||||
NodeEventConsolidator eventConsolidator = new NodeEventConsolidator(nodeResourceHelper);
|
||||
|
||||
eventConsolidator.addAspect(ContentModel.ASSOC_CONTAINS);
|
||||
eventConsolidator.addAspect(ContentModel.ASSOC_CONTAINS);
|
||||
|
||||
@@ -206,7 +212,6 @@ public class EventConsolidatorUnitTest
|
||||
@Test
|
||||
public void testGetMappedAspectsBefore_FilteredAspectAdded()
|
||||
{
|
||||
NodeEventConsolidator eventConsolidator = new NodeEventConsolidator(nodeResourceHelper);
|
||||
eventConsolidator.addAspect(ContentModel.ASPECT_COPIEDFROM);
|
||||
|
||||
Set<String> currentAspects = new HashSet<>();
|
||||
@@ -227,7 +232,6 @@ public class EventConsolidatorUnitTest
|
||||
@Test
|
||||
public void testAddAspect()
|
||||
{
|
||||
NodeEventConsolidator eventConsolidator = new NodeEventConsolidator(nodeResourceHelper);
|
||||
eventConsolidator.addAspect(ContentModel.ASSOC_CONTAINS);
|
||||
|
||||
assertEquals(1, eventConsolidator.getAspectsAdded().size());
|
||||
@@ -238,7 +242,6 @@ public class EventConsolidatorUnitTest
|
||||
@Test
|
||||
public void testRemoveAspect()
|
||||
{
|
||||
NodeEventConsolidator eventConsolidator = new NodeEventConsolidator(nodeResourceHelper);
|
||||
eventConsolidator.removeAspect(ContentModel.ASSOC_CONTAINS);
|
||||
|
||||
assertEquals(0, eventConsolidator.getAspectsAdded().size());
|
||||
@@ -249,7 +252,6 @@ public class EventConsolidatorUnitTest
|
||||
@Test
|
||||
public void testAddAspectRemoveAspect()
|
||||
{
|
||||
NodeEventConsolidator eventConsolidator = new NodeEventConsolidator(nodeResourceHelper);
|
||||
eventConsolidator.addAspect(ContentModel.ASSOC_CONTAINS);
|
||||
eventConsolidator.removeAspect(ContentModel.ASSOC_CONTAINS);
|
||||
|
||||
@@ -260,7 +262,6 @@ public class EventConsolidatorUnitTest
|
||||
@Test
|
||||
public void testRemoveAspectAddAspect()
|
||||
{
|
||||
NodeEventConsolidator eventConsolidator = new NodeEventConsolidator(nodeResourceHelper);
|
||||
eventConsolidator.removeAspect(ContentModel.ASSOC_CONTAINS);
|
||||
eventConsolidator.addAspect(ContentModel.ASSOC_CONTAINS);
|
||||
|
||||
@@ -271,7 +272,6 @@ public class EventConsolidatorUnitTest
|
||||
@Test
|
||||
public void testAddAspectTwiceRemoveAspectOnce()
|
||||
{
|
||||
NodeEventConsolidator eventConsolidator = new NodeEventConsolidator(nodeResourceHelper);
|
||||
eventConsolidator.addAspect(ContentModel.ASSOC_CONTAINS);
|
||||
eventConsolidator.removeAspect(ContentModel.ASSOC_CONTAINS);
|
||||
eventConsolidator.addAspect(ContentModel.ASSOC_CONTAINS);
|
||||
@@ -284,7 +284,6 @@ public class EventConsolidatorUnitTest
|
||||
@Test
|
||||
public void testAddAspectOnceRemoveAspectTwice()
|
||||
{
|
||||
NodeEventConsolidator eventConsolidator = new NodeEventConsolidator(nodeResourceHelper);
|
||||
eventConsolidator.removeAspect(ContentModel.ASSOC_CONTAINS);
|
||||
eventConsolidator.addAspect(ContentModel.ASSOC_CONTAINS);
|
||||
eventConsolidator.removeAspect(ContentModel.ASSOC_CONTAINS);
|
||||
@@ -293,4 +292,83 @@ public class EventConsolidatorUnitTest
|
||||
assertEquals(1, eventConsolidator.getAspectsRemoved().size());
|
||||
assertTrue(eventConsolidator.getAspectsRemoved().contains(ContentModel.ASSOC_CONTAINS));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnMoveNodeWithPrimaryParent()
|
||||
{
|
||||
ChildAssociationRef oldAssociationMock = mock(ChildAssociationRef.class);
|
||||
ChildAssociationRef newAssociationMock = mock(ChildAssociationRef.class);
|
||||
NodeRef parentRefMock = mock(NodeRef.class);
|
||||
given(newAssociationMock.isPrimary()).willReturn(true);
|
||||
given(oldAssociationMock.getParentRef()).willReturn(parentRefMock);
|
||||
|
||||
eventConsolidator.onMoveNode(oldAssociationMock, newAssociationMock);
|
||||
|
||||
then(newAssociationMock).should().getChildRef();
|
||||
then(newAssociationMock).should().isPrimary();
|
||||
then(newAssociationMock).shouldHaveNoMoreInteractions();
|
||||
then(nodeResourceHelper).should().getPrimaryHierarchy(parentRefMock, true);
|
||||
assertTrue("Node event consolidator should contain event type: UPDATED", eventConsolidator.getEventTypes().contains(EventType.NODE_UPDATED));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnMoveNodeAfterSecondaryParentAdded()
|
||||
{
|
||||
ChildAssociationRef oldAssociationMock = mock(ChildAssociationRef.class);
|
||||
ChildAssociationRef newAssociationMock = mock(ChildAssociationRef.class);
|
||||
NodeRef nodeRefMock = mock(NodeRef.class);
|
||||
NodeRef parentRefMock = mock(NodeRef.class);
|
||||
List<String> secondaryParentsMock = mock(List.class);
|
||||
given(newAssociationMock.isPrimary()).willReturn(false);
|
||||
given(newAssociationMock.getChildRef()).willReturn(nodeRefMock);
|
||||
given(newAssociationMock.getParentRef()).willReturn(parentRefMock);
|
||||
given(parentRefMock.getId()).willReturn("parent-id");
|
||||
given(nodeResourceHelper.getSecondaryParents(any(NodeRef.class))).willReturn(secondaryParentsMock);
|
||||
|
||||
// when
|
||||
eventConsolidator.onMoveNode(oldAssociationMock, newAssociationMock);
|
||||
|
||||
then(newAssociationMock).should().isPrimary();
|
||||
then(newAssociationMock).should(times(2)).getChildRef();
|
||||
then(newAssociationMock).should(times(2)).getParentRef();
|
||||
then(newAssociationMock).shouldHaveNoMoreInteractions();
|
||||
then(oldAssociationMock).shouldHaveNoInteractions();
|
||||
then(nodeResourceHelper).should().getSecondaryParents(nodeRefMock);
|
||||
then(secondaryParentsMock).should().remove("parent-id");
|
||||
then(secondaryParentsMock).shouldHaveNoMoreInteractions();
|
||||
assertTrue("Node event consolidator should contain event type: UPDATED", eventConsolidator.getEventTypes().contains(EventType.NODE_UPDATED));
|
||||
assertEquals(secondaryParentsMock, eventConsolidator.getSecondaryParentsBefore());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnMoveNodeBeforeSecondaryParentRemoved()
|
||||
{
|
||||
ChildAssociationRef oldAssociationMock = mock(ChildAssociationRef.class);
|
||||
ChildAssociationRef newAssociationMock = mock(ChildAssociationRef.class);
|
||||
NodeRef nodeRefMock = mock(NodeRef.class);
|
||||
NodeRef parentRefMock = mock(NodeRef.class);
|
||||
List<String> secondaryParentsMock = mock(List.class);
|
||||
given(newAssociationMock.isPrimary()).willReturn(false);
|
||||
given(newAssociationMock.getChildRef()).willReturn(nodeRefMock);
|
||||
given(oldAssociationMock.getParentRef()).willReturn(parentRefMock);
|
||||
given(parentRefMock.getId()).willReturn("parent-id");
|
||||
given(nodeResourceHelper.getSecondaryParents(any(NodeRef.class))).willReturn(secondaryParentsMock);
|
||||
|
||||
// when
|
||||
eventConsolidator.onMoveNode(oldAssociationMock, newAssociationMock);
|
||||
|
||||
then(newAssociationMock).should().isPrimary();
|
||||
then(newAssociationMock).should(times(2)).getChildRef();
|
||||
then(newAssociationMock).should().getParentRef();
|
||||
then(newAssociationMock).shouldHaveNoMoreInteractions();
|
||||
then(oldAssociationMock).should(times(3)).getParentRef();
|
||||
then(oldAssociationMock).shouldHaveNoMoreInteractions();
|
||||
then(nodeResourceHelper).should().getSecondaryParents(nodeRefMock);
|
||||
then(secondaryParentsMock).should().contains("parent-id");
|
||||
then(secondaryParentsMock).should().add("parent-id");
|
||||
then(secondaryParentsMock).shouldHaveNoMoreInteractions();
|
||||
assertTrue("Node event consolidator should contain event type: NODE_UPDATED", eventConsolidator.getEventTypes().contains(EventType.NODE_UPDATED));
|
||||
assertEquals(secondaryParentsMock, eventConsolidator.getSecondaryParentsBefore());
|
||||
}
|
||||
}
|
||||
|
@@ -28,14 +28,43 @@ package org.alfresco.repo.event2;
|
||||
import static org.alfresco.repo.event2.NodeResourceHelper.getLocalizedPropertiesBefore;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class NodeResourceHelperUnitTest
|
||||
{
|
||||
@Mock
|
||||
private NodeService nodeServiceMock;
|
||||
|
||||
@InjectMocks
|
||||
private NodeResourceHelper nodeResourceHelper;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception
|
||||
{
|
||||
MockitoAnnotations.openMocks(this);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldExtractOnlyRelevantPropertiesForBeforeNode()
|
||||
{
|
||||
@@ -111,4 +140,39 @@ public class NodeResourceHelperUnitTest
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSecondaryParents()
|
||||
{
|
||||
NodeRef nodeRefMock = mock(NodeRef.class);
|
||||
NodeRef parentRefMock = mock(NodeRef.class);
|
||||
ChildAssociationRef secondaryParentMock = mock(ChildAssociationRef.class);
|
||||
given(nodeServiceMock.getParentAssocs(any(NodeRef.class))).willReturn(List.of(secondaryParentMock));
|
||||
given(secondaryParentMock.isPrimary()).willReturn(false);
|
||||
given(secondaryParentMock.getParentRef()).willReturn(parentRefMock);
|
||||
|
||||
// when
|
||||
List<String> secondaryParents = nodeResourceHelper.getSecondaryParents(nodeRefMock);
|
||||
|
||||
then(nodeServiceMock).should().getParentAssocs(nodeRefMock);
|
||||
then(nodeServiceMock).shouldHaveNoMoreInteractions();
|
||||
then(secondaryParentMock).should().isPrimary();
|
||||
then(secondaryParentMock).should().getParentRef();
|
||||
then(secondaryParentMock).shouldHaveNoMoreInteractions();
|
||||
then(parentRefMock).should().getId();
|
||||
then(parentRefMock).shouldHaveNoMoreInteractions();
|
||||
assertNotNull(secondaryParents);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetNoneSecondaryParents()
|
||||
{
|
||||
NodeRef nodeRefMock = mock(NodeRef.class);
|
||||
|
||||
// when
|
||||
List<String> secondaryParents = nodeResourceHelper.getSecondaryParents(nodeRefMock);
|
||||
|
||||
assertNotNull(secondaryParents);
|
||||
assertTrue(secondaryParents.isEmpty());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user