From 3b6dd5502fdfcccd98982615dfeb163df9289b4c Mon Sep 17 00:00:00 2001 From: Andrei Rusu Date: Thu, 24 Nov 2016 17:20:42 +0200 Subject: [PATCH 01/23] Added tests for getRating CoreTests --- .../rest/ratings/GetRatingCoreTests.java | 161 ++++++++++++++++++ 1 file changed, 161 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/ratings/GetRatingCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingCoreTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingCoreTests.java new file mode 100644 index 000000000..232dced69 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/ratings/GetRatingCoreTests.java @@ -0,0 +1,161 @@ +package org.alfresco.rest.ratings; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.model.RestRatingModel; +import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.ErrorModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +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.apache.commons.lang.RandomStringUtils; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) +public class GetRatingCoreTests extends RestTest { + + private SiteModel siteModel; + private UserModel adminUserModel, userModel; + private FileModel document; + private RestRatingModel returnedRatingModel; + private FolderModel firstFolderModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws DataPreparationException { + adminUserModel = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingAdmin().createPublicRandomSite(); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Check that rating for invalid ratingId provided status code is 400.") + public void checkInvalidRatingIdStatusCode() throws Exception { + + document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUserModel).withCoreAPI(); + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "nodes/{nodeId}/ratings/{ratingId}", + document.getNodeRef(), "invalid ratingId"); + restClient.processModel(RestRatingModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary("Invalid ratingSchemeId invalid ratingId"); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Check that rating for nodeId does not exist status code 404 is returned.") + public void getRatingUsingInvalidNodeId() throws Exception { + + document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); + document.setNodeRef(RandomStringUtils.randomAlphanumeric(20)); + returnedRatingModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document) + .getFiveStarRating(); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, document.getNodeRef())); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Get rating of a file that has only likes.") + public void getRatingOfFileThatHasOnlyLikes() throws Exception { + + document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).likeDocument(); + + returnedRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); + Assert.assertEquals(returnedRatingModel.getAggregate().getNumberOfRatings(), 1, + "Node should have 1 like ratings"); + + returnedRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + Assert.assertEquals(returnedRatingModel.getAggregate().getNumberOfRatings(), 0, + "Node should have no five star ratings"); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Get rating of a file that has only stars.") + public void getRatingOfFileThatHasOnlyStars() throws Exception { + + document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); + restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).rateStarsToDocument(5); + + returnedRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and() + .field("aggregate").isNotEmpty(); + Assert.assertEquals(returnedRatingModel.getAggregate().getNumberOfRatings(), 1, + "Node should have 1 five star ratings"); + + returnedRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + Assert.assertEquals(returnedRatingModel.getAggregate().getNumberOfRatings(), 0, + "Node should have no like ratings"); + + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Get rating of a file that has likes and stars.") + public void getRatingOfFileThatHasLikesAndStars() throws Exception { + + document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); + restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).likeDocument(); + restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).rateStarsToDocument(5); + + returnedRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); + Assert.assertEquals(returnedRatingModel.getAggregate().getNumberOfRatings(), 1, + "Node should have 1 like ratings"); + + returnedRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and() + .field("aggregate").isNotEmpty(); + Assert.assertEquals(returnedRatingModel.getAggregate().getNumberOfRatings(), 1, + "Node should have 1 five stars ratings"); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Get rating of a folder that has only likes.") + public void getRatingOfFolderThatHasOnlyLikes() throws Exception { + + firstFolderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(firstFolderModel).likeDocument(); + + returnedRatingModel = restClient.withCoreAPI().usingResource(firstFolderModel).getLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); + Assert.assertEquals(returnedRatingModel.getAggregate().getNumberOfRatings(), 1, + "Node should have 1 like rating"); + + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Get rating of a file that has no ratings.") + public void getRatingOfFileThatHasNoRatings() throws Exception { + + document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); + restClient.authenticateUser(adminUserModel).withCoreAPI(); + + returnedRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + Assert.assertEquals(returnedRatingModel.getAggregate().getNumberOfRatings(), 0, + "Node should have no likes ratings"); + + returnedRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + Assert.assertEquals(returnedRatingModel.getAggregate().getNumberOfRatings(), 0, + "Node should have no five star ratings"); + } + +} From 07b329c9ba8b0fef35825002e5e035d13c373b9d Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Mon, 5 Dec 2016 15:39:22 +0200 Subject: [PATCH 02/23] CORE-REST API: addTag (post /nodes/{nodeId}/tags) --- .../alfresco/rest/tags/AddTagCoreTests.java | 150 ++++++++++++++++++ 1 file changed, 150 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/tags/AddTagCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/tags/AddTagCoreTests.java b/e2e-test/java/org/alfresco/rest/tags/AddTagCoreTests.java new file mode 100644 index 000000000..dc3c9806f --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/tags/AddTagCoreTests.java @@ -0,0 +1,150 @@ +package org.alfresco.rest.tags; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestTagModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +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.apache.commons.lang.RandomStringUtils; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) +public class AddTagCoreTests extends RestTest +{ + private UserModel adminUserModel; + private UserModel testUser; + private FileModel document; + private SiteModel siteModel; + private ListUserWithRoles usersWithRoles; + private String tagValue; + private RestTagModel returnedModel; + private FolderModel folderModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + testUser = dataUser.createRandomTestUser(); + adminUserModel = dataUser.getAdminUser(); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); + } + + @BeforeMethod(alwaysRun = true) + public void generateRandomTag() + { + tagValue = RandomData.getRandomName("tag"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that adding empty tag returns status code 400") + public void emptyTagTest() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel); + returnedModel = restClient.withCoreAPI().usingResource(document).addTag(""); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.NULL_ARGUMENT, "tag")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that adding tag with user that has no permissions returns status code 403") + public void addTagWithUserThatDoesNotHavePermissions() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(testUser); + returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that adding tag to a node that does not exist returns status code 404") + public void addTagToInexistentNode() throws JsonToModelConversionException, Exception + { + FileModel document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + + String nodeRef = RandomStringUtils.randomAlphanumeric(10); + document.setNodeRef(nodeRef); + + restClient.authenticateUser(adminUserModel); + returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, nodeRef)); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that adding tag to a node that does not accepts tags returns status code 405") + public void addTagToANodeThatDoesNotAcceptsTags() throws JsonToModelConversionException, Exception + { + FileModel document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUserModel); + returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue); + document.setNodeRef(returnedModel.getId()); + restClient.withCoreAPI().usingResource(document).addTag(tagValue); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.CANNOT_TAG); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that manager is able to tag a file") + public void managerIsAbleToTagAFile() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedModel.assertThat().field("tag").is(tagValue).and().field("id").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that manager is able to tag a folder") + public void managerIsAbleToTagAFolder() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + returnedModel = restClient.withCoreAPI().usingResource(folderModel).addTag(tagValue); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedModel.assertThat().field("tag").is(tagValue).and().field("id").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that tagged file can be tagged again") + public void addTagToATaggedFile() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel); + + returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedModel.assertThat().field("tag").is(tagValue).and().field("id").isNotEmpty(); + + returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedModel.assertThat().field("tag").is(tagValue).and().field("id").isNotEmpty(); + + returnedModel = restClient.withCoreAPI().usingResource(document).addTag("random_tag_value"); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedModel.assertThat().field("tag").is("random_tag_value").and().field("id").isNotEmpty(); + + restClient.withCoreAPI().usingResource(document).getNodeTags().assertThat() + .entriesListContains("tag", tagValue.toLowerCase()) + .and().entriesListContains("tag", "random_tag_value"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that user cannot add invalid tag") + public void addInvalidTag() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel); + returnedModel = restClient.withCoreAPI().usingResource(document).addTag("-1~!|@#$%^&*()_="); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_TAG, "|")); + } +} \ No newline at end of file From 6769d6c058ec9d7640912b4b7b561f418859c49d Mon Sep 17 00:00:00 2001 From: cagache Date: Mon, 5 Dec 2016 16:32:20 +0200 Subject: [PATCH 03/23] test: implemented get process definition core scenarios --- .../GetProcessDefinitionCoreTests.java | 80 +++++++++++++++++++ .../GetProcessDefinitionSanityTests.java | 18 ++--- 2 files changed, 86 insertions(+), 12 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionCoreTests.java new file mode 100644 index 000000000..0ee7933fb --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionCoreTests.java @@ -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()); + } + +} diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java index 1a0f6a03b..da8aaf7c0 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java @@ -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()); } } From 3f72f50a5b6b2c85ef5b4c58275387f139245901 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Mon, 5 Dec 2016 16:55:35 +0200 Subject: [PATCH 04/23] CORE-REST API: removeTag (delete /nodes/{nodeId}/tags/{tagId}) --- .../rest/tags/DeleteTagCoreTests.java | 104 ++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/tags/DeleteTagCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/tags/DeleteTagCoreTests.java b/e2e-test/java/org/alfresco/rest/tags/DeleteTagCoreTests.java new file mode 100644 index 000000000..fd3edb3c2 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/tags/DeleteTagCoreTests.java @@ -0,0 +1,104 @@ +package org.alfresco.rest.tags; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestTagModel; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +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.apache.commons.lang3.RandomStringUtils; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) +public class DeleteTagCoreTests extends RestTest +{ + private UserModel adminUserModel, userModel; + private SiteModel siteModel; + private RestTagModel tag; + private FileModel document; + private FolderModel folderModel; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + adminUserModel = dataUser.getAdminUser(); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); + } + + @BeforeMethod + public void setUp() throws Exception { + restClient.authenticateUser(adminUserModel); + tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that if user has no permission to remove tag returned status code is 403") + public void deleteTagWithUserWithoutPermission() throws Exception + { + restClient.authenticateUser(userModel); + restClient.withCoreAPI().usingResource(document).deleteTag(tag); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that if node does not exist returned status code is 404") + public void deleteTagForAnInexistentNode() throws Exception + { + FileModel document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + String nodeRef = RandomStringUtils.randomAlphanumeric(10); + document.setNodeRef(nodeRef); + restClient.withCoreAPI().usingResource(document).deleteTag(tag); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, nodeRef)); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that if tag does not exist returned status code is 404") + public void deleteTagThatDoesNotExist() throws Exception + { + tag.setId("abc"); + restClient.withCoreAPI().usingResource(document).deleteTag(tag); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "abc")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that if tag id is empty returned status code is 405") + public void deleteTagWithEmptyId() throws Exception + { + tag.setId(""); + restClient.withCoreAPI().usingResource(document).deleteTag(tag); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.DELETE_EMPTY_ARGUMENT); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that file tag can be deleted") + public void deleteFileTag() throws Exception + { + restClient.withCoreAPI().usingResource(document).deleteTag(tag); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingResource(document).getNodeTags() + .assertThat().entriesListDoesNotContain("tag", tag.getTag()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that folder tag can be deleted") + public void deleteFolderTag() throws Exception + { + tag = restClient.withCoreAPI().usingResource(folderModel).addTag(RandomData.getRandomName("tag")); + restClient.withCoreAPI().usingResource(folderModel).deleteTag(tag); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingResource(folderModel).getNodeTags() + .assertThat().entriesListDoesNotContain("tag", tag.getTag()); + } +} \ No newline at end of file From 67f479a61c73993cd1a849422642c0a34867a332 Mon Sep 17 00:00:00 2001 From: cagache Date: Mon, 5 Dec 2016 17:25:28 +0200 Subject: [PATCH 05/23] bug: fix title --- .../rest/people/UpdateSiteMembershipRequestCoreTests.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestCoreTests.java b/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestCoreTests.java index ce43b7789..eb523fd29 100644 --- a/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestCoreTests.java @@ -126,7 +126,7 @@ public class UpdateSiteMembershipRequestCoreTests extends RestTest restClient.authenticateUser(newMember) .withCoreAPI() .usingAuthUser() - .addSiteMembershipRequest(siteModel, updatedMessage); + .addSiteMembershipRequest(updatedMessage, siteModel, "Accept me"); returnedResponse = restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(siteModel, updatedMessage); restClient.assertStatusCodeIs(HttpStatus.OK); returnedResponse.assertMembershipRequestMessageIs(updatedMessage) @@ -142,7 +142,7 @@ public class UpdateSiteMembershipRequestCoreTests extends RestTest restClient.authenticateUser(newMember) .withCoreAPI() .usingAuthUser() - .addSiteMembershipRequest(siteModel, ""); + .addSiteMembershipRequest("", siteModel, "Accept me"); returnedResponse = restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(siteModel, updatedMessage); restClient.assertStatusCodeIs(HttpStatus.OK); returnedResponse.assertMembershipRequestMessageIs(updatedMessage) From 0c1419af51be68229346492136ac8a27d7bcb5db Mon Sep 17 00:00:00 2001 From: Andrei Rusu Date: Tue, 6 Dec 2016 10:23:57 +0200 Subject: [PATCH 06/23] Changes for getRatingCoreTests --- .../rest/ratings/GetRatingCoreTests.java | 220 ++++++++---------- 1 file changed, 102 insertions(+), 118 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingCoreTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingCoreTests.java index 232dced69..6cbef9d9e 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/GetRatingCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/GetRatingCoreTests.java @@ -1,6 +1,7 @@ package org.alfresco.rest.ratings; import org.alfresco.dataprep.CMISUtil; +import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.model.RestRatingModel; @@ -18,144 +19,127 @@ import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.testng.Assert; import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) -public class GetRatingCoreTests extends RestTest { +public class GetRatingCoreTests extends RestTest +{ + private SiteModel siteModel; + private UserModel adminUserModel, userModel; + private FileModel document; + private RestRatingModel returnedRatingModel; + private FolderModel firstFolderModel; - private SiteModel siteModel; - private UserModel adminUserModel, userModel; - private FileModel document; - private RestRatingModel returnedRatingModel; - private FolderModel firstFolderModel; + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws DataPreparationException + { + adminUserModel = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingAdmin().createPublicRandomSite(); + } - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws DataPreparationException { - adminUserModel = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingAdmin().createPublicRandomSite(); - } + @BeforeMethod(alwaysRun = true) + public void setUp() throws DataPreparationException, Exception + { + document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); + } - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Check that rating for invalid ratingId provided status code is 400.") - public void checkInvalidRatingIdStatusCode() throws Exception { + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Check that using invalid ratingId for get rating call returns status code 400.") + public void checkInvalidRatingIdStatusCode() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI(); + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "nodes/{nodeId}/ratings/{ratingId}", document.getNodeRef(), "invalid ratingId"); + restClient.processModel(RestRatingModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("invalid ratingId"); + } - document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Check that using invalid node ID for get rating call returns status code 404.") + public void getRatingUsingInvalidNodeId() throws Exception + { + document.setNodeRef(RandomStringUtils.randomAlphanumeric(20)); + returnedRatingModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getFiveStarRating(); - restClient.authenticateUser(adminUserModel).withCoreAPI(); - RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "nodes/{nodeId}/ratings/{ratingId}", - document.getNodeRef(), "invalid ratingId"); - restClient.processModel(RestRatingModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary("Invalid ratingSchemeId invalid ratingId"); - } + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, document.getNodeRef())); + } - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Check that rating for nodeId does not exist status code 404 is returned.") - public void getRatingUsingInvalidNodeId() throws Exception { + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Get rating of a file that has only likes.") + public void getRatingOfFileThatHasOnlyLikes() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).likeDocument(); - document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); - document.setNodeRef(RandomStringUtils.randomAlphanumeric(20)); - returnedRatingModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document) - .getFiveStarRating(); + returnedRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); + returnedRatingModel.getAggregate().assertThat().field("numberOfRatings").is("1"); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, document.getNodeRef())); - } + returnedRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedRatingModel.getAggregate().assertThat().field("numberOfRatings").is("0"); + } - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Get rating of a file that has only likes.") - public void getRatingOfFileThatHasOnlyLikes() throws Exception { + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Get rating of a file that has only stars.") + public void getRatingOfFileThatHasOnlyStars() throws Exception + { + restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).rateStarsToDocument(5); - document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).likeDocument(); + returnedRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); + returnedRatingModel.getAggregate().assertThat().field("numberOfRatings").is("1"); - returnedRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); - Assert.assertEquals(returnedRatingModel.getAggregate().getNumberOfRatings(), 1, - "Node should have 1 like ratings"); + returnedRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedRatingModel.getAggregate().assertThat().field("numberOfRatings").is("0"); + } - returnedRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - Assert.assertEquals(returnedRatingModel.getAggregate().getNumberOfRatings(), 0, - "Node should have no five star ratings"); - } + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Get rating of a file that has likes and stars.") + public void getRatingOfFileThatHasLikesAndStars() throws Exception + { + restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).likeDocument(); + restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).rateStarsToDocument(5); - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Get rating of a file that has only stars.") - public void getRatingOfFileThatHasOnlyStars() throws Exception { + returnedRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); + returnedRatingModel.getAggregate().assertThat().field("numberOfRatings").is("1"); - document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); - restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).rateStarsToDocument(5); + returnedRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); + returnedRatingModel.getAggregate().assertThat().field("numberOfRatings").is("1"); + } - returnedRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and() - .field("aggregate").isNotEmpty(); - Assert.assertEquals(returnedRatingModel.getAggregate().getNumberOfRatings(), 1, - "Node should have 1 five star ratings"); + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Get rating of a folder that has only likes.") + public void getRatingOfFolderThatHasOnlyLikes() throws Exception + { + firstFolderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(firstFolderModel).likeDocument(); - returnedRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - Assert.assertEquals(returnedRatingModel.getAggregate().getNumberOfRatings(), 0, - "Node should have no like ratings"); + returnedRatingModel = restClient.withCoreAPI().usingResource(firstFolderModel).getLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); + returnedRatingModel.getAggregate().assertThat().field("numberOfRatings").is("1"); + } - } + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Get rating of a file that has no ratings.") + public void getRatingOfFileThatHasNoRatings() throws Exception + { + returnedRatingModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedRatingModel.getAggregate().assertThat().field("numberOfRatings").is("0"); - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Get rating of a file that has likes and stars.") - public void getRatingOfFileThatHasLikesAndStars() throws Exception { - - document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); - restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).likeDocument(); - restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).rateStarsToDocument(5); - - returnedRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); - Assert.assertEquals(returnedRatingModel.getAggregate().getNumberOfRatings(), 1, - "Node should have 1 like ratings"); - - returnedRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and() - .field("aggregate").isNotEmpty(); - Assert.assertEquals(returnedRatingModel.getAggregate().getNumberOfRatings(), 1, - "Node should have 1 five stars ratings"); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Get rating of a folder that has only likes.") - public void getRatingOfFolderThatHasOnlyLikes() throws Exception { - - firstFolderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(firstFolderModel).likeDocument(); - - returnedRatingModel = restClient.withCoreAPI().usingResource(firstFolderModel).getLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); - Assert.assertEquals(returnedRatingModel.getAggregate().getNumberOfRatings(), 1, - "Node should have 1 like rating"); - - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Get rating of a file that has no ratings.") - public void getRatingOfFileThatHasNoRatings() throws Exception { - - document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); - restClient.authenticateUser(adminUserModel).withCoreAPI(); - - returnedRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - Assert.assertEquals(returnedRatingModel.getAggregate().getNumberOfRatings(), 0, - "Node should have no likes ratings"); - - returnedRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - Assert.assertEquals(returnedRatingModel.getAggregate().getNumberOfRatings(), 0, - "Node should have no five star ratings"); - } + returnedRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedRatingModel.getAggregate().assertThat().field("numberOfRatings").is("0"); + } } From c2f893dffd2ba4336dbd2e9a8277b6755b87a7e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alecsandru=20Prun=C4=83?= Date: Tue, 6 Dec 2016 10:41:39 +0200 Subject: [PATCH 07/23] test: Added valid values for skipCount and maxItems --- .../AddSiteMembershipRequestCoreTests.java | 4 ++ ...GetSiteMembershipInformationCoreTests.java | 55 +++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestCoreTests.java b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestCoreTests.java index f27718f90..127075d19 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestCoreTests.java @@ -43,6 +43,7 @@ public class AddSiteMembershipRequestCoreTests extends RestTest .usingMe() .addSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + restClient.assertLastError().containsSummary(String.format("%s is already a member of site %s", newMember.getUsername(), siteModel.getId())); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, @@ -53,6 +54,7 @@ public class AddSiteMembershipRequestCoreTests extends RestTest .withCoreAPI() .usingUser(new UserModel("invalidUser", "password")).addSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + restClient.assertLastError().containsSummary("The entity with id: invalidUser was not found"); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, @@ -63,6 +65,8 @@ public class AddSiteMembershipRequestCoreTests extends RestTest .withCoreAPI() .usingMe().addSiteMembershipRequest(new SiteModel("invalidSiteID")); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + restClient.assertLastError().containsSummary(String.format("The relationship resource was not found for" + + " the entity with id: %s and a relationship id of invalidSiteID", newMember.getUsername())); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipInformationCoreTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipInformationCoreTests.java index 4a755125a..07745dca6 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipInformationCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipInformationCoreTests.java @@ -56,6 +56,7 @@ public class GetSiteMembershipInformationCoreTests extends RestTest .getSitesMembershipInformation() .assertThat().entriesListIsEmpty(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + restClient.assertLastError().containsSummary("The entity with id: invalidPersonId was not found"); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, @@ -69,6 +70,37 @@ public class GetSiteMembershipInformationCoreTests extends RestTest .getSitesMembershipInformation() .assertThat().entriesListIsEmpty(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + restClient.assertLastError().containsSummary("Only positive values supported for maxItems"); + + restClient.withParams("maxItems=-1") + .withCoreAPI() + .usingAuthUser() + .getSitesMembershipInformation() + .assertThat().entriesListIsEmpty(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + restClient.assertLastError().containsSummary("Only positive values supported for maxItems"); + + restClient.withParams("maxItems=test") + .withCoreAPI() + .usingAuthUser() + .getSitesMembershipInformation() + .assertThat().entriesListIsEmpty(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + restClient.assertLastError().containsSummary("Invalid paging parameter maxItems:test"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify if get site membership information request returns status code 200 for valid maxItems parameter") + public void getSiteMembershipInformationRequestReturns200ForValidMaxItemsParameter() throws Exception + { + restClient.authenticateUser(userModel) + .withParams("maxItems=5") + .withCoreAPI() + .usingAuthUser() + .getSitesMembershipInformation() + .assertThat().entriesListIsNotEmpty() + .getPagination().assertThat().field("maxItems").is("5"); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, @@ -82,6 +114,29 @@ public class GetSiteMembershipInformationCoreTests extends RestTest .getSitesMembershipInformation() .assertThat().entriesListIsEmpty(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + restClient.assertLastError().containsSummary("Negative values not supported for skipCount"); + + restClient.withParams("skipCount=test") + .withCoreAPI() + .usingAuthUser() + .getSitesMembershipInformation() + .assertThat().entriesListIsEmpty(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + restClient.assertLastError().containsSummary("Invalid paging parameter skipCount:test"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify if get site membership information request returns status code 200 for valid skipCount parameter") + public void getSiteMembershipInformationRequestReturns200ForValidSkipCountParameter() throws Exception + { + restClient.authenticateUser(userModel) + .withParams("skipCount=1") + .withCoreAPI() + .usingAuthUser() + .getSitesMembershipInformation() + .assertThat().entriesListIsNotEmpty() + .getPagination().assertThat().field("skipCount").is("1"); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, From 601d9a20f7011f432f595e0b41a4e0144a2a2f3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alecsandru=20Prun=C4=83?= Date: Tue, 6 Dec 2016 11:27:12 +0200 Subject: [PATCH 08/23] test: Replaced hard coded values with RestErrorModel --- .../people/AddSiteMembershipRequestCoreTests.java | 8 ++++---- .../GetSiteMembershipInformationCoreTests.java | 13 +++++++------ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestCoreTests.java b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestCoreTests.java index 127075d19..ace45b340 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestCoreTests.java @@ -1,6 +1,7 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.SiteModel; @@ -43,7 +44,7 @@ public class AddSiteMembershipRequestCoreTests extends RestTest .usingMe() .addSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - restClient.assertLastError().containsSummary(String.format("%s is already a member of site %s", newMember.getUsername(), siteModel.getId())); + restClient.assertLastError().containsSummary(String.format(RestErrorModel.ALREADY_Site_MEMBER, newMember.getUsername(), siteModel.getId())); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, @@ -54,7 +55,7 @@ public class AddSiteMembershipRequestCoreTests extends RestTest .withCoreAPI() .usingUser(new UserModel("invalidUser", "password")).addSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - restClient.assertLastError().containsSummary("The entity with id: invalidUser was not found"); + restClient.assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidUser")); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, @@ -65,8 +66,7 @@ public class AddSiteMembershipRequestCoreTests extends RestTest .withCoreAPI() .usingMe().addSiteMembershipRequest(new SiteModel("invalidSiteID")); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - restClient.assertLastError().containsSummary(String.format("The relationship resource was not found for" + - " the entity with id: %s and a relationship id of invalidSiteID", newMember.getUsername())); + restClient.assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, newMember.getUsername(), "invalidSiteID")); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipInformationCoreTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipInformationCoreTests.java index 07745dca6..8dbc2f6ca 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipInformationCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipInformationCoreTests.java @@ -1,6 +1,7 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.SiteModel; @@ -56,7 +57,7 @@ public class GetSiteMembershipInformationCoreTests extends RestTest .getSitesMembershipInformation() .assertThat().entriesListIsEmpty(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - restClient.assertLastError().containsSummary("The entity with id: invalidPersonId was not found"); + restClient.assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidPersonId")); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, @@ -70,7 +71,7 @@ public class GetSiteMembershipInformationCoreTests extends RestTest .getSitesMembershipInformation() .assertThat().entriesListIsEmpty(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - restClient.assertLastError().containsSummary("Only positive values supported for maxItems"); + restClient.assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); restClient.withParams("maxItems=-1") .withCoreAPI() @@ -78,7 +79,7 @@ public class GetSiteMembershipInformationCoreTests extends RestTest .getSitesMembershipInformation() .assertThat().entriesListIsEmpty(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - restClient.assertLastError().containsSummary("Only positive values supported for maxItems"); + restClient.assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); restClient.withParams("maxItems=test") .withCoreAPI() @@ -86,7 +87,7 @@ public class GetSiteMembershipInformationCoreTests extends RestTest .getSitesMembershipInformation() .assertThat().entriesListIsEmpty(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - restClient.assertLastError().containsSummary("Invalid paging parameter maxItems:test"); + restClient.assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "test")); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, @@ -114,7 +115,7 @@ public class GetSiteMembershipInformationCoreTests extends RestTest .getSitesMembershipInformation() .assertThat().entriesListIsEmpty(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - restClient.assertLastError().containsSummary("Negative values not supported for skipCount"); + restClient.assertLastError().containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT); restClient.withParams("skipCount=test") .withCoreAPI() @@ -122,7 +123,7 @@ public class GetSiteMembershipInformationCoreTests extends RestTest .getSitesMembershipInformation() .assertThat().entriesListIsEmpty(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - restClient.assertLastError().containsSummary("Invalid paging parameter skipCount:test"); + restClient.assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "test")); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, From 55f909faa0bf475a22f7df01f33e719daefcd141 Mon Sep 17 00:00:00 2001 From: Bogdan Bocancea Date: Tue, 6 Dec 2016 11:43:21 +0200 Subject: [PATCH 09/23] TAS-2064: add core tests for 'delete /processes/{processId}' request --- .../processes/DeleteProcessCoreTests.java | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessCoreTests.java new file mode 100644 index 000000000..110acf878 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessCoreTests.java @@ -0,0 +1,67 @@ +package org.alfresco.rest.workflow.processes; + +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.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; + +@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) +public class DeleteProcessCoreTests extends RestTest +{ + private UserModel userWhoAddsProcess, assignee; + private RestProcessModel process; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userWhoAddsProcess = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify admin user is able to delete a process started by another user.") + public void deleteProcessByAdminUser() throws Exception + { + process = restClient.authenticateUser(userWhoAddsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.authenticateUser(dataUser.getAdminUser()) + .withWorkflowAPI().usingProcess(process).deleteProcess(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().getProcesses() + .assertThat().entriesListDoesNotContain("id", process.getId()); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify User is not able to delete process with invalid id") + public void deleteProcessWithInvalidId() throws Exception + { + process = restClient.authenticateUser(userWhoAddsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + process.setId("00001"); + restClient.withWorkflowAPI().usingProcess(process).deleteProcess(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "00001")); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify User is not able to delete process with empty id") + public void deleteProcessWithEmptyId() throws Exception + { + process = restClient.authenticateUser(userWhoAddsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + process.setId(""); + restClient.withWorkflowAPI().usingProcess(process).deleteProcess(); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) + .assertLastError().containsSummary(RestErrorModel.DELETE_EMPTY_ARGUMENT); + } +} From 0775dc8b78b1421887603110096608f89673560a Mon Sep 17 00:00:00 2001 From: Bogdan Bocancea Date: Tue, 6 Dec 2016 15:31:11 +0200 Subject: [PATCH 10/23] TAS-2072: add core tests for delete /processes/{processId}/items/{itemId} request. Fix getProcessModelByProcessDefId(String processDefinitionId) from RestProcessModelsCollection --- .../processes/DeleteProcessItemCoreTests.java | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessItemCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessItemCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessItemCoreTests.java new file mode 100644 index 000000000..dfe37b9ad --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessItemCoreTests.java @@ -0,0 +1,83 @@ +package org.alfresco.rest.workflow.processes; + +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.rest.model.RestItemModelsCollection; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.ProcessModel; +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.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) +public class DeleteProcessItemCoreTests extends RestTest +{ + private FileModel document, secondDoc; + private SiteModel siteModel; + private UserModel userWhoStartsTask, assignee; + private RestProcessModel restProcessModel; + private ProcessModel processModel; + private RestItemModelsCollection items; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userWhoStartsTask = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + processModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document) + .createSingleReviewerTaskAndAssignTo(assignee); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process item with invalid id") + public void deleteProcessItemWithInvalidItemId() throws Exception + { + restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .getProcesses().getProcessModelByProcessDefId(processModel.getId()); + secondDoc = dataContent.usingUser(userWhoStartsTask).usingSite(siteModel).createContent(DocumentType.MSWORD); + RestItemModel processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(secondDoc); + processItem.setId("invalid-id"); + restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessItem(processItem); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.PROCESS_ENTITY_NOT_FOUND, "invalid-id")); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process item with empty id") + public void deleteProcessItemWithEmptyItemId() throws Exception + { + restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .getProcesses().getProcessModelByProcessDefId(processModel.getId()); + secondDoc = dataContent.usingUser(userWhoStartsTask).usingSite(siteModel).createContent(DocumentType.MSWORD); + RestItemModel processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(secondDoc); + processItem.setId(""); + restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessItem(processItem); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) + .assertLastError().containsSummary(String.format(RestErrorModel.DELETE_EMPTY_ARGUMENT)); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process item twice") + public void deleteProcessItemTwice() throws Exception + { + restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .getProcesses().getProcessModelByProcessDefId(processModel.getId()); + items = restClient.withWorkflowAPI().usingProcess(restProcessModel).getProcessItems(); + RestItemModel processItem = items.getEntries().get(0); + restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessItem(processItem.onModel()); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessItem(processItem.onModel()); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.PROCESS_ENTITY_NOT_FOUND, processItem.onModel().getId())); + } +} From a481510236b27e4107ebbf59d97508b639ab2bcc Mon Sep 17 00:00:00 2001 From: cagache Date: Tue, 6 Dec 2016 17:17:42 +0200 Subject: [PATCH 11/23] test: added core scenarios for getProcessDefinitionStartFormModel (get /process-definitions/{processDefinitionId}/start-form-model) --- ...cessDefinitionStartFormModelCoreTests.java | 96 +++++++++++++++++++ ...ssDefinitionStartFormModelSanityTests.java | 3 - 2 files changed, 96 insertions(+), 3 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java new file mode 100644 index 000000000..cf00f2fcd --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java @@ -0,0 +1,96 @@ +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.rest.model.RestProcessDefinitionModelsCollection; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +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/6/2016. + */ +@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE }) +public class GetProcessDefinitionStartFormModelCoreTests extends RestTest +{ + private UserModel adminUser, adminTenantUser; + private RestProcessDefinitionModel randomProcessDefinition, returnedProcessDefinition; + private RestProcessDefinitionModelsCollection allProcessDefinitions; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + allProcessDefinitions = restClient.authenticateUser(adminUser).withWorkflowAPI().getAllProcessDefinitions(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.REGRESSION, + description = "Verify any user gets a model of the start form type definition for non-network deployments using REST API and status code is OK (200)") + public void nonNetworkUserGetsStartFormModel() throws Exception + { + UserModel nonNetworkUser = dataUser.createRandomTestUser(); + + randomProcessDefinition = allProcessDefinitions.getOneRandomEntry(); + restClient.authenticateUser(nonNetworkUser).withWorkflowAPI() + .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionStartFormModel() + .assertThat().entriesListIsNotEmpty(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Bug(id = "ALF-20187") + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.REGRESSION, + description = "Verify if get request returns status code 404 when invalid processDefinitionId is used") + public void getStartFormModelUsingInvalidProcessDefinitionId() throws Exception + { + randomProcessDefinition = allProcessDefinitions.getOneRandomEntry(); + 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")); + } + + @Bug(id = "ALF-20187") + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.REGRESSION, + description = "Verify if get request returns status code 404 when empty processDefinitionId is used") + public void getStartFormModelUsingEmptyProcessDefinitionId() throws Exception + { + randomProcessDefinition = allProcessDefinitions.getOneRandomEntry(); + randomProcessDefinition.onModel().setId(""); + + restClient.authenticateUser(adminUser).withWorkflowAPI() + .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionStartFormModel(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.REGRESSION, + description = "Verify Tenant User gets a model of the start form type definition for network deployments using REST API and status code is OK (200)") + @Test(groups = { TestGroup.NETWORKS }) + public void networkUserGetsStartFormModel() 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(); + restClient.authenticateUser(tenantUser).withWorkflowAPI() + .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionStartFormModel() + .assertThat().entriesListIsNotEmpty(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } +} 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 9e4e2c3f4..229a5c8e0 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java @@ -18,9 +18,6 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY }) public class GetProcessDefinitionStartFormModelSanityTests extends RestTest { - @Autowired - private DataUser dataUser; - private UserModel adminUserModel, adminTenantUser; private RestProcessDefinitionModel randomProcessDefinition; From 7f98b3a51cb5bcf39aa6b5659b2e8e03ef70d221 Mon Sep 17 00:00:00 2001 From: cagache Date: Tue, 6 Dec 2016 17:19:42 +0200 Subject: [PATCH 12/23] test: removed variable declaration --- .../GetProcessDefinitionStartFormModelCoreTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 cf00f2fcd..e8a56fcae 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java @@ -20,7 +20,7 @@ import org.testng.annotations.Test; public class GetProcessDefinitionStartFormModelCoreTests extends RestTest { private UserModel adminUser, adminTenantUser; - private RestProcessDefinitionModel randomProcessDefinition, returnedProcessDefinition; + private RestProcessDefinitionModel randomProcessDefinition; private RestProcessDefinitionModelsCollection allProcessDefinitions; @BeforeClass(alwaysRun = true) From 8259b6464efef763ee5f1584cc72f87b45e6ef82 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Wed, 7 Dec 2016 10:33:55 +0200 Subject: [PATCH 13/23] Added core tests for GetProcesses --- .../processes/GetProcessesCoreTests.java | 92 +++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesCoreTests.java new file mode 100644 index 000000000..637b4c72f --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesCoreTests.java @@ -0,0 +1,92 @@ +package org.alfresco.rest.workflow.processes; + +import java.util.List; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.dataprep.CMISUtil.Priority; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestProcessModelsCollection; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.ProcessModel; +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 Cristina Axinte + * + */ +@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) +public class GetProcessesCoreTests extends RestTest +{ + private FileModel document; + private SiteModel siteModel; + private UserModel adminUser, userWhoStartsTask, assignee, adminTenantUser; + private TaskModel task1, task2; + private ProcessModel process3; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userWhoStartsTask = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + task1 = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); + task2 = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(adminUser); + process3 = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createSingleReviewerTaskAndAssignTo(assignee); + } + + @Test(groups = { TestGroup.NETWORKS }) + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify admin gets all processes from same network") + public void getProcessFromSameNetworkUsingAdmin() throws Exception + { + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser); + UserModel tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + UserModel tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); + RestProcessModel process = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, Priority.Normal); + + RestProcessModelsCollection tenantProcesses = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getProcesses(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + tenantProcesses.assertThat().entriesListContains("id", process.getId()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify user gets all processes started by him ordered descending by id") + public void getProcessesOrderedByIdDESC() throws Exception + { + RestProcessModelsCollection processes = restClient.authenticateUser(userWhoStartsTask).withParams("orderBy=id DESC") + .withWorkflowAPI().getProcesses(); + restClient.assertStatusCodeIs(HttpStatus.OK); + processes.assertThat().entriesListIsNotEmpty(); + List processesList = processes.getEntries(); + processesList.get(0).onModel().assertThat().field("id").is(process3.getId()); + processesList.get(1).onModel().assertThat().field("id").is(task2.getNodeRef()); + processesList.get(2).onModel().assertThat().field("id").is(task1.getNodeRef()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify user gets processes that matches a where clause") + public void getProcessesWithWhereClauseAsParameter() throws JsonToModelConversionException, Exception + { + RestProcessModelsCollection processes = restClient.authenticateUser(userWhoStartsTask).where("processDefinitionKey='activitiReview'") + .withWorkflowAPI().getProcesses(); + restClient.assertStatusCodeIs(HttpStatus.OK); + processes.assertThat().entriesListIsNotEmpty().and().entriesListContains("processDefinitionId", "activitiReview:1:8") + .and().entriesListDoesNotContain("processDefinitionId", "activitiAdhoc:1:4"); + } +} From c9cdaa7284dc08bb497a82752406e2af9fd440c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alecsandru=20Prun=C4=83?= Date: Wed, 7 Dec 2016 11:05:53 +0200 Subject: [PATCH 14/23] test: Added DeleteDeploymentCoreTests --- .../DeleteDeploymentCoreTests.java | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentCoreTests.java new file mode 100644 index 000000000..501bfa1ec --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentCoreTests.java @@ -0,0 +1,51 @@ +package org.alfresco.rest.workflow.deployments; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestDeploymentModel; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +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; + +@Test(groups = { TestGroup.REST_API, TestGroup.DEPLOYMENTS, TestGroup.CORE, TestGroup.WORKFLOW }) +public class DeleteDeploymentCoreTests extends RestTest +{ + private UserModel adminUser; + private UserModel userModel; + private RestDeploymentModel deployment; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + } + + @Bug(id = "MNT-16996") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, + description = "Verify deleteDeployment is unsupported for empty deployment id with REST API and status code is 404") + public void deleteDeploymentIsUnsupportedForEmptyId() throws Exception + { + deployment = restClient.authenticateUser(adminUser).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); + deployment.setId(""); + restClient.withWorkflowAPI().usingDeployment(deployment).deleteDeployment(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); + } + + @Bug(id = "MNT-16996") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, + description = "Verify deleteDeployment is forbidden using non admin user or different user than creator with REST API and status code is 403") + public void deleteDeploymentUsingNonAdminUser() throws Exception + { + deployment = restClient.authenticateUser(adminUser).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); + restClient.authenticateUser(userModel).withWorkflowAPI().usingDeployment(deployment).deleteDeployment(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } +} From df390fb876300f1fdeca4590447dbd544324229e Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Wed, 7 Dec 2016 11:07:39 +0200 Subject: [PATCH 15/23] Remove unused imports --- .../alfresco/rest/workflow/processes/GetProcessesCoreTests.java | 1 - 1 file changed, 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesCoreTests.java index 637b4c72f..1459cc2ee 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesCoreTests.java @@ -8,7 +8,6 @@ import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestProcessModelsCollection; -import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.ProcessModel; import org.alfresco.utility.model.SiteModel; From 1d970a3a97fd5a34613aaaac088edd4767859f3b Mon Sep 17 00:00:00 2001 From: Bogdan Bocancea Date: Wed, 7 Dec 2016 11:12:17 +0200 Subject: [PATCH 16/23] TAS-2068: add core tests for 'delete /processes/{processId}/variables/{variableName}' request --- .../DeleteProcessVariableCoreTests.java | 84 +++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableCoreTests.java new file mode 100644 index 000000000..e06514ffc --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableCoreTests.java @@ -0,0 +1,84 @@ +package org.alfresco.rest.workflow.processes; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +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.model.FileModel; +import org.alfresco.utility.model.ProcessModel; +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.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * + * @author bogdan.bocancea + * + */ +@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) +public class DeleteProcessVariableCoreTests extends RestTest +{ + private FileModel document; + private SiteModel siteModel; + private UserModel userWhoStartsTask, assignee; + private RestProcessModel restProcessModel; + private ProcessModel processModel; + private RestProcessVariableModel variableModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userWhoStartsTask = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + processModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document) + .createSingleReviewerTaskAndAssignTo(assignee); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete invalid process variable") + public void deleteInvalidProcessVariable() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("x:InvalidVar"); + restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .getProcesses().getProcessModelByProcessDefId(processModel.getId()); + restClient.withWorkflowAPI().usingProcess(restProcessModel).deleteProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, variableModel.getName())); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete empty process variable") + public void deleteEmptyProcessVariable() throws Exception + { + variableModel = new RestProcessVariableModel("","", "d:text"); + restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .getProcesses().getProcessModelByProcessDefId(processModel.getId()); + restClient.withWorkflowAPI().usingProcess(restProcessModel).deleteProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) + .assertLastError().containsSummary(RestErrorModel.DELETE_EMPTY_ARGUMENT); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process variable twice") + public void deleteProcessVariableTwice() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .getProcesses().getProcessModelByProcessDefId(processModel.getId()); + restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withWorkflowAPI().usingProcess(restProcessModel).deleteProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingProcess(restProcessModel).deleteProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, variableModel.getName())); + } +} From 535da8c547611995a6bcf8ff2e8e616ce6af174b Mon Sep 17 00:00:00 2001 From: cnechifor Date: Wed, 7 Dec 2016 14:32:58 +0200 Subject: [PATCH 17/23] TAS-2042 --- e2e-test/java/org/alfresco/rest/RestTest.java | 3 + .../sites/GetSiteContainersCoreTests.java | 220 ++++++++++++++++++ .../rest/sites/GetSitesCoreTests.java | 2 +- 3 files changed, 224 insertions(+), 1 deletion(-) create mode 100644 e2e-test/java/org/alfresco/rest/sites/GetSiteContainersCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/RestTest.java b/e2e-test/java/org/alfresco/rest/RestTest.java index ed8813179..a7540549d 100644 --- a/e2e-test/java/org/alfresco/rest/RestTest.java +++ b/e2e-test/java/org/alfresco/rest/RestTest.java @@ -50,6 +50,9 @@ public abstract class RestTest extends AbstractTestNGSpringContextTests @Autowired protected DataLink dataLink; + + @Autowired + protected DataDiscussion dataDiscussion; @BeforeClass(alwaysRun = true) public void checkServerHealth() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersCoreTests.java new file mode 100644 index 000000000..65d39c2fd --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersCoreTests.java @@ -0,0 +1,220 @@ +package org.alfresco.rest.sites; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.utility.constants.ContainerName; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +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.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) +public class GetSiteContainersCoreTests extends RestTest +{ + + private UserModel adminUserModel; + private SiteModel siteModel, siteModel1; + private SiteModel moderatedSiteModel, privateSiteModel; + private ListUserWithRoles usersWithRoles; + private ListUserWithRoles usersWithRoles1; + + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + siteModel1 = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + moderatedSiteModel = dataSite.usingUser(adminUserModel).createModeratedRandomSite(); + privateSiteModel = dataSite.usingUser(adminUserModel).createPrivateRandomSite(); + + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + + usersWithRoles1 = dataUser.addUsersWithRolesToSite(siteModel1, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + + dataLink.usingAdmin().usingSite(siteModel1).createRandomLink(); + dataDiscussion.usingAdmin().usingSite(siteModel1).createRandomDiscussion(); + + dataLink.usingAdmin().usingSite(moderatedSiteModel).createRandomLink(); + dataDiscussion.usingAdmin().usingSite(moderatedSiteModel).createRandomDiscussion(); + + dataLink.usingAdmin().usingSite(privateSiteModel).createRandomLink(); + dataDiscussion.usingAdmin().usingSite(privateSiteModel).createRandomDiscussion(); +} + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if get site container request returns status code 200 with valid maxItems parameter") + public void getContainersWithMaxItems() throws Exception + { + restClient.authenticateUser(usersWithRoles1.getOneUserWithRole(UserRole.SiteManager)) + .withParams("maxItems=5") + .withCoreAPI().usingSite(siteModel1).getSiteContainers() + .assertThat().entriesListCountIs(3) + .and().entriesListContains("folderId" ,ContainerName.documentLibrary.toString()) + .and().entriesListContains("folderId", ContainerName.links.toString()) + .and().entriesListContains("folderId", ContainerName.discussions.toString()); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.withParams("maxItems=1") + .withCoreAPI().usingSite(siteModel1).getSiteContainers() + .assertThat().entriesListCountIs(1); + + restClient.withParams("maxItems=3") + .withCoreAPI().usingSite(siteModel).getSiteContainers() + .assertThat().entriesListCountIs(1) + .and().entriesListContains("folderId", ContainerName.documentLibrary.toString()); + restClient.assertStatusCodeIs(HttpStatus.OK); + + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if get site container request returns status code 400 when invalid maxItems parameter is used") + public void getContainersWithMaxItemsZero () throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withParams("maxItems=0") + .withCoreAPI().usingSite(siteModel).getSiteContainers(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary("Only positive values supported for maxItems"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if get site container request returns status code 400 when invalid maxItems parameter is used") + public void getContainersWithMaxItemsCharacter () throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withParams("maxItems=test") + .withCoreAPI().usingSite(siteModel).getSiteContainers(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "test")); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if get site container request returns status code 400 when invalid maxItems parameter is used") + public void getContainersWithMaxItemsMultipleZero () throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withParams("maxItems=000007") + .withCoreAPI().usingSite(siteModel1).getSiteContainers() + .assertThat().entriesListCountIs(3); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if get site container request returns status code 200 when valid skipCount parameter is used") + public void getSitesWithValidSkipCount() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withParams("skipCount=1") + .withCoreAPI().usingSite(siteModel).getSiteContainers() + .assertThat().entriesListCountIs(0); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("skipCount=1") + .withCoreAPI().usingSite(siteModel1).getSiteContainers() + .assertThat().entriesListCountIs(2); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withParams("skipCount=2") + .withCoreAPI().usingSite(siteModel1).getSiteContainers() + .assertThat().entriesListCountIs(1); + restClient.assertStatusCodeIs(HttpStatus.OK); + + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("skipCount=0") + .withCoreAPI().usingSite(siteModel1).getSiteContainers() + .assertThat().entriesListCountIs(3); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if get site container request returns status code 400 when invalid skipCount parameter is used") + public void getSitesWithSkipCountCharacter() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("skipCount=abc") + .withCoreAPI().usingSite(siteModel).getSiteContainers(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc")); + } + + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if get site container request returns status code 400 when invalid skipCount parameter is used") + public void getSitesWithSkipCountZero() throws Exception + { + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if get site container request returns status code 400 when invalid skipCount parameter is used") + public void getSitesWithSkipCountMultipleZero() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("skipCount=00002") + .withCoreAPI().usingSite(siteModel1).getSiteContainers() + .assertThat().entriesListCountIs(1); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if get site container request returns status code 400 when invalid skipCount parameter is used") + public void getSiteContainerWithNonExistentSite() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingSite("NonExistentSiteId").getSiteContainers(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "NonExistentSiteId")); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify get site container request resturns status 200 for private site") + public void getSiteContainerForPrivateSite() throws Exception + { + restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingSite(privateSiteModel).getSiteContainers() + .assertThat().entriesListCountIs(3); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify get site container request resturns status 200 for moderated site") + public void getSiteContainerForModeratedSite() throws Exception + { + restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingSite(moderatedSiteModel).getSiteContainers() + .assertThat().entriesListCountIs(3); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify get site container request resturns status 200 for several container") + public void getSiteContainerForSeveralItems() throws Exception + { + restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingSite(siteModel1).getSiteContainers() + .assertThat().entriesListCountIs(3) + .and().entriesListContains("folderId" ,ContainerName.documentLibrary.toString()) + .and().entriesListContains("folderId", ContainerName.links.toString()) + .and().entriesListContains("folderId", ContainerName.discussions.toString()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify get site container request resturns status 200 for one container") + public void getSiteContainerWithOneItem() throws Exception + { + restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingSite(siteModel).getSiteContainers() + .assertThat().entriesListCountIs(1) + .and().entriesListContains("folderId" ,ContainerName.documentLibrary.toString()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } +} diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java index bb52a0bdf..cc603a473 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java @@ -50,7 +50,7 @@ public class GetSitesCoreTests extends RestTest description= "Verify if get sites request returns status code 400 when invalid maxItems parameter is used") public void getSitesWithInvalidMaxItems() throws Exception { - restClient.authenticateUser(regularUser).withParams("maxItems=0") + restClient.authenticateUser(regularUser).withParams("maxItems=0=09") .withCoreAPI().getSites(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) .assertLastError().containsSummary("Only positive values supported for maxItems"); From 7a6035b002b6d08ec57a807d957914f9430e4397 Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 7 Dec 2016 14:36:05 +0200 Subject: [PATCH 18/23] TAS-2057: add core tests for getDeployment (get /deployments/{deploymentId}) --- .../deployments/GetDeploymentCoreTests.java | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentCoreTests.java new file mode 100644 index 000000000..34fbcc70e --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentCoreTests.java @@ -0,0 +1,73 @@ +package org.alfresco.rest.workflow.deployments; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestDeploymentModel; +import org.alfresco.rest.model.RestErrorModel; +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/7/2016. + */ +@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.CORE }) +public class GetDeploymentCoreTests extends RestTest +{ + private UserModel adminUser, adminTenantUser; + private RestDeploymentModel expectedDeployment, actualDeployment; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, + executionType = ExecutionType.REGRESSION, description = "Verify if get deployment request returns status code 404 when invalid deploymentId is used.") + public void getNonNetworkDeploymentUsingInvalidDeploymentId() throws Exception + { + expectedDeployment = restClient.authenticateUser(adminUser).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); + expectedDeployment.setId("invalidId"); + + restClient.withWorkflowAPI().usingDeployment(expectedDeployment).getDeployment(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidId")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, + executionType = ExecutionType.REGRESSION, description = "Verify if network admin user gets a network deployment using REST API and status code is OK (200)") + @Test(groups = { TestGroup.NETWORKS }) + public void adminGetsNetworkDeploymentWithSuccess() throws Exception + { + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser) + .usingTenant().createTenant(adminTenantUser); + + expectedDeployment = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); + actualDeployment = restClient.withWorkflowAPI().usingDeployment(expectedDeployment).getDeployment(); + restClient.assertStatusCodeIs(HttpStatus.OK); + actualDeployment.assertThat().field("deployedAt").isNotEmpty() + .and().field("name").is(expectedDeployment.getName()) + .and().field("id").equals(expectedDeployment.getId()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, + executionType = ExecutionType.REGRESSION, description = "Verify non admin user is forbidden to get a network deployment using REST API (403)") + @Test(groups = { TestGroup.NETWORKS }) + public void nonAdminUserIsForbiddenToGetNetworkDeployment() throws Exception + { + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser) + .usingTenant().createTenant(adminTenantUser); + expectedDeployment = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); + UserModel tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + + restClient.authenticateUser(tenantUser).withWorkflowAPI().usingDeployment(expectedDeployment).getDeployment(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } +} From 6d7cd09f66a5075ad9505ecb5443e4a59c0a7dfe Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 7 Dec 2016 15:01:01 +0200 Subject: [PATCH 19/23] test: renamed variables --- .../sites/GetSiteContainersCoreTests.java | 117 ++++++++---------- 1 file changed, 53 insertions(+), 64 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersCoreTests.java index 65d39c2fd..00ceb0d2d 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersCoreTests.java @@ -17,47 +17,46 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) public class GetSiteContainersCoreTests extends RestTest { - private UserModel adminUserModel; - private SiteModel siteModel, siteModel1; + private SiteModel publicSiteModel, publicSiteWithContainers; private SiteModel moderatedSiteModel, privateSiteModel; - private ListUserWithRoles usersWithRoles; - private ListUserWithRoles usersWithRoles1; - + private ListUserWithRoles publicSiteUsers; + private ListUserWithRoles publicSiteWithContainersUsers; @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception { adminUserModel = dataUser.getAdminUser(); - - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - siteModel1 = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - moderatedSiteModel = dataSite.usingUser(adminUserModel).createModeratedRandomSite(); - privateSiteModel = dataSite.usingUser(adminUserModel).createPrivateRandomSite(); - - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - - usersWithRoles1 = dataUser.addUsersWithRolesToSite(siteModel1, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - - dataLink.usingAdmin().usingSite(siteModel1).createRandomLink(); - dataDiscussion.usingAdmin().usingSite(siteModel1).createRandomDiscussion(); - + + publicSiteModel = dataSite.usingAdmin().createPublicRandomSite(); + publicSiteWithContainers = dataSite.usingAdmin().createPublicRandomSite(); + moderatedSiteModel = dataSite.usingAdmin().createModeratedRandomSite(); + privateSiteModel = dataSite.usingAdmin().createPrivateRandomSite(); + + publicSiteUsers = dataUser + .addUsersWithRolesToSite(publicSiteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + + publicSiteWithContainersUsers = dataUser + .addUsersWithRolesToSite(publicSiteWithContainers, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + + dataLink.usingAdmin().usingSite(publicSiteWithContainers).createRandomLink(); + dataDiscussion.usingAdmin().usingSite(publicSiteWithContainers).createRandomDiscussion(); + dataLink.usingAdmin().usingSite(moderatedSiteModel).createRandomLink(); dataDiscussion.usingAdmin().usingSite(moderatedSiteModel).createRandomDiscussion(); - + dataLink.usingAdmin().usingSite(privateSiteModel).createRandomLink(); dataDiscussion.usingAdmin().usingSite(privateSiteModel).createRandomDiscussion(); } @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if get site container request returns status code 200 with valid maxItems parameter") - public void getContainersWithMaxItems() throws Exception + public void getContainersWithValidMaxItems() throws Exception { - restClient.authenticateUser(usersWithRoles1.getOneUserWithRole(UserRole.SiteManager)) + restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteManager)) .withParams("maxItems=5") - .withCoreAPI().usingSite(siteModel1).getSiteContainers() + .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() .assertThat().entriesListCountIs(3) .and().entriesListContains("folderId" ,ContainerName.documentLibrary.toString()) .and().entriesListContains("folderId", ContainerName.links.toString()) @@ -65,24 +64,23 @@ public class GetSiteContainersCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); restClient.withParams("maxItems=1") - .withCoreAPI().usingSite(siteModel1).getSiteContainers() + .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() .assertThat().entriesListCountIs(1); restClient.withParams("maxItems=3") - .withCoreAPI().usingSite(siteModel).getSiteContainers() + .withCoreAPI().usingSite(publicSiteModel).getSiteContainers() .assertThat().entriesListCountIs(1) .and().entriesListContains("folderId", ContainerName.documentLibrary.toString()); restClient.assertStatusCodeIs(HttpStatus.OK); - } @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if get site container request returns status code 400 when invalid maxItems parameter is used") public void getContainersWithMaxItemsZero () throws Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteManager)) .withParams("maxItems=0") - .withCoreAPI().usingSite(siteModel).getSiteContainers(); + .withCoreAPI().usingSite(publicSiteModel).getSiteContainers(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) .assertLastError().containsSummary("Only positive values supported for maxItems"); } @@ -91,20 +89,20 @@ public class GetSiteContainersCoreTests extends RestTest description= "Verify if get site container request returns status code 400 when invalid maxItems parameter is used") public void getContainersWithMaxItemsCharacter () throws Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)) .withParams("maxItems=test") - .withCoreAPI().usingSite(siteModel).getSiteContainers(); + .withCoreAPI().usingSite(publicSiteModel).getSiteContainers(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "test")); } @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get site container request returns status code 400 when invalid maxItems parameter is used") + description= "Verify if get site container request returns status code 200 when maxItems parameter starts with multiple zero") public void getContainersWithMaxItemsMultipleZero () throws Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteCollaborator)) .withParams("maxItems=000007") - .withCoreAPI().usingSite(siteModel1).getSiteContainers() + .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() .assertThat().entriesListCountIs(3); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -113,52 +111,43 @@ public class GetSiteContainersCoreTests extends RestTest description= "Verify if get site container request returns status code 200 when valid skipCount parameter is used") public void getSitesWithValidSkipCount() throws Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withParams("skipCount=1") - .withCoreAPI().usingSite(siteModel).getSiteContainers() + restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteManager)).withParams("skipCount=1") + .withCoreAPI().usingSite(publicSiteModel).getSiteContainers() .assertThat().entriesListCountIs(0); restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("skipCount=1") - .withCoreAPI().usingSite(siteModel1).getSiteContainers() + restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("skipCount=1") + .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() .assertThat().entriesListCountIs(2); restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withParams("skipCount=2") - .withCoreAPI().usingSite(siteModel1).getSiteContainers() + restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteConsumer)).withParams("skipCount=2") + .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() .assertThat().entriesListCountIs(1); restClient.assertStatusCodeIs(HttpStatus.OK); - - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("skipCount=0") - .withCoreAPI().usingSite(siteModel1).getSiteContainers() + + restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("skipCount=0") + .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() .assertThat().entriesListCountIs(3); restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if get site container request returns status code 400 when invalid skipCount parameter is used") public void getSitesWithSkipCountCharacter() throws Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("skipCount=abc") - .withCoreAPI().usingSite(siteModel).getSiteContainers(); + restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("skipCount=abc") + .withCoreAPI().usingSite(publicSiteModel).getSiteContainers(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc")); } - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get site container request returns status code 400 when invalid skipCount parameter is used") - public void getSitesWithSkipCountZero() throws Exception - { - } - - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get site container request returns status code 400 when invalid skipCount parameter is used") + description= "Verify if get site container request returns status code 200 when skipCount parameter starts with multiple zero") public void getSitesWithSkipCountMultipleZero() throws Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("skipCount=00002") - .withCoreAPI().usingSite(siteModel1).getSiteContainers() + restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("skipCount=00002") + .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() .assertThat().entriesListCountIs(1); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -168,14 +157,14 @@ public class GetSiteContainersCoreTests extends RestTest description= "Verify if get site container request returns status code 400 when invalid skipCount parameter is used") public void getSiteContainerWithNonExistentSite() throws Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)) .withCoreAPI().usingSite("NonExistentSiteId").getSiteContainers(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "NonExistentSiteId")); } @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify get site container request resturns status 200 for private site") + description= "Verify get site container request returns status 200 for private site") public void getSiteContainerForPrivateSite() throws Exception { restClient.authenticateUser(adminUserModel) @@ -185,7 +174,7 @@ public class GetSiteContainersCoreTests extends RestTest } @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify get site container request resturns status 200 for moderated site") + description= "Verify get site container request returns status 200 for moderated site") public void getSiteContainerForModeratedSite() throws Exception { restClient.authenticateUser(adminUserModel) @@ -195,11 +184,11 @@ public class GetSiteContainersCoreTests extends RestTest } @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify get site container request resturns status 200 for several container") + description= "Verify get site container request returns status 200 for several containers") public void getSiteContainerForSeveralItems() throws Exception { restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingSite(siteModel1).getSiteContainers() + .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() .assertThat().entriesListCountIs(3) .and().entriesListContains("folderId" ,ContainerName.documentLibrary.toString()) .and().entriesListContains("folderId", ContainerName.links.toString()) @@ -208,11 +197,11 @@ public class GetSiteContainersCoreTests extends RestTest } @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify get site container request resturns status 200 for one container") + description= "Verify get site container request returns status 200 for one container") public void getSiteContainerWithOneItem() throws Exception { restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingSite(siteModel).getSiteContainers() + .withCoreAPI().usingSite(publicSiteModel).getSiteContainers() .assertThat().entriesListCountIs(1) .and().entriesListContains("folderId" ,ContainerName.documentLibrary.toString()); restClient.assertStatusCodeIs(HttpStatus.OK); From dea4820a56141d543895d15dc62419cc2532c126 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Wed, 7 Dec 2016 16:22:37 +0200 Subject: [PATCH 20/23] test: added core tests for AddProcess --- .../processes/AddProcessCoreTests.java | 122 ++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessCoreTests.java new file mode 100644 index 000000000..548ab78d2 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessCoreTests.java @@ -0,0 +1,122 @@ +package org.alfresco.rest.workflow.processes; + +import org.alfresco.dataprep.CMISUtil.Priority; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestProcessModelsCollection; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +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.Test; + +/** + * + * @author Cristina Axinte + * + */ +@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) +public class AddProcessCoreTests extends RestTest +{ + private UserModel assignee, adminUser; + private RestProcessModel addedProcess; + private RestProcessModelsCollection processes; + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, + executionType = ExecutionType.REGRESSION, description = "Verify non network admin is able to start new process using REST API and status code is OK (200)") + public void nonNetworkAdminUserStartsNewProcess() throws JsonToModelConversionException, Exception + { + adminUser = dataUser.getAdminUser(); + assignee = dataUser.createRandomTestUser(); + + addedProcess = restClient.authenticateUser(adminUser).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + addedProcess.assertThat().field("id").is(addedProcess.getId()) + .and().field("startUserId").is(adminUser.getUsername()); + + processes = restClient.withWorkflowAPI().getProcesses(); + restClient.assertStatusCodeIs(HttpStatus.OK); + processes.assertThat().entriesListContains("id", addedProcess.getId()) + .assertThat().entriesListContains("processDefinitionId", "activitiAdhoc:1:4") + .assertThat().entriesListContains("startUserId", adminUser.getUsername()) + .assertThat().entriesListContains("startActivityId", "start") + .assertThat().entriesListContains("completed", "false") + .assertThat().entriesListContains("processDefinitionKey", "activitiAdhoc"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, + executionType = ExecutionType.REGRESSION, description = "Verify start new process with empty request body using REST API returns status code is Bad Request (400)") + public void startNewProcessWithEmptyProcessBody() throws JsonToModelConversionException, Exception + { + adminUser = dataUser.getAdminUser(); + assignee = dataUser.createRandomTestUser(); + + restClient.authenticateUser(adminUser).withWorkflowAPI(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "", "processes"); + restClient.processModel(RestProcessModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.NO_CONTENT, "No content to map to Object due to end of input")); + } + + @Bug(id = "ACE-5671") + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, + executionType = ExecutionType.REGRESSION, description = "Verify start new process with invalid request body using REST API returns status code is Bad Request (400)") + public void startNewProcessWithInvalidProcessDefInProcessBody() throws JsonToModelConversionException, Exception + { + adminUser = dataUser.getAdminUser(); + assignee = dataUser.createRandomTestUser(); + + restClient.authenticateUser(adminUser).withWorkflowAPI(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"processDefinitionKey\":\"activitiAdhoc\"}", "processes"); + restClient.processModel(RestProcessModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, + executionType = ExecutionType.REGRESSION, description = "Verify start new process with invalid request body using REST API returns status code is Bad Request (400)") + public void startNewProcessWithInvalidVariablesInProcessBody1() throws JsonToModelConversionException, Exception + { + adminUser = dataUser.getAdminUser(); + assignee = dataUser.createRandomTestUser(); + + restClient.authenticateUser(adminUser).withWorkflowAPI(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"variables\":{\"bpm_sendEMailNotifications\":false}}", "processes"); + restClient.processModel(RestProcessModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format("Either processDefinitionId or processDefinitionKey is required")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, + executionType = ExecutionType.REGRESSION, description = "Verify start new process with invalid request body using REST API returns status code is Bad Request (400)") + public void startNewProcessWithInvalidVariablesInProcessBody2() throws JsonToModelConversionException, Exception + { + adminUser = dataUser.getAdminUser(); + assignee = dataUser.createRandomTestUser(); + + restClient.authenticateUser(adminUser).withWorkflowAPI(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"variables\":{\"bpm_assignee\":\"admin\"}}", "processes"); + restClient.processModel(RestProcessModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format("Either processDefinitionId or processDefinitionKey is required")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, + executionType = ExecutionType.REGRESSION, description = "Verify start new process with invalid request body using REST API returns status code is Bad Request (400)") + public void startNewProcessWithInvalidVariablesInProcessBody3() throws JsonToModelConversionException, Exception + { + adminUser = dataUser.getAdminUser(); + assignee = dataUser.createRandomTestUser(); + + restClient.authenticateUser(adminUser).withWorkflowAPI(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"variables\":{\"bpm_workflowPriority\":2}}", "processes"); + restClient.processModel(RestProcessModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format("Either processDefinitionId or processDefinitionKey is required")); + } +} From 4925c3410f7e108389de110f19ebbb9495e50bdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alecsandru=20Prun=C4=83?= Date: Wed, 7 Dec 2016 16:31:20 +0200 Subject: [PATCH 21/23] test: Removed redundant String.format from AddProcessCoreTests --- .../rest/workflow/processes/AddProcessCoreTests.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessCoreTests.java index 548ab78d2..676741b11 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessCoreTests.java @@ -89,7 +89,7 @@ public class AddProcessCoreTests extends RestTest RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"variables\":{\"bpm_sendEMailNotifications\":false}}", "processes"); restClient.processModel(RestProcessModel.class, request); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format("Either processDefinitionId or processDefinitionKey is required")); + .assertLastError().containsSummary("Either processDefinitionId or processDefinitionKey is required"); } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, @@ -103,7 +103,7 @@ public class AddProcessCoreTests extends RestTest RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"variables\":{\"bpm_assignee\":\"admin\"}}", "processes"); restClient.processModel(RestProcessModel.class, request); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format("Either processDefinitionId or processDefinitionKey is required")); + .assertLastError().containsSummary("Either processDefinitionId or processDefinitionKey is required"); } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, @@ -117,6 +117,6 @@ public class AddProcessCoreTests extends RestTest RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"variables\":{\"bpm_workflowPriority\":2}}", "processes"); restClient.processModel(RestProcessModel.class, request); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format("Either processDefinitionId or processDefinitionKey is required")); + .assertLastError().containsSummary("Either processDefinitionId or processDefinitionKey is required"); } } From 355084a3b8ca9a78e6ec211f97f606a2f75c8f39 Mon Sep 17 00:00:00 2001 From: Bogdan Bocancea Date: Wed, 7 Dec 2016 16:56:03 +0200 Subject: [PATCH 22/23] TAS-2077: add core tests for get '/tasks/{taskId}/task-form-model' request --- .../tasks/GetTaskFormModelCoreTests.java | 101 ++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelCoreTests.java new file mode 100644 index 000000000..479789cff --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelCoreTests.java @@ -0,0 +1,101 @@ +package org.alfresco.rest.workflow.tasks; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestFormModelsCollection; +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 + * + */ +@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) +public class GetTaskFormModelCoreTests extends RestTest +{ + UserModel userModel; + SiteModel siteModel; + FileModel fileModel; + TaskModel taskModel; + RestFormModelsCollection returnedCollection; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.REGRESSION, + description = "Verify that non involved user in task cannot get form models with Rest API and response is FORBIDDEN (403)") + public void nonInvolvedUserCannotGetTaskFormModels() throws Exception + { + taskModel = dataWorkflow.usingUser(userModel) + .usingSite(siteModel) + .usingResource(fileModel).createNewTaskAndAssignTo(userModel); + UserModel nonInvolvedUser = dataUser.createRandomTestUser(); + restClient.authenticateUser(nonInvolvedUser); + restClient.withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.REGRESSION, + description = "Verify user involved in task cannot get task form models with invalid task id") + public void getTaskFormModelsInvalidTaskId() throws Exception + { + taskModel = dataWorkflow.usingUser(userModel) + .usingSite(siteModel) + .usingResource(fileModel).createNewTaskAndAssignTo(userModel); + taskModel.setId("0000"); + restClient.authenticateUser(userModel); + restClient.withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "0000")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.REGRESSION, + description = "Verify user involved in task cannot get task form models with invalid task id") + public void getTaskFormModelsEmptyTaskId() throws Exception + { + taskModel = dataWorkflow.usingUser(userModel) + .usingSite(siteModel) + .usingResource(fileModel).createNewTaskAndAssignTo(userModel); + taskModel.setId(""); + restClient.authenticateUser(userModel); + restClient.withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.REGRESSION, + description = "Verify user involved in task cannot get completed task form models") + public void getTaskFormModelsForCompletedTask() throws Exception + { + UserModel assignedUser = dataUser.createRandomTestUser(); + taskModel = dataWorkflow.usingUser(userModel) + .usingSite(siteModel) + .usingResource(fileModel).createNewTaskAndAssignTo(assignedUser); + dataWorkflow.usingUser(assignedUser).taskDone(taskModel); + dataWorkflow.usingUser(userModel).taskDone(taskModel); + restClient.authenticateUser(userModel); + returnedCollection = restClient.withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat().entriesListIsNotEmpty(); + } +} \ No newline at end of file From b887a6fcff1725141cc09a0aadc66cdd16e69dc5 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Wed, 7 Dec 2016 17:18:57 +0200 Subject: [PATCH 23/23] Merge master into TAS-2039 --- .../alfresco/rest/ratings/GetRatingCoreTests.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingCoreTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingCoreTests.java index 6cbef9d9e..38c120997 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/GetRatingCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/GetRatingCoreTests.java @@ -1,12 +1,11 @@ package org.alfresco.rest.ratings; -import org.alfresco.dataprep.CMISUtil; 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.RestRatingModel; import org.alfresco.utility.exception.DataPreparationException; -import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; @@ -17,7 +16,6 @@ import org.alfresco.utility.testrail.annotation.TestRail; import org.apache.commons.lang.RandomStringUtils; import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; -import org.testng.Assert; import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -42,7 +40,7 @@ public class GetRatingCoreTests extends RestTest @BeforeMethod(alwaysRun = true) public void setUp() throws DataPreparationException, Exception { - document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); + document = dataContent.usingSite(siteModel).usingAdmin().createContent(DocumentType.TEXT_PLAIN); } @TestRail(section = { TestGroup.REST_API, @@ -52,7 +50,7 @@ public class GetRatingCoreTests extends RestTest restClient.authenticateUser(adminUserModel).withCoreAPI(); RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "nodes/{nodeId}/ratings/{ratingId}", document.getNodeRef(), "invalid ratingId"); restClient.processModel(RestRatingModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("invalid ratingId"); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_RATING, "invalid ratingId")); } @TestRail(section = { TestGroup.REST_API, @@ -63,7 +61,7 @@ public class GetRatingCoreTests extends RestTest returnedRatingModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getFiveStarRating(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, document.getNodeRef())); + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, document.getNodeRef())); } @TestRail(section = { TestGroup.REST_API, @@ -142,4 +140,4 @@ public class GetRatingCoreTests extends RestTest returnedRatingModel.getAggregate().assertThat().field("numberOfRatings").is("0"); } -} +} \ No newline at end of file