diff --git a/amps/ags/pom.xml b/amps/ags/pom.xml index 87945c0a54..a3a35b62a4 100644 --- a/amps/ags/pom.xml +++ b/amps/ags/pom.xml @@ -7,7 +7,7 @@ org.alfresco alfresco-community-repo-amps - 20.119-SNAPSHOT + 20.120-SNAPSHOT diff --git a/amps/ags/rm-automation/pom.xml b/amps/ags/rm-automation/pom.xml index 9647cf1c24..d9d3c91e03 100644 --- a/amps/ags/rm-automation/pom.xml +++ b/amps/ags/rm-automation/pom.xml @@ -7,7 +7,7 @@ org.alfresco alfresco-governance-services-community-parent - 20.119-SNAPSHOT + 20.120-SNAPSHOT diff --git a/amps/ags/rm-automation/rm-automation-community-rest-api/pom.xml b/amps/ags/rm-automation/rm-automation-community-rest-api/pom.xml index 43d90a7770..e9254e28e9 100644 --- a/amps/ags/rm-automation/rm-automation-community-rest-api/pom.xml +++ b/amps/ags/rm-automation/rm-automation-community-rest-api/pom.xml @@ -7,7 +7,7 @@ org.alfresco alfresco-governance-services-automation-community-repo - 20.119-SNAPSHOT + 20.120-SNAPSHOT diff --git a/amps/ags/rm-community/pom.xml b/amps/ags/rm-community/pom.xml index 0fb4bb3335..6baf85562f 100644 --- a/amps/ags/rm-community/pom.xml +++ b/amps/ags/rm-community/pom.xml @@ -7,7 +7,7 @@ org.alfresco alfresco-governance-services-community-parent - 20.119-SNAPSHOT + 20.120-SNAPSHOT diff --git a/amps/ags/rm-community/rm-community-repo/pom.xml b/amps/ags/rm-community/rm-community-repo/pom.xml index 42d22888b1..3b7083dae7 100644 --- a/amps/ags/rm-community/rm-community-repo/pom.xml +++ b/amps/ags/rm-community/rm-community-repo/pom.xml @@ -8,7 +8,7 @@ org.alfresco alfresco-governance-services-community-repo-parent - 20.119-SNAPSHOT + 20.120-SNAPSHOT diff --git a/amps/ags/rm-community/rm-community-rest-api-explorer/pom.xml b/amps/ags/rm-community/rm-community-rest-api-explorer/pom.xml index 7b11b90d0e..f06d9f8c71 100644 --- a/amps/ags/rm-community/rm-community-rest-api-explorer/pom.xml +++ b/amps/ags/rm-community/rm-community-rest-api-explorer/pom.xml @@ -7,7 +7,7 @@ org.alfresco alfresco-governance-services-community-repo-parent - 20.119-SNAPSHOT + 20.120-SNAPSHOT diff --git a/amps/pom.xml b/amps/pom.xml index 1ab489790e..e851feaf0a 100644 --- a/amps/pom.xml +++ b/amps/pom.xml @@ -7,7 +7,7 @@ org.alfresco alfresco-community-repo - 20.119-SNAPSHOT + 20.120-SNAPSHOT diff --git a/amps/share-services/pom.xml b/amps/share-services/pom.xml index 24c24c6051..0ae3ca7532 100644 --- a/amps/share-services/pom.xml +++ b/amps/share-services/pom.xml @@ -8,7 +8,7 @@ org.alfresco alfresco-community-repo-amps - 20.119-SNAPSHOT + 20.120-SNAPSHOT diff --git a/core/pom.xml b/core/pom.xml index db1a275bd0..93b78bdd8c 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -7,7 +7,7 @@ org.alfresco alfresco-community-repo - 20.119-SNAPSHOT + 20.120-SNAPSHOT diff --git a/data-model/pom.xml b/data-model/pom.xml index fcf75df5eb..7723ae7938 100644 --- a/data-model/pom.xml +++ b/data-model/pom.xml @@ -7,7 +7,7 @@ org.alfresco alfresco-community-repo - 20.119-SNAPSHOT + 20.120-SNAPSHOT diff --git a/mmt/pom.xml b/mmt/pom.xml index 649ec970eb..df5a0c25af 100644 --- a/mmt/pom.xml +++ b/mmt/pom.xml @@ -7,7 +7,7 @@ org.alfresco alfresco-community-repo - 20.119-SNAPSHOT + 20.120-SNAPSHOT diff --git a/packaging/distribution/pom.xml b/packaging/distribution/pom.xml index a0b6cbbaf2..fd8e906f56 100644 --- a/packaging/distribution/pom.xml +++ b/packaging/distribution/pom.xml @@ -9,6 +9,6 @@ org.alfresco alfresco-community-repo-packaging - 20.119-SNAPSHOT + 20.120-SNAPSHOT diff --git a/packaging/docker-alfresco/pom.xml b/packaging/docker-alfresco/pom.xml index b9d95ff9bd..241ddc48b2 100644 --- a/packaging/docker-alfresco/pom.xml +++ b/packaging/docker-alfresco/pom.xml @@ -7,7 +7,7 @@ org.alfresco alfresco-community-repo-packaging - 20.119-SNAPSHOT + 20.120-SNAPSHOT diff --git a/packaging/pom.xml b/packaging/pom.xml index ce4a0a3b5c..fd87ff28ce 100644 --- a/packaging/pom.xml +++ b/packaging/pom.xml @@ -7,7 +7,7 @@ org.alfresco alfresco-community-repo - 20.119-SNAPSHOT + 20.120-SNAPSHOT diff --git a/packaging/tests/pom.xml b/packaging/tests/pom.xml index 0c9530cfd0..49bf71343d 100644 --- a/packaging/tests/pom.xml +++ b/packaging/tests/pom.xml @@ -6,7 +6,7 @@ org.alfresco alfresco-community-repo-packaging - 20.119-SNAPSHOT + 20.120-SNAPSHOT diff --git a/packaging/tests/tas-cmis/pom.xml b/packaging/tests/tas-cmis/pom.xml index a18ffe24b8..91e4f6af4f 100644 --- a/packaging/tests/tas-cmis/pom.xml +++ b/packaging/tests/tas-cmis/pom.xml @@ -7,7 +7,7 @@ org.alfresco alfresco-community-repo-tests - 20.119-SNAPSHOT + 20.120-SNAPSHOT diff --git a/packaging/tests/tas-email/pom.xml b/packaging/tests/tas-email/pom.xml index e1b8a49d93..62ac42f12b 100644 --- a/packaging/tests/tas-email/pom.xml +++ b/packaging/tests/tas-email/pom.xml @@ -9,7 +9,7 @@ org.alfresco alfresco-community-repo-tests - 20.119-SNAPSHOT + 20.120-SNAPSHOT diff --git a/packaging/tests/tas-integration/pom.xml b/packaging/tests/tas-integration/pom.xml index ec331927b7..5e68c85147 100644 --- a/packaging/tests/tas-integration/pom.xml +++ b/packaging/tests/tas-integration/pom.xml @@ -9,7 +9,7 @@ org.alfresco alfresco-community-repo-tests - 20.119-SNAPSHOT + 20.120-SNAPSHOT diff --git a/packaging/tests/tas-restapi/pom.xml b/packaging/tests/tas-restapi/pom.xml index 117a98c99b..ba4df03ce1 100644 --- a/packaging/tests/tas-restapi/pom.xml +++ b/packaging/tests/tas-restapi/pom.xml @@ -8,7 +8,7 @@ org.alfresco alfresco-community-repo-tests - 20.119-SNAPSHOT + 20.120-SNAPSHOT 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..8890965195 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 @@ -1,5 +1,10 @@ package org.alfresco.rest.tags; +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; + import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestTagModel; import org.alfresco.utility.constants.UserRole; @@ -14,6 +19,11 @@ import org.testng.annotations.Test; 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,25 @@ public class GetTagTests extends TagsDataPrep .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) .stackTraceIs(RestErrorModel.STACKTRACE); } -} \ No newline at end of file + + /** + * Verify that 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(); + } +} 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 f164cbd612..fc57d3ce08 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 @@ -1,6 +1,8 @@ package org.alfresco.rest.tags; +import static org.alfresco.utility.data.RandomData.getRandomName; import static org.alfresco.utility.report.log.Step.STEP; +import static org.springframework.http.HttpStatus.OK; import java.util.Set; @@ -8,7 +10,6 @@ import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestTagModel; import org.alfresco.rest.model.RestTagModelsCollection; import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; @@ -18,13 +19,18 @@ import org.testng.annotations.Test; @Test(groups = {TestGroup.REQUIRE_SOLR}) public class GetTagsTests extends TagsDataPrep { + + private static final String FIELD_ID = "id"; + private static final String FIELD_TAG = "tag"; + private static final String FIELD_COUNT = "count"; + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role gets tags using REST API and status code is OK (200)") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - public void getTagsWithManagerRole() throws Exception + public void getTagsWithManagerRole() { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.assertStatusCodeIs(OK); returnedCollection.assertThat().entriesListIsNotEmpty() .and().entriesListContains("tag", documentTagValue.toLowerCase()) .and().entriesListContains("tag", documentTagValue2.toLowerCase()); @@ -32,11 +38,11 @@ public class GetTagsTests extends TagsDataPrep @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify user with Collaborator role gets tags using REST API and status code is OK (200)") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void getTagsWithCollaboratorRole() throws Exception + public void getTagsWithCollaboratorRole() { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.assertStatusCodeIs(OK); returnedCollection.assertThat().entriesListIsNotEmpty() .and().entriesListContains("tag", documentTagValue.toLowerCase()) .and().entriesListContains("tag", documentTagValue2.toLowerCase()); @@ -44,11 +50,11 @@ public class GetTagsTests extends TagsDataPrep @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify user with Contributor role gets tags using REST API and status code is OK (200)") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void getTagsWithContributorRole() throws Exception + public void getTagsWithContributorRole() { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.assertStatusCodeIs(OK); returnedCollection.assertThat().entriesListIsNotEmpty() .and().entriesListContains("tag", documentTagValue.toLowerCase()) .and().entriesListContains("tag", documentTagValue2.toLowerCase()); @@ -56,11 +62,11 @@ public class GetTagsTests extends TagsDataPrep @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify user with Consumer role gets tags using REST API and status code is OK (200)") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void getTagsWithConsumerRole() throws Exception + public void getTagsWithConsumerRole() { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.assertStatusCodeIs(OK); returnedCollection.assertThat().entriesListIsNotEmpty() .and().entriesListContains("tag", documentTagValue.toLowerCase()) .and().entriesListContains("tag", documentTagValue2.toLowerCase()); @@ -69,7 +75,7 @@ public class GetTagsTests extends TagsDataPrep @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Failed authentication get tags call returns status code 401 with Manager role") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) // @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void failedAuthenticationReturnsUnauthorizedStatus() throws Exception + public void failedAuthenticationReturnsUnauthorizedStatus() { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); userModel = dataUser.createRandomTestUser(); @@ -83,7 +89,7 @@ public class GetTagsTests extends TagsDataPrep @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify that if maxItems is invalid status code returned is 400") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION}) - public void maxItemsInvalidValueTest() throws Exception + public void maxItemsInvalidValueTest() { restClient.authenticateUser(adminUserModel).withParams("maxItems=abc").withCoreAPI().getTags(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "abc")); @@ -92,7 +98,7 @@ public class GetTagsTests extends TagsDataPrep @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify that if skipCount is invalid status code returned is 400") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION}) - public void skipCountInvalidValueTest() throws Exception + public void skipCountInvalidValueTest() { restClient.authenticateUser(adminUserModel).withParams("skipCount=abc").withCoreAPI().getTags(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc")); @@ -101,11 +107,11 @@ public class GetTagsTests extends TagsDataPrep @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify that file tag is retrieved") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION}) - public void fileTagIsRetrieved() throws Exception + public void fileTagIsRetrieved() { restClient.authenticateUser(adminUserModel); returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.assertStatusCodeIs(OK); returnedCollection.assertThat().entriesListIsNotEmpty() .and().entriesListContains("tag", documentTagValue.toLowerCase()) .and().entriesListContains("tag", documentTagValue2.toLowerCase()); @@ -114,11 +120,11 @@ public class GetTagsTests extends TagsDataPrep @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify that folder tag is retrieved") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION}) - public void folderTagIsRetrieved() throws Exception + public void folderTagIsRetrieved() { restClient.authenticateUser(adminUserModel); returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.assertStatusCodeIs(OK); returnedCollection.assertThat().entriesListIsNotEmpty() .and().entriesListContains("tag", folderTagValue.toLowerCase()); } @@ -127,11 +133,11 @@ public class GetTagsTests extends TagsDataPrep description = "Verify site Manager is able to get tags using properties parameter." + "Check that properties filter is applied.") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void siteManagerIsAbleToRetrieveTagsWithPropertiesParameter() throws Exception + public void siteManagerIsAbleToRetrieveTagsWithPropertiesParameter() { returnedCollection = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) .withParams("maxItems=5000&properties=tag").withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.assertStatusCodeIs(OK); returnedCollection.assertThat().entriesListIsNotEmpty() .and().entriesListContains("tag", documentTagValue.toLowerCase()) .and().entriesListContains("tag", documentTagValue2.toLowerCase()) @@ -141,15 +147,15 @@ public class GetTagsTests extends TagsDataPrep @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "With admin get tags and use skipCount parameter. Check pagination") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void useSkipCountCheckPagination() throws Exception + public void useSkipCountCheckPagination() { returnedCollection = restClient.authenticateUser(adminUserModel).withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.assertStatusCodeIs(OK); RestTagModel firstTag = returnedCollection.getEntries().get(0).onModel(); RestTagModel secondTag = returnedCollection.getEntries().get(1).onModel(); RestTagModelsCollection tagsWithSkipCount = restClient.withParams("skipCount=2").withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.assertStatusCodeIs(OK); tagsWithSkipCount.assertThat().entriesListDoesNotContain("tag", firstTag.getTag()) .assertThat().entriesListDoesNotContain("tag", secondTag.getTag()); @@ -159,15 +165,15 @@ public class GetTagsTests extends TagsDataPrep @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "With admin get tags and use maxItems parameter. Check pagination") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void useMaxItemsParameterCheckPagination() throws Exception + public void useMaxItemsParameterCheckPagination() { returnedCollection = restClient.authenticateUser(adminUserModel).withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.assertStatusCodeIs(OK); RestTagModel firstTag = returnedCollection.getEntries().get(0).onModel(); RestTagModel secondTag = returnedCollection.getEntries().get(1).onModel(); RestTagModelsCollection tagsWithMaxItems = restClient.withParams("maxItems=2").withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.assertStatusCodeIs(OK); tagsWithMaxItems.assertThat().entriesListContains("tag", firstTag.getTag()) .assertThat().entriesListContains("tag", secondTag.getTag()) @@ -178,11 +184,11 @@ public class GetTagsTests extends TagsDataPrep @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "With manager get tags and use high skipCount parameter. Check pagination") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void useHighSkipCountCheckPagination() throws Exception + public void useHighSkipCountCheckPagination() { returnedCollection = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) .withParams("skipCount=20000").withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.assertStatusCodeIs(OK); returnedCollection.assertThat().entriesListIsEmpty() .getPagination().assertThat().field("maxItems").is(100) .and().field("hasMoreItems").is("false") @@ -194,7 +200,7 @@ public class GetTagsTests extends TagsDataPrep @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "With Collaborator user get tags and use maxItems with value zero. Check default error model schema") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void useMaxItemsWithValueZeroCheckDefaultErrorModelSchema() throws Exception + public void useMaxItemsWithValueZeroCheckDefaultErrorModelSchema() { returnedCollection = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) .withParams("maxItems=0").withCoreAPI().getTags(); @@ -208,9 +214,9 @@ public class GetTagsTests extends TagsDataPrep @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "With Manager user delete tag. Check it is not retrieved anymore.") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void checkThatDeletedTagIsNotRetrievedAnymore() throws Exception + public void checkThatDeletedTagIsNotRetrievedAnymore() { - String removedTag = RandomData.getRandomName("tag3"); + String removedTag = getRandomName("tag3"); RestTagModel deletedTag = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) .withCoreAPI().usingResource(document).addTag(removedTag); @@ -339,4 +345,36 @@ public class GetTagsTests extends TagsDataPrep restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) .assertLastError().containsSummary("An invalid WHERE query was received. Unsupported Predicate"); } + + /** + * Verify if count field is present for searched tags. + */ + @Test(groups = {TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION}) + public void testGetTags_includingCount() + { + STEP("Get tags including count and verify if it is present in the response"); + final RestTagModelsCollection searchedTags = restClient.withCoreAPI().include(FIELD_COUNT).getTags(); + + restClient.assertStatusCodeIs(OK); + searchedTags.assertThat().entriesListIsNotEmpty() + .assertThat().entriesListContains(FIELD_COUNT) + .assertThat().entriesListContains(FIELD_TAG) + .assertThat().entriesListContains(FIELD_ID); + } + + /** + * Verify if count field is not present for searched tags. + */ + @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); + searchedTags.assertThat().entriesListIsNotEmpty() + .assertThat().entriesListDoesNotContain(FIELD_COUNT) + .assertThat().entriesListContains(FIELD_TAG) + .assertThat().entriesListContains(FIELD_ID); + } } diff --git a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/tags/TagsDataPrep.java b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/tags/TagsDataPrep.java index 4d10915945..b0b976cfcb 100644 --- a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/tags/TagsDataPrep.java +++ b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/tags/TagsDataPrep.java @@ -78,4 +78,9 @@ public class TagsDataPrep extends RestTest .tag(tag) .create(); } + + protected RestTagModel createTagModelWithName(final String tagName) + { + return RestTagModel.builder().tag(tagName).create(); + } } diff --git a/packaging/tests/tas-webdav/pom.xml b/packaging/tests/tas-webdav/pom.xml index 016cd3df01..fccfeb189c 100644 --- a/packaging/tests/tas-webdav/pom.xml +++ b/packaging/tests/tas-webdav/pom.xml @@ -9,7 +9,7 @@ org.alfresco alfresco-community-repo-tests - 20.119-SNAPSHOT + 20.120-SNAPSHOT diff --git a/packaging/war/pom.xml b/packaging/war/pom.xml index efb5805f13..1caefea475 100644 --- a/packaging/war/pom.xml +++ b/packaging/war/pom.xml @@ -7,7 +7,7 @@ org.alfresco alfresco-community-repo-packaging - 20.119-SNAPSHOT + 20.120-SNAPSHOT diff --git a/pom.xml b/pom.xml index daac9fff41..7e5f00334f 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 alfresco-community-repo - 20.119-SNAPSHOT + 20.120-SNAPSHOT pom Alfresco Community Repo Parent diff --git a/remote-api/pom.xml b/remote-api/pom.xml index 5c3178510e..1c109cc2ae 100644 --- a/remote-api/pom.xml +++ b/remote-api/pom.xml @@ -7,7 +7,7 @@ org.alfresco alfresco-community-repo - 20.119-SNAPSHOT + 20.120-SNAPSHOT diff --git a/remote-api/src/main/java/org/alfresco/rest/api/impl/TagsImpl.java b/remote-api/src/main/java/org/alfresco/rest/api/impl/TagsImpl.java index f2bc90b570..e9785c0a51 100644 --- a/remote-api/src/main/java/org/alfresco/rest/api/impl/TagsImpl.java +++ b/remote-api/src/main/java/org/alfresco/rest/api/impl/TagsImpl.java @@ -164,21 +164,25 @@ public class TagsImpl implements Tags taggingService.deleteTag(storeRef, tagValue); } - @Override + @Override public CollectionWithPagingInfo getTags(StoreRef storeRef, Parameters params) { - Paging paging = params.getPaging(); - Map> namesFilters = resolveTagNamesQuery(params.getQuery()); - PagingResults> results = taggingService.getTags(storeRef, Util.getPagingRequest(paging), namesFilters.get(EQUALS), namesFilters.get(MATCHES)); + Paging paging = params.getPaging(); + Map> namesFilters = resolveTagNamesQuery(params.getQuery()); + PagingResults> results = taggingService.getTags(storeRef, Util.getPagingRequest(paging), namesFilters.get(EQUALS), namesFilters.get(MATCHES)); Integer totalItems = results.getTotalResultCount().getFirst(); List> page = results.getPage(); List tags = new ArrayList<>(page.size()); - List> tagsByCount; - Map tagsByCountMap = new HashMap<>(); + for (Pair pair : page) + { + Tag selectedTag = new Tag(pair.getFirst(), pair.getSecond()); + tags.add(selectedTag); + } if (params.getInclude().contains(PARAM_INCLUDE_COUNT)) { - tagsByCount = taggingService.findTaggedNodesAndCountByTagName(storeRef); + List> tagsByCount = taggingService.findTaggedNodesAndCountByTagName(storeRef); + Map tagsByCountMap = new HashMap<>(); if (tagsByCount != null) { for (Pair tagByCountElem : tagsByCount) @@ -186,12 +190,7 @@ public class TagsImpl implements Tags tagsByCountMap.put(tagByCountElem.getFirst(), tagByCountElem.getSecond()); } } - } - for (Pair pair : page) - { - Tag selectedTag = new Tag(pair.getFirst(), pair.getSecond()); - selectedTag.setCount(Optional.ofNullable(tagsByCountMap.get(selectedTag.getTag())).orElse(0)); - tags.add(selectedTag); + tags.forEach(tag -> tag.setCount(Optional.ofNullable(tagsByCountMap.get(tag.getTag())).orElse(0))); } return CollectionWithPagingInfo.asPaged(paging, tags, results.hasMoreItems(), totalItems); diff --git a/remote-api/src/test/java/org/alfresco/rest/api/impl/TagsImplTest.java b/remote-api/src/test/java/org/alfresco/rest/api/impl/TagsImplTest.java index 26de1a2854..2872bb7f0a 100644 --- a/remote-api/src/test/java/org/alfresco/rest/api/impl/TagsImplTest.java +++ b/remote-api/src/test/java/org/alfresco/rest/api/impl/TagsImplTest.java @@ -129,7 +129,7 @@ public class TagsImplTest then(taggingServiceMock).should().getTags(eq(STORE_REF_WORKSPACE_SPACESSTORE), any(PagingRequest.class), isNull(), isNull()); then(taggingServiceMock).shouldHaveNoMoreInteractions(); - final List expectedTags = createTagsWithNodeRefs(List.of(TAG_NAME)).stream().peek(tag -> tag.setCount(0)).collect(toList()); + final List expectedTags = createTagsWithNodeRefs(List.of(TAG_NAME)); assertEquals(expectedTags, actualTags.getCollection()); } @@ -151,6 +151,30 @@ public class TagsImplTest assertEquals(expectedTags, actualTags.getCollection()); } + /** Check that we can get counts for two tags - one in use and one not applied to any nodes. */ + @Test + public void testGetTags_verifyCountPopulatedCorrectly() + { + NodeRef tagNodeA = new NodeRef("tag://A/"); + NodeRef tagNodeB = new NodeRef("tag://B/"); + List> tagPairs = List.of(new Pair<>(tagNodeA, "tagA"), new Pair<>(tagNodeB, "tagB")); + + given(parametersMock.getPaging()).willReturn(pagingMock); + given(taggingServiceMock.getTags(any(StoreRef.class), any(PagingRequest.class), any(), any())).willReturn(pagingResultsMock); + given(pagingResultsMock.getTotalResultCount()).willReturn(new Pair<>(Integer.MAX_VALUE, 0)); + given(pagingResultsMock.getPage()).willReturn(tagPairs); + given(parametersMock.getInclude()).willReturn(List.of("count")); + // Only tagA is included in the returned list since tagB is not in use. + given(taggingServiceMock.findTaggedNodesAndCountByTagName(STORE_REF_WORKSPACE_SPACESSTORE)).willReturn(List.of(new Pair<>("tagA", 5))); + + final CollectionWithPagingInfo actualTags = objectUnderTest.getTags(STORE_REF_WORKSPACE_SPACESSTORE, parametersMock); + + then(taggingServiceMock).should().findTaggedNodesAndCountByTagName(STORE_REF_WORKSPACE_SPACESSTORE); + final List expectedTags = List.of(Tag.builder().tag("tagA").nodeRef(tagNodeA).count(5).create(), + Tag.builder().tag("tagB").nodeRef(tagNodeB).count(0).create()); + assertEquals(expectedTags, actualTags.getCollection()); + } + @Test public void testGetTags_withEqualsClauseWhereQuery() { diff --git a/remote-api/src/test/java/org/alfresco/rest/api/tests/SharedLinkApiTest.java b/remote-api/src/test/java/org/alfresco/rest/api/tests/SharedLinkApiTest.java index 3faadffb97..ffd018461e 100644 --- a/remote-api/src/test/java/org/alfresco/rest/api/tests/SharedLinkApiTest.java +++ b/remote-api/src/test/java/org/alfresco/rest/api/tests/SharedLinkApiTest.java @@ -734,195 +734,6 @@ public class SharedLinkApiTest extends AbstractBaseApiTest } } - /** - * Tests shared links to file (content) in a multi-tenant system. - * - *

POST:

- * {@literal :/alfresco/api//public/alfresco/versions/1/shared-links} - * - *

DELETE:

- * {@literal :/alfresco/api//public/alfresco/versions/1/shared-links/} - * - *

GET:

- * The following do not require authentication - * {@literal :/alfresco/api//public/alfresco/versions/1/shared-links/} - * {@literal :/alfresco/api//public/alfresco/versions/1/shared-links//content} - * {@literal :/alfresco/api//public/alfresco/versions/1/shared-links//renditions} - * {@literal :/alfresco/api//public/alfresco/versions/1/shared-links//renditions/} - * {@literal :/alfresco/api//public/alfresco/versions/1/shared-links//renditions//content} - * - */ - // TODO now covered by testSharedLinkCreateGetDelete ? (since base class now uses tenant context by default) - @Test - public void testSharedLinkCreateGetDelete_MultiTenant() throws Exception - { - // As user1 - setRequestContext(user1); - - String docLibNodeId = getSiteContainerNodeId(tSiteId, "documentLibrary"); - - String folderName = "folder" + System.currentTimeMillis() + "_1"; - String folderId = createFolder(docLibNodeId, folderName, null).getId(); - - // create doc d1 - pdf - String fileName1 = "quick" + RUNID + "_1.pdf"; - File file1 = getResourceFile("quick.pdf"); - - byte[] file1_originalBytes = Files.readAllBytes(Paths.get(file1.getAbsolutePath())); - - String file1_MimeType = MimetypeMap.MIMETYPE_PDF; - - MultiPartBuilder.MultiPartRequest reqBody = MultiPartBuilder.create() - .setFileData(new MultiPartBuilder.FileData(fileName1, file1, file1_MimeType)) - .build(); - - HttpResponse response = post(getNodeChildrenUrl(folderId), reqBody.getBody(), null, reqBody.getContentType(), 201); - Document doc1 = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Document.class); - String d1Id = doc1.getId(); - assertNotNull(d1Id); - - // create shared link to document 1 - Map body = new HashMap<>(); - body.put("nodeId", d1Id); - response = post(URL_SHARED_LINKS, toJsonAsStringNonNull(body), 201); - QuickShareLink resp = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), QuickShareLink.class); - String shared1Id = resp.getId(); - assertNotNull(shared1Id); - assertEquals(d1Id, resp.getNodeId()); - assertEquals(fileName1, resp.getName()); - assertEquals(file1_MimeType, resp.getContent().getMimeType()); - assertEquals(user1, resp.getSharedByUser().getId()); - - // allowable operations not included - no params - response = getSingle(QuickShareLinkEntityResource.class, shared1Id, null, 200); - resp = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), QuickShareLink.class); - assertNull(resp.getAllowableOperations()); - - setRequestContext(null); - - // unauth access to get shared link info - Map params = Collections.singletonMap("include", "allowableOperations"); // note: this will be ignore for unauth access - response = getSingle(QuickShareLinkEntityResource.class, shared1Id, params, 200); - resp = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), QuickShareLink.class); - assertEquals(shared1Id, resp.getId()); - assertEquals(fileName1, resp.getName()); - assertEquals(d1Id, resp.getNodeId()); - assertNull(resp.getAllowableOperations()); // include is ignored - assertNull(resp.getAllowableOperationsOnTarget()); // include is ignored - - - // unauth access to file 1 content (via shared link) - response = getSingle(QuickShareLinkEntityResource.class, shared1Id + "/content", null, 200); - assertArrayEquals(file1_originalBytes, response.getResponseAsBytes()); - Map responseHeaders = response.getHeaders(); - assertNotNull(responseHeaders); - assertEquals(file1_MimeType + ";charset=utf-8", responseHeaders.get("Content-Type")); - assertNotNull(responseHeaders.get("Expires")); - assertEquals("attachment; filename=\"" + fileName1 + "\"; filename*=UTF-8''" + fileName1 + "", responseHeaders.get("Content-Disposition")); - String lastModifiedHeader = responseHeaders.get(LAST_MODIFIED_HEADER); - assertNotNull(lastModifiedHeader); - // Test 304 response - Map headers = Collections.singletonMap(IF_MODIFIED_SINCE_HEADER, lastModifiedHeader); - getSingle(URL_SHARED_LINKS, shared1Id + "/content", null, headers, 304); - - // unauth access to file 1 content (via shared link) - without Content-Disposition header (attachment=false) - params = new HashMap<>(); - params.put("attachment", "false"); - response = getSingle(QuickShareLinkEntityResource.class, shared1Id + "/content", params, 200); - assertArrayEquals(file1_originalBytes, response.getResponseAsBytes()); - responseHeaders = response.getHeaders(); - assertNotNull(responseHeaders); - assertEquals(file1_MimeType + ";charset=utf-8", responseHeaders.get("Content-Type")); - assertNotNull(responseHeaders.get(LAST_MODIFIED_HEADER)); - assertNotNull(responseHeaders.get("Expires")); - assertNull(responseHeaders.get("Content-Disposition")); - - // -ve shared link rendition tests - { - // -ve test - try to get non-existent rendition content - getSingle(QuickShareLinkEntityResource.class, shared1Id + "/renditions/doclib/content", null, 404); - - // -ve test - try to get unregistered rendition content - getSingle(QuickShareLinkEntityResource.class, shared1Id + "/renditions/dummy/content", null, 404); - } - - // unauth access to get rendition info for a shared link (available => CREATED rendition only) - // -ve shared link rendition tests - { - // -ve test - try to get not created rendition for the given shared link - getSingle(QuickShareLinkEntityResource.class, shared1Id + "/renditions/doclib", null, 404); - - // -ve test - try to get unregistered rendition - getSingle(QuickShareLinkEntityResource.class, shared1Id + "/renditions/dummy", null, 404); - } - - // unauth access to get shared link renditions info (available => CREATED renditions only) - response = getAll(URL_SHARED_LINKS + "/" + shared1Id + "/renditions", null, 200); - List renditions = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Rendition.class); - assertEquals(0, renditions.size()); - - // create rendition of pdf doc - note: for some reason create rendition of txt doc fail on build m/c (TBC) ? - setRequestContext(user1); - - Rendition rendition = createAndGetRendition(d1Id, "doclib"); - assertNotNull(rendition); - assertEquals(Rendition.RenditionStatus.CREATED, rendition.getStatus()); - - setRequestContext(null); - - // unauth access to get shared link renditions info (available => CREATED renditions only) - response = getAll(URL_SHARED_LINKS + "/" + shared1Id + "/renditions", null, 200); - renditions = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Rendition.class); - assertEquals(1, renditions.size()); - assertEquals(Rendition.RenditionStatus.CREATED, renditions.get(0).getStatus()); - assertEquals("doclib", renditions.get(0).getId()); - - // unauth access to get rendition info for a shared link (available => CREATED rendition only) - { - // get a created rendition for the given shared link - getSingle(QuickShareLinkEntityResource.class, shared1Id + "/renditions/doclib", null, 200); - } - - // unauth access to get shared link file rendition content - response = getSingle(QuickShareLinkEntityResource.class, shared1Id + "/renditions/doclib/content", null, 200); - assertTrue(response.getResponseAsBytes().length > 0); - responseHeaders = response.getHeaders(); - assertNotNull(responseHeaders); - assertEquals(MimetypeMap.MIMETYPE_IMAGE_PNG + ";charset=utf-8", responseHeaders.get("Content-Type")); - assertNotNull(responseHeaders.get(LAST_MODIFIED_HEADER)); - assertNotNull(responseHeaders.get("Expires")); - String docName = "doclib"; - assertEquals("attachment; filename=\"" + docName + "\"; filename*=UTF-8''" + docName + "", responseHeaders.get("Content-Disposition")); - - // unauth access to get shared link file rendition content - without Content-Disposition header (attachment=false) - params = new HashMap<>(); - params.put("attachment", "false"); - response = getSingle(QuickShareLinkEntityResource.class, shared1Id + "/renditions/doclib/content", params, 200); - assertTrue(response.getResponseAsBytes().length > 0); - responseHeaders = response.getHeaders(); - assertNotNull(responseHeaders); - assertEquals(MimetypeMap.MIMETYPE_IMAGE_PNG + ";charset=utf-8", responseHeaders.get("Content-Type")); - assertNotNull(responseHeaders.get("Expires")); - assertNull(responseHeaders.get("Content-Disposition")); - lastModifiedHeader = responseHeaders.get(LAST_MODIFIED_HEADER); - assertNotNull(lastModifiedHeader); - // Test 304 response - headers = Collections.singletonMap(IF_MODIFIED_SINCE_HEADER, lastModifiedHeader); - getSingle(URL_SHARED_LINKS, shared1Id + "/renditions/doclib/content", null, headers, 304); - - // -ve test - userTwoN1 cannot delete shared link - setRequestContext(user2); - deleteSharedLink(shared1Id, 403); - - // -ve test - unauthenticated - setRequestContext(null); - deleteSharedLink(shared1Id, 401); - - // delete shared link - setRequestContext(user1); - deleteSharedLink(shared1Id); - } - /** * Tests shared links to file with expiry date. *

POST:

diff --git a/repository/pom.xml b/repository/pom.xml index eec544fd8c..e655b78663 100644 --- a/repository/pom.xml +++ b/repository/pom.xml @@ -7,7 +7,7 @@ org.alfresco alfresco-community-repo - 20.119-SNAPSHOT + 20.120-SNAPSHOT