From 2c8a67027136f0391339ca24313e28dbd3daa6a0 Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 1 Feb 2017 10:20:48 +0200 Subject: [PATCH] TAS - 2896 getProcessDefinitionStartFormModel --- .../DeleteDeploymentSanityTests.java | 10 ++ ...cessDefinitionStartFormModelCoreTests.java | 13 ++- ...cessDefinitionStartFormModelFullTests.java | 93 +++++++++++++++++++ ...ssDefinitionStartFormModelSanityTests.java | 4 +- 4 files changed, 113 insertions(+), 7 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java index f2af443f3..7fcd6da35 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java @@ -78,6 +78,16 @@ public class DeleteDeploymentSanityTests extends RestTest .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, processTask.getId())); } + //check getProcessDefinitionStartFormModel after deletion of process definition + restClient.withWorkflowAPI().usingProcessDefinitions(processDefinitionAssociated).getProcessDefinitionStartFormModel(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, processDefinitionAssociated.getId())); + + //check getProcessDefinitionImage after deletion of process definition + restClient.withWorkflowAPI().usingProcessDefinitions(processDefinitionAssociated).getProcessDefinitionImage(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, processDefinitionAssociated.getId())); + //delete deployment twice restClient.withWorkflowAPI().usingDeployment(deployment).deleteDeployment(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java index 6ddc232cc..71997998b 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java @@ -36,7 +36,7 @@ public class GetProcessDefinitionStartFormModelCoreTests extends RestTest public void nonNetworkUserGetsStartFormModel() throws Exception { UserModel nonNetworkUser = dataUser.createRandomTestUser(); - randomProcessDefinition = allProcessDefinitions.getOneRandomEntry(); + randomProcessDefinition = allProcessDefinitions.getOneRandomEntry().onModel(); restClient.authenticateUser(nonNetworkUser).withWorkflowAPI() .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionStartFormModel() .assertThat().entriesListIsNotEmpty(); @@ -50,13 +50,16 @@ public class GetProcessDefinitionStartFormModelCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE }) public void getStartFormModelUsingInvalidProcessDefinitionId() throws Exception { - randomProcessDefinition = allProcessDefinitions.getOneRandomEntry(); + randomProcessDefinition = allProcessDefinitions.getOneRandomEntry().onModel(); randomProcessDefinition.onModel().setId("invalidID"); restClient.authenticateUser(adminUser).withWorkflowAPI() .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionStartFormModel(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidID")); + .assertLastError().containsSummary(String.format("no deployed process definition found with id '%s'", "invalidID")) + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); } @Bug(id = "ALF-20187") @@ -66,7 +69,7 @@ public class GetProcessDefinitionStartFormModelCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE }) public void getStartFormModelUsingEmptyProcessDefinitionId() throws Exception { - randomProcessDefinition = allProcessDefinitions.getOneRandomEntry(); + randomProcessDefinition = allProcessDefinitions.getOneRandomEntry().onModel(); randomProcessDefinition.onModel().setId(""); restClient.authenticateUser(adminUser).withWorkflowAPI() @@ -86,7 +89,7 @@ public class GetProcessDefinitionStartFormModelCoreTests extends RestTest .usingTenant().createTenant(adminTenantUser); UserModel tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); randomProcessDefinition = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() - .getAllProcessDefinitions().getOneRandomEntry(); + .getAllProcessDefinitions().getOneRandomEntry().onModel(); restClient.authenticateUser(tenantUser).withWorkflowAPI() .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionStartFormModel() .assertThat().entriesListIsNotEmpty(); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelFullTests.java new file mode 100644 index 000000000..c80a5b704 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelFullTests.java @@ -0,0 +1,93 @@ +package org.alfresco.rest.workflow.processDefinitions; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestFormModelsCollection; +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; + +import java.util.Arrays; + +/** + * Created by Claudia Agache on 1/31/2017. + */ +public class GetProcessDefinitionStartFormModelFullTests extends RestTest +{ + private UserModel adminUser; + private RestProcessDefinitionModel activitiAdhoc; + private RestFormModelsCollection returnedResponse; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + activitiAdhoc = restClient.authenticateUser(adminUser).withWorkflowAPI().getAllProcessDefinitions().getProcessDefinitionByDeploymentId("1"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.REGRESSION, + description = "Verify admin gets a model of the start form type definition for specific process definition using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.FULL }) + public void adminGetsStartFormModelForActivitiAdhocProcessDefinition() throws Exception + { + returnedResponse = restClient.authenticateUser(adminUser).withWorkflowAPI() + .usingProcessDefinitions(activitiAdhoc).getProcessDefinitionStartFormModel(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedResponse.assertThat().entriesListContains("qualifiedName", "{http://www.alfresco.org/model/bpm/1.0}workflowPriority"); + returnedResponse.getStartFormModelByQualifiedName("{http://www.alfresco.org/model/bpm/1.0}workflowPriority") + .assertThat().field("defaultValue").is("2") + .and().field("dataType").is("d:int") + .and().field("name").is("bpm_workflowPriority") + .and().field("title").is("Workflow Priority") + .and().field("required").is("false") + .and().field("allowedValues").is(Arrays.asList("1", "2", "3")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.REGRESSION, + description = "Verify admin gets a model of the start form type definition with properties parameter applied using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.FULL }) + public void adminGetsStartFormModelWithPropertiesParameterApplied() throws Exception + { + returnedResponse = restClient.authenticateUser(adminUser).withParams("properties=qualifiedName,dataType,title").withWorkflowAPI() + .usingProcessDefinitions(activitiAdhoc).getProcessDefinitionStartFormModel(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedResponse.assertThat().entriesListContains("qualifiedName", "{http://www.alfresco.org/model/bpm/1.0}workflowPriority"); + returnedResponse.getStartFormModelByQualifiedName("{http://www.alfresco.org/model/bpm/1.0}workflowPriority") + .assertThat().fieldsCount().is(3) + .and().field("qualifiedName").is("{http://www.alfresco.org/model/bpm/1.0}workflowPriority") + .and().field("defaultValue").isNull() + .and().field("dataType").is("d:int") + .and().field("name").isNull() + .and().field("title").is("Workflow Priority") + .and().field("required").isNull() + .and().field("allowedValues").isNull(); + } + + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.REGRESSION, + description = "Verify Tenant User doesn't get a model of the start form type definition for another network deployment using REST API") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.FULL, TestGroup.NETWORKS }) + public void networkUserIsNotAbleToGetStartFormModelForAnotherNetwork() throws Exception + { + UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); + UserModel adminTenantUser2 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser1); + restClient.usingTenant().createTenant(adminTenantUser2); + + RestProcessDefinitionModel randomProcessDefinition = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI() + .getAllProcessDefinitions().getOneRandomEntry().onModel(); + restClient.authenticateUser(adminTenantUser2).withWorkflowAPI() + .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionStartFormModel(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, randomProcessDefinition.getId())); + } + +} diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java index 7603af737..0eb010e8c 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java @@ -32,7 +32,7 @@ public class GetProcessDefinitionStartFormModelSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY }) public void nonNetworkAdminGetsStartFormModel() throws Exception { - randomProcessDefinition = restClient.withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry(); + randomProcessDefinition = restClient.withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry().onModel(); restClient.withWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionStartFormModel().assertThat().entriesListIsNotEmpty(); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -45,7 +45,7 @@ public class GetProcessDefinitionStartFormModelSanityTests extends RestTest { restClient.usingTenant().createTenant(adminTenantUser); restClient.authenticateUser(adminTenantUser); - randomProcessDefinition = restClient.withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry(); + randomProcessDefinition = restClient.withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry().onModel(); restClient.withWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionStartFormModel().assertThat().entriesListIsNotEmpty(); restClient.assertStatusCodeIs(HttpStatus.OK); }