mirror of
https://github.com/Alfresco/SearchServices.git
synced 2026-09-16 18:12:56 +00:00
Added annotations @Test to each test/method for ratings
This commit is contained in:
@@ -24,7 +24,6 @@ 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 AddRatingCoreTests extends RestTest
|
||||
{
|
||||
private UserModel userModel;
|
||||
@@ -33,7 +32,7 @@ public class AddRatingCoreTests extends RestTest
|
||||
private FolderModel folderModel;
|
||||
private FileModel document;
|
||||
private ListUserWithRoles usersWithRoles;
|
||||
private RestRatingModel returnedRatingModel; //placeholder for returned model
|
||||
private RestRatingModel returnedRatingModel; // placeholder for returned model
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void dataPreparation() throws DataPreparationException
|
||||
@@ -53,25 +52,29 @@ public class AddRatingCoreTests extends RestTest
|
||||
document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that if unknown rating scheme is provided status code is 400")
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify that if unknown rating scheme is provided status code is 400")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE })
|
||||
public void unknownRatingSchemeReturnsBadRequest() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"invalidRate\"}");
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_RATING, "invalidRate"));
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that if nodeId does not exist status code 404 is returned")
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify that if nodeId does not exist status code 404 is returned")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE })
|
||||
public void invalidNodeIdReturnsNotFound() throws Exception
|
||||
{
|
||||
document.setNodeRef(RandomStringUtils.randomAlphanumeric(10));
|
||||
restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument();
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, document.getNodeRef()));
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError()
|
||||
.containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, document.getNodeRef()));
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that if nodeId provided cannot be rated 405 status code is returned")
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify that if nodeId provided cannot be rated 405 status code is returned")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE })
|
||||
@Bug(id = "MNT-16904")
|
||||
public void likeResourceThatCannotBeRated() throws Exception
|
||||
{
|
||||
@@ -80,138 +83,141 @@ public class AddRatingCoreTests extends RestTest
|
||||
restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument();
|
||||
restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that manager is able to like a file")
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify that manager is able to like a file")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE })
|
||||
public void managerIsAbleToLikeAFile() throws Exception
|
||||
{
|
||||
returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document).likeDocument();
|
||||
returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document)
|
||||
.likeDocument();
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
|
||||
returnedRatingModel.assertThat().field("myRating").is("true")
|
||||
.and().field("id").is("likes")
|
||||
.and().field("aggregate").isNotEmpty();
|
||||
|
||||
returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty();
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that manager is able to like a folder")
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify that manager is able to like a folder")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE })
|
||||
public void managerIsAbleToLikeAFolder() throws Exception
|
||||
{
|
||||
returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(folderModel).likeDocument();
|
||||
returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(folderModel)
|
||||
.likeDocument();
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
|
||||
returnedRatingModel.assertThat().field("myRating").is("true")
|
||||
.and().field("id").is("likes")
|
||||
.and().field("aggregate").isNotEmpty();
|
||||
|
||||
returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty();
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that manager is able to rate a folder")
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify that manager is able to rate a folder")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE })
|
||||
public void managerIsAbleToRateAFolder() throws Exception
|
||||
{
|
||||
returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(folderModel).rateStarsToDocument(5);
|
||||
returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(folderModel)
|
||||
.rateStarsToDocument(5);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
|
||||
returnedRatingModel.assertThat().field("myRating").is("5")
|
||||
.and().field("id").is("fiveStar")
|
||||
.and().field("aggregate").isNotEmpty();
|
||||
|
||||
returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty();
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that manager is able to rate a file")
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify that manager is able to rate a file")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE })
|
||||
public void managerIsAbleToRateAFile() throws Exception
|
||||
{
|
||||
returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document).rateStarsToDocument(5);
|
||||
returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document)
|
||||
.rateStarsToDocument(5);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
|
||||
returnedRatingModel.assertThat().field("myRating").is("5")
|
||||
.and().field("id").is("fiveStar")
|
||||
.and().field("aggregate").isNotEmpty();
|
||||
|
||||
returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty();
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that adding like again has no effect on a file")
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify that adding like again has no effect on a file")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE })
|
||||
public void fileCanBeLikedTwice() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument();
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
returnedRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument();
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
|
||||
returnedRatingModel.assertThat().field("myRating").is("true")
|
||||
.and().field("id").is("likes")
|
||||
.and().field("aggregate").isNotEmpty();
|
||||
|
||||
returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty();
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that adding rate again has no effect on a file")
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify that adding rate again has no effect on a file")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE })
|
||||
public void fileCanBeRatedTwice() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).rateStarsToDocument(5);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
returnedRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).rateStarsToDocument(5);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
|
||||
returnedRatingModel.assertThat().field("myRating").is("5")
|
||||
.and().field("id").is("fiveStar")
|
||||
.and().field("aggregate").isNotEmpty();
|
||||
|
||||
returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty();
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that rate is not added if empty rating object is provided")
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify that rate is not added if empty rating object is provided")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE })
|
||||
public void addRateUsingEmptyRatingObject() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("");
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.NO_CONTENT,
|
||||
"No content to map to Object due to end of input"));
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError()
|
||||
.containsSummary(String.format(RestErrorModel.NO_CONTENT, "No content to map to Object due to end of input"));
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that if empty rate id is provided status code is 400")
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify that if empty rate id is provided status code is 400")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE })
|
||||
public void addRateUsingEmptyValueForId() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"\"}");
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.NO_CONTENT,
|
||||
"N/A (through reference chain: org.alfresco.rest.api.model.NodeRating[\"id\"])"));
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError()
|
||||
.containsSummary(String.format(RestErrorModel.NO_CONTENT, "N/A (through reference chain: org.alfresco.rest.api.model.NodeRating[\"id\"])"));
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that if empty rating is provided status code is 400")
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify that if empty rating is provided status code is 400")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE })
|
||||
public void addRateUsingEmptyValueForMyRating() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"likes\", \"myRating\":\"\"}");
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.NULL_LIKE_RATING));
|
||||
|
||||
|
||||
restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"fiveStar\", \"myRating\":\"\"}");
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.NULL_FIVESTAR_RATING));
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that user is not able to rate a comment")
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify that user is not able to rate a comment")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE })
|
||||
public void addRatingToAComment() throws Exception
|
||||
{
|
||||
RestCommentModel comment = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addComment("This is a comment");
|
||||
document.setNodeRef(comment.getId());
|
||||
|
||||
|
||||
restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument();
|
||||
restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(String.format(RestErrorModel.CANNOT_RATE));
|
||||
|
||||
|
||||
restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).rateStarsToDocument(5);
|
||||
restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(String.format(RestErrorModel.CANNOT_RATE));
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that user is not able to rate a tag")
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify that user is not able to rate a tag")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE })
|
||||
public void addRatingToATag() throws Exception
|
||||
{
|
||||
RestTagModel tag = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addTag("randomTag");
|
||||
document.setNodeRef(tag.getId());
|
||||
|
||||
|
||||
restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument();
|
||||
restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(String.format(RestErrorModel.CANNOT_RATE));
|
||||
|
||||
|
||||
restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).rateStarsToDocument(5);
|
||||
restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(String.format(RestErrorModel.CANNOT_RATE));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -16,7 +16,6 @@ import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY })
|
||||
public class AddRatingSanityTests extends RestTest
|
||||
{
|
||||
private UserModel userModel;
|
||||
@@ -25,7 +24,7 @@ public class AddRatingSanityTests extends RestTest
|
||||
private FolderModel folderModel;
|
||||
private FileModel document;
|
||||
private ListUserWithRoles usersWithRoles;
|
||||
private RestRatingModel returnedRatingModel; //placeholder for returned model
|
||||
private RestRatingModel returnedRatingModel; // placeholder for returned model
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void dataPreparation() throws DataPreparationException
|
||||
@@ -47,68 +46,66 @@ public class AddRatingSanityTests extends RestTest
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role is able to post like rating to a document")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY })
|
||||
public void managerIsAbleToLikeDocument() throws Exception
|
||||
{
|
||||
returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withCoreAPI().usingResource(document).likeDocument();
|
||||
returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document)
|
||||
.likeDocument();
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
|
||||
returnedRatingModel.assertThat().field("myRating").is("true")
|
||||
.and().field("id").is("likes")
|
||||
.and().field("aggregate").isNotEmpty();
|
||||
|
||||
returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty();
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role is able to post like rating to a document")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY })
|
||||
public void collaboratorIsAbleToLikeDocument() throws Exception
|
||||
{
|
||||
returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
|
||||
.withCoreAPI().usingResource(document).likeDocument();
|
||||
returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(document)
|
||||
.likeDocument();
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
|
||||
returnedRatingModel.assertThat().field("myRating").is("true")
|
||||
.and().field("id").is("likes")
|
||||
.and().field("aggregate").isNotEmpty();
|
||||
|
||||
returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty();
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role is able to post like rating to a document")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY })
|
||||
public void contributorIsAbleToLikeDocument() throws Exception
|
||||
{
|
||||
returnedRatingModel =restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingResource(document).likeDocument();
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
|
||||
returnedRatingModel.assertThat().field("myRating").is("true")
|
||||
.and().field("id").is("likes")
|
||||
.and().field("aggregate").isNotEmpty();
|
||||
returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingResource(document)
|
||||
.likeDocument();
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
|
||||
returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty();
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role is able to post like rating to a document")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY })
|
||||
public void consumerIsAbleToLikeDocument() throws Exception
|
||||
{
|
||||
returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingResource(document).likeDocument();
|
||||
returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingResource(document)
|
||||
.likeDocument();
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
|
||||
returnedRatingModel.assertThat().field("myRating").is("true")
|
||||
.and().field("id").is("likes")
|
||||
.and().field("aggregate").isNotEmpty();
|
||||
|
||||
returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty();
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify admin user is able to post like rating to a document")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY })
|
||||
public void adminIsAbleToLikeDocument() throws Exception
|
||||
{
|
||||
returnedRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument();
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
|
||||
returnedRatingModel.assertThat().field("myRating").is("true")
|
||||
.and().field("id").is("likes")
|
||||
.and().field("aggregate").isNotEmpty();
|
||||
|
||||
returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty();
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to post like rating to a document")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY })
|
||||
@Bug(id = "MNT-16904")
|
||||
public void unauthenticatedUserIsNotAbleToLikeDocument() throws Exception
|
||||
{
|
||||
@@ -118,62 +115,62 @@ public class AddRatingSanityTests extends RestTest
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role is able to post stars rating to a document")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY })
|
||||
public void managerIsAbleToAddStarsToDocument() throws Exception
|
||||
{
|
||||
returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document).rateStarsToDocument(5);
|
||||
returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document)
|
||||
.rateStarsToDocument(5);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
returnedRatingModel.assertThat().field("myRating").is("5")
|
||||
.and().field("id").is("fiveStar")
|
||||
.and().field("aggregate").isNotEmpty();
|
||||
returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty();
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role is able to post stars rating to a document")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY })
|
||||
public void collaboratorIsAbleToAddStarsToDocument() throws Exception
|
||||
{
|
||||
returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(document).rateStarsToDocument(5);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
returnedRatingModel.assertThat().field("myRating").is("5")
|
||||
.and().field("id").is("fiveStar")
|
||||
.and().field("aggregate").isNotEmpty();
|
||||
|
||||
returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(document)
|
||||
.rateStarsToDocument(5);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty();
|
||||
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role is able to post stars rating to a document")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY })
|
||||
public void contributorIsAbleToAddStarsToDocument() throws Exception
|
||||
{
|
||||
returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingResource(document).rateStarsToDocument(5);
|
||||
returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingResource(document)
|
||||
.rateStarsToDocument(5);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
returnedRatingModel.assertThat().field("myRating").is("5")
|
||||
.and().field("id").is("fiveStar")
|
||||
.and().field("aggregate").isNotEmpty();
|
||||
returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty();
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role is able to post stars rating to a document")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY })
|
||||
public void consumerIsAbleToAddStarsToDocument() throws Exception
|
||||
{
|
||||
returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingResource(document).rateStarsToDocument(5);
|
||||
returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingResource(document)
|
||||
.rateStarsToDocument(5);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
returnedRatingModel.assertThat().field("myRating").is("5")
|
||||
.and().field("id").is("fiveStar")
|
||||
.and().field("aggregate").isNotEmpty();
|
||||
returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty();
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify admin user is able to post stars rating to a document")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY })
|
||||
public void adminIsAbleToAddStarsToDocument() throws Exception
|
||||
{
|
||||
{
|
||||
returnedRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).rateStarsToDocument(3);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
returnedRatingModel.assertThat().field("myRating").is(String.valueOf(3))
|
||||
.and().field("id").is("fiveStar")
|
||||
.and().field("aggregate").isNotEmpty();
|
||||
returnedRatingModel.assertThat().field("myRating").is(String.valueOf(3)).and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty();
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to post stars rating to a document")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY })
|
||||
@Bug(id = "MNT-16904")
|
||||
public void unauthenticatedUserIsNotAbleToRateStarsToDocument() throws Exception
|
||||
{
|
||||
|
||||
@@ -20,7 +20,6 @@ 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 DeleteRatingCoreTests extends RestTest
|
||||
{
|
||||
|
||||
@@ -31,74 +30,79 @@ public class DeleteRatingCoreTests extends RestTest
|
||||
private ListUserWithRoles usersWithRoles;
|
||||
private RestRatingModel returnedRatingModel;
|
||||
|
||||
@BeforeClass(alwaysRun=true)
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void dataPreparation() throws DataPreparationException
|
||||
{
|
||||
adminUser = dataUser.getAdminUser();
|
||||
siteModel = dataSite.usingUser(adminUser).createPublicRandomSite();
|
||||
|
||||
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,
|
||||
UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor);
|
||||
|
||||
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer,
|
||||
UserRole.SiteContributor);
|
||||
}
|
||||
|
||||
|
||||
@BeforeMethod()
|
||||
public void setUp() throws DataPreparationException, Exception {
|
||||
public void setUp() throws DataPreparationException, Exception
|
||||
{
|
||||
folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder();
|
||||
document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
}
|
||||
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that if ratingId provided is unknown status code returned is 400")
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify that if ratingId provided is unknown status code returned is 400")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE })
|
||||
public void deleteInvalidRating() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).deleteInvalidRating("random_rating");
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_RATING, "random_rating"));
|
||||
}
|
||||
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that if nodeId does not exist status code returned is 404")
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify that if nodeId does not exist status code returned is 404")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE })
|
||||
public void deleteRatingUsingInvalidDocument() throws Exception
|
||||
{
|
||||
document.setNodeRef("random_value");
|
||||
restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).deleteLikeRating();
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "random_value"));
|
||||
}
|
||||
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Delete rating stars for a document that was not rated")
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Delete rating stars for a document that was not rated")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE })
|
||||
@Bug(id = "MNT-17181")
|
||||
public void deleteStarsForANotRatedDocument() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).deleteFiveStarRating();
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND);
|
||||
}
|
||||
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Delete like rating for a document that was not liked")
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Delete like rating for a document that was not liked")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE })
|
||||
@Bug(id = "MNT-17181")
|
||||
public void deleteLikeForANotLikedDocument() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).deleteLikeRating();
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND);
|
||||
}
|
||||
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Delete like for a file then add it again")
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Delete like for a file then add it again")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE })
|
||||
public void likeDocumentAfterLikeRatingIsDeleted() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument();
|
||||
restClient.withCoreAPI().usingResource(document).deleteLikeRating();
|
||||
returnedRatingModel = restClient.withCoreAPI().usingResource(document).likeDocument();
|
||||
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
|
||||
returnedRatingModel.assertThat().field("myRating").is("true")
|
||||
.and().field("id").is("likes")
|
||||
.and().field("aggregate").isNotEmpty();
|
||||
|
||||
returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty();
|
||||
}
|
||||
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Delete stars for a file then add them again")
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Delete stars for a file then add them again")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE })
|
||||
public void addStarsToDocumentAfterRatingIsDeleted() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(document).rateStarsToDocument(5);
|
||||
@@ -106,16 +110,15 @@ public class DeleteRatingCoreTests extends RestTest
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
|
||||
returnedRatingModel = restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5);
|
||||
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
|
||||
returnedRatingModel.assertThat().field("myRating").is("5")
|
||||
.and().field("id").is("fiveStar")
|
||||
.and().field("aggregate").isNotEmpty();
|
||||
|
||||
returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty();
|
||||
}
|
||||
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Delete rating of a document using site manager")
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Delete rating of a document using site manager")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE })
|
||||
public void deleteDocumentRatingUsingManager() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(document).rateStarsToDocument(5);
|
||||
@@ -124,17 +127,18 @@ public class DeleteRatingCoreTests extends RestTest
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document).deleteFiveStarRating();
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document).deleteLikeRating();
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
|
||||
restClient.withCoreAPI().usingResource(document).getRatings().assertNodeIsLiked().assertNodeHasFiveStarRating();
|
||||
|
||||
restClient.withCoreAPI().usingResource(document).getRatings().assertNodeIsLiked().assertNodeHasFiveStarRating();
|
||||
}
|
||||
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "One user is not able to delete like of another user")
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "One user is not able to delete like of another user")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE })
|
||||
public void deleteLikeOfAnotherUser() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingResource(document).likeDocument();
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(document).deleteLikeRating();
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
restClient.withCoreAPI().usingResource(document).getRatings().assertNodeIsLiked();
|
||||
restClient.withCoreAPI().usingResource(document).getRatings().assertNodeIsLiked();
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,6 @@ import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY })
|
||||
public class DeleteRatingSanityTests extends RestTest
|
||||
{
|
||||
|
||||
@@ -26,177 +25,172 @@ public class DeleteRatingSanityTests extends RestTest
|
||||
private ListUserWithRoles usersWithRoles;
|
||||
private RestRatingModelsCollection returnedRatingModelCollection;
|
||||
|
||||
@BeforeClass(alwaysRun=true)
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void dataPreparation() throws DataPreparationException
|
||||
{
|
||||
adminUser = dataUser.getAdminUser();
|
||||
siteModel = dataSite.usingUser(adminUser).createPublicRandomSite();
|
||||
|
||||
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,
|
||||
UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor);
|
||||
|
||||
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer,
|
||||
UserRole.SiteContributor);
|
||||
}
|
||||
|
||||
|
||||
@BeforeMethod()
|
||||
public void setUp() throws DataPreparationException, Exception {
|
||||
public void setUp() throws DataPreparationException, Exception
|
||||
{
|
||||
folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder();
|
||||
document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
}
|
||||
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify user with Manager role is able to remove its own rating of a document")
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role is able to remove its own rating of a document")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY })
|
||||
public void managerIsAbleToDeleteItsOwnRatings() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
restClient.withCoreAPI().usingResource(document).likeDocument();
|
||||
restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5);
|
||||
|
||||
|
||||
restClient.withCoreAPI().usingResource(document).deleteLikeRating();
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
|
||||
|
||||
restClient.withCoreAPI().usingResource(document).deleteFiveStarRating();
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
|
||||
|
||||
returnedRatingModelCollection = restClient.withCoreAPI().usingResource(document).getRatings();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedRatingModelCollection.assertNodeIsNotLiked()
|
||||
.assertNodeHasNoFiveStarRating()
|
||||
.and().entriesListIsNotEmpty()
|
||||
.and().paginationExist();
|
||||
}
|
||||
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify user with Collaborator role is able to remove its own rating of a document")
|
||||
returnedRatingModelCollection.assertNodeIsNotLiked().assertNodeHasNoFiveStarRating().and().entriesListIsNotEmpty().and().paginationExist();
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role is able to remove its own rating of a document")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY })
|
||||
public void collaboratorIsAbleToDeleteItsOwnRatings() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
|
||||
|
||||
restClient.withCoreAPI().usingResource(document).likeDocument();
|
||||
restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5);
|
||||
|
||||
|
||||
restClient.withCoreAPI().usingResource(document).deleteLikeRating();
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
|
||||
|
||||
restClient.withCoreAPI().usingResource(document).deleteFiveStarRating();
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
|
||||
|
||||
returnedRatingModelCollection = restClient.withCoreAPI().usingResource(document).getRatings();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedRatingModelCollection.assertNodeIsNotLiked()
|
||||
.assertNodeHasNoFiveStarRating()
|
||||
.and().entriesListIsNotEmpty()
|
||||
.and().paginationExist();
|
||||
}
|
||||
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify user with Contributor role is able to remove its own rating of a document")
|
||||
returnedRatingModelCollection.assertNodeIsNotLiked().assertNodeHasNoFiveStarRating().and().entriesListIsNotEmpty().and().paginationExist();
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role is able to remove its own rating of a document")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY })
|
||||
public void contributorIsAbleToDeleteItsOwnRatings() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
|
||||
|
||||
restClient.withCoreAPI().usingResource(document).likeDocument();
|
||||
restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5);
|
||||
|
||||
|
||||
restClient.withCoreAPI().usingResource(document).deleteLikeRating();
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
|
||||
|
||||
restClient.withCoreAPI().usingResource(document).deleteFiveStarRating();
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
|
||||
|
||||
returnedRatingModelCollection = restClient.withCoreAPI().usingResource(document).getRatings();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedRatingModelCollection.assertNodeIsNotLiked()
|
||||
.assertNodeHasNoFiveStarRating()
|
||||
.and().entriesListIsNotEmpty()
|
||||
.and().paginationExist();
|
||||
}
|
||||
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify user with Consumer role is able to remove its own rating of a document")
|
||||
returnedRatingModelCollection.assertNodeIsNotLiked().assertNodeHasNoFiveStarRating().and().entriesListIsNotEmpty().and().paginationExist();
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role is able to remove its own rating of a document")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY })
|
||||
public void consumerIsAbleToDeleteItsOwnRatings() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer));
|
||||
|
||||
restClient.withCoreAPI().usingResource(document).likeDocument();
|
||||
restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5);
|
||||
|
||||
|
||||
restClient.withCoreAPI().usingResource(document).deleteLikeRating();
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
|
||||
|
||||
restClient.withCoreAPI().usingResource(document).deleteFiveStarRating();
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
|
||||
|
||||
returnedRatingModelCollection = restClient.withCoreAPI().usingResource(document).getRatings();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedRatingModelCollection.assertNodeIsNotLiked()
|
||||
.assertNodeHasNoFiveStarRating()
|
||||
.and().entriesListIsNotEmpty()
|
||||
.and().paginationExist();
|
||||
}
|
||||
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify admin user is able to remove its own rating of a document")
|
||||
returnedRatingModelCollection.assertNodeIsNotLiked().assertNodeHasNoFiveStarRating().and().entriesListIsNotEmpty().and().paginationExist();
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify admin user is able to remove its own rating of a document")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY })
|
||||
public void adminIsAbleToDeleteItsOwnRatings() throws Exception
|
||||
{
|
||||
document = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
document = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).usingResource(folderModel)
|
||||
.createContent(DocumentType.TEXT_PLAIN);
|
||||
|
||||
restClient.authenticateUser(adminUser);
|
||||
|
||||
restClient.withCoreAPI().usingResource(document).likeDocument();
|
||||
restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5);
|
||||
|
||||
|
||||
restClient.withCoreAPI().usingResource(document).deleteLikeRating();
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
|
||||
|
||||
restClient.withCoreAPI().usingResource(document).deleteFiveStarRating();
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
|
||||
|
||||
returnedRatingModelCollection = restClient.withCoreAPI().usingResource(document).getRatings();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedRatingModelCollection.assertNodeIsNotLiked()
|
||||
.assertNodeHasNoFiveStarRating()
|
||||
.and().entriesListIsNotEmpty()
|
||||
.and().paginationExist();
|
||||
returnedRatingModelCollection.assertNodeIsNotLiked().assertNodeHasNoFiveStarRating().and().entriesListIsNotEmpty().and().paginationExist();
|
||||
}
|
||||
|
||||
@Bug(id = "MNT-16904")
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify unauthenticated user is not able to remove its own rating of a document")
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to remove its own rating of a document")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY })
|
||||
public void unauthenticatedUserIsNotAbleToDeleteRatings() throws Exception
|
||||
{
|
||||
document = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
document = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).usingResource(folderModel)
|
||||
.createContent(DocumentType.TEXT_PLAIN);
|
||||
restClient.authenticateUser(adminUser);
|
||||
|
||||
|
||||
restClient.withCoreAPI().usingResource(document).likeDocument();
|
||||
restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5);
|
||||
|
||||
|
||||
restClient.authenticateUser(new UserModel("random user", "random password"));
|
||||
|
||||
|
||||
restClient.withCoreAPI().usingResource(document).deleteLikeRating();
|
||||
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED);
|
||||
|
||||
|
||||
restClient.withCoreAPI().usingResource(document).deleteFiveStarRating();
|
||||
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED);
|
||||
}
|
||||
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify one user is not able to remove rating added by another user")
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify one user is not able to remove rating added by another user")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY })
|
||||
@Bug(id = "ACE-5459")
|
||||
public void oneUserIsNotAbleToDeleteRatingsOfAnotherUser() throws Exception
|
||||
{
|
||||
UserModel userA = dataUser.createRandomTestUser();
|
||||
UserModel userB = dataUser.createRandomTestUser();
|
||||
|
||||
|
||||
restClient.authenticateUser(userA);
|
||||
|
||||
|
||||
restClient.withCoreAPI().usingResource(document).likeDocument();
|
||||
restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5);
|
||||
|
||||
|
||||
restClient.authenticateUser(userB);
|
||||
|
||||
|
||||
restClient.authenticateUser(userB).withCoreAPI().usingResource(document).deleteLikeRating();
|
||||
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED);
|
||||
|
||||
|
||||
restClient.withCoreAPI().usingResource(document).deleteFiveStarRating();
|
||||
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,6 @@ 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
|
||||
{
|
||||
private SiteModel siteModel;
|
||||
@@ -45,16 +44,19 @@ public class GetRatingCoreTests extends RestTest
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Check that using invalid ratingId for get rating call returns status code 400.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE })
|
||||
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(String.format(RestErrorModel.INVALID_RATING, "invalid ratingId"));
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError()
|
||||
.containsSummary(String.format(RestErrorModel.INVALID_RATING, "invalid ratingId"));
|
||||
}
|
||||
|
||||
@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.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE })
|
||||
public void getRatingUsingInvalidNodeId() throws Exception
|
||||
{
|
||||
document.setNodeRef(RandomStringUtils.randomAlphanumeric(20));
|
||||
@@ -66,6 +68,7 @@ public class GetRatingCoreTests extends RestTest
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Get rating of a file that has only likes.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE })
|
||||
public void getRatingOfFileThatHasOnlyLikes() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).likeDocument();
|
||||
@@ -82,6 +85,7 @@ public class GetRatingCoreTests extends RestTest
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Get rating of a file that has only stars.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE })
|
||||
public void getRatingOfFileThatHasOnlyStars() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).rateStarsToDocument(5);
|
||||
@@ -98,6 +102,7 @@ public class GetRatingCoreTests extends RestTest
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Get rating of a file that has likes and stars.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE })
|
||||
public void getRatingOfFileThatHasLikesAndStars() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).likeDocument();
|
||||
@@ -116,6 +121,7 @@ public class GetRatingCoreTests extends RestTest
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Get rating of a folder that has only likes.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE })
|
||||
public void getRatingOfFolderThatHasOnlyLikes() throws Exception
|
||||
{
|
||||
firstFolderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder();
|
||||
@@ -129,6 +135,7 @@ public class GetRatingCoreTests extends RestTest
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Get rating of a file that has no ratings.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE })
|
||||
public void getRatingOfFileThatHasNoRatings() throws Exception
|
||||
{
|
||||
returnedRatingModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getLikeRating();
|
||||
|
||||
@@ -20,110 +20,116 @@ import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY })
|
||||
public class GetRatingSanityTests extends RestTest
|
||||
{
|
||||
|
||||
private SiteModel siteModel;
|
||||
private UserModel adminUser;
|
||||
private FolderModel folderModel;
|
||||
private FileModel document;
|
||||
private FileModel document;
|
||||
private ListUserWithRoles usersWithRoles;
|
||||
private RestRatingModel restRatingModel;
|
||||
|
||||
@BeforeClass(alwaysRun=true)
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void dataPreparation() throws DataPreparationException
|
||||
{
|
||||
adminUser = dataUser.getAdminUser();
|
||||
siteModel = dataSite.usingUser(adminUser).createPublicRandomSite();
|
||||
|
||||
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,
|
||||
UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor);
|
||||
|
||||
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer,
|
||||
UserRole.SiteContributor);
|
||||
}
|
||||
|
||||
|
||||
@BeforeMethod()
|
||||
public void setUp() throws DataPreparationException, Exception {
|
||||
public void setUp() throws DataPreparationException, Exception
|
||||
{
|
||||
folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder();
|
||||
document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
}
|
||||
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify user with Manager role is able to retrieve rating of a document")
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role is able to retrieve rating of a document")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY })
|
||||
public void managerIsAbleToRetrieveRating() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
|
||||
restClient.withCoreAPI().usingResource(document).likeDocument();
|
||||
restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5);
|
||||
|
||||
|
||||
restRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
restRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true");
|
||||
|
||||
|
||||
restRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").is("5");
|
||||
}
|
||||
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify user with Collaborator role is able to retrieve rating of a document")
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role is able to retrieve rating of a document")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY })
|
||||
public void collaboratorIsAbleToRetrieveRating() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
|
||||
|
||||
restClient.withCoreAPI().usingResource(document).likeDocument();
|
||||
restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5);
|
||||
|
||||
|
||||
restRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
restRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true");
|
||||
|
||||
|
||||
restRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").is("5");
|
||||
}
|
||||
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify user with Contributor role is able to retrieve rating of a document")
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role is able to retrieve rating of a document")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY })
|
||||
public void contributorIsAbleToRetrieveRating() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
|
||||
|
||||
restClient.withCoreAPI().usingResource(document).likeDocument();
|
||||
restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5);
|
||||
|
||||
|
||||
restRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
restRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true");
|
||||
|
||||
|
||||
restRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").is("5");
|
||||
}
|
||||
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify user with Consumer role is able to retrieve rating of a document")
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role is able to retrieve rating of a document")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY })
|
||||
public void consumerIsAbleToRetrieveRating() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer));
|
||||
|
||||
restClient.withCoreAPI().usingResource(document).likeDocument();
|
||||
restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5);
|
||||
|
||||
|
||||
restRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
restRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true");
|
||||
|
||||
|
||||
restRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").is("5");
|
||||
}
|
||||
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify admin user is able to retrieve rating of a document")
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify admin user is able to retrieve rating of a document")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY })
|
||||
public void adminIsAbleToRetrieveRating() throws Exception
|
||||
{
|
||||
document = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
document = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingResource(folderModel)
|
||||
.createContent(DocumentType.TEXT_PLAIN);
|
||||
|
||||
restClient.authenticateUser(adminUser);
|
||||
restClient.withCoreAPI().usingResource(document).likeDocument();
|
||||
@@ -132,14 +138,15 @@ public class GetRatingSanityTests extends RestTest
|
||||
restRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
restRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true");
|
||||
|
||||
|
||||
restRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").is("5");
|
||||
}
|
||||
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify unauthenticated user is not able to retrieve rating of a document")
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to retrieve rating of a document")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY })
|
||||
@Bug(id = "MNT-16904")
|
||||
public void unauthenticatedUserIsNotAbleToRetrieveRating() throws Exception
|
||||
{
|
||||
@@ -148,11 +155,11 @@ public class GetRatingSanityTests extends RestTest
|
||||
restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5);
|
||||
|
||||
restClient.authenticateUser(new UserModel("random user", "random password"));
|
||||
|
||||
|
||||
restClient.withCoreAPI().usingResource(document).getLikeRating();
|
||||
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED);
|
||||
|
||||
|
||||
restClient.withCoreAPI().usingResource(document).getFiveStarRating();
|
||||
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,79 +17,82 @@ 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 GetRatingsCoreTests extends RestTest {
|
||||
private SiteModel siteModel;
|
||||
private UserModel adminUserModel, userModel;
|
||||
private FileModel document;
|
||||
private RestRatingModel returnedRatingModel;
|
||||
public class GetRatingsCoreTests extends RestTest
|
||||
{
|
||||
private SiteModel siteModel;
|
||||
private UserModel adminUserModel, userModel;
|
||||
private FileModel document;
|
||||
private RestRatingModel returnedRatingModel;
|
||||
|
||||
@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);
|
||||
}
|
||||
@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 maxItems status code is 400")
|
||||
public void checkInvalidMaxItemsStatusCode() throws Exception {
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Check that rating for invalid maxItems status code is 400")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE })
|
||||
public void checkInvalidMaxItemsStatusCode() throws Exception
|
||||
{
|
||||
|
||||
restClient.authenticateUser(adminUserModel).withParams("maxItems=0").withCoreAPI().usingResource(document)
|
||||
.getLikeRating();
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError()
|
||||
.containsSummary("Only positive values supported for maxItems");
|
||||
}
|
||||
restClient.authenticateUser(adminUserModel).withParams("maxItems=0").withCoreAPI().usingResource(document).getLikeRating();
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Only positive values supported for maxItems");
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Check that rating for invalid skipCount status code is 400")
|
||||
public void checkInvalidSkipCountStatusCode() throws Exception {
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Check that rating for invalid skipCount status code is 400")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE })
|
||||
public void checkInvalidSkipCountStatusCode() throws Exception
|
||||
{
|
||||
|
||||
restClient.authenticateUser(adminUserModel).withParams("skipCount=AB").withCoreAPI().usingResource(document)
|
||||
.getLikeRating();
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError()
|
||||
.containsSummary("Invalid paging parameter skipCount:AB");
|
||||
}
|
||||
restClient.authenticateUser(adminUserModel).withParams("skipCount=AB").withCoreAPI().usingResource(document).getLikeRating();
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Invalid paging parameter skipCount:AB");
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "If nodeId does not exist status code is 404 when a document is liked")
|
||||
public void addLikeUsingInvalidNodeId() throws Exception {
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "If nodeId does not exist status code is 404 when a document is liked")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE })
|
||||
public void addLikeUsingInvalidNodeId() throws Exception
|
||||
{
|
||||
|
||||
document.setNodeRef(RandomStringUtils.randomAlphanumeric(20));
|
||||
returnedRatingModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document)
|
||||
.likeDocument();
|
||||
document.setNodeRef(RandomStringUtils.randomAlphanumeric(20));
|
||||
returnedRatingModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).likeDocument();
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError()
|
||||
.containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, document.getNodeRef()));
|
||||
}
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError()
|
||||
.containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, document.getNodeRef()));
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Check that rating value is TRUE for a like rating")
|
||||
public void checkRatingValueIsTrueForLikedDoc() throws Exception {
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Check that rating value is TRUE for a like rating")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE })
|
||||
public void checkRatingValueIsTrueForLikedDoc() throws Exception
|
||||
{
|
||||
|
||||
returnedRatingModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document)
|
||||
.likeDocument();
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
returnedRatingModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).likeDocument();
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
|
||||
returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes");
|
||||
}
|
||||
returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes");
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Check that rating value is an INTEGER value for stars rating")
|
||||
public void checkRatingValueIsIntegerForStarsRating() throws Exception {
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Check that rating value is an INTEGER value for stars rating")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE })
|
||||
public void checkRatingValueIsIntegerForStarsRating() throws Exception
|
||||
{
|
||||
|
||||
returnedRatingModel = restClient.authenticateUser(userModel).withCoreAPI().usingResource(document)
|
||||
.rateStarsToDocument(5);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
returnedRatingModel = restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).rateStarsToDocument(5);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
|
||||
returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar")
|
||||
.and().field("aggregate").isNotEmpty();
|
||||
}
|
||||
returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,94 +19,99 @@ import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY })
|
||||
public class GetRatingsSanityTests extends RestTest
|
||||
{
|
||||
private SiteModel siteModel;
|
||||
private UserModel adminUser;
|
||||
private FolderModel folderModel;
|
||||
private FileModel document;
|
||||
private FileModel document;
|
||||
private ListUserWithRoles usersWithRoles;
|
||||
private RestRatingModelsCollection restRatingModelsCollection;
|
||||
|
||||
@BeforeClass(alwaysRun=true)
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void dataPreparation() throws DataPreparationException
|
||||
{
|
||||
adminUser = dataUser.getAdminUser();
|
||||
siteModel = dataSite.usingUser(adminUser).createPublicRandomSite();
|
||||
|
||||
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,
|
||||
UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor);
|
||||
|
||||
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer,
|
||||
UserRole.SiteContributor);
|
||||
}
|
||||
|
||||
|
||||
@BeforeMethod()
|
||||
public void setUp() throws DataPreparationException, Exception {
|
||||
public void setUp() throws DataPreparationException, Exception
|
||||
{
|
||||
folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder();
|
||||
document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
}
|
||||
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY,
|
||||
description = "Manager is able to retrieve document ratings")
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Manager is able to retrieve document ratings")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY })
|
||||
public void managerIsAbleToRetrieveDocumentRatings() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
|
||||
restClient.withCoreAPI().usingResource(document).likeDocument();
|
||||
restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5);
|
||||
|
||||
|
||||
restRatingModelsCollection = restClient.withCoreAPI().usingResource(document).getRatings();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
restRatingModelsCollection.assertNodeHasFiveStarRating().assertNodeIsLiked();
|
||||
}
|
||||
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY,
|
||||
description = "Collaborator is able to retrieve document ratings")
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Collaborator is able to retrieve document ratings")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY })
|
||||
public void collaboratorIsAbleToRetrieveDocumentRatings() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
|
||||
|
||||
restClient.withCoreAPI().usingResource(document).likeDocument();
|
||||
restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5);
|
||||
|
||||
|
||||
restRatingModelsCollection = restClient.withCoreAPI().usingResource(document).getRatings();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
restRatingModelsCollection.assertNodeHasFiveStarRating().assertNodeIsLiked();
|
||||
}
|
||||
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY,
|
||||
description = "Contributor is able to retrieve document ratings")
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Contributor is able to retrieve document ratings")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY })
|
||||
public void contributorIsAbleToRetrieveDocumentRatings() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
|
||||
|
||||
restClient.withCoreAPI().usingResource(document).likeDocument();
|
||||
restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5);
|
||||
|
||||
|
||||
restRatingModelsCollection = restClient.withCoreAPI().usingResource(document).getRatings();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
restRatingModelsCollection.assertNodeHasFiveStarRating().assertNodeIsLiked();
|
||||
}
|
||||
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY,
|
||||
description = "Consumer is able to retrieve document ratings")
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Consumer is able to retrieve document ratings")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY })
|
||||
public void consumerIsAbleToRetrieveDocumentRatings() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer));
|
||||
|
||||
restClient.withCoreAPI().usingResource(document).likeDocument();
|
||||
restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5);
|
||||
|
||||
|
||||
restRatingModelsCollection = restClient.withCoreAPI().usingResource(document).getRatings();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
restRatingModelsCollection.assertNodeHasFiveStarRating().assertNodeIsLiked();
|
||||
}
|
||||
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY,
|
||||
description = "Admin user is able to retrieve document ratings")
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Admin user is able to retrieve document ratings")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY })
|
||||
public void adminIsAbleToRetrieveDocumentRatings() throws Exception
|
||||
{
|
||||
document = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor))
|
||||
.usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
document = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingResource(folderModel)
|
||||
.createContent(DocumentType.TEXT_PLAIN);
|
||||
|
||||
restClient.authenticateUser(adminUser);
|
||||
restClient.withCoreAPI().usingResource(document).likeDocument();
|
||||
@@ -115,10 +120,11 @@ public class GetRatingsSanityTests extends RestTest
|
||||
restRatingModelsCollection = restClient.withCoreAPI().usingResource(document).getRatings();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
restRatingModelsCollection.assertNodeHasFiveStarRating().assertNodeIsLiked();
|
||||
}
|
||||
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify unauthenticated user is not able to retrieve document ratings")
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to retrieve document ratings")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY })
|
||||
public void unauthenticatedUserIsNotAbleToRetrieveRatings() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUser);
|
||||
@@ -126,8 +132,8 @@ public class GetRatingsSanityTests extends RestTest
|
||||
restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5);
|
||||
|
||||
restClient.authenticateUser(new UserModel("random user", "random password"));
|
||||
|
||||
|
||||
restClient.withCoreAPI().usingResource(document).getRatings();
|
||||
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user