mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
update tests according to the latest changes
This commit is contained in:
@@ -28,6 +28,7 @@ package org.alfresco.rest.core;
|
|||||||
|
|
||||||
import org.alfresco.rest.rm.community.requests.igCoreAPI.FilePlanComponentAPI;
|
import org.alfresco.rest.rm.community.requests.igCoreAPI.FilePlanComponentAPI;
|
||||||
import org.alfresco.rest.rm.community.requests.igCoreAPI.RMSiteAPI;
|
import org.alfresco.rest.rm.community.requests.igCoreAPI.RMSiteAPI;
|
||||||
|
import org.alfresco.rest.rm.community.requests.igCoreAPI.RecordsAPI;
|
||||||
import org.alfresco.rest.rm.community.requests.igCoreAPI.RestIGCoreAPI;
|
import org.alfresco.rest.rm.community.requests.igCoreAPI.RestIGCoreAPI;
|
||||||
import org.alfresco.utility.data.DataUser;
|
import org.alfresco.utility.data.DataUser;
|
||||||
import org.alfresco.utility.model.UserModel;
|
import org.alfresco.utility.model.UserModel;
|
||||||
@@ -84,4 +85,14 @@ public class RestAPIFactory
|
|||||||
{
|
{
|
||||||
return getRestIGCoreAPI(userModel).usingFilePlanComponents();
|
return getRestIGCoreAPI(userModel).usingFilePlanComponents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RecordsAPI getRecordsAPI()
|
||||||
|
{
|
||||||
|
return getRestIGCoreAPI(null).usingRecords();
|
||||||
|
}
|
||||||
|
|
||||||
|
public RecordsAPI getRecordsAPI(UserModel userModel)
|
||||||
|
{
|
||||||
|
return getRestIGCoreAPI(userModel).usingRecords();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -138,8 +138,31 @@ public class FilePlanComponentAPI extends RMModelRequest
|
|||||||
|
|
||||||
return getRMRestWrapper().processModels(FilePlanComponentsCollection.class, simpleRequest(
|
return getRMRestWrapper().processModels(FilePlanComponentsCollection.class, simpleRequest(
|
||||||
GET,
|
GET,
|
||||||
"fileplan-components/{fileplanComponentId}/children?{parameters}",
|
"fileplan-components/{fileplanComponentId}/children",
|
||||||
filePlanComponentId, getParameters()
|
filePlanComponentId
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List child components of a file plan component
|
||||||
|
* @param parameters The URL parameters to add
|
||||||
|
* @param filePlanComponentId The id of the file plan component of which to get child components
|
||||||
|
* @return The {@link FilePlanComponent} for the given file plan component id
|
||||||
|
* @throws Exception for the following cases:
|
||||||
|
* <ul>
|
||||||
|
* <li>{@code fileplanComponentId} is not a valid format</li>
|
||||||
|
* <li>authentication fails</li>
|
||||||
|
* <li>{@code fileplanComponentId} does not exist</li>
|
||||||
|
*</ul>
|
||||||
|
*/
|
||||||
|
public FilePlanComponentsCollection listChildComponents(String filePlanComponentId, String parameters) throws Exception
|
||||||
|
{
|
||||||
|
mandatoryString("filePlanComponentId", filePlanComponentId);
|
||||||
|
|
||||||
|
return getRMRestWrapper().processModels(FilePlanComponentsCollection.class, simpleRequest(
|
||||||
|
GET,
|
||||||
|
"fileplan-components/{fileplanComponentId}/children?{parameters}",
|
||||||
|
filePlanComponentId,parameters
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -248,6 +271,7 @@ public class FilePlanComponentAPI extends RMModelRequest
|
|||||||
}
|
}
|
||||||
|
|
||||||
builder.addMultiPart("filedata", recordContent, ContentType.BINARY.name());
|
builder.addMultiPart("filedata", recordContent, ContentType.BINARY.name());
|
||||||
|
/*
|
||||||
* Upload the file using RestAssured library.
|
* Upload the file using RestAssured library.
|
||||||
*/
|
*/
|
||||||
Response response = given()
|
Response response = given()
|
||||||
@@ -288,7 +312,7 @@ public class FilePlanComponentAPI extends RMModelRequest
|
|||||||
/**
|
/**
|
||||||
* Updates a file plan component
|
* Updates a file plan component
|
||||||
*
|
*
|
||||||
* @param filePlanComponentModel The properties to be updated
|
* @param filePlanComponent The properties to be updated
|
||||||
* @param parameters The URL parameters to add
|
* @param parameters The URL parameters to add
|
||||||
* @param filePlanComponentId The id of the file plan component which will be updated
|
* @param filePlanComponentId The id of the file plan component which will be updated
|
||||||
* @param returns The updated {@link FilePlanComponent}
|
* @param returns The updated {@link FilePlanComponent}
|
||||||
|
@@ -24,7 +24,7 @@
|
|||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
package org.alfresco.rest.rm.community.requests;
|
package org.alfresco.rest.rm.community.requests.igCoreAPI;
|
||||||
|
|
||||||
import static com.jayway.restassured.RestAssured.given;
|
import static com.jayway.restassured.RestAssured.given;
|
||||||
|
|
||||||
@@ -32,9 +32,10 @@ import static org.alfresco.rest.rm.community.util.ParameterCheck.mandatoryString
|
|||||||
|
|
||||||
import com.jayway.restassured.response.Response;
|
import com.jayway.restassured.response.Response;
|
||||||
|
|
||||||
import org.alfresco.rest.core.RestAPI;
|
import org.alfresco.rest.core.RMRestWrapper;
|
||||||
import org.alfresco.rest.core.RestRequest;
|
import org.alfresco.rest.core.RestRequest;
|
||||||
import org.alfresco.rest.model.RestHtmlResponse;
|
import org.alfresco.rest.model.RestHtmlResponse;
|
||||||
|
import org.alfresco.rest.rm.community.requests.RMModelRequest;
|
||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
import org.springframework.http.HttpMethod;
|
import org.springframework.http.HttpMethod;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@@ -47,8 +48,16 @@ import org.springframework.stereotype.Component;
|
|||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
@Scope (value = "prototype")
|
@Scope (value = "prototype")
|
||||||
public class RecordsAPI extends RestAPI<FilePlanComponentAPI>
|
public class RecordsAPI extends RMModelRequest
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @param rmRestWrapper
|
||||||
|
*/
|
||||||
|
public RecordsAPI(RMRestWrapper rmRestWrapper)
|
||||||
|
{
|
||||||
|
super(rmRestWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the content for the electronic record
|
* Get the content for the electronic record
|
||||||
*
|
*
|
||||||
@@ -65,13 +74,12 @@ public class RecordsAPI extends RestAPI<FilePlanComponentAPI>
|
|||||||
public <T> T getRecordContentText(String recordId) throws Exception
|
public <T> T getRecordContentText(String recordId) throws Exception
|
||||||
{
|
{
|
||||||
mandatoryString("recordId", recordId);
|
mandatoryString("recordId", recordId);
|
||||||
Response response = given().auth().basic(usingRestWrapper().getTestUser().getUsername(), usingRestWrapper().getTestUser().getPassword())
|
Response response = given().auth().basic(getRMRestWrapper().getTestUser().getUsername(), getRMRestWrapper().getTestUser().getPassword())
|
||||||
.get("records/{recordId}/content?{parameters}", recordId, getParameters())
|
.get("records/{recordId}/content", recordId)
|
||||||
.andReturn();
|
.andReturn();
|
||||||
|
|
||||||
usingRestWrapper().setStatusCode(Integer.toString(response.getStatusCode()));
|
getRMRestWrapper().setStatusCode(Integer.toString(response.getStatusCode()));
|
||||||
|
|
||||||
LOG.info("The record content is " + response.getBody().prettyPrint());
|
|
||||||
return (T) response.getBody().prettyPrint();
|
return (T) response.getBody().prettyPrint();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,7 +99,7 @@ public class RecordsAPI extends RestAPI<FilePlanComponentAPI>
|
|||||||
public RestHtmlResponse getRecordContent(String recordId) throws Exception
|
public RestHtmlResponse getRecordContent(String recordId) throws Exception
|
||||||
{
|
{
|
||||||
mandatoryString("recordId", recordId);
|
mandatoryString("recordId", recordId);
|
||||||
RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "records/{recordId}/content?{parameters}", recordId, getParameters());
|
RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "records/{recordId}/content", recordId);
|
||||||
return usingRestWrapper().processHtmlResponse(request);
|
return getRMRestWrapper().processHtmlResponse(request);
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -77,4 +77,14 @@ public class RestIGCoreAPI extends RMModelRequest
|
|||||||
{
|
{
|
||||||
return new FilePlanComponentAPI(getRMRestWrapper());
|
return new FilePlanComponentAPI(getRMRestWrapper());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides DSL on all REST calls under <code>records/...</code> API path
|
||||||
|
*
|
||||||
|
* @return {@link FilePlanComponentAPI}
|
||||||
|
*/
|
||||||
|
public RecordsAPI usingRecords()
|
||||||
|
{
|
||||||
|
return new RecordsAPI(getRMRestWrapper());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -39,6 +39,11 @@ import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
|
|||||||
import static org.springframework.http.HttpStatus.CREATED;
|
import static org.springframework.http.HttpStatus.CREATED;
|
||||||
import static org.springframework.http.HttpStatus.OK;
|
import static org.springframework.http.HttpStatus.OK;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.OutputStreamWriter;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
|
||||||
import org.alfresco.rest.RestTest;
|
import org.alfresco.rest.RestTest;
|
||||||
import org.alfresco.rest.core.RestAPIFactory;
|
import org.alfresco.rest.core.RestAPIFactory;
|
||||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent;
|
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent;
|
||||||
@@ -332,7 +337,7 @@ public class BaseRMRestTest extends RestTest
|
|||||||
* @param name file name
|
* @param name file name
|
||||||
* @return {@link File} file
|
* @return {@link File} file
|
||||||
*/
|
*/
|
||||||
public static File createTempFile(final String name,String content)
|
public static File createTempFile(final String name, String content)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@@ -47,17 +47,12 @@ import static org.testng.AssertJUnit.assertTrue;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
|
|
||||||
import org.alfresco.rest.core.RestWrapper;
|
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
||||||
import org.alfresco.rest.rm.community.base.BaseRestTest;
|
|
||||||
import org.alfresco.rest.rm.community.base.TestData;
|
import org.alfresco.rest.rm.community.base.TestData;
|
||||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent;
|
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent;
|
||||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentContent;
|
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentContent;
|
||||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentProperties;
|
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentProperties;
|
||||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentsCollection;
|
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentsCollection;
|
||||||
import org.alfresco.rest.rm.community.requests.FilePlanComponentAPI;
|
|
||||||
import org.alfresco.rest.rm.community.requests.RecordsAPI;
|
|
||||||
import org.alfresco.utility.data.DataUser;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.testng.annotations.DataProvider;
|
import org.testng.annotations.DataProvider;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
@@ -68,16 +63,8 @@ import org.testng.annotations.Test;
|
|||||||
* @author Rodica Sutu
|
* @author Rodica Sutu
|
||||||
* @since 2.6
|
* @since 2.6
|
||||||
*/
|
*/
|
||||||
public class ReadRecordTests extends BaseRestTest
|
public class ReadRecordTests extends BaseRMRestTest
|
||||||
{
|
{
|
||||||
@Autowired
|
|
||||||
private FilePlanComponentAPI filePlanComponentAPI;
|
|
||||||
@Autowired
|
|
||||||
private RecordsAPI recordsAPI;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private DataUser dataUser;
|
|
||||||
|
|
||||||
String CATEGORY_NAME=TestData.CATEGORY_NAME +getRandomAlphanumeric();
|
String CATEGORY_NAME=TestData.CATEGORY_NAME +getRandomAlphanumeric();
|
||||||
|
|
||||||
String ELECTRONIC_RECORD_NAME = "Record electronic" + getRandomAlphanumeric();
|
String ELECTRONIC_RECORD_NAME = "Record electronic" + getRandomAlphanumeric();
|
||||||
@@ -107,10 +94,10 @@ public class ReadRecordTests extends BaseRestTest
|
|||||||
public Object[][] getInvalidContainersForRecords() throws Exception
|
public Object[][] getInvalidContainersForRecords() throws Exception
|
||||||
{
|
{
|
||||||
return new Object[][] {
|
return new Object[][] {
|
||||||
{ FILE_PLAN_ALIAS.toString() },
|
{ FILE_PLAN_ALIAS },
|
||||||
{ TRANSFERS_ALIAS.toString() },
|
{ TRANSFERS_ALIAS },
|
||||||
{ HOLDS_ALIAS.toString() },
|
{ HOLDS_ALIAS },
|
||||||
{ createCategory(FILE_PLAN_ALIAS.toString(), CATEGORY_NAME).getId()}
|
{ createCategoryFolderInFilePlan().getParentId()}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
@@ -121,33 +108,33 @@ public class ReadRecordTests extends BaseRestTest
|
|||||||
public void readRecordsFromInvalidContainers(String container) throws Exception
|
public void readRecordsFromInvalidContainers(String container) throws Exception
|
||||||
{
|
{
|
||||||
|
|
||||||
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
|
||||||
|
|
||||||
FilePlanComponent electronicRecord = FilePlanComponent.builder()
|
FilePlanComponent electronicRecord = FilePlanComponent.builder()
|
||||||
.name(ELECTRONIC_RECORD_NAME)
|
.name(ELECTRONIC_RECORD_NAME)
|
||||||
.nodeType(CONTENT_TYPE.toString())
|
.nodeType(CONTENT_TYPE.toString())
|
||||||
.content(FilePlanComponentContent.builder().mimeType("text/plain").build())
|
.content(FilePlanComponentContent.builder().mimeType("text/plain").build())
|
||||||
.build();
|
.build();
|
||||||
FilePlanComponent nonelectronicRecord= FilePlanComponent.builder()
|
FilePlanComponent nonelectronicRecord = FilePlanComponent.builder()
|
||||||
.properties(FilePlanComponentProperties.builder()
|
.properties(FilePlanComponentProperties.builder()
|
||||||
.description("Description")
|
.description("Description")
|
||||||
.title("Title")
|
.title("Title")
|
||||||
.build())
|
.build())
|
||||||
.name(NONELECTRONIC_RECORD_NAME)
|
.name(NONELECTRONIC_RECORD_NAME)
|
||||||
.nodeType(NON_ELECTRONIC_RECORD_TYPE.toString())
|
.nodeType(NON_ELECTRONIC_RECORD_TYPE.toString())
|
||||||
.build();
|
.build();
|
||||||
//create records
|
//create records
|
||||||
filePlanComponentAPI.createFilePlanComponent(electronicRecord,container);
|
getRestAPIFactory().getFilePlanComponentsAPI().createFilePlanComponent(electronicRecord, container);
|
||||||
filePlanComponentAPI.createFilePlanComponent(nonelectronicRecord, container);
|
getRestAPIFactory().getFilePlanComponentsAPI().createFilePlanComponent(nonelectronicRecord, container);
|
||||||
|
|
||||||
|
|
||||||
// List children from API
|
// List children from API
|
||||||
filePlanComponentAPI.withParams("where=(isFile=true)").listChildComponents(container)
|
getRestAPIFactory().getFilePlanComponentsAPI().listChildComponents(container, "where=(isFile=true)")
|
||||||
//check the list returned is empty
|
.assertThat()//check the list returned is empty
|
||||||
.assertThat().entriesListIsEmpty().assertThat().paginationExist();
|
.entriesListIsEmpty().assertThat().paginationExist();
|
||||||
// Check status code
|
//check response status code
|
||||||
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(OK);
|
assertStatusCode(OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given a record
|
* Given a record
|
||||||
* When I try to read the meta-data
|
* When I try to read the meta-data
|
||||||
@@ -157,18 +144,17 @@ public class ReadRecordTests extends BaseRestTest
|
|||||||
public void readRecordMetadata() throws Exception
|
public void readRecordMetadata() throws Exception
|
||||||
{
|
{
|
||||||
String RELATIVE_PATH = "/" + CATEGORY_NAME + getRandomAlphanumeric() + "/folder";
|
String RELATIVE_PATH = "/" + CATEGORY_NAME + getRandomAlphanumeric() + "/folder";
|
||||||
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
//create the containers from the relativePath
|
||||||
//create the containers from the relativePath
|
|
||||||
FilePlanComponent recordFolder = FilePlanComponent.builder()
|
FilePlanComponent recordFolder = FilePlanComponent.builder()
|
||||||
.name(FOLDER_NAME)
|
.name(FOLDER_NAME)
|
||||||
.nodeType(RECORD_FOLDER_TYPE.toString())
|
.nodeType(RECORD_FOLDER_TYPE.toString())
|
||||||
.relativePath(RELATIVE_PATH)
|
.relativePath(RELATIVE_PATH)
|
||||||
.build();
|
.build();
|
||||||
String folderId = filePlanComponentAPI.createFilePlanComponent(recordFolder, FILE_PLAN_ALIAS.toString()).getId();
|
String folderId = getRestAPIFactory().getFilePlanComponentsAPI().createFilePlanComponent(recordFolder, FILE_PLAN_ALIAS.toString()).getId();
|
||||||
//create electronic record
|
//create electronic record
|
||||||
String recordWithContentId = filePlanComponentAPI.createElectronicRecord(electronicRecord, createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME), folderId).getId();
|
String recordWithContentId = getRestAPIFactory().getFilePlanComponentsAPI().createElectronicRecord(electronicRecord, createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME), folderId).getId();
|
||||||
//Get the record created
|
//Get the record created
|
||||||
FilePlanComponent recordWithContent=filePlanComponentAPI.withParams("include = "+ IS_COMPLETED).getFilePlanComponent(recordWithContentId);
|
FilePlanComponent recordWithContent=getRestAPIFactory().getFilePlanComponentsAPI().getFilePlanComponent(recordWithContentId, "include = "+IS_COMPLETED);
|
||||||
//Check the metadata returned
|
//Check the metadata returned
|
||||||
assertTrue(recordWithContent.getName().startsWith(ELECTRONIC_RECORD_NAME));
|
assertTrue(recordWithContent.getName().startsWith(ELECTRONIC_RECORD_NAME));
|
||||||
assertTrue(recordWithContent.getIsFile());
|
assertTrue(recordWithContent.getIsFile());
|
||||||
@@ -179,12 +165,12 @@ public class ReadRecordTests extends BaseRestTest
|
|||||||
assertNotNull(recordWithContent.getContent().getEncoding());
|
assertNotNull(recordWithContent.getContent().getEncoding());
|
||||||
assertNotNull(recordWithContent.getContent().getMimeType());
|
assertNotNull(recordWithContent.getContent().getMimeType());
|
||||||
assertNotNull(recordWithContent.getAspectNames());
|
assertNotNull(recordWithContent.getAspectNames());
|
||||||
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(OK);
|
assertStatusCode(OK);
|
||||||
|
|
||||||
//create non-electronic record
|
//create non-electronic record
|
||||||
String nonElectronicRecordId = filePlanComponentAPI.createFilePlanComponent(nonelectronicRecord, folderId).getId();
|
String nonElectronicRecordId = getRestAPIFactory().getFilePlanComponentsAPI().createFilePlanComponent(nonelectronicRecord, folderId).getId();
|
||||||
//Get the record created
|
//Get the record created
|
||||||
FilePlanComponent nonElectronicRecord = filePlanComponentAPI.withParams("include = " + IS_COMPLETED).getFilePlanComponent(nonElectronicRecordId);
|
FilePlanComponent nonElectronicRecord = getRestAPIFactory().getFilePlanComponentsAPI().getFilePlanComponent(nonElectronicRecordId, "include = " + IS_COMPLETED);
|
||||||
|
|
||||||
//Check the metadata returned
|
//Check the metadata returned
|
||||||
assertTrue(nonElectronicRecord.getName().startsWith(NONELECTRONIC_RECORD_NAME));
|
assertTrue(nonElectronicRecord.getName().startsWith(NONELECTRONIC_RECORD_NAME));
|
||||||
@@ -197,7 +183,7 @@ public class ReadRecordTests extends BaseRestTest
|
|||||||
assertNotNull(nonElectronicRecord.getContent().getMimeType());
|
assertNotNull(nonElectronicRecord.getContent().getMimeType());
|
||||||
assertNotNull(nonElectronicRecord.getAspectNames());
|
assertNotNull(nonElectronicRecord.getAspectNames());
|
||||||
assertEquals(nonElectronicRecord.getProperties().getDescription(), NONELECTRONIC_RECORD_NAME);
|
assertEquals(nonElectronicRecord.getProperties().getDescription(), NONELECTRONIC_RECORD_NAME);
|
||||||
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(OK);
|
assertStatusCode(OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -208,36 +194,33 @@ public class ReadRecordTests extends BaseRestTest
|
|||||||
@Test
|
@Test
|
||||||
public void readRecordContent() throws Exception
|
public void readRecordContent() throws Exception
|
||||||
{
|
{
|
||||||
String RECORD_ELECTRONIC= "Record " + getRandomAlphanumeric();
|
String RECORD_ELECTRONIC = "Record " + getRandomAlphanumeric();
|
||||||
String RELATIVE_PATH="/"+CATEGORY_NAME+ getRandomAlphanumeric()+"/folder";
|
String RELATIVE_PATH = "/"+CATEGORY_NAME+ getRandomAlphanumeric()+"/folder";
|
||||||
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
|
||||||
//create the containers from the relativePath
|
//create the containers from the relativePath
|
||||||
FilePlanComponent recordFolder = FilePlanComponent.builder()
|
FilePlanComponent recordFolder = FilePlanComponent.builder()
|
||||||
.name(FOLDER_NAME)
|
.name(FOLDER_NAME)
|
||||||
.nodeType(RECORD_FOLDER_TYPE.toString())
|
.nodeType(RECORD_FOLDER_TYPE.toString())
|
||||||
.relativePath(RELATIVE_PATH)
|
.relativePath(RELATIVE_PATH)
|
||||||
.build();
|
.build();
|
||||||
String folderId=filePlanComponentAPI.createFilePlanComponent(recordFolder,FILE_PLAN_ALIAS.toString()).getId();
|
String folderId = getRestAPIFactory().getFilePlanComponentsAPI().createFilePlanComponent(recordFolder,FILE_PLAN_ALIAS.toString()).getId();
|
||||||
//
|
//
|
||||||
FilePlanComponent record = FilePlanComponent.builder()
|
FilePlanComponent record = FilePlanComponent.builder()
|
||||||
.name(RECORD_ELECTRONIC)
|
.name(RECORD_ELECTRONIC)
|
||||||
.nodeType(CONTENT_TYPE.toString())
|
.nodeType(CONTENT_TYPE.toString())
|
||||||
.build();
|
.build();
|
||||||
String recordId =filePlanComponentAPI.createElectronicRecord(record, createTempFile(RECORD_ELECTRONIC, RECORD_ELECTRONIC), folderId).getId();
|
String recordId = getRestAPIFactory().getFilePlanComponentsAPI().createElectronicRecord(record, createTempFile(RECORD_ELECTRONIC, RECORD_ELECTRONIC), folderId).getId();
|
||||||
|
|
||||||
recordsAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
assertEquals(getRestAPIFactory().getRecordsAPI().getRecordContentText(recordId),RECORD_ELECTRONIC);
|
||||||
|
|
||||||
assertEquals(recordsAPI.getRecordContentText(recordId),RECORD_ELECTRONIC);
|
|
||||||
// Check status code
|
// Check status code
|
||||||
recordsAPI.usingRestWrapper().assertStatusCodeIs(OK);
|
assertStatusCode(OK);
|
||||||
|
|
||||||
FilePlanComponent recordNoContent = FilePlanComponent.builder()
|
FilePlanComponent recordNoContent = FilePlanComponent.builder()
|
||||||
.name(RECORD_ELECTRONIC)
|
.name(RECORD_ELECTRONIC)
|
||||||
.nodeType(CONTENT_TYPE.toString())
|
.nodeType(CONTENT_TYPE.toString())
|
||||||
.build();
|
.build();
|
||||||
String recordNoContentId=filePlanComponentAPI.createFilePlanComponent(recordNoContent,folderId).getId();
|
String recordNoContentId = getRestAPIFactory().getFilePlanComponentsAPI().createFilePlanComponent(recordNoContent,folderId).getId();
|
||||||
assertTrue(recordsAPI.getRecordContentText(recordNoContentId).toString().isEmpty());
|
assertTrue(getRestAPIFactory().getRecordsAPI().getRecordContentText(recordNoContentId).toString().isEmpty());
|
||||||
recordsAPI.usingRestWrapper().assertStatusCodeIs(OK);
|
assertStatusCode(OK);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Given a non-electronic record
|
* Given a non-electronic record
|
||||||
@@ -254,12 +237,12 @@ public class ReadRecordTests extends BaseRestTest
|
|||||||
.nodeType(NON_ELECTRONIC_RECORD_TYPE.toString())
|
.nodeType(NON_ELECTRONIC_RECORD_TYPE.toString())
|
||||||
.relativePath("/"+CATEGORY_NAME+getRandomAlphanumeric()+"/"+FOLDER_NAME)
|
.relativePath("/"+CATEGORY_NAME+getRandomAlphanumeric()+"/"+FOLDER_NAME)
|
||||||
.build();
|
.build();
|
||||||
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
|
||||||
String nonElectronicRecord=filePlanComponentAPI.createFilePlanComponent(record,FILE_PLAN_ALIAS.toString()).getId();
|
|
||||||
|
|
||||||
recordsAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
String nonElectronicRecord= getRestAPIFactory().getFilePlanComponentsAPI().createFilePlanComponent(record,FILE_PLAN_ALIAS.toString()).getId();
|
||||||
assertTrue(recordsAPI.getRecordContentText(nonElectronicRecord).toString().isEmpty());
|
|
||||||
recordsAPI.usingRestWrapper().assertStatusCodeIs(OK);
|
|
||||||
|
assertTrue(getRestAPIFactory().getRecordsAPI().getRecordContentText(nonElectronicRecord).toString().isEmpty());
|
||||||
|
assertStatusCode(OK);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -276,9 +259,8 @@ public class ReadRecordTests extends BaseRestTest
|
|||||||
)
|
)
|
||||||
public void readContentFromInvalidContainers(String container) throws Exception
|
public void readContentFromInvalidContainers(String container) throws Exception
|
||||||
{
|
{
|
||||||
recordsAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
getRestAPIFactory().getRecordsAPI().getRecordContentText(container).toString();
|
||||||
recordsAPI.getRecordContentText(container).toString();
|
assertStatusCode(BAD_REQUEST);
|
||||||
recordsAPI.usingRestWrapper().assertStatusCodeIs(BAD_REQUEST);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -293,7 +275,7 @@ public class ReadRecordTests extends BaseRestTest
|
|||||||
{
|
{
|
||||||
return new Object[][] {
|
return new Object[][] {
|
||||||
// an arbitrary record folder
|
// an arbitrary record folder
|
||||||
{ createCategoryFolderInFilePlan(dataUser.getAdminUser(), FILE_PLAN_ALIAS.toString()).getId() },
|
{ createCategoryFolderInFilePlan().getId()},
|
||||||
// an arbitrary unfiled records folder
|
// an arbitrary unfiled records folder
|
||||||
{ createUnfiledRecordsFolder(UNFILED_RECORDS_CONTAINER_ALIAS.toString(), "Unfiled Folder " + getRandomAlphanumeric()).getId() }
|
{ createUnfiledRecordsFolder(UNFILED_RECORDS_CONTAINER_ALIAS.toString(), "Unfiled Folder " + getRandomAlphanumeric()).getId() }
|
||||||
};
|
};
|
||||||
@@ -308,7 +290,6 @@ public class ReadRecordTests extends BaseRestTest
|
|||||||
{
|
{
|
||||||
final int NUMBER_OF_RECORDS = 5;
|
final int NUMBER_OF_RECORDS = 5;
|
||||||
//String RELATIVE_PATH = "/" + CATEGORY_NAME + getRandomAlphanumeric();
|
//String RELATIVE_PATH = "/" + CATEGORY_NAME + getRandomAlphanumeric();
|
||||||
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
|
||||||
|
|
||||||
// Create Electronic Records
|
// Create Electronic Records
|
||||||
ArrayList<FilePlanComponent> children = new ArrayList<FilePlanComponent>();
|
ArrayList<FilePlanComponent> children = new ArrayList<FilePlanComponent>();
|
||||||
@@ -320,7 +301,7 @@ public class ReadRecordTests extends BaseRestTest
|
|||||||
.nodeType(CONTENT_TYPE.toString())
|
.nodeType(CONTENT_TYPE.toString())
|
||||||
.build();
|
.build();
|
||||||
//create a child
|
//create a child
|
||||||
FilePlanComponent child = filePlanComponentAPI.createElectronicRecord(record, createTempFile(ELECTRONIC_RECORD_NAME + i, ELECTRONIC_RECORD_NAME + i ), containerId);
|
FilePlanComponent child = getRestAPIFactory().getFilePlanComponentsAPI().createElectronicRecord(record, createTempFile(ELECTRONIC_RECORD_NAME + i, ELECTRONIC_RECORD_NAME + i ), containerId);
|
||||||
children.add(child);
|
children.add(child);
|
||||||
}
|
}
|
||||||
//Create NonElectronicRecords
|
//Create NonElectronicRecords
|
||||||
@@ -335,24 +316,22 @@ public class ReadRecordTests extends BaseRestTest
|
|||||||
.nodeType(NON_ELECTRONIC_RECORD_TYPE.toString())
|
.nodeType(NON_ELECTRONIC_RECORD_TYPE.toString())
|
||||||
.build();
|
.build();
|
||||||
//create records
|
//create records
|
||||||
FilePlanComponent child=filePlanComponentAPI.createFilePlanComponent(nonelectronicRecord, containerId);
|
FilePlanComponent child= getRestAPIFactory().getFilePlanComponentsAPI().createFilePlanComponent(nonelectronicRecord, containerId);
|
||||||
children.add(child);
|
children.add(child);
|
||||||
}
|
}
|
||||||
// Authenticate with admin user
|
|
||||||
RestWrapper restWrapper = filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
|
||||||
|
|
||||||
// List children from API
|
// List children from API
|
||||||
FilePlanComponentsCollection apiChildren =
|
FilePlanComponentsCollection apiChildren =
|
||||||
(FilePlanComponentsCollection) filePlanComponentAPI.listChildComponents(containerId).assertThat().entriesListIsNotEmpty();
|
(FilePlanComponentsCollection) getRestAPIFactory().getFilePlanComponentsAPI().listChildComponents(containerId).assertThat().entriesListIsNotEmpty();
|
||||||
|
|
||||||
// Check status code
|
// Check status code
|
||||||
restWrapper.assertStatusCodeIs(OK);
|
assertStatusCode(OK);
|
||||||
|
|
||||||
|
|
||||||
// Check listed children against created list
|
// Check listed children against created list
|
||||||
apiChildren.getEntries().forEach(c ->
|
apiChildren.getEntries().forEach(c ->
|
||||||
{
|
{
|
||||||
FilePlanComponent filePlanComponent = c.getFilePlanComponent();
|
FilePlanComponent filePlanComponent = c.getFilePlanComponentModel();
|
||||||
assertNotNull(filePlanComponent.getId());
|
assertNotNull(filePlanComponent.getId());
|
||||||
logger.info("Checking child " + filePlanComponent.getId());
|
logger.info("Checking child " + filePlanComponent.getId());
|
||||||
|
|
||||||
@@ -365,7 +344,7 @@ public class ReadRecordTests extends BaseRestTest
|
|||||||
.get();
|
.get();
|
||||||
|
|
||||||
// Created by
|
// Created by
|
||||||
assertEquals(filePlanComponent.getCreatedByUser().getId(), dataUser.getAdminUser().getUsername());
|
assertEquals(filePlanComponent.getCreatedByUser().getId(), getAdminUser().getUsername());
|
||||||
|
|
||||||
// Is parent Id set correctly
|
// Is parent Id set correctly
|
||||||
assertEquals(filePlanComponent.getParentId(), containerId);
|
assertEquals(filePlanComponent.getParentId(), containerId);
|
||||||
@@ -409,47 +388,45 @@ public class ReadRecordTests extends BaseRestTest
|
|||||||
.name(NONELECTRONIC_RECORD_NAME)
|
.name(NONELECTRONIC_RECORD_NAME)
|
||||||
.nodeType(NON_ELECTRONIC_RECORD_TYPE.toString())
|
.nodeType(NON_ELECTRONIC_RECORD_TYPE.toString())
|
||||||
.build();
|
.build();
|
||||||
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
|
||||||
|
|
||||||
//create records in Unfiled Container
|
//create records in Unfiled Container
|
||||||
FilePlanComponent recordElecInUnfiled = filePlanComponentAPI.createFilePlanComponent(electRecord, UNFILED_RECORDS_CONTAINER_ALIAS.toString());
|
FilePlanComponent recordElecInUnfiled = getRestAPIFactory().getFilePlanComponentsAPI().createFilePlanComponent(electRecord, UNFILED_RECORDS_CONTAINER_ALIAS.toString());
|
||||||
FilePlanComponent recordNonElecInUnfiled = filePlanComponentAPI.createFilePlanComponent(nonElectronic, UNFILED_RECORDS_CONTAINER_ALIAS.toString());
|
FilePlanComponent recordNonElecInUnfiled = getRestAPIFactory().getFilePlanComponentsAPI().createFilePlanComponent(nonElectronic, UNFILED_RECORDS_CONTAINER_ALIAS.toString());
|
||||||
|
|
||||||
// List children for the electronic Record
|
// List children for the electronic Record
|
||||||
filePlanComponentAPI.withParams("where=(isFile=true)").listChildComponents(recordElecInUnfiled.getId())
|
getRestAPIFactory().getFilePlanComponentsAPI().listChildComponents(recordElecInUnfiled.getId(), "where=(isFile=true)")
|
||||||
//check the list returned is empty
|
//check the list returned is empty
|
||||||
.assertThat().entriesListIsEmpty().assertThat().paginationExist();
|
.assertThat().entriesListIsEmpty().assertThat().paginationExist();
|
||||||
// Check status code
|
// Check status code
|
||||||
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(OK);
|
assertStatusCode(OK);
|
||||||
|
|
||||||
// List children for the nonElectronic Record
|
// List children for the nonElectronic Record
|
||||||
filePlanComponentAPI.withParams("where=(isFile=true)").listChildComponents(recordNonElecInUnfiled.getId())
|
getRestAPIFactory().getFilePlanComponentsAPI().listChildComponents(recordNonElecInUnfiled.getId(), "where=(isFile=true)")
|
||||||
//check the list returned is empty
|
//check the list returned is empty
|
||||||
.assertThat().entriesListIsEmpty().assertThat().paginationExist();
|
.assertThat().entriesListIsEmpty().assertThat().paginationExist();
|
||||||
// Check status code
|
// Check status code
|
||||||
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(OK);
|
assertStatusCode(OK);
|
||||||
|
|
||||||
//Update the Records objects
|
//Update the Records objects
|
||||||
electRecord.setRelativePath(RELATIVE_PATH);
|
electRecord.setRelativePath(RELATIVE_PATH);
|
||||||
nonElectronic.setRelativePath(RELATIVE_PATH);
|
nonElectronic.setRelativePath(RELATIVE_PATH);
|
||||||
|
|
||||||
//create records in Unfiled Container
|
//create records in Unfiled Container
|
||||||
FilePlanComponent recordElecFromRecordFolder = filePlanComponentAPI.createFilePlanComponent(electRecord, FILE_PLAN_ALIAS.toString());
|
FilePlanComponent recordElecFromRecordFolder = getRestAPIFactory().getFilePlanComponentsAPI().createFilePlanComponent(electRecord, FILE_PLAN_ALIAS.toString());
|
||||||
FilePlanComponent recordNonElecFromRecordFolder = filePlanComponentAPI.createFilePlanComponent(nonElectronic, FILE_PLAN_ALIAS.toString());
|
FilePlanComponent recordNonElecFromRecordFolder = getRestAPIFactory().getFilePlanComponentsAPI().createFilePlanComponent(nonElectronic, FILE_PLAN_ALIAS.toString());
|
||||||
|
|
||||||
// List children for the electronic Record
|
// List children for the electronic Record
|
||||||
filePlanComponentAPI.withParams("where=(isFile=true)").listChildComponents(recordElecFromRecordFolder.getId())
|
getRestAPIFactory().getFilePlanComponentsAPI().listChildComponents(recordElecFromRecordFolder.getId(), "where=(isFile=true)")
|
||||||
//check the list returned is empty
|
//check the list returned is empty
|
||||||
.assertThat().entriesListIsEmpty().assertThat().paginationExist();
|
.assertThat().entriesListIsEmpty().assertThat().paginationExist();
|
||||||
// Check status code
|
// Check status code
|
||||||
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(OK);
|
assertStatusCode(OK);
|
||||||
|
|
||||||
// List children for the nonElectronic Record
|
// List children for the nonElectronic Record
|
||||||
filePlanComponentAPI.withParams("where=(isFile=true)").listChildComponents(recordNonElecFromRecordFolder.getId())
|
getRestAPIFactory().getFilePlanComponentsAPI().listChildComponents(recordNonElecFromRecordFolder.getId(), "where=(isFile=true)")
|
||||||
//check the list returned is empty
|
//check the list returned is empty
|
||||||
.assertThat().entriesListIsEmpty().assertThat().paginationExist();
|
.assertThat().entriesListIsEmpty().assertThat().paginationExist();
|
||||||
// Check status code
|
// Check status code
|
||||||
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(OK);
|
assertStatusCode(OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user