mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
ACS-3225 Get rules REST tests. (#1228)
* ACS-3225 REST tests for getting one or more rules. * ACS-3225 Update TAS REST API. * ACS-3225 [tas] Include new REST tests.
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
package org.alfresco.rest.rules;
|
||||
|
||||
import static org.alfresco.utility.report.log.Step.STEP;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.springframework.http.HttpStatus.NOT_FOUND;
|
||||
import static org.springframework.http.HttpStatus.OK;
|
||||
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.model.RestRuleModelsCollection;
|
||||
import org.alfresco.utility.model.FolderModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* Tests for GET /nodes/{nodeId}/rule-sets/{ruleSetId}/rules and GET /nodes/{nodeId}/rule-sets/{ruleSetId}/rules/{ruleId}.
|
||||
*/
|
||||
@Test(groups = {TestGroup.RULES})
|
||||
public class GetRulesTests extends RestTest
|
||||
{
|
||||
private UserModel user;
|
||||
private SiteModel site;
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void dataPreparation()
|
||||
{
|
||||
user = dataUser.createRandomTestUser();
|
||||
site = dataSite.usingUser(user).createPublicRandomSite();
|
||||
}
|
||||
|
||||
/** Check we can get an empty list of rules. */
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RULES, TestGroup.SANITY })
|
||||
public void getEmptyRulesList()
|
||||
{
|
||||
STEP("Create a folder in existing site");
|
||||
FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder();
|
||||
|
||||
STEP("Get the rules that apply to the folder");
|
||||
RestRuleModelsCollection rules = restClient.authenticateUser(user).withCoreAPI().usingNode(folder).usingDefaultRuleSet().getListOfRules();
|
||||
|
||||
restClient.assertStatusCodeIs(OK);
|
||||
assertTrue("Expected no rules to be present.", rules.isEmpty());
|
||||
}
|
||||
|
||||
/** Check we get a 404 if trying to load rules for a folder that doesn't exist. */
|
||||
@Test (groups = { TestGroup.REST_API, TestGroup.RULES })
|
||||
public void getRulesForNonExistentFolder()
|
||||
{
|
||||
STEP("Try to load rules for a non-existent folder.");
|
||||
FolderModel nonExistentFolder = FolderModel.getRandomFolderModel();
|
||||
nonExistentFolder.setNodeRef("fake-id");
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(nonExistentFolder).usingDefaultRuleSet().getListOfRules();
|
||||
restClient.assertStatusCodeIs(NOT_FOUND);
|
||||
}
|
||||
|
||||
/** Check we get a 404 if trying to load rules with a rule set id that doesn't exist. */
|
||||
@Test (groups = { TestGroup.REST_API, TestGroup.RULES })
|
||||
public void getRulesFromNonExistentRuleSet()
|
||||
{
|
||||
STEP("Create a folder in existing site");
|
||||
FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder();
|
||||
STEP("Try to load rules for a non-existent rule set.");
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(folder).usingRuleSet("fake-id").getListOfRules();
|
||||
restClient.assertStatusCodeIs(NOT_FOUND);
|
||||
}
|
||||
|
||||
/** Check we get a 404 if trying to load a rule from a folder that doesn't exist. */
|
||||
@Test (groups = { TestGroup.REST_API, TestGroup.RULES })
|
||||
public void getSingleRuleFromNonExistentFolder()
|
||||
{
|
||||
STEP("Try to load a rule from a non-existent folder.");
|
||||
FolderModel nonExistentFolder = FolderModel.getRandomFolderModel();
|
||||
nonExistentFolder.setNodeRef("fake-id");
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(nonExistentFolder).usingDefaultRuleSet().getSingleRule("fake-rule-id");
|
||||
restClient.assertStatusCodeIs(NOT_FOUND);
|
||||
}
|
||||
|
||||
/** Check we get a 404 if trying to load a rule with a rule set id that doesn't exist. */
|
||||
@Test (groups = { TestGroup.REST_API, TestGroup.RULES })
|
||||
public void getSingleRuleFromNonExistentRuleSet()
|
||||
{
|
||||
STEP("Create a folder in existing site");
|
||||
FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder();
|
||||
STEP("Try to load rules for a non-existent rule set.");
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(folder).usingRuleSet("fake-id").getSingleRule("fake-rule-id");
|
||||
restClient.assertStatusCodeIs(NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
@@ -1,11 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
|
||||
<suite name="REST API tests part1" preserve-order="true">
|
||||
<listeners>
|
||||
<listeners>
|
||||
<listener class-name="org.alfresco.utility.report.HtmlReportListener"/>
|
||||
<listener class-name="org.alfresco.utility.testrail.TestRailExecutorListener"/>
|
||||
<listener class-name="org.alfresco.utility.testng.OSTestMethodSelector"/>
|
||||
</listeners>
|
||||
</listeners>
|
||||
|
||||
<test name="Part1">
|
||||
<packages>
|
||||
@@ -14,6 +14,7 @@
|
||||
<package name="org.alfresco.rest.comments.*"/>
|
||||
<package name="org.alfresco.rest.downloads.*"/>
|
||||
<package name="org.alfresco.rest.favorites.*"/>
|
||||
<package name="org.alfresco.rest.rules.*" />
|
||||
<package name="org.alfresco.rest.servlet.*"/>
|
||||
</packages>
|
||||
</test>
|
||||
|
2
pom.xml
2
pom.xml
@@ -120,7 +120,7 @@
|
||||
<dependency.mariadb.version>2.7.4</dependency.mariadb.version>
|
||||
<dependency.tas-utility.version>3.0.49</dependency.tas-utility.version>
|
||||
<dependency.rest-assured.version>3.3.0</dependency.rest-assured.version>
|
||||
<dependency.tas-restapi.version>1.90</dependency.tas-restapi.version>
|
||||
<dependency.tas-restapi.version>1.93</dependency.tas-restapi.version>
|
||||
<dependency.tas-cmis.version>1.31</dependency.tas-cmis.version>
|
||||
<dependency.tas-email.version>1.8</dependency.tas-email.version>
|
||||
<dependency.tas-webdav.version>1.6</dependency.tas-webdav.version>
|
||||
|
Reference in New Issue
Block a user