Formatting, change test names

This commit is contained in:
Valentin Popa
2016-09-02 16:57:19 +03:00
parent 932ddb2e02
commit 5bb07e9f4d
4 changed files with 50 additions and 42 deletions

View File

@@ -47,13 +47,14 @@ public class RestDemoTest extends RestTest
* @throws Exception * @throws Exception
*/ */
@Test @Test
public void sitesTest() throws JsonToModelConversionException, Exception public void adminRetrievesCorrectSiteDetails() throws JsonToModelConversionException, Exception
{ {
sitesApi.getAllSites().assertThatResponseHasSite(siteModel) sitesApi.getAllSites()
.getSite(siteModel) .assertThatResponseHasSite(siteModel)
.assertSiteHasVisibility(Visibility.PUBLIC) .getSite(siteModel)
.assertSiteHasTitle(siteModel.getTitle()) .assertSiteHasVisibility(Visibility.PUBLIC)
.assertSiteHasDescription(siteModel.getDescription()); .assertSiteHasTitle(siteModel.getTitle())
.assertSiteHasDescription(siteModel.getDescription());
} }
/** /**
@@ -64,7 +65,7 @@ public class RestDemoTest extends RestTest
* @throws Exception * @throws Exception
*/ */
@Test @Test
public void commentsTest() throws Exception public void adminCanPostAndUpdateComments() throws Exception
{ {
FileModel fileModel = dataContent.usingResource("Shared") FileModel fileModel = dataContent.usingResource("Shared")
.usingUser(userModel) .usingUser(userModel)
@@ -72,18 +73,18 @@ public class RestDemoTest extends RestTest
// add new comment // add new comment
RestCommentModel commentEntry = commentsAPI.addComment(fileModel.getNodeRef(), "This is a new comment"); RestCommentModel commentEntry = commentsAPI.addComment(fileModel.getNodeRef(), "This is a new comment");
commentsAPI.getNodeComments(fileModel.getNodeRef()) commentsAPI.getNodeComments(fileModel.getNodeRef())
.assertThatResponseIsNotEmpty() .assertThatResponseIsNotEmpty()
.assertThatCommentWithIdExists(commentEntry.getId()) .assertThatCommentWithIdExists(commentEntry.getId())
.assertThatCommentWithContentExists("This is a new comment"); .assertThatCommentWithContentExists("This is a new comment");
// update comment // update comment
commentEntry = commentsAPI.updateComment(fileModel.getNodeRef(), commentEntry = commentsAPI.updateComment(fileModel.getNodeRef(),
commentEntry.getId(), commentEntry.getId(),
"This is the updated comment"); "This is the updated comment");
commentsAPI.getNodeComments(fileModel.getNodeRef()) commentsAPI.getNodeComments(fileModel.getNodeRef())
.assertThatResponseIsNotEmpty() .assertThatResponseIsNotEmpty()
.assertThatCommentWithIdExists(commentEntry.getId()) .assertThatCommentWithIdExists(commentEntry.getId())
.assertThatCommentWithContentExists("This is the updated comment"); .assertThatCommentWithContentExists("This is the updated comment");
} }
/** /**
@@ -96,29 +97,32 @@ public class RestDemoTest extends RestTest
* @throws JsonToModelConversionException * @throws JsonToModelConversionException
*/ */
@Test @Test
public void siteMembersTest() throws Exception public void adminCanAddAndUpdateSiteMemberDetails() throws Exception
{ {
UserModel newUser = dataUser.createRandomTestUser(); UserModel newUser = dataUser.createRandomTestUser();
SiteMember siteMember = new SiteMember(Role.SiteConsumer.toString(), newUser.getUsername()); SiteMember siteMember = new SiteMember(Role.SiteConsumer.toString(),
newUser.getUsername());
// add user as Consumer to site // add user as Consumer to site
sitesApi.addPerson(siteModel.getId(), siteMember); sitesApi.addPerson(siteModel.getId(), siteMember);
sitesApi.getSiteMembers(siteModel.getId()) sitesApi.getSiteMembers(siteModel.getId())
.assertThatSiteHasMember(siteMember.getId()) .assertThatSiteHasMember(siteMember.getId())
.getSiteMember(siteMember.getId()) .getSiteMember(siteMember.getId())
.assertSiteMemberHasRole(Role.SiteConsumer); .assertSiteMemberHasRole(Role.SiteConsumer);
// update site member to Manager // update site member to Manager
siteMember.setRole(Role.SiteManager.toString()); siteMember.setRole(Role.SiteManager.toString());
; sitesApi.updateSiteMember(siteModel.getId(),
sitesApi.updateSiteMember(siteModel.getId(), newUser.getUsername(), siteMember); newUser.getUsername(), siteMember);
sitesApi.getSiteMembers(siteModel.getId()) sitesApi.getSiteMembers(siteModel.getId())
.assertThatSiteHasMember(siteMember.getId()) .assertThatSiteHasMember(siteMember.getId())
.getSiteMember(siteMember.getId()) .getSiteMember(siteMember.getId())
.assertSiteMemberHasRole(Role.SiteManager); .assertSiteMemberHasRole(Role.SiteManager);
// delete site member // delete site member
sitesApi.deleteSiteMember(siteModel.getId(), newUser.getUsername()); sitesApi.deleteSiteMember(siteModel.getId(),
sitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT.toString()); newUser.getUsername());
sitesApi.usingRestWrapper()
.assertStatusCodeIs(HttpStatus.NO_CONTENT.toString());
} }
} }

View File

@@ -35,7 +35,7 @@ public class SampleCommentsTest extends RestTest
} }
@Test @Test
public void addComments() throws JsonToModelConversionException, Exception public void adminIsAbleToAddComment() throws JsonToModelConversionException, Exception
{ {
commentsAPI.addComment(document.getNodeRef(), "This is a new comment"); commentsAPI.addComment(document.getNodeRef(), "This is a new comment");
commentsAPI.usingRestWrapper() commentsAPI.usingRestWrapper()
@@ -43,7 +43,7 @@ public class SampleCommentsTest extends RestTest
} }
@Test @Test
public void getCommentsCheckStatusCode() throws JsonToModelConversionException public void adminIsAbleToRetrieveComments() throws JsonToModelConversionException
{ {
commentsAPI.getNodeComments(document.getNodeRef()); commentsAPI.getNodeComments(document.getNodeRef());
commentsAPI.usingRestWrapper() commentsAPI.usingRestWrapper()
@@ -51,13 +51,15 @@ public class SampleCommentsTest extends RestTest
} }
@Test @Test
public void updateComment() throws JsonToModelConversionException, Exception public void adminIsAbleToUpdateComment() throws JsonToModelConversionException, Exception
{ {
// add initial comment // add initial comment
String commentId = commentsAPI.addComment(document.getNodeRef(), "This is a new comment").getId(); String commentId = commentsAPI.addComment(document.getNodeRef(), "This is a new comment").getId();
// update comment // update comment
RestCommentModel commentEntry = commentsAPI.updateComment(document.getNodeRef(), commentId, "This is the updated comment"); RestCommentModel commentEntry = commentsAPI.updateComment(document.getNodeRef(),
commentId,
"This is the updated comment");
commentEntry.assertCommentContentIs("This is the updated comment"); commentEntry.assertCommentContentIs("This is the updated comment");
} }

View File

@@ -18,17 +18,19 @@ public class SamplePeopleTest extends RestTest
DataUser dataUser; DataUser dataUser;
private UserModel userModel; private UserModel userModel;
private UserModel adminUser;
@BeforeClass @BeforeClass
public void setUp() throws DataPreparationException public void setUp() throws DataPreparationException
{ {
userModel = dataUser.createUser(RandomStringUtils.randomAlphanumeric(20)); userModel = dataUser.createUser(RandomStringUtils.randomAlphanumeric(20));
restClient.authenticateUser(userModel); adminUser = dataUser.getAdminUser();
restClient.authenticateUser(adminUser);
peopleAPI.useRestClient(restClient); peopleAPI.useRestClient(restClient);
} }
@Test @Test
public void getPersonCheckResponseAndStatus() throws Exception public void adminIsAbleToRetrievePerson() throws Exception
{ {
peopleAPI.getPerson(userModel.getUsername()) peopleAPI.getPerson(userModel.getUsername())
.assertResponseIsNotEmpty(); .assertResponseIsNotEmpty();
@@ -38,10 +40,10 @@ public class SamplePeopleTest extends RestTest
} }
@Test @Test
public void getPersonCheckStatusCode1() throws Exception public void adminIsAbleToRetrieveItself() throws Exception
{ {
peopleAPI.getPerson(userModel.getUsername()) peopleAPI.getPerson(adminUser.getUsername())
.assertPersonHasName(userModel.getUsername()); .assertPersonHasName(adminUser.getUsername());
} }
} }

View File

@@ -37,13 +37,13 @@ public class SampleSitesTest extends RestTest
} }
@Test @Test
public void getSiteResponseNotNull() throws JsonToModelConversionException, Exception public void adminCanGetSiteDetails() throws JsonToModelConversionException, Exception
{ {
siteAPI.getSite(siteModel.getId()).assertResponseIsNotEmpty(); siteAPI.getSite(siteModel.getId()).assertResponseIsNotEmpty();
} }
@Test @Test
public void getSiteCheckStatusCode() throws JsonToModelConversionException, Exception public void adminCanAccessSiteDetails() throws JsonToModelConversionException, Exception
{ {
siteAPI.getSite(siteModel.getId()); siteAPI.getSite(siteModel.getId());
siteAPI.usingRestWrapper() siteAPI.usingRestWrapper()
@@ -51,14 +51,14 @@ public class SampleSitesTest extends RestTest
} }
@Test @Test
public void getSitesResponseNotEmpty() throws JsonToModelConversionException, Exception public void adminCanAccessSites() throws JsonToModelConversionException, Exception
{ {
siteAPI.getSites() siteAPI.getSites()
.assertThatResponseIsNotEmpty(); .assertThatResponseIsNotEmpty();
} }
@Test @Test
public void getSitesCheckStatusCode() throws JsonToModelConversionException, Exception public void adminIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception
{ {
siteAPI.getSites(); siteAPI.getSites();
siteAPI.usingRestWrapper() siteAPI.usingRestWrapper()
@@ -66,13 +66,13 @@ public class SampleSitesTest extends RestTest
} }
@Test @Test
public void sitesCollectionHasPagination() throws JsonToModelConversionException, Exception public void adminIsAbleToAccessResponsePagination() throws JsonToModelConversionException, Exception
{ {
siteAPI.getSites().assertResponseHasPagination(); siteAPI.getSites().assertResponseHasPagination();
} }
@Test @Test
public void addMemberToSiteCheckStatusCode() throws JsonToModelConversionException, DataPreparationException, Exception public void adminIsAbleToAddNewSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception
{ {
UserModel newMember = dataUser.createRandomTestUser(); UserModel newMember = dataUser.createRandomTestUser();
SiteMember siteMember = new SiteMember(Role.SiteCollaborator.toString(), SiteMember siteMember = new SiteMember(Role.SiteCollaborator.toString(),
@@ -84,14 +84,14 @@ public class SampleSitesTest extends RestTest
} }
@Test @Test
public void isSiteReturned() throws JsonToModelConversionException, Exception public void adminIsAbleToGetSiteFromSitesList() throws JsonToModelConversionException, Exception
{ {
siteAPI.getAllSites() siteAPI.getAllSites()
.assertThatResponseHasSite(siteModel.getId()); .assertThatResponseHasSite(siteModel.getId());
} }
@Test @Test
public void checkSiteDetails() throws JsonToModelConversionException, Exception public void adminIsAbleToAccessSiteDetails() throws JsonToModelConversionException, Exception
{ {
siteAPI.getSite(siteModel.getId()) siteAPI.getSite(siteModel.getId())
.assertResponseIsNotEmpty() .assertResponseIsNotEmpty()