Merge branch 'TAS-2059' into 'master'

Tas 2059

See merge request !272
This commit is contained in:
Alecsandru Prună
2016-12-06 08:05:57 +00:00
2 changed files with 86 additions and 12 deletions
@@ -0,0 +1,80 @@
package org.alfresco.rest.workflow.processDefinitions;
import org.alfresco.rest.RestTest;
import org.alfresco.rest.model.RestErrorModel;
import org.alfresco.rest.model.RestProcessDefinitionModel;
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;
/**
* Created by Claudia Agache on 12/5/2016.
*/
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE })
public class GetProcessDefinitionCoreTests extends RestTest
{
private UserModel adminUser, adminTenantUser;
private RestProcessDefinitionModel randomProcessDefinition, returnedProcessDefinition;
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
adminUser = dataUser.getAdminUser();
}
@TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION },
executionType = ExecutionType.REGRESSION,
description = "Verify if get process definition returns status code 404 when invalid processDefinitionId is used")
public void getProcessDefinitionUsingInvalidProcessDefinitionId() throws Exception
{
restClient.authenticateUser(adminUser);
randomProcessDefinition = restClient.withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry().onModel();
randomProcessDefinition.setId("invalidID");
restClient.withWorkflowAPI()
.usingProcessDefinitions(randomProcessDefinition).getProcessDefinition();
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND)
.assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidID"));
}
@TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION },
executionType = ExecutionType.REGRESSION,
description = "Verify network admin is able to get a process definition using REST API and status code is OK (200)")
@Test(groups = { TestGroup.NETWORKS })
public void networkAdminGetProcessDefinition() throws Exception
{
adminTenantUser = UserModel.getAdminTenantUser();
restClient.authenticateUser(adminUser)
.usingTenant().createTenant(adminTenantUser);
randomProcessDefinition = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry().onModel();
returnedProcessDefinition = restClient.withWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinition();
restClient.assertStatusCodeIs(HttpStatus.OK);
returnedProcessDefinition.assertThat().field("name").is(randomProcessDefinition.getName());
}
@TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION },
executionType = ExecutionType.REGRESSION,
description = "Verify network user is able to get a process definition using REST API and status code is OK (200)")
@Test(groups = { TestGroup.NETWORKS })
public void networkUserGetProcessDefinition() throws Exception
{
adminTenantUser = UserModel.getAdminTenantUser();
restClient.authenticateUser(adminUser)
.usingTenant().createTenant(adminTenantUser);
UserModel tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant");
randomProcessDefinition = restClient.authenticateUser(adminTenantUser).withWorkflowAPI()
.getAllProcessDefinitions().getOneRandomEntry().onModel();
returnedProcessDefinition = restClient.authenticateUser(tenantUser).withWorkflowAPI()
.usingProcessDefinitions(randomProcessDefinition).getProcessDefinition();
restClient.assertStatusCodeIs(HttpStatus.OK);
returnedProcessDefinition.assertThat().field("name").is(randomProcessDefinition.getName());
}
}
@@ -2,12 +2,10 @@ package org.alfresco.rest.workflow.processDefinitions;
import org.alfresco.rest.RestTest;
import org.alfresco.rest.model.RestProcessDefinitionModel;
import org.alfresco.utility.data.DataUser;
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.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@@ -18,17 +16,15 @@ import org.testng.annotations.Test;
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY })
public class GetProcessDefinitionSanityTests extends RestTest
{
@Autowired
private DataUser dataUser;
private UserModel testUser;
private RestProcessDefinitionModel randomProcessDefinition;
private RestProcessDefinitionModel randomProcessDefinition, returnedProcessDefinition;
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
testUser = dataUser.createRandomTestUser();
restClient.authenticateUser(dataUser.getAdminUser());
randomProcessDefinition = restClient.withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry();
randomProcessDefinition = restClient.withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry().onModel();
}
@TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION },
@@ -36,11 +32,9 @@ public class GetProcessDefinitionSanityTests extends RestTest
description = "Verify Admin user gets a specific process definition for non-network deployments using REST API and status code is OK (200)")
public void adminGetsProcessDefinition() throws Exception
{
restClient.withWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinition().
assertThat().field("name").is(randomProcessDefinition.onModel().getName());
restClient.withWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinition().assertThat().field("name")
.is(randomProcessDefinition.onModel().getName());
returnedProcessDefinition = restClient.withWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinition();
restClient.assertStatusCodeIs(HttpStatus.OK);
returnedProcessDefinition.assertThat().field("name").is(randomProcessDefinition.getName());
}
@TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION },
@@ -49,8 +43,8 @@ public class GetProcessDefinitionSanityTests extends RestTest
public void anyUserGetsProcessDefinition() throws Exception
{
restClient.authenticateUser(testUser);
restClient.withWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinition().assertThat().field("name")
.is(randomProcessDefinition.onModel().getName());
returnedProcessDefinition = restClient.withWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinition();
restClient.assertStatusCodeIs(HttpStatus.OK);
returnedProcessDefinition.assertThat().field("name").is(randomProcessDefinition.getName());
}
}