test- added AddTaskItemFullTests.java

test - added test cases using multiple items/variables
This commit is contained in:
mionescu
2017-02-08 15:37:51 +02:00
parent d687f9af6f
commit 8e2618bcd0
10 changed files with 682 additions and 23 deletions
@@ -99,6 +99,22 @@ public class AddProcessItemCoreTests extends RestTest
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError()
.containsSummary(String.format(RestErrorModel.ACCESS_INFORMATION_NOT_ALLOWED, processModel.getId()));
}
@TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION,
description = "Add multiple process item by a random user.")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE })
public void addMultipleProcessItemByAnyUser() throws Exception
{
anotherUser = dataUser.createRandomTestUser();
document2 = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN);
processModel = restClient.authenticateUser(adminUser).withParams("maxItems=1").withWorkflowAPI().getProcesses().getOneRandomEntry().onModel();
processItems = restClient.authenticateUser(anotherUser).withWorkflowAPI().usingProcess(processModel)
.addProcessItems(document2, document);
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError()
.containsSummary(String.format(RestErrorModel.ACCESS_INFORMATION_NOT_ALLOWED, processModel.getId()));
}
@TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION,
description = "Add process item using by the admin in same network.")
@@ -42,7 +42,7 @@ public class AddProcessItemFullTests extends RestTest
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION,
description = "Adding multiple process items is falling in case of empty process id is provided")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL })
public void failedAddingMultipleProcessItemsIfInvalidProcessIdIsProvided() throws Exception
public void failedAddingMultipleProcessItemsIfEmptyProcessIdIsProvided() throws Exception
{
processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel();
FileModel testDocument = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN);
@@ -53,6 +53,20 @@ public class AddProcessItemFullTests extends RestTest
.containsSummary(String.format(RestErrorModel.ENTITY_WAS_NOT_FOUND, ""));
}
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION,
description = "Adding process items is falling in case of empty process id is provided")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL })
public void failedAddingProcessItemsIfEmptyProcessIdIsProvided() throws Exception
{
processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel();
FileModel testDocument = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN);
processModel.setId("");
processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(testDocument);
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError()
.containsSummary(String.format(RestErrorModel.ENTITY_WAS_NOT_FOUND, ""));
}
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION,
description = "Adding process item is falling in case of empty body item value is provided")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL })
@@ -4,6 +4,7 @@ import org.alfresco.dataprep.CMISUtil.DocumentType;
import org.alfresco.rest.RestTest;
import org.alfresco.rest.exception.JsonToModelConversionException;
import org.alfresco.rest.model.RestItemModel;
import org.alfresco.rest.model.RestItemModelsCollection;
import org.alfresco.rest.model.RestProcessModel;
import org.alfresco.utility.model.FileModel;
import org.alfresco.utility.model.FileType;
@@ -27,6 +28,7 @@ public class AddProcessItemSanityTests extends RestTest
private UserModel userWhoStartsTask, assignee, adminUser;
private RestProcessModel processModel;
private RestItemModel processItem;
private RestItemModelsCollection processItems;
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
@@ -62,6 +64,45 @@ public class AddProcessItemSanityTests extends RestTest
restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems()
.assertThat().entriesListContains("id", processItem.getId());
}
@TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY,
description = "Create non-existing process item")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY})
public void addMultipleProcessItem() throws JsonToModelConversionException, Exception
{
document2 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file content");
dataContent.usingSite(siteModel).createContent(document2);
document = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file content");
dataContent.usingSite(siteModel).createContent(document);
processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel();
processItems = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItems(document2, document);
restClient.assertStatusCodeIs(HttpStatus.CREATED);
processItems.getEntries().get(0).onModel()
.assertThat().field("createdAt").isNotEmpty()
.and().field("size").is(document2.getContent().length())
.and().field("createdBy").is(adminUser.getUsername())
.and().field("modifiedAt").isNotEmpty()
.and().field("name").is(document2.getName())
.and().field("modifiedBy").is(adminUser.getUsername())
.and().field("id").isNotEmpty()
.and().field("mimeType").is(document2.getFileType().mimeType);
processItems.getEntries().get(1).onModel()
.assertThat().field("createdAt").isNotEmpty()
.and().field("size").is(document.getContent().length())
.and().field("createdBy").is(adminUser.getUsername())
.and().field("modifiedAt").isNotEmpty()
.and().field("name").is(document.getName())
.and().field("modifiedBy").is(adminUser.getUsername())
.and().field("id").isNotEmpty()
.and().field("mimeType").is(document.getFileType().mimeType);
restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems()
.assertThat().entriesListContains("id", processItems.getEntries().get(0).onModel().getId())
.assertThat().entriesListContains("id", processItems.getEntries().get(1).onModel().getId());
}
@Bug(id= "MNT-16966")
@TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY,
@@ -89,4 +130,46 @@ public class AddProcessItemSanityTests extends RestTest
restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2);
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST);
}
@Bug(id= "MNT-16966")
@TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY,
description = "Add process item that already exists")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY})
public void addMultipleProcessItemThatAlreadyExists() throws JsonToModelConversionException, Exception
{
document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML);
document = dataContent.usingSite(siteModel).createContent(DocumentType.XML);
processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel();
processItems = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItems(document2, document);
restClient.assertStatusCodeIs(HttpStatus.CREATED);
processItems.getEntries().get(0).onModel()
.assertThat().field("createdAt").isNotEmpty()
.and().field("size").is("19")
.and().field("createdBy").is(adminUser.getUsername())
.and().field("modifiedAt").isNotEmpty()
.and().field("name").is(document2.getName())
.and().field("modifiedBy").is(adminUser.getUsername())
.and().field("id").isNotEmpty()
.and().field("mimeType").is(document2.getFileType().mimeType);
processItems.getEntries().get(1).onModel()
.assertThat().field("createdAt").isNotEmpty()
.and().field("size").is("19")
.and().field("createdBy").is(adminUser.getUsername())
.and().field("modifiedAt").isNotEmpty()
.and().field("name").is(document.getName())
.and().field("modifiedBy").is(adminUser.getUsername())
.and().field("id").isNotEmpty()
.and().field("mimeType").is(document.getFileType().mimeType);
restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems()
.assertThat().entriesListContains("id", processItems.getEntries().get(0).onModel().getId())
.and().entriesListContains("name", document2.getName())
.assertThat().entriesListContains("id", processItems.getEntries().get(1).onModel().getId())
.and().entriesListContains("name", document.getName());
restClient.withWorkflowAPI().usingProcess(processModel).addProcessItems(document2, document);
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST);
}
}
@@ -4,6 +4,7 @@ import org.alfresco.dataprep.CMISUtil;
import org.alfresco.rest.RestTest;
import org.alfresco.rest.model.RestErrorModel;
import org.alfresco.rest.model.RestProcessModel;
import org.alfresco.rest.model.RestProcessVariableCollection;
import org.alfresco.rest.model.RestProcessVariableModel;
import org.alfresco.utility.model.FileModel;
import org.alfresco.utility.model.SiteModel;
@@ -22,6 +23,7 @@ public class AddProcessVariablesCoreTests extends RestTest
private UserModel userWhoStartsProcess, assignee, adminUser;
private RestProcessModel processModel;
private RestProcessVariableModel variableModel, processVariable, variableModel1;
private RestProcessVariableCollection processVariableCollection;
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
@@ -52,6 +54,33 @@ public class AddProcessVariablesCoreTests extends RestTest
restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables()
.assertThat().entriesListContains("name", processVariable.getName());
}
@TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION,
description = "Verify multiple addProcessVariable by any user with REST API and status code is CREATED (201)")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE })
public void addMultipleProcessVariableByAnyUser() throws Exception
{
variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text");
variableModel1 = RestProcessVariableModel.getRandomProcessVariableModel("d:text");
processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel();
processVariableCollection = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(processModel)
.addProcessVariables(variableModel, variableModel1);
restClient.assertStatusCodeIs(HttpStatus.CREATED);
processVariableCollection.getEntries().get(0).onModel()
.assertThat().field("name").is(variableModel.getName())
.and().field("type").is(variableModel.getType())
.and().field("value").is(variableModel.getValue());
processVariableCollection.getEntries().get(1).onModel()
.assertThat().field("name").is(variableModel1.getName())
.and().field("type").is(variableModel1.getType())
.and().field("value").is(variableModel1.getValue());
restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables()
.assertThat().entriesListContains("name", processVariableCollection.getEntries().get(0).onModel().getName())
.assertThat().entriesListContains("name", processVariableCollection.getEntries().get(1).onModel().getName());
}
@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)")
@@ -71,7 +100,7 @@ public class AddProcessVariablesCoreTests extends RestTest
@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.CORE })
public void addProcessVariableForInvalidProcessIdIsEmpty() throws Exception
public void addProcessVariableForEmptyProcessIdIsEmpty() throws Exception
{
variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text");
processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel();
@@ -101,6 +130,33 @@ public class AddProcessVariablesCoreTests extends RestTest
.assertThat().entriesListContains("name", processVariable.getName());
}
@TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION,
description = "Add multiple process variables using by the user who started the process.")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE })
public void addMultipleProcessVariableByUserThatStartedTheProcess() throws Exception
{
variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text");
variableModel1 = RestProcessVariableModel.getRandomProcessVariableModel("d:text");
processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel();
processVariableCollection = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(processModel)
.addProcessVariables(variableModel, variableModel1);
restClient.assertStatusCodeIs(HttpStatus.CREATED);
processVariableCollection.getEntries().get(0).onModel()
.assertThat().field("name").is(variableModel.getName())
.and().field("type").is(variableModel.getType())
.and().field("value").is(variableModel.getValue());
processVariableCollection.getEntries().get(1).onModel()
.assertThat().field("name").is(variableModel1.getName())
.and().field("type").is(variableModel1.getType())
.and().field("value").is(variableModel1.getValue());
restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables()
.assertThat().entriesListContains("name", processVariableCollection.getEntries().get(1).onModel().getName())
.assertThat().entriesListContains("name", processVariableCollection.getEntries().get(0).onModel().getName());
}
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION,
description = "Adding multiple process variables is falling in case invalid process id is provided")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL })
@@ -62,6 +62,35 @@ public class AddProcessVariablesFullTests extends RestTest
.assertThat().entriesListContains("name", processVariable.getName());
}
@TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION,
description = "Add process variables using by the user involved in the process.")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL })
public void addMultipleProcessVariableByUserInvolvedTheProcess() throws Exception
{
variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text");
variableModel1 = RestProcessVariableModel.getRandomProcessVariableModel("d:text");
restProcessModel = restClient.authenticateUser(assignee).withWorkflowAPI().getProcesses()
.getProcessModelByProcessDefId(processModel.getId());
processVariableCollection = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(restProcessModel)
.addProcessVariables(variableModel, variableModel1);
restClient.assertStatusCodeIs(HttpStatus.CREATED);
processVariableCollection.getEntries().get(0).onModel()
.assertThat().field("name").is(processVariableCollection.getEntries().get(0).onModel().getName())
.and().field("type").is(processVariableCollection.getEntries().get(0).onModel().getType())
.and().field("value").is(processVariableCollection.getEntries().get(0).onModel().getValue());
processVariableCollection.getEntries().get(1).onModel()
.assertThat().field("name").is(processVariableCollection.getEntries().get(1).onModel().getName())
.and().field("type").is(processVariableCollection.getEntries().get(1).onModel().getType())
.and().field("value").is(processVariableCollection.getEntries().get(1).onModel().getValue());
restClient.withWorkflowAPI().usingProcess(restProcessModel).getProcessVariables()
.assertThat().entriesListContains("name", processVariableCollection.getEntries().get(0).onModel().getName())
.assertThat().entriesListContains("name", processVariableCollection.getEntries().get(1).onModel().getName());
}
@TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION,
description = "Add process variables using by inexistent user.")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL })
@@ -82,6 +111,27 @@ public class AddProcessVariablesFullTests extends RestTest
.stackTraceIs(RestErrorModel.STACKTRACE);
}
@TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION,
description = "Add multiple process variables using by inexistent user.")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL })
public void addMultipleProcessVariableByInexistentUser() throws Exception
{
variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text");
variableModel1 = RestProcessVariableModel.getRandomProcessVariableModel("d:text");
restProcessModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses()
.getProcessModelByProcessDefId(processModel.getId());
processVariableCollection = restClient.authenticateUser(UserModel.getRandomUserModel()).withWorkflowAPI()
.usingProcess(restProcessModel)
.addProcessVariables(variableModel,variableModel1);
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED)
.assertLastError()
.containsSummary(RestErrorModel.AUTHENTICATION_FAILED)
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER)
.containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY)
.stackTraceIs(RestErrorModel.STACKTRACE);
}
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION,
description = "Adding process variables is falling in case invalid type is provided")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL })
@@ -23,7 +23,7 @@ public class AddProcessVariablesSanityTests extends RestTest
private SiteModel siteModel;
private UserModel userWhoStartsProcess, assignee, adminUser, adminTenantUser, tenantUserAssignee, tenantUser;
private RestProcessModel processModel;
private RestProcessVariableModel variableModel, variableModel1, processVariable;
private RestProcessVariableModel variableModel, variableModel1, variableModel2, processVariable;
private RestProcessVariableCollection processVariableCollection;
@BeforeClass(alwaysRun = true)
@@ -55,6 +55,41 @@ public class AddProcessVariablesSanityTests extends RestTest
.assertThat().entriesListContains("name", processVariable.getName());
}
@TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY,
description = "Create non-existing variable")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY })
public void addMultipleProcessVariable() throws Exception
{
variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text");
variableModel1 = RestProcessVariableModel.getRandomProcessVariableModel("d:text");
variableModel2 = RestProcessVariableModel.getRandomProcessVariableModel("d:text");
processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel();
processVariableCollection = restClient.withWorkflowAPI().usingProcess(processModel)
.addProcessVariables(variableModel, variableModel1, variableModel2);
restClient.assertStatusCodeIs(HttpStatus.CREATED);
processVariableCollection.getEntries().get(0).onModel()
.assertThat().field("name").is( processVariableCollection.getEntries().get(0).onModel().getName())
.and().field("type").is( processVariableCollection.getEntries().get(0).onModel().getType())
.and().field("value").is( processVariableCollection.getEntries().get(0).onModel().getValue());
processVariableCollection.getEntries().get(1).onModel()
.assertThat().field("name").is( processVariableCollection.getEntries().get(1).onModel().getName())
.and().field("type").is( processVariableCollection.getEntries().get(1).onModel().getType())
.and().field("value").is( processVariableCollection.getEntries().get(1).onModel().getValue());
processVariableCollection.getEntries().get(2).onModel()
.assertThat().field("name").is( processVariableCollection.getEntries().get(2).onModel().getName())
.and().field("type").is( processVariableCollection.getEntries().get(2).onModel().getType())
.and().field("value").is( processVariableCollection.getEntries().get(2).onModel().getValue());
restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables()
.assertThat().entriesListContains("name", processVariableCollection.getEntries().get(1).onModel().getName())
.assertThat().entriesListContains("name", processVariableCollection.getEntries().get(0).onModel().getName())
.assertThat().entriesListContains("name", processVariableCollection.getEntries().get(2).onModel().getName());
}
@TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY,
description = "Update existing variables")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY })
@@ -76,6 +111,39 @@ public class AddProcessVariablesSanityTests extends RestTest
processVariable.assertThat().field("value").is(newValue);
}
@TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY,
description = "Update existing variables")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY })
public void updateExistingMultipleProcessVariable() throws Exception
{
variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text");
variableModel1 = RestProcessVariableModel.getRandomProcessVariableModel("d:text");
processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel();
processVariableCollection = restClient.withWorkflowAPI().usingProcess(processModel)
.addProcessVariables(variableModel, variableModel1);
restClient.assertStatusCodeIs(HttpStatus.CREATED);
processVariableCollection.getEntries().get(0).onModel()
.assertThat().field("name").is(variableModel.getName())
.and().field("type").is(variableModel.getType())
.and().field("value").is(variableModel.getValue());
processVariableCollection.getEntries().get(1).onModel()
.assertThat().field("name").is(variableModel1.getName())
.and().field("type").is(variableModel1.getType())
.and().field("value").is(variableModel1.getValue());
String newValueVar = RandomData.getRandomName("valueVar");
variableModel.setValue(newValueVar);
String newValueVar1 = RandomData.getRandomName("valueVar1");
variableModel1.setValue(newValueVar1);
processVariableCollection = restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariables(variableModel, variableModel1);
restClient.assertStatusCodeIs(HttpStatus.CREATED);
processVariableCollection.getEntries().get(0).onModel().assertThat().field("value").is(newValueVar);
processVariableCollection.getEntries().get(1).onModel().assertThat().field("value").is(newValueVar1);
}
@TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY,
description = "Adding process variables is falling in case invalid variableBody is provided")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY })
@@ -24,11 +24,8 @@ public class AddTaskItemCoreTests extends RestTest
{
private UserModel userModel, assigneeUser, anotherUser;
private SiteModel siteModel;
private FileModel fileModel;
private FileModel fileModel, fileModel1;
private TaskModel taskModel;
@SuppressWarnings("unused")
private RestItemModel taskItem;
private String taskId;
@BeforeClass(alwaysRun = true)
@@ -37,6 +34,7 @@ public class AddTaskItemCoreTests extends RestTest
userModel = dataUser.createRandomTestUser();
siteModel = dataSite.usingUser(userModel).createPublicRandomSite();
fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN);
fileModel1 = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN);
assigneeUser = dataUser.createRandomTestUser();
taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser);
@@ -44,51 +42,130 @@ public class AddTaskItemCoreTests extends RestTest
}
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE })
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Add task item using random user.")
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION,
description = "Add task item using random user.")
public void addTaskItemByRandomUser() throws JsonToModelConversionException, Exception
{
anotherUser = dataUser.createRandomTestUser();
taskItem = restClient.authenticateUser(anotherUser).withWorkflowAPI().usingTask(taskModel).addTaskItem(fileModel);
restClient.authenticateUser(anotherUser).withWorkflowAPI().usingTask(taskModel).addTaskItem(fileModel);
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED);
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN)
.assertLastError()
.containsSummary(RestErrorModel.PERMISSION_WAS_DENIED)
.containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY)
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER)
.stackTraceIs(RestErrorModel.STACKTRACE);
}
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE })
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION,
description = "Add multiple task item using random user.")
public void addMultipleTaskItemByRandomUser() throws JsonToModelConversionException, Exception
{
anotherUser = dataUser.createRandomTestUser();
restClient.authenticateUser(anotherUser).withWorkflowAPI().usingTask(taskModel)
.addTaskItems(fileModel,fileModel1);
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN)
.assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED)
.containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY)
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER)
.stackTraceIs(RestErrorModel.STACKTRACE);;
}
@Bug(id = "ACE-5683")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE })
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task item, is falling in case invalid itemBody is provided")
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION,
description = "Adding task item, is falling in case invalid itemBody is provided")
public void failedAddingTaskItemIfInvalidItemBodyIsProvided() throws Exception
{
fileModel.setNodeRef("invalidNodeRef");
taskItem = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskItem(fileModel);
restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskItem(fileModel);
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidNodeRef"));
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError()
.containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidNodeRef"))
.containsErrorKey(RestErrorModel.NOT_FOUND_ERRORKEY)
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER)
.stackTraceIs(RestErrorModel.STACKTRACE);
}
@Bug(id = "ACE-5683")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE })
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION,
description = "Adding multiple task item, is falling in case invalid itemBody is provided")
public void failedAddingMultipleTaskItemIfInvalidItemBodyIsProvided() throws Exception
{
fileModel.setNodeRef("invalidNodeRef");
restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel)
.addTaskItems(fileModel, fileModel1);
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError()
.containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidNodeRef"))
.containsErrorKey(RestErrorModel.NOT_FOUND_ERRORKEY)
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER)
.stackTraceIs(RestErrorModel.STACKTRACE);;
}
@Bug(id = "ACE-5675")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE })
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task item is falling in case empty item body is provided")
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION,
description = "Adding task item is falling in case empty item body is provided")
public void failedAddingTaskItemIfEmptyItemBodyIsProvided() throws Exception
{
fileModel.setNodeRef("");
taskItem = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskItem(fileModel);
restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskItem(fileModel);
// TODO - expected error message to be added
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("");
}
@Bug(id = "ACE-5675")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE })
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION,
description = "Adding multiple task item is falling in case empty item body is provided")
public void failedAddingMultipleTaskItemIfEmptyItemBodyIsProvided() throws Exception
{
fileModel.setNodeRef("");
restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskItems(fileModel, fileModel1);
// TODO - expected error message to be added
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("");
}
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE })
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task item is falling in case invalid task id is provided")
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION,
description = "Adding task item is falling in case invalid task id is provided")
public void failedAddingTaskItemIfInvalidTaskIdIsProvided() throws Exception
{
taskModel.setId("invalidTaskId");
taskItem = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskItem(fileModel);
restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskItem(fileModel);
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidTaskId"));
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError()
.containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidTaskId"))
.containsErrorKey(RestErrorModel.NOT_FOUND_ERRORKEY)
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER)
.stackTraceIs(RestErrorModel.STACKTRACE);;
}
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE })
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION,
description = "Adding task item is falling in case invalid task id is provided")
public void failedAddingMultipleTaskItemIfInvalidTaskIdIsProvided() throws Exception
{
taskModel.setId("invalidTaskId");
restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskItems(fileModel,fileModel1);
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError()
.containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidTaskId"))
.containsErrorKey(RestErrorModel.NOT_FOUND_ERRORKEY)
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER)
.stackTraceIs(RestErrorModel.STACKTRACE);;
}
@Bug(id = "ACE-5675")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE })
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task item is falling in case incomplete body type is provided")
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION,
description = "Adding task item is falling in case incomplete body type is provided")
public void failedAddingTaskVariableIfIncompleteBodyIsProvided() throws Exception
{
RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{}", "tasks/{taskId}/items", taskId);
@@ -96,5 +173,5 @@ public class AddTaskItemCoreTests extends RestTest
// TODO - expected error message to be added
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("");
}
}
}
@@ -0,0 +1,182 @@
package org.alfresco.rest.workflow.tasks;
import org.alfresco.dataprep.CMISUtil.DocumentType;
import org.alfresco.rest.RestTest;
import org.alfresco.rest.exception.JsonToModelConversionException;
import org.alfresco.rest.model.RestErrorModel;
import org.alfresco.rest.model.RestItemModel;
import org.alfresco.rest.model.RestItemModelsCollection;
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;
public class AddTaskItemFullTests extends RestTest
{
private UserModel userModel, adminUser,userWhoStartsTask, assigneeUser, adminTenantUser, tenantUser, tenantUserAssignee, adminTenantUser2;
private SiteModel siteModel;
private FileModel fileModel, fileModel1, document1, document2,document3;
private TaskModel taskModel;
private RestItemModelsCollection taskItems;
private RestItemModel taskItem;
@BeforeClass(alwaysRun=true)
public void dataPreparation() throws Exception
{
adminUser = dataUser.getAdminUser();
userModel = dataUser.createRandomTestUser();
siteModel = dataSite.usingUser(userModel).createPublicRandomSite();
fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN);
userWhoStartsTask = dataUser.createRandomTestUser();
assigneeUser = dataUser.createRandomTestUser();
taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser);
}
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL })
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION,
description = "Add task item using random user.")
public void addTaskItemByTheUserThatStartedTheProcess() throws JsonToModelConversionException, Exception
{
taskItem = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(taskModel).addTaskItem(fileModel);
restClient.assertStatusCodeIs(HttpStatus.CREATED);
taskItem.assertThat().field("createdAt").is(taskItem.getCreatedAt())
.and().field("size").is(taskItem.getSize())
.and().field("createdBy").is(taskItem.getCreatedBy())
.and().field("modifiedAt").is(taskItem.getModifiedAt())
.and().field("name").is(taskItem.getName())
.and().field("modifiedBy").is(taskItem.getModifiedBy())
.and().field("id").is(taskItem.getId())
.and().field("mimeType").is(taskItem.getMimeType());
}
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL })
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION,
description = "Add multiple task item using random user.")
public void addMultipleTaskItemByTheUserThatStartedTheProcess() throws JsonToModelConversionException, Exception
{
fileModel1 = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN);
taskItems = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(taskModel)
.addTaskItems(fileModel, fileModel1);
restClient.assertStatusCodeIs(HttpStatus.CREATED);
taskItems.getEntries().get(0).onModel()
.assertThat().field("createdAt").is(taskItems.getEntries().get(0).onModel().getCreatedAt())
.and().field("size").is(taskItems.getEntries().get(0).onModel().getSize())
.and().field("createdBy").is(taskItems.getEntries().get(0).onModel().getCreatedBy())
.and().field("modifiedAt").is(taskItems.getEntries().get(0).onModel().getModifiedAt())
.and().field("name").is(taskItems.getEntries().get(0).onModel().getName())
.and().field("modifiedBy").is(taskItems.getEntries().get(0).onModel().getModifiedBy())
.and().field("id").is(taskItems.getEntries().get(0).onModel().getId())
.and().field("mimeType").is(taskItems.getEntries().get(0).onModel().getMimeType());
taskItems.getEntries().get(1).onModel()
.assertThat().field("createdAt").is(taskItems.getEntries().get(1).onModel().getCreatedAt())
.assertThat().field("size").is(taskItems.getEntries().get(1).onModel().getSize())
.assertThat().field("createdBy").is(taskItems.getEntries().get(1).onModel().getCreatedBy())
.assertThat().field("modifiedAt").is(taskItems.getEntries().get(1).onModel().getModifiedAt())
.assertThat().field("name").is(taskItems.getEntries().get(1).onModel().getName())
.assertThat().field("modifiedBy").is(taskItems.getEntries().get(1).onModel().getModifiedBy())
.assertThat().field("id").is(taskItems.getEntries().get(1).onModel().getId())
.assertThat().field("mimeType").is(taskItems.getEntries().get(1).onModel().getMimeType());
}
@TestRail(section = { TestGroup.REST_API, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION,
description = "Add task item using by admin in other network.")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL, TestGroup.NETWORKS })
public void addTaskItemByAdminInOtherNetwork() throws Exception
{
adminTenantUser = UserModel.getAdminTenantUser();
adminTenantUser2 = UserModel.getAdminTenantUser();
restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser);
tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee");
restClient.usingTenant().createTenant(adminTenantUser2);
siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite();
dataWorkflow.usingUser(tenantUser).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(tenantUserAssignee);
document1 = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(DocumentType.XML);
restClient.authenticateUser(adminTenantUser2).withWorkflowAPI().usingTask(taskModel).addTaskItem(document1);
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError()
.containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT)
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER)
.containsErrorKey(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT)
.stackTraceIs(RestErrorModel.STACKTRACE);
}
@TestRail(section = { TestGroup.REST_API, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION,
description = "Add multiple task item using by admin in other network.")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL, TestGroup.NETWORKS })
public void addMultipleTaskItemByAdminInOtherNetwork() throws Exception
{
adminTenantUser = UserModel.getAdminTenantUser();
adminTenantUser2 = UserModel.getAdminTenantUser();
restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser);
tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee");
restClient.usingTenant().createTenant(adminTenantUser2);
siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite();
dataWorkflow.usingUser(tenantUser).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(tenantUserAssignee);
document1 = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(DocumentType.XML);
document2 = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(DocumentType.XML);
restClient.authenticateUser(adminTenantUser2).withWorkflowAPI().usingTask(taskModel).addTaskItems(document1, document2);
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError()
.containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT)
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER)
.containsErrorKey(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT)
.stackTraceIs(RestErrorModel.STACKTRACE);;
}
@TestRail(section = { TestGroup.REST_API, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION,
description = "Delete task item then create it again")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL})
public void deleteTaskItemThenCreateItAgain() 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.assertStatusCodeIs(HttpStatus.CREATED);
restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem);
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2);
restClient.assertStatusCodeIs(HttpStatus.CREATED);
}
@TestRail(section = { TestGroup.REST_API, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION,
description = "Delete multiple task item then create it again")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL})
public void deleteMultipleTaskItemThenCreateItAgain() throws Exception
{
taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel)
.createNewTaskAndAssignTo(assigneeUser);
restClient.authenticateUser(userWhoStartsTask);
document1 = dataContent.usingSite(siteModel).createContent(DocumentType.XML);
document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML);
document3 = dataContent.usingSite(siteModel).createContent(DocumentType.XML);
taskItems = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItems(document2, document1, document3);
restClient.assertStatusCodeIs(HttpStatus.CREATED);
restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItems.getEntries().get(0).onModel());
restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItems.getEntries().get(1).onModel());
restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItems.getEntries().get(2).onModel());
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
restClient.withWorkflowAPI().usingTask(taskModel).addTaskItems(document2, document1, document3);
restClient.assertStatusCodeIs(HttpStatus.CREATED);
}
}
@@ -4,6 +4,7 @@ import org.alfresco.dataprep.CMISUtil.DocumentType;
import org.alfresco.rest.RestTest;
import org.alfresco.rest.exception.JsonToModelConversionException;
import org.alfresco.rest.model.RestItemModel;
import org.alfresco.rest.model.RestItemModelsCollection;
import org.alfresco.utility.model.FileModel;
import org.alfresco.utility.model.SiteModel;
import org.alfresco.utility.model.TaskModel;
@@ -23,7 +24,7 @@ public class AddTaskItemSanityTests extends RestTest
private SiteModel siteModel;
private FileModel fileModel, document2, document3, document4;
private TaskModel taskModel;
private RestItemModelsCollection taskItems;
private RestItemModel taskItem;
@BeforeClass(alwaysRun=true)
@@ -56,8 +57,40 @@ public class AddTaskItemSanityTests extends RestTest
.assertThat().field("name").is(taskItem.getName())
.assertThat().field("modifiedBy").is(taskItem.getModifiedBy())
.assertThat().field("id").is(taskItem.getId())
.assertThat().field("mimeType").is(taskItem.getMimeType());
.assertThat().field("mimeType").is(taskItem.getMimeType());
}
@Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY })
@TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY,
description = "Create multiple non-existing task item")
public void createMultipleTaskItem() throws Exception
{
UserModel adminUser = dataUser.getAdminUser();
restClient.authenticateUser(adminUser);
document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML);
taskItems = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItems(document2, fileModel);
restClient.assertStatusCodeIs(HttpStatus.CREATED);
taskItems.getEntries().get(0).onModel()
.assertThat().field("createdAt").is(taskItems.getEntries().get(0).onModel().getCreatedAt())
.assertThat().field("size").is(taskItems.getEntries().get(0).onModel().getSize())
.assertThat().field("createdBy").is(taskItems.getEntries().get(0).onModel().getCreatedBy())
.assertThat().field("modifiedAt").is(taskItems.getEntries().get(0).onModel().getModifiedAt())
.assertThat().field("name").is(taskItems.getEntries().get(0).onModel().getName())
.assertThat().field("modifiedBy").is(taskItems.getEntries().get(0).onModel().getModifiedBy())
.assertThat().field("id").is(taskItems.getEntries().get(0).onModel().getId())
.assertThat().field("mimeType").is(taskItems.getEntries().get(0).onModel().getMimeType());
taskItems.getEntries().get(1).onModel()
.assertThat().field("createdAt").is(taskItems.getEntries().get(1).onModel().getCreatedAt())
.assertThat().field("size").is(taskItems.getEntries().get(1).onModel().getSize())
.assertThat().field("createdBy").is(taskItems.getEntries().get(1).onModel().getCreatedBy())
.assertThat().field("modifiedAt").is(taskItems.getEntries().get(1).onModel().getModifiedAt())
.assertThat().field("name").is(taskItems.getEntries().get(1).onModel().getName())
.assertThat().field("modifiedBy").is(taskItems.getEntries().get(1).onModel().getModifiedBy())
.assertThat().field("id").is(taskItems.getEntries().get(1).onModel().getId())
.assertThat().field("mimeType").is(taskItems.getEntries().get(1).onModel().getMimeType());
}
@Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY })
@@ -85,6 +118,44 @@ public class AddTaskItemSanityTests extends RestTest
taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document3);
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST);
}
@Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY })
@Bug(id = "MNT-16966")
@TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY,
description = "Verify that in case task item exists the request fails")
public void createMultipleTaskItemThatAlreadyExists() throws Exception
{
UserModel adminUser = dataUser.getAdminUser();
restClient.authenticateUser(adminUser);
document3 = dataContent.usingSite(siteModel).createContent(DocumentType.XML);
document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML);
taskItems = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItems(document3, document2);
restClient.assertStatusCodeIs(HttpStatus.CREATED);
taskItems.getEntries().get(0).onModel()
.assertThat().field("createdAt").is(taskItems.getEntries().get(0).onModel().getCreatedAt())
.assertThat().field("size").is(taskItems.getEntries().get(0).onModel().getSize())
.assertThat().field("createdBy").is(taskItems.getEntries().get(0).onModel().getCreatedBy())
.assertThat().field("modifiedAt").is(taskItems.getEntries().get(0).onModel().getModifiedAt())
.assertThat().field("name").is(taskItems.getEntries().get(0).onModel().getName())
.assertThat().field("modifiedBy").is(taskItems.getEntries().get(0).onModel().getModifiedBy())
.assertThat().field("id").is(taskItems.getEntries().get(0).onModel().getId())
.assertThat().field("mimeType").is(taskItems.getEntries().get(0).onModel().getMimeType());
taskItems.getEntries().get(1).onModel()
.assertThat().field("createdAt").is(taskItems.getEntries().get(1).onModel().getCreatedAt())
.assertThat().field("size").is(taskItems.getEntries().get(1).onModel().getSize())
.assertThat().field("createdBy").is(taskItems.getEntries().get(1).onModel().getCreatedBy())
.assertThat().field("modifiedAt").is(taskItems.getEntries().get(1).onModel().getModifiedAt())
.assertThat().field("name").is(taskItems.getEntries().get(1).onModel().getName())
.assertThat().field("modifiedBy").is(taskItems.getEntries().get(1).onModel().getModifiedBy())
.assertThat().field("id").is(taskItems.getEntries().get(1).onModel().getId())
.assertThat().field("mimeType").is(taskItems.getEntries().get(1).onModel().getMimeType());
taskItems = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItems(document3, document2);
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST);
}
@Test(groups = { TestGroup.NETWORKS,TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY })
@TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY,
@@ -116,4 +187,47 @@ public class AddTaskItemSanityTests extends RestTest
.and().field("id").is(taskItem.getId())
.and().field("mimeType").is(taskItem.getMimeType());
}
@Test(groups = { TestGroup.NETWORKS,TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY })
@TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY,
description = "Add task item using admin user from same network")
public void addMultipleTaskItemByAdminSameNetwork() throws JsonToModelConversionException, Exception
{
UserModel adminuser = dataUser.getAdminUser();
restClient.authenticateUser(adminuser);
adminTenantUser = UserModel.getAdminTenantUser();
restClient.usingTenant().createTenant(adminTenantUser);
tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant");
tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee");
siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite();
dataWorkflow.usingUser(tenantUser).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(tenantUserAssignee);
document4 = dataContent.usingSite(siteModel).createContent(DocumentType.XML);
document3 = dataContent.usingSite(siteModel).createContent(DocumentType.XML);
taskItems = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItems(document4,document3);
restClient.assertStatusCodeIs(HttpStatus.CREATED);
taskItems.getEntries().get(0).onModel()
.assertThat().field("createdAt").is(taskItems.getEntries().get(0).onModel().getCreatedAt())
.assertThat().field("size").is(taskItems.getEntries().get(0).onModel().getSize())
.assertThat().field("createdBy").is(taskItems.getEntries().get(0).onModel().getCreatedBy())
.assertThat().field("modifiedAt").is(taskItems.getEntries().get(0).onModel().getModifiedAt())
.assertThat().field("name").is(taskItems.getEntries().get(0).onModel().getName())
.assertThat().field("modifiedBy").is(taskItems.getEntries().get(0).onModel().getModifiedBy())
.assertThat().field("id").is(taskItems.getEntries().get(0).onModel().getId())
.assertThat().field("mimeType").is(taskItems.getEntries().get(0).onModel().getMimeType());
taskItems.getEntries().get(1).onModel()
.assertThat().field("createdAt").is(taskItems.getEntries().get(1).onModel().getCreatedAt())
.assertThat().field("size").is(taskItems.getEntries().get(1).onModel().getSize())
.assertThat().field("createdBy").is(taskItems.getEntries().get(1).onModel().getCreatedBy())
.assertThat().field("modifiedAt").is(taskItems.getEntries().get(1).onModel().getModifiedAt())
.assertThat().field("name").is(taskItems.getEntries().get(1).onModel().getName())
.assertThat().field("modifiedBy").is(taskItems.getEntries().get(1).onModel().getModifiedBy())
.assertThat().field("id").is(taskItems.getEntries().get(1).onModel().getId());
}
}
@@ -28,7 +28,6 @@ public class AddTaskVariablesCoreTests extends RestTest
private UserModel assigneeUser;
private TaskModel taskModel;
private RestVariableModel invalidVariableModel, variableModel, variableModel1;
private RestVariableModelsCollection restVariableCollection;
private String taskId;