diff --git a/source/java/org/alfresco/repo/node/integrity/AssocSourceMultiplicityIntegrityEvent.java b/source/java/org/alfresco/repo/node/integrity/AssocSourceMultiplicityIntegrityEvent.java index 6f57aeebdd..da54523c55 100644 --- a/source/java/org/alfresco/repo/node/integrity/AssocSourceMultiplicityIntegrityEvent.java +++ b/source/java/org/alfresco/repo/node/integrity/AssocSourceMultiplicityIntegrityEvent.java @@ -169,13 +169,11 @@ public class AssocSourceMultiplicityIntegrityEvent extends AbstractIntegrityEven { if (actualSize == 0) { - // Double check that the association source is still present - ClassDefinition classDef = assocDef.getTargetClass(); - if (classDef.isAspect() && !nodeService.hasAspect(targetNodeRef, classDef.getName())) - { - // The target is an aspect but the aspect is not present - return; - } + // ALF-9591: Integrity check: Association source multiplicity checking is incorrect + // At this point, there is no point worrying. There are no more associations + // pointing *to* this node and therefore the checking of the source + // multiplicity (a feature of the source type/aspect) is not relevant + return; } String parentOrSourceStr = (assocDef.isChild() ? "parent" : "source"); diff --git a/source/java/org/alfresco/repo/node/integrity/IntegrityTest.java b/source/java/org/alfresco/repo/node/integrity/IntegrityTest.java index 01af365813..a9fe9bc6e0 100644 --- a/source/java/org/alfresco/repo/node/integrity/IntegrityTest.java +++ b/source/java/org/alfresco/repo/node/integrity/IntegrityTest.java @@ -448,4 +448,28 @@ public class IntegrityTest extends TestCase checkIntegrityExpectFailure("Failed to detect excess source cardinality for one-to-many assocs", 1); } + + public void testSourceAssocAfterDeletion() throws Exception + { + NodeRef source1 = createNode("abc", TEST_TYPE_WITH_ASSOCS, null); + NodeRef source2 = createNode("abc", TEST_TYPE_WITH_ASSOCS, null); + NodeRef target1 = createNode("target1", TEST_TYPE_WITHOUT_ANYTHING, null); + NodeRef target2 = createNode("target1", TEST_TYPE_WITHOUT_ANYTHING, null); + nodeService.createAssociation(source1, target1, TEST_ASSOC_NODE_ONE_ONE); + nodeService.createAssociation(source2, target2, TEST_ASSOC_NODE_ONE_ONE); + checkIntegrityNoFailure(); + + nodeService.createAssociation(source1, target1, TEST_ASSOC_NODE_ONE_MANY); + nodeService.createAssociation(source2, target1, TEST_ASSOC_NODE_ONE_MANY); + // Both (or either of) the associations are in violation + checkIntegrityExpectFailure("Failed to detect excess source cardinality for one-to-many assocs", 1); + + // Now remove one of the associations + nodeService.removeAssociation(source2, target1, TEST_ASSOC_NODE_ONE_MANY); + checkIntegrityNoFailure(); + + // Now remove the last association + nodeService.removeAssociation(source1, target1, TEST_ASSOC_NODE_ONE_MANY); + checkIntegrityNoFailure(); + } }