Search in sources :

Example 6 with ActionConditionImpl

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));
}
Also used : ActionConditionImpl(org.alfresco.repo.action.ActionConditionImpl) ActionCondition(org.alfresco.service.cmr.action.ActionCondition)

Example 7 with ActionConditionImpl

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));
}
Also used : ActionConditionImpl(org.alfresco.repo.action.ActionConditionImpl) ActionCondition(org.alfresco.service.cmr.action.ActionCondition)

Example 8 with ActionConditionImpl

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
    }
}
Also used : ActionConditionImpl(org.alfresco.repo.action.ActionConditionImpl) ActionCondition(org.alfresco.service.cmr.action.ActionCondition) BaseSpringTest(org.alfresco.util.BaseSpringTest) Test(org.junit.Test)

Example 9 with ActionConditionImpl

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));
}
Also used : ContentWriter(org.alfresco.service.cmr.repository.ContentWriter) ActionConditionImpl(org.alfresco.repo.action.ActionConditionImpl) BaseSpringTest(org.alfresco.util.BaseSpringTest) Test(org.junit.Test)

Example 10 with ActionConditionImpl

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));
}
Also used : ActionConditionImpl(org.alfresco.repo.action.ActionConditionImpl) ActionCondition(org.alfresco.service.cmr.action.ActionCondition) BaseSpringTest(org.alfresco.util.BaseSpringTest) Test(org.junit.Test)

Aggregations

ActionConditionImpl (org.alfresco.repo.action.ActionConditionImpl)22 BaseSpringTest (org.alfresco.util.BaseSpringTest)16 Test (org.junit.Test)16 ActionCondition (org.alfresco.service.cmr.action.ActionCondition)12 ActionServiceException (org.alfresco.service.cmr.action.ActionServiceException)4 Date (java.util.Date)2 ContentWriter (org.alfresco.service.cmr.repository.ContentWriter)2 JSONObject (org.json.JSONObject)2 NodeRef (org.alfresco.service.cmr.repository.NodeRef)1 FailedThumbnailInfo (org.alfresco.service.cmr.thumbnail.FailedThumbnailInfo)1