Merge branch 'master' into TAS-3192

This commit is contained in:
Valentin Popa
2017-02-07 11:15:14 +02:00
6 changed files with 522 additions and 96 deletions
@@ -547,4 +547,79 @@ public class FunctionalCasesTests extends RestTest
.assertThat().entriesListContains("target.site.id", favoriteSite.getId());
}
/**
* Scenario:
* 1. Regular user adds moderated site membership request
* 2. Site manager approves the request
* 3. Site manager updates the new member role to Manager
* 4. New member adds comment to a file on site
* 5. New member likes and rate one file
* 6. New member adds tags to a file
* 7. New member adds site to favorite
* 8. New member adds, then deletes a site member
*/
@TestRail(section = { TestGroup.REST_API, TestGroup.SITES },
executionType = ExecutionType.REGRESSION,
description = "Check that a user who joins a moderated site as manager is able to comment, rate, tag an existing file from the site, add site to favorites, add and remove site members.")
@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL })
public void checkNewManagerActions() throws Exception
{
UserModel newMember = dataUser.createRandomTestUser();
file = dataContent.usingSite(moderatedSite).usingUser(adminUser).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(moderatedSite);
restClient.assertStatusCodeIs(HttpStatus.CREATED);
RestTaskModel taskModel = restClient.withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite);
workflow.approveSiteMembershipRequest(adminUser.getUsername(), adminUser.getPassword(), taskModel.getId(), true, "Approve");
returnedCollection = restClient.withCoreAPI().usingMe().getSiteMembershipRequests();
restClient.assertStatusCodeIs(HttpStatus.OK);
returnedCollection.assertThat().entriesListDoesNotContain("id", moderatedSite.getId());
newMember.setUserRole(UserRole.SiteManager);
restClient.authenticateUser(adminUser).withCoreAPI().usingSite(moderatedSite).updateSiteMember(newMember)
.assertThat().field("id").is(newMember.getUsername())
.and().field("role").is(newMember.getUserRole());
restClient.assertStatusCodeIs(HttpStatus.OK);
RestCommentModel comment = restClient.authenticateUser(newMember).withCoreAPI().usingResource(file).addComment("new comment");
restClient.assertStatusCodeIs(HttpStatus.CREATED);
comment.assertThat().field("content").is("new comment");
RestRatingModel returnedRatingModel = restClient.withCoreAPI().usingResource(file).likeDocument();
restClient.assertStatusCodeIs(HttpStatus.CREATED);
returnedRatingModel.assertThat().field("myRating").is("true")
.and().field("id").is("likes")
.and().field("aggregate").isNotEmpty();
returnedRatingModel = restClient.withCoreAPI().usingResource(file).rateStarsToDocument(5);
restClient.assertStatusCodeIs(HttpStatus.CREATED);
returnedRatingModel.assertThat().field("myRating").is("5")
.and().field("id").is("fiveStar")
.and().field("aggregate").isNotEmpty();
RestTagModel tag = restClient.withCoreAPI().usingResource(file).addTag("filetag");
restClient.assertStatusCodeIs(HttpStatus.CREATED);
tag.assertThat().field("tag").is("filetag")
.and().field("id").isNotEmpty();
restFavoriteSiteModel = restClient.withCoreAPI().usingAuthUser().addFavoriteSite(moderatedSite);
restClient.assertStatusCodeIs(HttpStatus.CREATED);
restFavoriteSiteModel.assertThat().field("id").is(moderatedSite.getId());
UserModel testUser = dataUser.createRandomTestUser("testUser");
testUser.setUserRole(UserRole.SiteManager);
restClient.withCoreAPI().usingSite(moderatedSite).addPerson(testUser)
.assertThat().field("id").is(testUser.getUsername())
.and().field("role").is(testUser.getUserRole());
restClient.assertStatusCodeIs(HttpStatus.CREATED);
restClient.withCoreAPI().usingSite(moderatedSite).deleteSiteMember(testUser);
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
restClient.withCoreAPI().usingSite(moderatedSite).getSiteMembers()
.assertThat().entriesListDoesNotContain("id", testUser.getUsername());
restClient.assertStatusCodeIs(HttpStatus.OK);
}
}
@@ -49,8 +49,9 @@ public class AddProcessVariableCoreTests extends RestTest
processVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel);
restClient.assertStatusCodeIs(HttpStatus.OK);
processVariable.assertThat().field("name").is(processVariable.getName()).and().field("type").is(processVariable.getType()).and().field("value")
.is(processVariable.getValue());
processVariable.assertThat().field("name").is(processVariable.getName())
.and().field("type").is(processVariable.getType())
.and().field("value").is(processVariable.getValue());
}
@TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION,
@@ -63,10 +64,127 @@ public class AddProcessVariableCoreTests extends RestTest
processVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel);
restClient.assertStatusCodeIs(HttpStatus.OK);
processVariable.assertThat().field("name").is(processVariable.getName()).and().field("type").is(processVariable.getType()).and().field("value")
.is(processVariable.getValue());
processVariable.assertThat().field("name").is(processVariable.getName())
.and().field("type").is(processVariable.getType())
.and().field("value").is(processVariable.getValue());
}
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION,
description = "Adding process variable is falling in case invalid type is provided")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE })
public void failedAddingProcessVariableIfInvalidTypeIsProvided() throws Exception
{
variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:textarea");
processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel();
restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel);
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST)
.assertLastError()
.containsErrorKey(String.format(RestErrorModel.UNSUPPORTED_TYPE, "d:textarea"))
.containsSummary(String.format(RestErrorModel.UNSUPPORTED_TYPE, "d:textarea"))
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER)
.stackTraceIs(RestErrorModel.STACKTRACE);
}
@Bug(id = "REPO-1938")
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION,
description = "Adding process variable is falling in case invalid type prefix is provided")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE })
public void failedAddingProcessVariableIfInvalidTypePrefixIsProvided() throws Exception
{
variableModel = RestProcessVariableModel.getRandomProcessVariableModel("ddt:text");
processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel();
restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel);
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST)
.assertLastError()
.containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY)
.containsSummary(String.format(RestErrorModel.INVALID_NAMEPACE_PREFIX, "ddt"))
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER)
.stackTraceIs(RestErrorModel.STACKTRACE);
}
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION,
description = "Adding process variable is falling in case invalid value is provided")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE })
public void failedAddingProcessVariableIfInvalidValueIsProvided() throws Exception
{
RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:int");
variableModel.setValue("invalidValue");
processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel();
restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel);
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST)
.assertLastError()
.containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY)
.containsSummary(String.format(RestErrorModel.FOR_INPUT_STRING, "invalidValue"))
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER)
.stackTraceIs(RestErrorModel.STACKTRACE);
}
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION,
description = "Adding process variable is falling in case missing required variable body (name) is provided")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE })
public void failedAddingProcessVariableIfMissingRequiredVariableNameBodyIsProvided() throws Exception
{
variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text");
processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel();
RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"value\": \"missingVariableName\",\"type\": \"d:text\"}",
"processes/{processId}/variables/{variableName}", processModel.getId(), variableModel.getName());
restClient.processModel(RestProcessVariableModel.class, request);
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST)
.assertLastError()
.containsErrorKey(RestErrorModel.VARIABLE_NAME_REQUIRED)
.containsSummary(RestErrorModel.VARIABLE_NAME_REQUIRED)
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER)
.stackTraceIs(RestErrorModel.STACKTRACE);
}
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION,
description = "Adding process variable is falling in case invalid variableBody (adding extra parameter in body) is provided")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE })
public void failedAddingProcessVariableIfInvalidBodyIsProvided() throws Exception
{
variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text");
processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel();
RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"scope\": \"local\",\"value\": \"testing\",\"type\": \"d:text\"}",
"processes/{processId}/variables/{variableName}", processModel.getId(), variableModel.getName());
restClient.processModel(RestProcessVariableModel.class, request);
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST)
.assertLastError()
.containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "Unrecognized field \"scope\""))
.containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unrecognized field \"scope\""))
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER)
.stackTraceIs(RestErrorModel.STACKTRACE);
}
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION,
description = "Adding process variable is falling in case empty name is provided")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE })
public void failedAddingProcessVariableIfEmptyNameIsProvided() throws Exception
{
processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal);
RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text");
variableModel.setName("");
processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel();
restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel);
restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED)
.assertLastError()
.containsErrorKey(RestErrorModel.PUT_EMPTY_ARGUMENT)
.containsSummary(RestErrorModel.PUT_EMPTY_ARGUMENT)
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER)
.stackTraceIs(RestErrorModel.STACKTRACE);
}
@TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION,
description = "Add process variable using by admin in other network.")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE, TestGroup.NETWORKS })
@@ -84,93 +202,9 @@ public class AddProcessVariableCoreTests extends RestTest
restClient.authenticateUser(adminTenantUser2);
variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text");
processVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel);
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT);
}
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION,
description = "Adding process variable is falling in case invalid type is provided")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE })
public void failedAddingProcessVariableIfInvalidTypeIsProvided() throws Exception
{
variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:textarea");
processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel();
restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel);
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(
String.format(RestErrorModel.UNSUPPORTED_TYPE, "d:textarea"));
}
@Bug(id = "REPO-1938")
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION,
description = "Adding process variable is falling in case invalid type prefix is provided")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE })
public void failedAddingProcessVariableIfInvalidTypePrefixIsProvided() throws Exception
{
variableModel = RestProcessVariableModel.getRandomProcessVariableModel("ddt:text");
processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel();
restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel);
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Namespace prefix ddt is not mapped to a namespace URI");
}
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION,
description = "Adding process variable is falling in case invalid value is provided")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE })
public void failedAddingProcessVariableIfInvalidValueIsProvided() throws Exception
{
RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:int");
variableModel.setValue("invalidValue");
processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel();
restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel);
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("For input string: \"invalidValue\"");
}
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION,
description = "Adding process variable is falling in case missing required variable body (name) is provided")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE })
public void failedAddingProcessVariableIfMissingRequiredVariableBodyIsProvided() throws Exception
{
processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel();
RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"value\": \"missingVariableName\",\"type\": \"d:text\"}",
"processes/{processId}/variables/{variableName}", processModel.getId(), variableModel.getName());
restClient.processModel(RestProcessVariableModel.class, request);
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Variable name is required.");
}
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION,
description = "Adding process variable is falling in case invalid variableBody (adding extra parameter in body) is provided")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE })
public void failedAddingProcessVariableIfInvalidBodyIsProvided() throws Exception
{
processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel();
RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"scope\": \"local\",\"value\": \"testing\",\"type\": \"d:text\"}",
"processes/{processId}/variables/{variableName}", processModel.getId(), variableModel.getName());
restClient.processModel(RestProcessVariableModel.class, request);
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError()
.containsSummary("Could not read content from HTTP request body: Unrecognized field \"scope\"");
}
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION,
description = "Adding process variable is falling in case empty name is provided")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE })
public void failedAddingProcessVariableIfEmptyNameIsProvided() throws Exception
{
processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal);
RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text");
variableModel.setName("");
processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel();
restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel);
restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.PUT_EMPTY_ARGUMENT);
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN)
.assertLastError()
.containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT);
}
}
@@ -0,0 +1,201 @@
package org.alfresco.rest.workflow.processes;
import org.alfresco.dataprep.CMISUtil.DocumentType;
import org.alfresco.rest.RestTest;
import org.alfresco.rest.core.RestRequest;
import org.alfresco.rest.model.RestErrorModel;
import org.alfresco.rest.model.RestProcessModel;
import org.alfresco.rest.model.RestProcessVariableModel;
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.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class AddProcessVariableFullTests extends RestTest
{
private FileModel document;
private SiteModel siteModel;
private UserModel userWhoStartsProcess, assignee, adminUser;
private RestProcessModel processModel;
private RestProcessVariableModel variableModel, processVariable, updatedProcessVariable;
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
adminUser = dataUser.getAdminUser();
userWhoStartsProcess = dataUser.createRandomTestUser();
assignee = dataUser.createRandomTestUser();
siteModel = dataSite.usingUser(userWhoStartsProcess).createPublicRandomSite();
document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN);
dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee);
}
@TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION,
description = "Verify addProcessVariable by any user for invalid processID with REST API and status code is NOT_FOUND (404)")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL })
public void addProcessVariableWithInvalidProcessId() throws Exception
{
variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text");
processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel();
processModel.setId("invalidProcessID");
processVariable = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(processModel)
.updateProcessVariable(variableModel);
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND)
.assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidProcessID"));
}
@TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION,
description = "Verify addProcessVariable by any user for empty processID with REST API and status code is NOT_FOUND (404)")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL })
public void addProcessVariableWithEmptyProcessId() throws Exception
{
variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text");
processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel();
processModel.setId("");
processVariable = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(processModel)
.updateProcessVariable(variableModel);
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND)
.assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, ""));
}
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION,
description = "Adding process variable is falling in case of empty value is provided")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL })
public void failedAddingProcessVariableIfEmptyValueIsProvided() throws Exception
{
variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:int");
variableModel.setValue("");
processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel();
restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel);
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST)
.assertLastError()
.containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY)
.containsSummary(String.format(RestErrorModel.FOR_INPUT_STRING, ""))
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER)
.stackTraceIs(RestErrorModel.STACKTRACE);
}
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION,
description = "Adding process variable in case of having only 'name' field is provided")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL })
public void addingProcessVariableWithOnlyNameProvided() throws Exception
{
processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel();
RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"name\": \"variableName\"}",
"processes/{processId}/variables/{variableName}", processModel.getId(), "variableName");
processVariable = restClient.processModel(RestProcessVariableModel.class, request);
restClient.assertStatusCodeIs(HttpStatus.OK);
processVariable.assertThat().field("name").is("variableName")
.and().field("type").is("d:any")
.and().field("value").isNull();
}
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION,
description = "Adding process variable in case of missing type field is provided")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL })
public void addingProcessVariableIfMissingValueIsProvided() throws Exception
{
processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel();
RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"name\": \"variableName\", \"type\": \"d:text\"}",
"processes/{processId}/variables/{variableName}", processModel.getId(), "variableName");
processVariable = restClient.processModel(RestProcessVariableModel.class, request);
restClient.assertStatusCodeIs(HttpStatus.OK);
processVariable.assertThat().field("name").is("variableName")
.and().field("type").is("d:text")
.and().field("value").isNull();
}
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION,
description = "Adding process variable in case of missing type field is provided")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL })
public void addingProcessVariableIfMissingTypeIsProvided() throws Exception
{
processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel();
RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"value\": \"variableValue\", \"name\": \"variableName\"}",
"processes/{processId}/variables/{variableName}", processModel.getId(), "variableValue");
processVariable = restClient.processModel(RestProcessVariableModel.class, request);
restClient.assertStatusCodeIs(HttpStatus.OK);
processVariable.assertThat().field("name").is("variableName")
.and().field("type").is("d:text")
.and().field("value").is("variableValue");
}
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION,
description = "Adding process variable is case of empty type value is provided")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL })
public void addingProcessVariableIfEmptyTypeIsProvided() throws Exception
{
variableModel = RestProcessVariableModel.getRandomProcessVariableModel("");
processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel();
processVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel);
restClient.assertStatusCodeIs(HttpStatus.OK);
processVariable.assertThat().field("name").is(processVariable.getName())
.and().field("type").is("d:text")
.and().field("value").is(processVariable.getValue());
}
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION,
description = "Adding process variable in case of empty body field is provided")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL })
public void addingProcessVariableWithEmptyBodyProvided() throws Exception
{
variableModel = RestProcessVariableModel.getRandomProcessVariableModel("");
processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel();
RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{ }",
"processes/{processId}/variables/{variableName}", processModel.getId(), variableModel.getName());
processVariable = restClient.processModel(RestProcessVariableModel.class, request);
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST)
.assertLastError()
.containsErrorKey(RestErrorModel.VARIABLE_NAME_REQUIRED)
.containsSummary(RestErrorModel.VARIABLE_NAME_REQUIRED)
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER)
.stackTraceIs(RestErrorModel.STACKTRACE);
}
@TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION,
description = "Update twice in a row the same variable.")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL })
public void updateTwiceInARowSameProcessVariable() throws Exception
{
variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text");
processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel();
processVariable = restClient.withWorkflowAPI().usingProcess(processModel)
.updateProcessVariable(variableModel);
restClient.assertStatusCodeIs(HttpStatus.OK);
processVariable.assertThat().field("name").is(variableModel.getName())
.and().field("type").is(variableModel.getType())
.and().field("value").is(variableModel.getValue());
restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables()
.assertThat().entriesListContains("name", processVariable.getName());
updatedProcessVariable = restClient.withWorkflowAPI().usingProcess(processModel)
.updateProcessVariable(variableModel);
restClient.assertStatusCodeIs(HttpStatus.OK);
updatedProcessVariable.assertThat().field("name").is(variableModel.getName())
.and().field("type").is(variableModel.getType())
.and().field("value").is(variableModel.getValue());
restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables()
.assertThat().entriesListContains("name", variableModel.getName());
}
}
@@ -3,6 +3,7 @@ package org.alfresco.rest.workflow.processes;
import org.alfresco.dataprep.CMISUtil.DocumentType;
import org.alfresco.dataprep.CMISUtil.Priority;
import org.alfresco.rest.RestTest;
import org.alfresco.rest.model.RestErrorModel;
import org.alfresco.rest.model.RestProcessModel;
import org.alfresco.rest.model.RestProcessVariableModel;
import org.alfresco.utility.data.RandomData;
@@ -89,6 +90,7 @@ public class AddProcessVariableSanityTests extends RestTest
restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, Priority.Normal);
variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text");
processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel();
processVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel);
restClient.assertStatusCodeIs(HttpStatus.OK);
processVariable.assertThat().field("name").is(variableModel.getName())
@@ -103,8 +105,13 @@ public class AddProcessVariableSanityTests extends RestTest
{
variableModel = RestProcessVariableModel.getRandomProcessVariableModel("incorrect type");
processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel();
restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel);
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST)
.assertLastError().containsSummary("Unsupported type of variable: 'incorrect type'.");
.assertLastError()
.containsErrorKey(String.format(RestErrorModel.UNSUPPORTED_TYPE, "incorrect type"))
.containsSummary(String.format(RestErrorModel.UNSUPPORTED_TYPE, "incorrect type"))
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER)
.stackTraceIs(RestErrorModel.STACKTRACE);
}
}
@@ -114,11 +114,23 @@ public class GetProcessesFullTests extends RestTest
RestProcessModelsCollection processes = restClient.authenticateUser(userWhoStartsTask).withParams("properties=id")
.withWorkflowAPI().getProcesses();
restClient.assertStatusCodeIs(HttpStatus.OK);
processes.assertThat().entriesListIsNotEmpty();
List<RestProcessModel> processesList = processes.getEntries();
processesList.get(0).onModel().assertThat().fieldsCount().is(1).and().field("id").is(process3.getId());
processesList.get(1).onModel().assertThat().fieldsCount().is(1).and().field("id").is(task2.getProcessId());
processesList.get(2).onModel().assertThat().fieldsCount().is(1).and().field("id").is(task1.getProcessId());
processesList.get(0).onModel().assertThat().fieldsCount().is(1)
.and().field("id").isNotEmpty()
.and().field("processDefinitionId").isNull()
.and().field("startUserId").isNull();
processesList.get(1).onModel().assertThat().fieldsCount().is(1)
.and().field("id").isNotEmpty()
.and().field("processDefinitionId").isNull()
.and().field("startUserId").isNull();
processesList.get(2).onModel().assertThat().fieldsCount().is(1)
.and().field("id").isNotEmpty()
.and().field("processDefinitionId").isNull()
.and().field("startUserId").isNull();
processes.assertThat().entriesListIsNotEmpty()
.and().entriesListContains("id", process3.getId())
.and().entriesListContains("id", task2.getProcessId())
.and().entriesListContains("id", task1.getProcessId());
}
@Bug(id = "REPO-1958")
@@ -0,0 +1,97 @@
package org.alfresco.rest.workflow.tasks;
import org.alfresco.dataprep.CMISUtil.DocumentType;
import org.alfresco.rest.RestTest;
import org.alfresco.rest.model.RestErrorModel;
import org.alfresco.rest.model.RestItemModel;
import org.alfresco.utility.model.FileModel;
import org.alfresco.utility.model.SiteModel;
import org.alfresco.utility.model.TaskModel;
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.springframework.http.HttpStatus;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
/**
* @author bogdan.bocancea
*/
public class RemoveTaskItemFullTests extends RestTest
{
private UserModel userWhoStartsTask, assigneeUser;
private SiteModel siteModel;
private FileModel fileModel, document2;
private TaskModel taskModel;
private RestItemModel taskItem;
@BeforeClass(alwaysRun=true)
public void dataPreparation() throws Exception
{
userWhoStartsTask = dataUser.createRandomTestUser();
siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite();
fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN);
assigneeUser = dataUser.createRandomTestUser();
}
@TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION,
description = "Delete task item twice")
@Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL })
public void deleteTaskItemTwice() throws Exception
{
taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser);
restClient.authenticateUser(userWhoStartsTask);
document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML);
taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2);
restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem);
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem);
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND)
.assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, ""))
.containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY)
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER)
.stackTraceIs(RestErrorModel.STACKTRACE);
}
@TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION,
description = "Delete task item with locked document")
@Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL })
public void deleteTaskItemWithLockedDocument() throws Exception
{
taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser);
restClient.authenticateUser(userWhoStartsTask);
document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML);
taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2);
dataContent.usingUser(userWhoStartsTask).usingResource(document2).checkOutDocument();
restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem);
restClient.assertStatusCodeIs(HttpStatus.CONFLICT)
.assertLastError().containsSummary(String.format(RestErrorModel.LOCKED_NODE_OPERATION, document2.getNodeRefWithoutVersion()))
.containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY)
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER)
.stackTraceIs(RestErrorModel.STACKTRACE);
}
@TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION,
description = "Delete task item with deleted document")
@Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL })
public void deleteTaskItemWithDeletedDocument() throws Exception
{
taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser);
restClient.authenticateUser(userWhoStartsTask);
document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML);
taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2);
dataContent.usingUser(userWhoStartsTask).usingResource(document2).deleteContent();
restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem);
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND)
.assertLastError().containsSummary(String.format(RestErrorModel.PROCESS_ENTITY_NOT_FOUND, document2.getNodeRefWithoutVersion()))
.containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY)
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER)
.stackTraceIs(RestErrorModel.STACKTRACE);
}
}