use of org.alfresco.repo.action.ActionConditionImpl in project alfresco-repository by Alfresco.
the class HasChildEvaluatorTest method testPass.
public void testPass() {
ActionCondition condition = new ActionConditionImpl(ID, HasChildEvaluator.NAME, null);
// no parameters means match all.
assertTrue(this.evaluator.evaluate(condition, this.parentNodeRef));
// should find child with specific assoc type
condition.setParameterValue(HasChildEvaluator.PARAM_ASSOC_TYPE, ContentModel.ASSOC_CHILDREN);
assertTrue(this.evaluator.evaluate(condition, this.parentNodeRef));
// should find child with specific assoc type (and name)
condition.setParameterValue(HasChildEvaluator.PARAM_ASSOC_NAME, this.parentChildAssocName);
assertTrue(this.evaluator.evaluate(condition, this.parentNodeRef));
// should find child with specific assoc name (no type specified)
condition = new ActionConditionImpl(ID, HasChildEvaluator.NAME, null);
condition.setParameterValue(HasChildEvaluator.PARAM_ASSOC_NAME, this.parentChildAssocName);
assertTrue(this.evaluator.evaluate(condition, this.parentNodeRef));
}
use of org.alfresco.repo.action.ActionConditionImpl in project alfresco-repository by Alfresco.
the class HasChildEvaluatorTest method testFail.
public void testFail() {
ActionCondition condition = new ActionConditionImpl(ID, HasChildEvaluator.NAME, null);
// node has no children
assertFalse(this.evaluator.evaluate(condition, this.childNodeRef));
// node has child of unmatched assoc type
condition.setParameterValue(HasChildEvaluator.PARAM_ASSOC_TYPE, ContentModel.ASSOC_ATTACHMENTS);
assertFalse(this.evaluator.evaluate(condition, this.parentNodeRef));
// node has child of unmatched assoc name
condition = new ActionConditionImpl(ID, HasChildEvaluator.NAME, null);
condition.setParameterValue(HasChildEvaluator.PARAM_ASSOC_NAME, QName.createQName("{foo}noSuchName"));
assertFalse(this.evaluator.evaluate(condition, this.parentNodeRef));
}
use of org.alfresco.repo.action.ActionConditionImpl in project alfresco-repository by Alfresco.
the class IsSubTypeEvaluatorTest method testMandatoryParamsMissing.
@Test
public void testMandatoryParamsMissing() {
ActionCondition condition = new ActionConditionImpl(ID, IsSubTypeEvaluator.NAME, null);
try {
this.evaluator.evaluate(condition, this.nodeRef);
fail("The fact that a mandatory parameter has not been set should have been detected.");
} catch (Throwable exception) {
// Do nothing since this is correct
}
}
use of org.alfresco.repo.action.ActionConditionImpl in project alfresco-repository by Alfresco.
the class CompareMimeTypeEvaluatorTest method testContentPropertyComparisons.
@Test
public void testContentPropertyComparisons() {
ActionConditionImpl condition = new ActionConditionImpl(GUID.generate(), ComparePropertyValueEvaluator.NAME);
// What happens if you do this and the node has no content set yet !!
// Add some content to the node reference
ContentWriter contentWriter = this.contentService.getWriter(this.nodeRef, ContentModel.PROP_CONTENT, true);
contentWriter.setEncoding("UTF-8");
contentWriter.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);
contentWriter.putContent("This is some test content.");
// Test matching the mimetype
condition.setParameterValue(ComparePropertyValueEvaluator.PARAM_VALUE, MimetypeMap.MIMETYPE_TEXT_PLAIN);
assertTrue(this.evaluator.evaluate(condition, this.nodeRef));
condition.setParameterValue(ComparePropertyValueEvaluator.PARAM_VALUE, MimetypeMap.MIMETYPE_HTML);
assertFalse(this.evaluator.evaluate(condition, this.nodeRef));
}
use of org.alfresco.repo.action.ActionConditionImpl in project alfresco-repository by Alfresco.
the class HasAspectEvaluatorTest method testFail.
@Test
public void testFail() {
ActionCondition condition = new ActionConditionImpl(ID, HasAspectEvaluator.NAME, null);
condition.setParameterValue(HasAspectEvaluator.PARAM_ASPECT, ContentModel.ASPECT_VERSIONABLE);
assertFalse(this.evaluator.evaluate(condition, this.nodeRef));
}
Aggregations