diff --git a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/tags/GetTagTests.java b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/tags/GetTagTests.java index 9e5661816b..944bbd6d2b 100644 --- a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/tags/GetTagTests.java +++ b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/tags/GetTagTests.java @@ -10,10 +10,20 @@ import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; import org.testng.annotations.Test; +import static org.alfresco.utility.data.RandomData.getRandomName; +import static org.alfresco.utility.report.log.Step.STEP; +import static org.springframework.http.HttpStatus.CREATED; +import static org.springframework.http.HttpStatus.OK; + @Test(groups = {TestGroup.REQUIRE_SOLR}) public class GetTagTests extends TagsDataPrep { + private static final String FIELD_ID = "id"; + private static final String FIELD_TAG = "tag"; + private static final String FIELD_COUNT = "count"; + private static final String TAG_NAME_PREFIX = "tag-name"; + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify admin user gets tag using REST API and status code is OK (200)") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) public void adminIsAbleToGetTag() throws Exception @@ -128,4 +138,46 @@ public class GetTagTests extends TagsDataPrep .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) .stackTraceIs(RestErrorModel.STACKTRACE); } + + /** + * Verify if count field is present and with value 0 for searched tag. + */ + + @Test(groups = {TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION}) + public void testGetTag_includingCount() { + STEP("Create single tag as admin"); + final RestTagModel tagModel = createTagModelWithName(getRandomName(TAG_NAME_PREFIX).toLowerCase()); + final RestTagModel createdTag = restClient.authenticateUser(adminUserModel).withCoreAPI().createSingleTag(tagModel); + + restClient.assertStatusCodeIs(CREATED); + + STEP("Get a single tag, including count and verify if it is 0"); + final RestTagModel searchedTag = restClient.withCoreAPI().include(FIELD_COUNT).getTag(createdTag); + + restClient.assertStatusCodeIs(OK); + searchedTag.assertThat().field(FIELD_TAG).is(tagModel.getTag()) + .assertThat().field(FIELD_ID).isNotEmpty() + .assertThat().field(FIELD_COUNT).is(0); + } + + /** + * Verify if count field is not present for searched tag. + */ + + @Test(groups = {TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION}) + public void testGetTag_notIncludingCount() { + STEP("Create single tag as admin"); + final RestTagModel tagModel = createTagModelWithName(getRandomName(TAG_NAME_PREFIX).toLowerCase()); + final RestTagModel createdTag = restClient.authenticateUser(adminUserModel).withCoreAPI().createSingleTag(tagModel); + + restClient.assertStatusCodeIs(CREATED); + + STEP("Get a single tag, not including count and verify if it is not present in the response"); + final RestTagModel searchedTag = restClient.withCoreAPI().getTag(createdTag); + + restClient.assertStatusCodeIs(OK); + searchedTag.assertThat().field(FIELD_TAG).is(tagModel.getTag()) + .assertThat().field(FIELD_ID).isNotEmpty() + .assertThat().field(FIELD_COUNT).isNull(); + } } \ No newline at end of file diff --git a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/tags/GetTagsTests.java b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/tags/GetTagsTests.java index 20b8e41488..b71b42613e 100644 --- a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/tags/GetTagsTests.java +++ b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/tags/GetTagsTests.java @@ -237,65 +237,17 @@ public class GetTagsTests extends TagsDataPrep .and().entriesListDoesNotContain("tag", removedTag.toLowerCase()); } - /** - * Verify if count field is present and with value 0 for searched tag. - */ - - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void testGetTag_includingCount() - { - STEP("Create single tag as admin including count and verify if it is 0"); - final RestTagModel tagModel = createTagModelWithName(getRandomName(TAG_NAME_PREFIX).toLowerCase()); - final RestTagModel createdTag = restClient.authenticateUser(adminUserModel).withCoreAPI().include(FIELD_COUNT).createSingleTag(tagModel); - - restClient.assertStatusCodeIs(CREATED); - - STEP("Get a single tag, including count and verify if it is 0"); - final RestTagModel searchedTag = restClient.withCoreAPI().include(FIELD_COUNT).getTag(createdTag); - restClient.assertStatusCodeIs(OK); - searchedTag.assertThat().field(FIELD_TAG).is(tagModel.getTag()) - .assertThat().field(FIELD_ID).isNotEmpty() - .assertThat().field(FIELD_COUNT).is(0); - } - - /** - * Verify if count field is not present for searched tag. - */ - - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void testGetTag_notIncludingCount() - { - STEP("Create single tag as admin including count and verify if it is 0"); - final RestTagModel tagModel = createTagModelWithName(getRandomName(TAG_NAME_PREFIX).toLowerCase()); - final RestTagModel createdTag = restClient.authenticateUser(adminUserModel).withCoreAPI().include(FIELD_COUNT).createSingleTag(tagModel); - - restClient.assertStatusCodeIs(CREATED); - - STEP("Get a single tag, not including count and verify if it is not present in the response"); - final RestTagModel searchedTag = restClient.withCoreAPI().getTag(createdTag); - restClient.assertStatusCodeIs(OK); - searchedTag.assertThat().field(FIELD_TAG).is(tagModel.getTag()) - .assertThat().field(FIELD_ID).isNotEmpty() - .assertThat().field(FIELD_COUNT).isNull(); - } - /** * Verify if count field is present for searched tags. */ - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void testGetTags_includingCount() - { - STEP("Create single tag as admin including count and verify if it is 0"); - final RestTagModel tagModel = createTagModelWithName(getRandomName(TAG_NAME_PREFIX).toLowerCase()); - final RestTagModel createdTag = restClient.authenticateUser(adminUserModel).withCoreAPI().include(FIELD_COUNT).createSingleTag(tagModel); - - restClient.assertStatusCodeIs(CREATED); + @Test(groups = {TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION}) + public void testGetTags_includingCount() { STEP("Get tags including count and verify if it is present int the response"); final RestTagModelsCollection searchedTags = restClient.withCoreAPI().include(FIELD_COUNT).getTags(); - restClient.assertStatusCodeIs(OK); + restClient.assertStatusCodeIs(OK); searchedTags.assertThat().entriesListIsNotEmpty() .assertThat().entriesListContains(FIELD_COUNT) .assertThat().entriesListContains(FIELD_TAG) @@ -306,23 +258,16 @@ public class GetTagsTests extends TagsDataPrep * Verify if count field is not present for searched tags. */ - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void testGetTags_notIncludingCount() - { - STEP("Create single tag as admin including count and verify if it is 0"); - final RestTagModel tagModel = createTagModelWithName(getRandomName(TAG_NAME_PREFIX).toLowerCase()); - final RestTagModel createdTag = restClient.authenticateUser(adminUserModel).withCoreAPI().include(FIELD_COUNT).createSingleTag(tagModel); - - restClient.assertStatusCodeIs(CREATED); + @Test(groups = {TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION}) + public void testGetTags_notIncludingCount() { STEP("Get tags, not including count and verify if it is not in the response"); final RestTagModelsCollection searchedTags = restClient.withCoreAPI().getTags(); - restClient.assertStatusCodeIs(OK); + restClient.assertStatusCodeIs(OK); searchedTags.assertThat().entriesListIsNotEmpty() .assertThat().entriesListDoesNotContain(FIELD_COUNT) - .assertThat().entriesListContains(FIELD_TAG, tagModel.getTag()) + .assertThat().entriesListContains(FIELD_TAG) .assertThat().entriesListContains(FIELD_ID); } - }