From 70097bfc27ce01f9c12d171836d8cd8a68fa6bc6 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Tue, 29 Nov 2016 11:46:11 +0200 Subject: [PATCH] CORE-REST API: getTag (get /tags/{tagId}) --- .../alfresco/rest/tags/GetTagCoreTests.java | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/tags/GetTagCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagCoreTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagCoreTests.java new file mode 100644 index 000000000..73d4fed78 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagCoreTests.java @@ -0,0 +1,71 @@ +package org.alfresco.rest.tags; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestTagModel; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.model.ErrorModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.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 GetTagCoreTests extends RestTest +{ + private UserModel adminUserModel; + private SiteModel siteModel; + private FileModel document; + private String tagValue; + private RestTagModel tag; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + } + + @BeforeMethod + public void setUp() throws Exception { + tagValue = RandomData.getRandomName("tag"); + restClient.authenticateUser(adminUserModel); + tag = restClient.withCoreAPI().usingResource(document).addTag(tagValue); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that if tag id is invalid status code returned is 400") + public void invalidTagIdTest() throws JsonToModelConversionException, Exception + { + tag.setId("random_tag_value"); + restClient.withCoreAPI().getTag(tag); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, "random_tag_value")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Retrieve and validate the id of a tag added to a file") + public void validateTagIdTest() throws JsonToModelConversionException, Exception + { + RestTagModel returnedTag = restClient.authenticateUser(adminUserModel).withCoreAPI().getTag(tag); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedTag.assertThat().field("id").is(tag.getId()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Retrieve and validate the name of a tag added to a file") + public void validateTagNameTest() throws JsonToModelConversionException, Exception + { + RestTagModel returnedTag = restClient.authenticateUser(adminUserModel).withCoreAPI().getTag(tag); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedTag.assertThat().field("tag").is(tagValue.toLowerCase()); + } + +} \ No newline at end of file