mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
ACS-3427: Add GET e2es for actions and conditions (#1451)
* ACS-3427: Add GET e2es for actions and conditions * ACS-3427: Remove unnecessary cast
This commit is contained in:
committed by
GitHub
parent
c8cf52baef
commit
8776109582
@@ -363,25 +363,13 @@ public class CreateRulesTests extends RestTest
|
||||
@Test(groups = {TestGroup.REST_API, TestGroup.RULES})
|
||||
public void createRuleWithActions()
|
||||
{
|
||||
final Map<String, Serializable> copyParams =
|
||||
Map.of("destination-folder", "dummy-folder-node", "deep-copy", true);
|
||||
final RestActionBodyExecTemplateModel copyAction = createCustomActionModel("copy", copyParams);
|
||||
final Map<String, Serializable> checkOutParams =
|
||||
Map.of("destination-folder", "dummy-folder-node", "assoc-name", "cm:checkout", "assoc-type",
|
||||
"cm:contains");
|
||||
final RestActionBodyExecTemplateModel checkOutAction = createCustomActionModel("check-out", checkOutParams);
|
||||
final Map<String, Serializable> scriptParams = Map.of("script-ref", "dummy-script-node-id");
|
||||
final RestActionBodyExecTemplateModel scriptAction = createCustomActionModel("script", scriptParams);
|
||||
final RestRuleModel ruleModel = createRuleModelWithDefaultValues();
|
||||
ruleModel.setActions(Arrays.asList(copyAction, checkOutAction, scriptAction));
|
||||
|
||||
final UserModel admin = dataUser.getAdminUser();
|
||||
|
||||
final RestRuleModel rule = restClient.authenticateUser(admin).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.createSingleRule(ruleModel);
|
||||
.createSingleRule(createVariousActions());
|
||||
|
||||
final RestRuleModel expectedRuleModel = createRuleModelWithDefaultValues();
|
||||
expectedRuleModel.setActions(Arrays.asList(copyAction, checkOutAction, scriptAction));
|
||||
RestRuleModel expectedRuleModel = createRuleModelWithDefaultValues();
|
||||
expectedRuleModel.setActions(createVariousActions().getActions());
|
||||
expectedRuleModel.setTriggers(List.of("inbound"));
|
||||
|
||||
restClient.assertStatusCodeIs(CREATED);
|
||||
|
@@ -63,6 +63,8 @@ public class GetRulesTests extends RestTest
|
||||
private RestRuleModel createdRuleA;
|
||||
private static final String IGNORE_ID = "id";
|
||||
private static final String IGNORE_IS_SHARED = "isShared";
|
||||
private static final String ACTIONS = "actions";
|
||||
private static final String CONDITIONS = "conditions";
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void dataPreparation()
|
||||
@@ -305,4 +307,56 @@ public class GetRulesTests extends RestTest
|
||||
restClient.assertStatusCodeIs(OK);
|
||||
rules.assertThat().entriesListContains("name", "Private site rule");
|
||||
}
|
||||
|
||||
/**
|
||||
* Check we can GET Rule's actions.
|
||||
*/
|
||||
@Test(groups = {TestGroup.REST_API, TestGroup.RULES})
|
||||
public void getRuleActions()
|
||||
{
|
||||
STEP("Create a rule with a few actions");
|
||||
FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder();
|
||||
final RestRuleModel rule = restClient.authenticateUser(user).withCoreAPI().usingNode(folder).usingDefaultRuleSet()
|
||||
.createSingleRule(createVariousActions());
|
||||
|
||||
STEP("Retrieve the created rule via the GET endpoint");
|
||||
final RestRuleModel getRuleBody = restClient.authenticateUser(user).withCoreAPI().usingNode(folder).usingDefaultRuleSet().getSingleRule(rule.getId());
|
||||
|
||||
STEP("Assert that actions are returned as expected from the GET endpoint");
|
||||
restClient.assertStatusCodeIs(OK);
|
||||
getRuleBody.assertThat().field(ACTIONS).contains("actionDefinitionId=copy")
|
||||
.assertThat().field(ACTIONS).contains("destination-folder=dummy-folder-node")
|
||||
.assertThat().field(ACTIONS).contains("deep-copy=true")
|
||||
.assertThat().field(ACTIONS).contains("actionDefinitionId=check-out")
|
||||
.assertThat().field(ACTIONS).contains("destination-folder=fake-folder-node")
|
||||
.assertThat().field(ACTIONS).contains("assoc-name=cm:checkout");
|
||||
}
|
||||
|
||||
/**
|
||||
* Check we can GET rule's conditions.
|
||||
*/
|
||||
@Test(groups = {TestGroup.REST_API, TestGroup.RULES})
|
||||
public void getRulesConditions()
|
||||
{
|
||||
STEP("Create a rule with several conditions");
|
||||
RestRuleModel ruleModel = createRuleModelWithDefaultValues();
|
||||
ruleModel.setConditions(createVariousConditions());
|
||||
|
||||
FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder();
|
||||
|
||||
RestRuleModel rule = restClient.authenticateUser(user).withCoreAPI().usingNode(folder).usingDefaultRuleSet()
|
||||
.createSingleRule(ruleModel);
|
||||
|
||||
STEP("Retrieve the created rule via the GET endpoint");
|
||||
final RestRuleModel getRuleBody = restClient.authenticateUser(user).withCoreAPI().usingNode(folder).usingDefaultRuleSet().getSingleRule(rule.getId());
|
||||
|
||||
STEP("Assert that conditions are retrieved using the GET endpoint");
|
||||
restClient.assertStatusCodeIs(OK);
|
||||
getRuleBody.assertThat().field(CONDITIONS).contains("comparator=ends")
|
||||
.assertThat().field(CONDITIONS).contains("field=cm:creator")
|
||||
.assertThat().field(CONDITIONS).contains("parameter=ski")
|
||||
.assertThat().field(CONDITIONS).contains("comparator=begins")
|
||||
.assertThat().field(CONDITIONS).contains("field=cm:modelVersion")
|
||||
.assertThat().field(CONDITIONS).contains("parameter=1.");
|
||||
}
|
||||
}
|
||||
|
@@ -26,6 +26,7 @@
|
||||
package org.alfresco.rest.rules;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -144,6 +145,23 @@ public class RulesTestsUtils
|
||||
));
|
||||
}
|
||||
|
||||
public static RestRuleModel createVariousActions()
|
||||
{
|
||||
final Map<String, Serializable> copyParams =
|
||||
Map.of("destination-folder", "dummy-folder-node", "deep-copy", true);
|
||||
final RestActionBodyExecTemplateModel copyAction = createCustomActionModel("copy", copyParams);
|
||||
final Map<String, Serializable> checkOutParams =
|
||||
Map.of("destination-folder", "fake-folder-node", "assoc-name", "cm:checkout", "assoc-type",
|
||||
"cm:contains");
|
||||
final RestActionBodyExecTemplateModel checkOutAction = createCustomActionModel("check-out", checkOutParams);
|
||||
final Map<String, Serializable> scriptParams = Map.of("script-ref", "dummy-script-node-id");
|
||||
final RestActionBodyExecTemplateModel scriptAction = createCustomActionModel("script", scriptParams);
|
||||
final RestRuleModel ruleModel = createRuleModelWithDefaultValues();
|
||||
ruleModel.setActions(Arrays.asList(copyAction, checkOutAction, scriptAction));
|
||||
|
||||
return ruleModel;
|
||||
}
|
||||
|
||||
public static RestSimpleConditionDefinitionModel createSimpleCondition(String field, String comparator, String parameter)
|
||||
{
|
||||
RestSimpleConditionDefinitionModel simpleCondition = new RestSimpleConditionDefinitionModel();
|
||||
|
Reference in New Issue
Block a user