REPO-1309 - Execute an action asynchronously:

This commit is contained in:
Andrei Forascu
2018-01-23 13:10:45 +00:00
parent 106804933f
commit 5e67dc9f32
@@ -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");
}
}