mirror of
https://github.com/Alfresco/SearchServices.git
synced 2025-09-17 14:21:20 +00:00
small refactoring: using helper of DataContent for creation of files
This commit is contained in:
@@ -1,14 +1,9 @@
|
|||||||
package org.alfresco.rest;
|
package org.alfresco.rest;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
import org.alfresco.dataprep.CMISUtil.DocumentType;
|
import org.alfresco.dataprep.CMISUtil.DocumentType;
|
||||||
import org.alfresco.dataprep.ContentService;
|
|
||||||
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.rest.model.SiteMember;
|
import org.alfresco.rest.model.SiteMember;
|
||||||
import org.alfresco.utility.data.DataSite;
|
|
||||||
import org.alfresco.utility.data.DataUser;
|
|
||||||
import org.alfresco.utility.exception.DataPreparationException;
|
import org.alfresco.utility.exception.DataPreparationException;
|
||||||
import org.alfresco.utility.model.SiteModel;
|
import org.alfresco.utility.model.SiteModel;
|
||||||
import org.alfresco.utility.model.UserModel;
|
import org.alfresco.utility.model.UserModel;
|
||||||
@@ -25,15 +20,6 @@ public class RestDemoTest extends RestTest
|
|||||||
@Autowired
|
@Autowired
|
||||||
RestSitesApi sitesApi;
|
RestSitesApi sitesApi;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
DataUser dataUser;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
DataSite dataSite;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
ContentService content;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
RestCommentsApi commentsAPI;
|
RestCommentsApi commentsAPI;
|
||||||
|
|
||||||
@@ -46,6 +32,9 @@ public class RestDemoTest extends RestTest
|
|||||||
userModel = dataUser.getAdminUser();
|
userModel = dataUser.getAdminUser();
|
||||||
siteModel = dataSite.createPublicRandomSite();
|
siteModel = dataSite.createPublicRandomSite();
|
||||||
restClient.authenticateUser(userModel);
|
restClient.authenticateUser(userModel);
|
||||||
|
|
||||||
|
sitesApi.useRestClient(restClient);
|
||||||
|
commentsAPI.useRestClient(restClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -60,12 +49,11 @@ public class RestDemoTest extends RestTest
|
|||||||
@Test
|
@Test
|
||||||
public void sitesTest() throws JsonToModelConversionException, Exception
|
public void sitesTest() throws JsonToModelConversionException, Exception
|
||||||
{
|
{
|
||||||
sitesApi.useRestClient(restClient);
|
sitesApi.getAllSites().assertThatResponseHasSite(siteModel)
|
||||||
|
.getSite(siteModel)
|
||||||
sitesApi.getAllSites().assertThatResponseHasSite(siteModel.getId()).getSite(siteModel.getId())
|
.assertSiteHasVisibility(Visibility.PUBLIC)
|
||||||
.assertSiteHasVisibility(Visibility.PUBLIC)
|
.assertSiteHasTitle(siteModel.getTitle())
|
||||||
.assertSiteHasTitle(siteModel.getTitle())
|
.assertSiteHasDescription(siteModel.getDescription());
|
||||||
.assertSiteHasDescription(siteModel.getDescription());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -79,17 +67,15 @@ public class RestDemoTest extends RestTest
|
|||||||
@Test
|
@Test
|
||||||
public void commentsTest() throws JsonToModelConversionException
|
public void commentsTest() throws JsonToModelConversionException
|
||||||
{
|
{
|
||||||
commentsAPI.useRestClient(restClient);
|
Document document = dataContent.usingPath("Shared")
|
||||||
|
.usingUser(userModel)
|
||||||
File file = new File("textDocument-" + System.currentTimeMillis());
|
.createDocument(DocumentType.TEXT_PLAIN);
|
||||||
Document document = content.createDocumentInRepository(userModel.getUsername(),
|
|
||||||
userModel.getPassword(), "Shared", DocumentType.TEXT_PLAIN, file, "This is a text file");
|
|
||||||
|
|
||||||
// add new comment
|
// add new comment
|
||||||
RestCommentModel commentEntry = commentsAPI.addComment(document.getId(), "This is a new comment");
|
RestCommentModel commentEntry = commentsAPI.addComment(document.getId(), "This is a new comment");
|
||||||
commentsAPI.getNodeComments(document.getId()).assertThatResponseIsNotEmpty()
|
commentsAPI.getNodeComments(document.getId())
|
||||||
.assertThatCommentWithIdExists(commentEntry.getId())
|
.assertThatResponseIsNotEmpty()
|
||||||
.assertThatCommentWithContentExists("This is a new comment");
|
.assertThatCommentWithIdExists(commentEntry.getId())
|
||||||
|
.assertThatCommentWithContentExists("This is a new comment");
|
||||||
|
|
||||||
// update comment
|
// update comment
|
||||||
commentEntry = commentsAPI.updateComment(document.getId(), commentEntry.getId(), "This is the updated comment");
|
commentEntry = commentsAPI.updateComment(document.getId(), commentEntry.getId(), "This is the updated comment");
|
||||||
@@ -110,8 +96,6 @@ public class RestDemoTest extends RestTest
|
|||||||
@Test
|
@Test
|
||||||
public void siteMembersTest() throws DataPreparationException, JsonToModelConversionException
|
public void siteMembersTest() throws DataPreparationException, JsonToModelConversionException
|
||||||
{
|
{
|
||||||
sitesApi.useRestClient(restClient);
|
|
||||||
|
|
||||||
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());
|
||||||
|
|
||||||
|
@@ -4,6 +4,9 @@ import org.alfresco.rest.core.RestProperties;
|
|||||||
import org.alfresco.rest.core.RestWrapper;
|
import org.alfresco.rest.core.RestWrapper;
|
||||||
import org.alfresco.utility.ServerHealth;
|
import org.alfresco.utility.ServerHealth;
|
||||||
import org.alfresco.utility.TasProperties;
|
import org.alfresco.utility.TasProperties;
|
||||||
|
import org.alfresco.utility.data.DataContent;
|
||||||
|
import org.alfresco.utility.data.DataSite;
|
||||||
|
import org.alfresco.utility.data.DataUser;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
|
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
|
||||||
@@ -25,6 +28,15 @@ public abstract class RestTest extends AbstractTestNGSpringContextTests
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
protected RestWrapper restClient;
|
protected RestWrapper restClient;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
DataUser dataUser;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
DataSite dataSite;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
DataContent dataContent;
|
||||||
|
|
||||||
@BeforeClass(alwaysRun = true)
|
@BeforeClass(alwaysRun = true)
|
||||||
public void setupRestTest() throws Exception
|
public void setupRestTest() throws Exception
|
||||||
|
Reference in New Issue
Block a user