update based on DSL

This commit is contained in:
Paul Brodner
2016-09-02 12:30:17 +03:00
parent f20f683404
commit 00169fcc9c
2 changed files with 14 additions and 16 deletions

View File

@@ -5,9 +5,9 @@ import org.alfresco.rest.exception.JsonToModelConversionException;
import org.alfresco.rest.model.RestCommentModel; import org.alfresco.rest.model.RestCommentModel;
import org.alfresco.rest.model.SiteMember; import org.alfresco.rest.model.SiteMember;
import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.exception.DataPreparationException;
import org.alfresco.utility.model.FileModel;
import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.SiteModel;
import org.alfresco.utility.model.UserModel; import org.alfresco.utility.model.UserModel;
import org.apache.chemistry.opencmis.client.api.Document;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.social.alfresco.api.entities.Role; import org.springframework.social.alfresco.api.entities.Role;
@@ -61,27 +61,26 @@ public class RestDemoTest extends RestTest
* POST one comment to file using admin user <br/> * POST one comment to file using admin user <br/>
* Perform GET comments, check the new one is listed <br/> * Perform GET comments, check the new one is listed <br/>
* Update existing comment using PUT call, check that comment content is updated <br/> * Update existing comment using PUT call, check that comment content is updated <br/>
* * @throws Exception
* @throws JsonToModelConversionException
*/ */
@Test @Test
public void commentsTest() throws JsonToModelConversionException, Exception public void commentsTest() throws Exception
{ {
Document document = dataContent.usingPath("Shared") FileModel fileModel = dataContent.usingResource("Shared")
.usingUser(userModel) .usingUser(userModel)
.createDocument(DocumentType.TEXT_PLAIN); .createContent(DocumentType.TEXT_PLAIN);
// add new comment // add new comment
RestCommentModel commentEntry = commentsAPI.addComment(document.getId(), "This is a new comment"); RestCommentModel commentEntry = commentsAPI.addComment(fileModel.getNodeRef(), "This is a new comment");
commentsAPI.getNodeComments(document.getId()) 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(document.getId(), commentEntry = commentsAPI.updateComment(fileModel.getNodeRef(),
commentEntry.getId(), commentEntry.getId(),
"This is the updated comment"); "This is the updated comment");
commentsAPI.getNodeComments(document.getId()) commentsAPI.getNodeComments(fileModel.getNodeRef())
.assertThatResponseIsNotEmpty() .assertThatResponseIsNotEmpty()
.assertThatCommentWithIdExists(commentEntry.getId()) .assertThatCommentWithIdExists(commentEntry.getId())
.assertThatCommentWithContentExists("This is the updated comment"); .assertThatCommentWithContentExists("This is the updated comment");
@@ -97,7 +96,7 @@ public class RestDemoTest extends RestTest
* @throws JsonToModelConversionException * @throws JsonToModelConversionException
*/ */
@Test @Test
public void siteMembersTest() throws DataPreparationException, JsonToModelConversionException, Exception public void siteMembersTest() 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());

View File

@@ -4,7 +4,6 @@ import org.alfresco.dataprep.CMISUtil.DocumentType;
import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.exception.JsonToModelConversionException;
import org.alfresco.rest.model.RestCommentModel; import org.alfresco.rest.model.RestCommentModel;
import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser;
import org.alfresco.utility.exception.DataPreparationException;
import org.alfresco.utility.model.UserModel; import org.alfresco.utility.model.UserModel;
import org.apache.chemistry.opencmis.client.api.Document; import org.apache.chemistry.opencmis.client.api.Document;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@@ -24,15 +23,15 @@ public class SampleCommentsTest extends RestTest
private Document document; private Document document;
@BeforeClass @BeforeClass
public void initTest() throws DataPreparationException public void initTest() throws Exception
{ {
userModel = dataUser.getAdminUser(); userModel = dataUser.getAdminUser();
restClient.authenticateUser(userModel); restClient.authenticateUser(userModel);
commentsAPI.useRestClient(restClient); commentsAPI.useRestClient(restClient);
document = dataContent.usingPath("Shared") document = dataContent.usingResource("Shared")
.usingUser(userModel) .usingUser(userModel)
.createDocument(DocumentType.TEXT_PLAIN); .createContent(DocumentType.TEXT_PLAIN);
} }
@Test @Test