Search in sources :

Example 11 with ActionConditionImpl

use of org.alfresco.repo.action.ActionConditionImpl in project alfresco-repository by Alfresco.

the class HasAspectEvaluatorTest method testPass.

@Test
public void testPass() {
    this.nodeService.addAspect(this.nodeRef, ContentModel.ASPECT_VERSIONABLE, null);
    ActionCondition condition = new ActionConditionImpl(ID, HasAspectEvaluator.NAME, null);
    condition.setParameterValue(HasAspectEvaluator.PARAM_ASPECT, ContentModel.ASPECT_VERSIONABLE);
    assertTrue(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)

Example 12 with ActionConditionImpl

use of org.alfresco.repo.action.ActionConditionImpl in project alfresco-repository by Alfresco.

the class HasTagEvaluatorTest method testPass.

public void testPass() {
    taggingService.addTag(nodeRef, "testTag");
    ActionCondition condition = new ActionConditionImpl(ID, HasTagEvaluator.NAME, null);
    condition.setParameterValue(HasTagEvaluator.PARAM_TAG, "testTag");
    boolean value = this.evaluator.evaluate(condition, this.nodeRef);
    assertTrue("Tag should have been set", value);
}
Also used : ActionConditionImpl(org.alfresco.repo.action.ActionConditionImpl) ActionCondition(org.alfresco.service.cmr.action.ActionCondition)

Example 13 with ActionConditionImpl

use of org.alfresco.repo.action.ActionConditionImpl in project alfresco-repository by Alfresco.

the class HasTagEvaluatorTest method testFail.

public void testFail() {
    ActionCondition condition = new ActionConditionImpl(ID, HasTagEvaluator.NAME, null);
    condition.setParameterValue(HasTagEvaluator.PARAM_TAG, "testTag");
    boolean value = this.evaluator.evaluate(condition, this.nodeRef);
    assertFalse(value);
}
Also used : ActionConditionImpl(org.alfresco.repo.action.ActionConditionImpl) ActionCondition(org.alfresco.service.cmr.action.ActionCondition)

Example 14 with ActionConditionImpl

use of org.alfresco.repo.action.ActionConditionImpl in project alfresco-repository by Alfresco.

the class NodeEligibleForRethumbnailingEvaluatorTest method testNodeWithNoFailedThumbnails.

@SuppressWarnings("deprecation")
@Test
public void testNodeWithNoFailedThumbnails() {
    // Such a node is always eligible for thumbnailing.
    ActionCondition condition = new ActionConditionImpl(GUID.generate(), NodeEligibleForRethumbnailingEvaluator.NAME);
    condition.setParameterValue(NodeEligibleForRethumbnailingEvaluator.PARAM_THUMBNAIL_DEFINITION_NAME, thumbnailDef1.getLocalName());
    // Offset values don't matter here.
    condition.setParameterValue(NodeEligibleForRethumbnailingEvaluator.PARAM_RETRY_PERIOD, 0L);
    condition.setParameterValue(NodeEligibleForRethumbnailingEvaluator.PARAM_RETRY_COUNT, failureHandlingOptions.getRetryCount());
    condition.setParameterValue(NodeEligibleForRethumbnailingEvaluator.PARAM_QUIET_PERIOD, 0L);
    condition.setParameterValue(NodeEligibleForRethumbnailingEvaluator.PARAM_QUIET_PERIOD_RETRIES_ENABLED, true);
    NodeEligibleForRethumbnailingEvaluator evaluator = (NodeEligibleForRethumbnailingEvaluator) this.applicationContext.getBean(NodeEligibleForRethumbnailingEvaluator.NAME);
    assertTrue(evaluator.evaluate(condition, newUnthumbnailedNodeRef));
}
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 15 with ActionConditionImpl

use of org.alfresco.repo.action.ActionConditionImpl in project alfresco-remote-api by Alfresco.

the class RulePut method updateActionConditionFromJson.

protected ActionCondition updateActionConditionFromJson(JSONObject jsonCondition, ActionConditionImpl conditionToUpdate) throws JSONException {
    ActionConditionImpl result = null;
    if (jsonCondition.has("id")) {
        // update exiting object
        result = conditionToUpdate;
    } else {
        // create new onject as id was not sent
        result = parseJsonActionCondition(jsonCondition);
        return result;
    }
    if (jsonCondition.has("invertCondition")) {
        result.setInvertCondition(jsonCondition.getBoolean("invertCondition"));
    }
    if (jsonCondition.has("parameterValues")) {
        JSONObject jsonParameterValues = jsonCondition.getJSONObject("parameterValues");
        result.setParameterValues(parseJsonParameterValues(jsonParameterValues, result.getActionConditionDefinitionName(), false));
    }
    return result;
}
Also used : JSONObject(org.json.JSONObject) ActionConditionImpl(org.alfresco.repo.action.ActionConditionImpl)

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