diff --git a/e2e-test/java/org/alfresco/rest/actions/ActionsTests.java b/e2e-test/java/org/alfresco/rest/actions/ActionsTests.java index 4d87dcfae..f85d9d8ae 100644 --- a/e2e-test/java/org/alfresco/rest/actions/ActionsTests.java +++ b/e2e-test/java/org/alfresco/rest/actions/ActionsTests.java @@ -1,21 +1,40 @@ package org.alfresco.rest.actions; +import static junit.framework.Assert.fail; +import static org.testng.Assert.assertFalse; + +import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.EmptyJsonResponseException; import org.alfresco.rest.model.RestActionDefinitionModel; import org.alfresco.rest.model.RestActionDefinitionModelsCollection; +import org.alfresco.rest.model.RestNodeModel; +import org.alfresco.utility.Utility; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; +import org.json.JSONObject; import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static junit.framework.TestCase.fail; -import static org.testng.Assert.assertFalse; - public class ActionsTests extends RestTest { + private UserModel adminUser; + private FileModel document; + private SiteModel publicSite; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + publicSite = dataSite.createPublicRandomSite(); + document = dataContent.usingSite(publicSite).usingUser(adminUser).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + } + @TestRail(section = { TestGroup.REST_API,TestGroup.ACTIONS }, executionType = ExecutionType.SANITY, description = "Verify actions") @Test(groups = { TestGroup.REST_API, TestGroup.ACTIONS, TestGroup.SANITY}) @@ -64,6 +83,28 @@ public class ActionsTests extends RestTest } } + @TestRail(section = { TestGroup.REST_API,TestGroup.ACTIONS }, executionType = ExecutionType.SANITY, + description = "Sanity test for POST /action-executions") + @Test(groups = { TestGroup.REST_API, TestGroup.ACTIONS, TestGroup.SANITY}) + public void executeAction() throws Exception + { + JSONObject response = restClient.authenticateUser(adminUser).withCoreAPI().usingActions().executeAction("add-features", document, "aspect-name", "cm:versionable"); + restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); + + assertFalse(response.getString("id").isEmpty()); + + /* + * Get all node properties and check that action was executed and + * cm:versionable aspect was added + */ + Utility.sleep(500, 20000, () -> { + RestNodeModel fileModel = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(document).getNode(); + + restClient.assertStatusCodeIs(HttpStatus.OK); + fileModel.assertThat().field("aspectNames").contains("cm:versionable"); + }); + } + @TestRail(section = { TestGroup.REST_API,TestGroup.ACTIONS }, executionType = ExecutionType.SANITY, description = "Sanity test for ACTIONS endpoint GET action-definitions/{actionDefinitionId}") @Test(groups = { TestGroup.REST_API, TestGroup.ACTIONS, TestGroup.SANITY}) @@ -82,5 +123,4 @@ public class ActionsTests extends RestTest restActionDefinition.getDescription().equals("This will add an aspect to the matched item."); restActionDefinition.getTitle().equals("Add aspect"); } - }