wip: on NPE tests

This commit is contained in:
Paul Brodner
2016-12-13 23:39:10 +02:00
parent c7ec0786d8
commit de43fef7dc
4 changed files with 103 additions and 42 deletions
@@ -18,7 +18,6 @@ import org.alfresco.utility.testrail.annotation.TestRail;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@Test(groups="DEV")
public class AddSiteMembershipRequestSanityTests extends RestTest
@@ -33,8 +32,7 @@ public class AddSiteMembershipRequestSanityTests extends RestTest
private ListUserWithRoles usersWithRoles;
private UserModel adminUser;
private UserModel newMember;
private UserModel adminUser;
private RestSiteMembershipRequestModel requestModel;
@BeforeClass(alwaysRun = true)
@@ -46,17 +44,12 @@ public class AddSiteMembershipRequestSanityTests extends RestTest
UserRole.SiteContributor);
}
@BeforeMethod
public void setUp() throws DataPreparationException
{
newMember = dataUser.createRandomTestUser();
}
@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY })
@TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site manager is able to create new site membership request")
@Bug(id = "MNT-16557")
public void siteManagerIsAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception
{
UserModel newMember = dataUser.createRandomTestUser();
requestModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingUser(newMember)
.addSiteMembershipRequest(siteModel);
restClient.assertStatusCodeIs(HttpStatus.CREATED);
@@ -68,6 +61,7 @@ public class AddSiteMembershipRequestSanityTests extends RestTest
@Bug(id = "MNT-16557")
public void siteCollaboatorIsAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception
{
UserModel newMember = dataUser.createRandomTestUser();
requestModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(newMember)
.addSiteMembershipRequest(siteModel);
restClient.assertStatusCodeIs(HttpStatus.CREATED);
@@ -79,6 +73,7 @@ public class AddSiteMembershipRequestSanityTests extends RestTest
@Bug(id = "MNT-16557")
public void siteContributorIsAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception
{
UserModel newMember = dataUser.createRandomTestUser();
requestModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingUser(newMember)
.addSiteMembershipRequest(siteModel);
restClient.assertStatusCodeIs(HttpStatus.CREATED);
@@ -90,6 +85,7 @@ public class AddSiteMembershipRequestSanityTests extends RestTest
@Bug(id = "MNT-16557")
public void siteConsumerIsAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception
{
UserModel newMember = dataUser.createRandomTestUser();
requestModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingUser(newMember)
.addSiteMembershipRequest(siteModel);
restClient.assertStatusCodeIs(HttpStatus.CREATED);
@@ -101,6 +97,7 @@ public class AddSiteMembershipRequestSanityTests extends RestTest
@Bug(id = "MNT-16557")
public void adminUserIsAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception
{
UserModel newMember = dataUser.createRandomTestUser();
requestModel = restClient.authenticateUser(adminUser).withCoreAPI().usingUser(newMember).addSiteMembershipRequest(siteModel);
restClient.assertStatusCodeIs(HttpStatus.CREATED);
requestModel.assertThat().field("id").isNotEmpty().assertThat().field("site").isNotEmpty();
@@ -110,6 +107,7 @@ public class AddSiteMembershipRequestSanityTests extends RestTest
@TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to create new site membership request")
public void unauthenticatedUserIsNotAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception
{
UserModel newMember = dataUser.createRandomTestUser();
restClient.authenticateUser(new UserModel("random user", "random password")).withCoreAPI().usingUser(newMember).addSiteMembershipRequest(siteModel);
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED);
}
@@ -21,16 +21,13 @@ import org.alfresco.utility.testrail.annotation.TestRail;
import org.apache.commons.lang3.RandomStringUtils;
import org.springframework.http.HttpStatus;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
public class AddRatingCoreTests extends RestTest
{
private UserModel userModel;
private SiteModel siteModel;
private UserModel adminUser;
private FolderModel folderModel;
private FileModel document;
private UserModel adminUser;
private ListUserWithRoles usersWithRoles;
private RestRatingModel returnedRatingModel; // placeholder for returned model
@@ -45,18 +42,13 @@ public class AddRatingCoreTests extends RestTest
UserRole.SiteContributor);
}
@BeforeMethod
public void setUp() throws Exception
{
folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder();
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")
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE })
public void unknownRatingSchemeReturnsBadRequest() throws Exception
{
FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder();
FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN);
restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"invalidRate\"}");
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_RATING, "invalidRate"));
}
@@ -66,6 +58,9 @@ public class AddRatingCoreTests extends RestTest
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE })
public void invalidNodeIdReturnsNotFound() throws Exception
{
FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder();
FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN);
document.setNodeRef(RandomStringUtils.randomAlphanumeric(10));
restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument();
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError()
@@ -78,6 +73,9 @@ public class AddRatingCoreTests extends RestTest
@Bug(id = "MNT-16904")
public void likeResourceThatCannotBeRated() throws Exception
{
FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder();
FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN);
LinkModel link = dataLink.usingAdmin().usingSite(siteModel).createRandomLink();
document.setNodeRef(link.getNodeRef());
restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument();
@@ -89,6 +87,9 @@ public class AddRatingCoreTests extends RestTest
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE })
public void managerIsAbleToLikeAFile() throws Exception
{
FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder();
FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN);
returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document)
.likeDocument();
restClient.assertStatusCodeIs(HttpStatus.CREATED);
@@ -101,6 +102,8 @@ public class AddRatingCoreTests extends RestTest
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE })
public void managerIsAbleToLikeAFolder() throws Exception
{
FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder();
returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(folderModel)
.likeDocument();
restClient.assertStatusCodeIs(HttpStatus.CREATED);
@@ -113,6 +116,7 @@ public class AddRatingCoreTests extends RestTest
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE })
public void managerIsAbleToRateAFolder() throws Exception
{
FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder();
returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(folderModel)
.rateStarsToDocument(5);
restClient.assertStatusCodeIs(HttpStatus.CREATED);
@@ -125,6 +129,8 @@ public class AddRatingCoreTests extends RestTest
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE })
public void managerIsAbleToRateAFile() throws Exception
{
FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder();
FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN);
returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document)
.rateStarsToDocument(5);
restClient.assertStatusCodeIs(HttpStatus.CREATED);
@@ -137,6 +143,9 @@ public class AddRatingCoreTests extends RestTest
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE })
public void fileCanBeLikedTwice() throws Exception
{
FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder();
FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN);
restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument();
restClient.assertStatusCodeIs(HttpStatus.CREATED);
returnedRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument();
@@ -150,6 +159,9 @@ public class AddRatingCoreTests extends RestTest
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE })
public void fileCanBeRatedTwice() throws Exception
{
FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder();
FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN);
restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).rateStarsToDocument(5);
restClient.assertStatusCodeIs(HttpStatus.CREATED);
returnedRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).rateStarsToDocument(5);
@@ -163,6 +175,9 @@ public class AddRatingCoreTests extends RestTest
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE })
public void addRateUsingEmptyRatingObject() throws Exception
{
FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder();
FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN);
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"));
@@ -173,6 +188,9 @@ public class AddRatingCoreTests extends RestTest
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE })
public void addRateUsingEmptyValueForId() throws Exception
{
FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder();
FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN);
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\"])"));
@@ -183,6 +201,9 @@ public class AddRatingCoreTests extends RestTest
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE })
public void addRateUsingEmptyValueForMyRating() throws Exception
{
FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder();
FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN);
restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"likes\", \"myRating\":\"\"}");
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.NULL_LIKE_RATING));
@@ -195,6 +216,9 @@ public class AddRatingCoreTests extends RestTest
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE })
public void addRatingToAComment() throws Exception
{
FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder();
FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN);
RestCommentModel comment = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addComment("This is a comment");
document.setNodeRef(comment.getId());
@@ -210,6 +234,9 @@ public class AddRatingCoreTests extends RestTest
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE })
public void addRatingToATag() throws Exception
{
FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder();
FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN);
RestTagModel tag = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addTag("randomTag");
document.setNodeRef(tag.getId());
@@ -18,7 +18,6 @@ import org.alfresco.utility.testrail.annotation.TestRail;
import org.apache.commons.lang3.RandomStringUtils;
import org.springframework.http.HttpStatus;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@Test(groups="DEV")
@@ -27,8 +26,6 @@ public class AddRatingSanityTests extends RestTest
private UserModel userModel;
private SiteModel siteModel;
private UserModel adminUser;
private FolderModel folderModel;
private FileModel document;
private ListUserWithRoles usersWithRoles;
private RestRatingModel returnedRatingModel; // placeholder for returned model
@@ -42,19 +39,15 @@ public class AddRatingSanityTests extends RestTest
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer,
UserRole.SiteContributor);
}
@BeforeMethod
public void setUp() throws Exception
{
folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder();
document = dataContent.usingUser(userModel).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 post like rating to a document")
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY })
public void managerIsAbleToLikeDocument() throws Exception
{
FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder();
FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN);
returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document)
.likeDocument();
restClient.assertStatusCodeIs(HttpStatus.CREATED);
@@ -67,6 +60,9 @@ public class AddRatingSanityTests extends RestTest
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY })
public void collaboratorIsAbleToLikeDocument() throws Exception
{
FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder();
FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN);
returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(document)
.likeDocument();
restClient.assertStatusCodeIs(HttpStatus.CREATED);
@@ -79,6 +75,9 @@ public class AddRatingSanityTests extends RestTest
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY })
public void contributorIsAbleToLikeDocument() throws Exception
{
FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder();
FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN);
returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingResource(document)
.likeDocument();
restClient.assertStatusCodeIs(HttpStatus.CREATED);
@@ -91,6 +90,9 @@ public class AddRatingSanityTests extends RestTest
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY })
public void consumerIsAbleToLikeDocument() throws Exception
{
FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder();
FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN);
returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingResource(document)
.likeDocument();
restClient.assertStatusCodeIs(HttpStatus.CREATED);
@@ -103,6 +105,9 @@ public class AddRatingSanityTests extends RestTest
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY })
public void adminIsAbleToLikeDocument() throws Exception
{
FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder();
FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN);
returnedRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument();
restClient.assertStatusCodeIs(HttpStatus.CREATED);
@@ -114,6 +119,9 @@ public class AddRatingSanityTests extends RestTest
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY })
public void unauthenticatedUserIsNotAbleToLikeDocument() throws Exception
{
FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder();
FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN);
restClient.authenticateUser(new UserModel("random user", "random password")).withCoreAPI().usingResource(document).likeDocument();
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(RestErrorModel.AUTHENTICATION_FAILED);
}
@@ -123,6 +131,9 @@ public class AddRatingSanityTests extends RestTest
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY })
public void managerIsAbleToAddStarsToDocument() throws Exception
{
FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder();
FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN);
returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document)
.rateStarsToDocument(5);
restClient.assertStatusCodeIs(HttpStatus.CREATED);
@@ -134,6 +145,9 @@ public class AddRatingSanityTests extends RestTest
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY })
public void collaboratorIsAbleToAddStarsToDocument() throws Exception
{
FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder();
FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN);
returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(document)
.rateStarsToDocument(5);
restClient.assertStatusCodeIs(HttpStatus.CREATED);
@@ -146,6 +160,9 @@ public class AddRatingSanityTests extends RestTest
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY })
public void contributorIsAbleToAddStarsToDocument() throws Exception
{
FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder();
FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN);
returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingResource(document)
.rateStarsToDocument(5);
restClient.assertStatusCodeIs(HttpStatus.CREATED);
@@ -157,6 +174,9 @@ public class AddRatingSanityTests extends RestTest
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY })
public void consumerIsAbleToAddStarsToDocument() throws Exception
{
FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder();
FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN);
returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingResource(document)
.rateStarsToDocument(5);
restClient.assertStatusCodeIs(HttpStatus.CREATED);
@@ -168,6 +188,9 @@ public class AddRatingSanityTests extends RestTest
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY })
public void adminIsAbleToAddStarsToDocument() throws Exception
{
FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder();
FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN);
returnedRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).rateStarsToDocument(3);
restClient.assertStatusCodeIs(HttpStatus.CREATED);
returnedRatingModel.assertThat().field("myRating").is("3").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty();
@@ -178,6 +201,9 @@ public class AddRatingSanityTests extends RestTest
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY })
public void unauthenticatedUserIsNotAbleToRateStarsToDocument() throws Exception
{
FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder();
FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN);
restClient.authenticateUser(new UserModel("random user", "random password")).withCoreAPI().usingResource(document).rateStarsToDocument(5);
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED);
}
@@ -16,16 +16,12 @@ import org.alfresco.utility.testrail.ExecutionType;
import org.alfresco.utility.testrail.annotation.TestRail;
import org.springframework.http.HttpStatus;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
public class DeleteRatingSanityTests extends RestTest
{
private SiteModel siteModel;
private UserModel adminUser;
private FolderModel folderModel;
private FileModel document;
private ListUserWithRoles usersWithRoles;
private RestRatingModelsCollection returnedRatingModelCollection;
@@ -39,18 +35,15 @@ public class DeleteRatingSanityTests extends RestTest
UserRole.SiteContributor);
}
@BeforeMethod()
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")
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY })
public void managerIsAbleToDeleteItsOwnRatings() throws Exception
{
FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder();
FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN);
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
restClient.withCoreAPI().usingResource(document).likeDocument();
restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5);
@@ -71,6 +64,9 @@ public class DeleteRatingSanityTests extends RestTest
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY })
public void collaboratorIsAbleToDeleteItsOwnRatings() throws Exception
{
FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder();
FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN);
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
restClient.withCoreAPI().usingResource(document).likeDocument();
@@ -92,6 +88,9 @@ public class DeleteRatingSanityTests extends RestTest
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY })
public void contributorIsAbleToDeleteItsOwnRatings() throws Exception
{
FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder();
FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN);
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
restClient.withCoreAPI().usingResource(document).likeDocument();
@@ -113,6 +112,9 @@ public class DeleteRatingSanityTests extends RestTest
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY })
public void consumerIsAbleToDeleteItsOwnRatings() throws Exception
{
FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder();
FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN);
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer));
restClient.withCoreAPI().usingResource(document).likeDocument();
@@ -134,6 +136,9 @@ public class DeleteRatingSanityTests extends RestTest
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY })
public void adminIsAbleToDeleteItsOwnRatings() throws Exception
{
FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder();
FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN);
document = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).usingResource(folderModel)
.createContent(DocumentType.TEXT_PLAIN);
@@ -158,6 +163,9 @@ public class DeleteRatingSanityTests extends RestTest
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY })
public void unauthenticatedUserIsNotAbleToDeleteRatings() throws Exception
{
FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder();
FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN);
document = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).usingResource(folderModel)
.createContent(DocumentType.TEXT_PLAIN);
restClient.authenticateUser(adminUser);
@@ -178,6 +186,8 @@ public class DeleteRatingSanityTests extends RestTest
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY })
public void oneUserIsNotAbleToDeleteRatingsOfAnotherUser() throws Exception
{
FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder();
FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN);
UserModel userA = dataUser.createRandomTestUser();
UserModel userB = dataUser.createRandomTestUser();