mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-08 14:51:49 +00:00
Merged 5.1.N (5.1.2) to 5.2.N (5.2.1)
124085 amorarasu: Merged 5.0.N (5.0.4) to 5.1.N (5.1.2) 123477 amorarasu: Merged V4.2-BUG-FIX (4.2.7) to 5.0.N (5.0.4) 123368 gjames: MNT-15114: Test to ensure the policy fires git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@124211 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -75,7 +75,6 @@ import org.alfresco.service.namespace.RegexQNamePattern;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.alfresco.util.BaseSpringTest;
|
||||
import org.alfresco.util.GUID;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.hibernate.dialect.DB2Dialect;
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
@@ -1451,7 +1450,7 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest
|
||||
pathARef.getChildRef(),
|
||||
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
||||
QName.createQName("pathC"));
|
||||
|
||||
|
||||
// remove the path B association
|
||||
boolean removedB = nodeService.removeChildAssociation(pathBRef);
|
||||
assertTrue("Association was not removed", removedB);
|
||||
@@ -1461,13 +1460,13 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest
|
||||
// remove the path C association
|
||||
boolean removedC = nodeService.removeChildAssociation(pathCRef);
|
||||
assertTrue("Association was not removed", removedC);
|
||||
removedC = nodeService.removeSeconaryChildAssociation(pathCRef);
|
||||
removedC = nodeService.removeSecondaryChildAssociation(pathCRef);
|
||||
assertFalse("Non-existent association was apparently removed", removedC);
|
||||
|
||||
// Now verify that primary associations are caught
|
||||
try
|
||||
{
|
||||
nodeService.removeSeconaryChildAssociation(pathPrimaryRef);
|
||||
nodeService.removeSecondaryChildAssociation(pathPrimaryRef);
|
||||
fail("Primary association not detected");
|
||||
}
|
||||
catch (IllegalArgumentException e)
|
||||
@@ -1475,6 +1474,45 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest
|
||||
// Expected
|
||||
}
|
||||
}
|
||||
|
||||
public void testRemoveChildPolicyFires() throws Exception
|
||||
{
|
||||
ChildAssociationRef pathPrimaryRef = nodeService.createNode(
|
||||
rootNodeRef,
|
||||
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
||||
QName.createQName("parent_child"),
|
||||
ContentModel.TYPE_CONTAINER);
|
||||
NodeRef parentRef = pathPrimaryRef.getParentRef();
|
||||
ChildAssociationRef pathARef = nodeService.createNode(
|
||||
parentRef,
|
||||
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
||||
QName.createQName("patha"),
|
||||
ContentModel.TYPE_CONTAINER);
|
||||
ChildAssociationRef pathBRef = nodeService.addChild(
|
||||
parentRef,
|
||||
pathARef.getChildRef(),
|
||||
ContentModel.ASSOC_ARCHIVED_LINK,
|
||||
QName.createQName("pathb"));
|
||||
ChildAssociationRef pathCRef = nodeService.addChild(
|
||||
parentRef,
|
||||
pathARef.getChildRef(),
|
||||
ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
||||
QName.createQName("pathc"));
|
||||
|
||||
BeforeDeletePolicyTester beforeDeletePolicy = new BeforeDeletePolicyTester();
|
||||
this.policyComponent.bindAssociationBehaviour(
|
||||
NodeServicePolicies.BeforeDeleteChildAssociationPolicy.QNAME,
|
||||
beforeDeletePolicy,
|
||||
new JavaBehaviour(beforeDeletePolicy, "beforeDeleteChildAssociation"));
|
||||
|
||||
boolean removed = nodeService.removeSecondaryChildAssociation(pathBRef);
|
||||
assertTrue("Association was removed", removed);
|
||||
assertEquals("The BeforeDeleteChildAssociationPolicy must fire on removeSecondaryChildAssociation",pathBRef, beforeDeletePolicy.childRef);
|
||||
|
||||
removed = nodeService.removeChildAssociation(pathCRef);
|
||||
assertTrue("Association was removed", removed);
|
||||
assertEquals("The BeforeDeleteChildAssociationPolicy must fire on removeChildAssociation", pathCRef, beforeDeletePolicy.childRef);
|
||||
}
|
||||
|
||||
public void testRemoveChildByRef() throws Exception
|
||||
{
|
||||
@@ -2572,7 +2610,17 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
public static class BeforeDeletePolicyTester implements NodeServicePolicies.BeforeDeleteChildAssociationPolicy
|
||||
{
|
||||
ChildAssociationRef childRef;
|
||||
|
||||
@Override
|
||||
public void beforeDeleteChildAssociation(ChildAssociationRef childAssocRef)
|
||||
{
|
||||
this.childRef = childAssocRef;
|
||||
}
|
||||
}
|
||||
|
||||
public void testMoveNode() throws Exception
|
||||
{
|
||||
Map<QName, ChildAssociationRef> assocRefs = buildNodeGraph();
|
||||
|
Reference in New Issue
Block a user