mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
-Add tests for Read Records (1)
This commit is contained in:
@@ -19,6 +19,16 @@
|
|||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
<pluginManagement>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok-maven-plugin</artifactId>
|
||||||
|
<version>1.16.10</version>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
|
||||||
|
</pluginManagement>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.codehaus.mojo</groupId>
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
@@ -29,6 +39,23 @@
|
|||||||
<descriptionTemplate>${project.parent.parent.basedir}/license/description.ftl</descriptionTemplate>
|
<descriptionTemplate>${project.parent.parent.basedir}/license/description.ftl</descriptionTemplate>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok-maven-plugin</artifactId>
|
||||||
|
<version>1.16.8.0</version>
|
||||||
|
<configuration>
|
||||||
|
<encoding>UTF-8</encoding>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>generate-sources</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>testDelombok</goal>
|
||||||
|
<goal>delombok</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
@@ -90,7 +90,7 @@ public class FilePlanComponent
|
|||||||
@JsonProperty (required = true)
|
@JsonProperty (required = true)
|
||||||
private FilePlanComponentUserInfo createdByUser;
|
private FilePlanComponentUserInfo createdByUser;
|
||||||
|
|
||||||
@JsonProperty(value = PROPERTIES, required = true)
|
@JsonProperty(value = PROPERTIES)
|
||||||
private FilePlanComponentProperties properties;
|
private FilePlanComponentProperties properties;
|
||||||
|
|
||||||
@JsonProperty (value = ALLOWABLE_OPERATIONS)
|
@JsonProperty (value = ALLOWABLE_OPERATIONS)
|
||||||
|
@@ -28,11 +28,20 @@ package org.alfresco.rest.rm.community.model.fileplancomponents;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* POJO for FilePlanComponent content field
|
* POJO for FilePlanComponent content field
|
||||||
* @author Kristijan Conkas
|
* @author Kristijan Conkas
|
||||||
* @since 2.6
|
* @since 2.6
|
||||||
*/
|
*/
|
||||||
|
@Builder
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
public class FilePlanComponentContent
|
public class FilePlanComponentContent
|
||||||
{
|
{
|
||||||
@JsonProperty (required = true)
|
@JsonProperty (required = true)
|
||||||
|
@@ -110,8 +110,8 @@ public class FilePlanComponentAPI extends RestAPI<FilePlanComponentAPI>
|
|||||||
|
|
||||||
return usingRestWrapper().processModels(FilePlanComponentsCollection.class, simpleRequest(
|
return usingRestWrapper().processModels(FilePlanComponentsCollection.class, simpleRequest(
|
||||||
GET,
|
GET,
|
||||||
"fileplan-components/{fileplanComponentId}/children",
|
"fileplan-components/{fileplanComponentId}/children?{parameters}",
|
||||||
filePlanComponentId
|
filePlanComponentId, getParameters()
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,7 +203,7 @@ public class FilePlanComponentAPI extends RestAPI<FilePlanComponentAPI>
|
|||||||
builder.addMultiPart("filedata", recordContent, ContentType.BINARY.name());
|
builder.addMultiPart("filedata", recordContent, ContentType.BINARY.name());
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* RestWrapper adds some headers which break multipart/form-data uploads and also assumes json POST requests.
|
* RestWrapper adds some headers which break multipart/form-data uploads and also assumes json POST requests.
|
||||||
* Upload the file using RestAssured library.
|
* Upload the file using RestAssured library.
|
||||||
*/
|
*/
|
||||||
Response response = given()
|
Response response = given()
|
||||||
|
@@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
* #%L
|
||||||
|
* Alfresco Records Management Module
|
||||||
|
* %%
|
||||||
|
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||||
|
* %%
|
||||||
|
* This file is part of the Alfresco software.
|
||||||
|
* -
|
||||||
|
* If the software was purchased under a paid Alfresco license, the terms of
|
||||||
|
* the paid license agreement will prevail. Otherwise, the software is
|
||||||
|
* provided under the following open source license terms:
|
||||||
|
* -
|
||||||
|
* Alfresco is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* -
|
||||||
|
* Alfresco is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
* -
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
* #L%
|
||||||
|
*/
|
||||||
|
package org.alfresco.rest.rm.community.requests;
|
||||||
|
|
||||||
|
import static com.jayway.restassured.RestAssured.given;
|
||||||
|
|
||||||
|
import static org.alfresco.rest.rm.community.util.ParameterCheck.mandatoryString;
|
||||||
|
|
||||||
|
import com.jayway.restassured.response.Response;
|
||||||
|
|
||||||
|
import org.alfresco.rest.core.RestAPI;
|
||||||
|
import org.alfresco.rest.core.RestRequest;
|
||||||
|
import org.alfresco.rest.model.RestHtmlResponse;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.http.HttpMethod;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*Records REST API Wrapper
|
||||||
|
*
|
||||||
|
*@author Rodica Sutu
|
||||||
|
*@since 2.6
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@Scope (value = "prototype")
|
||||||
|
public class RecordsAPI extends RestAPI<FilePlanComponentAPI>
|
||||||
|
{
|
||||||
|
public <T> T getRecordContentText(String recordId) throws Exception
|
||||||
|
{
|
||||||
|
mandatoryString("recordId", recordId);
|
||||||
|
//RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "records/{recordId}/content?{parameters}", recordId, getParameters());
|
||||||
|
Response response = given().auth().basic(usingRestWrapper().getTestUser().getUsername(), usingRestWrapper().getTestUser().getPassword())
|
||||||
|
.get("records/{recordId}/content?{parameters}", recordId, getParameters())
|
||||||
|
.andReturn();
|
||||||
|
usingRestWrapper().setStatusCode(Integer.toString(response.getStatusCode()));
|
||||||
|
LOG.info("The record content is " + response.getBody().prettyPrint());
|
||||||
|
return (T) response.getBody().prettyPrint();
|
||||||
|
}
|
||||||
|
|
||||||
|
public RestHtmlResponse getRecordContent(String recordId) throws Exception
|
||||||
|
{
|
||||||
|
mandatoryString("recordId", recordId);
|
||||||
|
RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "records/{recordId}/content?{parameters}", recordId, getParameters());
|
||||||
|
return usingRestWrapper().processHtmlResponse(request);
|
||||||
|
}
|
||||||
|
}
|
@@ -44,6 +44,11 @@ import static org.springframework.http.HttpStatus.CREATED;
|
|||||||
import static org.springframework.http.HttpStatus.OK;
|
import static org.springframework.http.HttpStatus.OK;
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.OutputStreamWriter;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
|
||||||
import com.jayway.restassured.RestAssured;
|
import com.jayway.restassured.RestAssured;
|
||||||
import com.jayway.restassured.builder.RequestSpecBuilder;
|
import com.jayway.restassured.builder.RequestSpecBuilder;
|
||||||
import com.jayway.restassured.http.ContentType;
|
import com.jayway.restassured.http.ContentType;
|
||||||
@@ -99,7 +104,7 @@ public class BaseRestTest extends RestTest
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RMSiteAPI rmSiteAPI;
|
private RMSiteAPI rmSiteAPI;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private DataUser dataUser;
|
private DataUser dataUser;
|
||||||
|
|
||||||
@@ -239,18 +244,18 @@ public class BaseRestTest extends RestTest
|
|||||||
public FilePlanComponent closeFolder(String folderId) throws Exception
|
public FilePlanComponent closeFolder(String folderId) throws Exception
|
||||||
{
|
{
|
||||||
RestWrapper restWrapper = filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
RestWrapper restWrapper = filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||||
|
|
||||||
// build fileplan component + properties for update request
|
// build fileplan component + properties for update request
|
||||||
FilePlanComponentProperties properties = new FilePlanComponentProperties();
|
FilePlanComponentProperties properties = new FilePlanComponentProperties();
|
||||||
properties.setIsClosed(true);
|
properties.setIsClosed(true);
|
||||||
FilePlanComponent filePlanComponent = new FilePlanComponent();
|
FilePlanComponent filePlanComponent = new FilePlanComponent();
|
||||||
filePlanComponent.setProperties(properties);
|
filePlanComponent.setProperties(properties);
|
||||||
|
|
||||||
FilePlanComponent updatedComponent = filePlanComponentAPI.updateFilePlanComponent(filePlanComponent, folderId);
|
FilePlanComponent updatedComponent = filePlanComponentAPI.updateFilePlanComponent(filePlanComponent, folderId);
|
||||||
restWrapper.assertStatusCodeIs(OK);
|
restWrapper.assertStatusCodeIs(OK);
|
||||||
return updatedComponent;
|
return updatedComponent;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method to create a randomly-named <category>/<folder> structure in fileplan
|
* Helper method to create a randomly-named <category>/<folder> structure in fileplan
|
||||||
* @param user user under whose privileges this structure is going to be created
|
* @param user user under whose privileges this structure is going to be created
|
||||||
@@ -261,14 +266,14 @@ public class BaseRestTest extends RestTest
|
|||||||
public FilePlanComponent createCategoryFolderInFilePlan(UserModel user, String parentId) throws Exception
|
public FilePlanComponent createCategoryFolderInFilePlan(UserModel user, String parentId) throws Exception
|
||||||
{
|
{
|
||||||
filePlanComponentAPI.usingRestWrapper().authenticateUser(user);
|
filePlanComponentAPI.usingRestWrapper().authenticateUser(user);
|
||||||
|
|
||||||
// create root category
|
// create root category
|
||||||
FilePlanComponent recordCategory = createCategory(parentId, "Category " + getRandomAlphanumeric());
|
FilePlanComponent recordCategory = createCategory(parentId, "Category " + getRandomAlphanumeric());
|
||||||
|
|
||||||
// and return a folder underneath
|
// and return a folder underneath
|
||||||
return createFolder(recordCategory.getId(), "Folder " + getRandomAlphanumeric());
|
return createFolder(recordCategory.getId(), "Folder " + getRandomAlphanumeric());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method to retieve a fileplan component with user's privilege
|
* Helper method to retieve a fileplan component with user's privilege
|
||||||
* @param user user under whose privileges a component is to be read
|
* @param user user under whose privileges a component is to be read
|
||||||
@@ -281,6 +286,7 @@ public class BaseRestTest extends RestTest
|
|||||||
filePlanComponentAPI.usingRestWrapper().authenticateUser(user);
|
filePlanComponentAPI.usingRestWrapper().authenticateUser(user);
|
||||||
return filePlanComponentAPI.getFilePlanComponent(componentId);
|
return filePlanComponentAPI.getFilePlanComponent(componentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method to add permission on a component to user
|
* Helper method to add permission on a component to user
|
||||||
@@ -325,3 +331,33 @@ public class BaseRestTest extends RestTest
|
|||||||
filePlanComponentAPI.usingRestWrapper().setStatusCode(Integer.toString(response.getStatusCode()));
|
filePlanComponentAPI.usingRestWrapper().setStatusCode(Integer.toString(response.getStatusCode()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create temp file
|
||||||
|
* real size content
|
||||||
|
*
|
||||||
|
* @param name file name
|
||||||
|
* @return {@link File} file
|
||||||
|
*/
|
||||||
|
public static File createTempFile(final String name,String content)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// create file
|
||||||
|
final File file = File.createTempFile(name, ".txt");
|
||||||
|
|
||||||
|
// create writer
|
||||||
|
try (FileOutputStream fos = new FileOutputStream(file);
|
||||||
|
OutputStreamWriter writer = new OutputStreamWriter(fos, Charset.forName("UTF-8").newEncoder()))
|
||||||
|
{
|
||||||
|
// place content in file
|
||||||
|
writer.write(content);
|
||||||
|
}
|
||||||
|
|
||||||
|
return file;
|
||||||
|
} catch (Exception exception)
|
||||||
|
{
|
||||||
|
throw new RuntimeException("Unable to create test file.", exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -0,0 +1,305 @@
|
|||||||
|
/*
|
||||||
|
* #%L
|
||||||
|
* Alfresco Records Management Module
|
||||||
|
* %%
|
||||||
|
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||||
|
* %%
|
||||||
|
* This file is part of the Alfresco software.
|
||||||
|
* -
|
||||||
|
* If the software was purchased under a paid Alfresco license, the terms of
|
||||||
|
* the paid license agreement will prevail. Otherwise, the software is
|
||||||
|
* provided under the following open source license terms:
|
||||||
|
* -
|
||||||
|
* Alfresco is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* -
|
||||||
|
* Alfresco is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
* -
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
* #L%
|
||||||
|
*/
|
||||||
|
package org.alfresco.rest.rm.community.fileplancomponents;
|
||||||
|
|
||||||
|
import static org.alfresco.rest.rm.community.base.TestData.FOLDER_NAME;
|
||||||
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS;
|
||||||
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.HOLDS_ALIAS;
|
||||||
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.TRANSFERS_ALIAS;
|
||||||
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.UNFILED_RECORDS_CONTAINER_ALIAS;
|
||||||
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.CONTENT_TYPE;
|
||||||
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.NON_ELECTRONIC_RECORD_TYPE;
|
||||||
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.RECORD_FOLDER_TYPE;
|
||||||
|
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
|
||||||
|
import static org.springframework.http.HttpStatus.BAD_REQUEST;
|
||||||
|
import static org.springframework.http.HttpStatus.OK;
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
import static org.testng.AssertJUnit.assertTrue;
|
||||||
|
|
||||||
|
import org.alfresco.rest.rm.community.base.BaseRestTest;
|
||||||
|
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.FilePlanComponentContent;
|
||||||
|
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentProperties;
|
||||||
|
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.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class contains the tests for
|
||||||
|
* read records API
|
||||||
|
*
|
||||||
|
* @author Rodica Sutu
|
||||||
|
* @since 2.6
|
||||||
|
*/
|
||||||
|
public class ReadRecordTests extends BaseRestTest
|
||||||
|
{
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private FilePlanComponentAPI filePlanComponentAPI;
|
||||||
|
@Autowired
|
||||||
|
private RecordsAPI recordsAPI;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DataUser dataUser;
|
||||||
|
|
||||||
|
private String CATEGORY_NAME=TestData.CATEGORY_NAME +getRandomAlphanumeric();
|
||||||
|
|
||||||
|
String ELECTRONIC_RECORD_NAME = "Record electronic" + getRandomAlphanumeric();
|
||||||
|
String NONELECTRONIC_RECORD_NAME = "Record nonelectronic" + getRandomAlphanumeric();
|
||||||
|
|
||||||
|
FilePlanComponent electronicRecord = FilePlanComponent.builder()
|
||||||
|
.name(ELECTRONIC_RECORD_NAME)
|
||||||
|
.nodeType(CONTENT_TYPE.toString())
|
||||||
|
.content(FilePlanComponentContent.builder().mimeType("text/plain").build())
|
||||||
|
.build();
|
||||||
|
FilePlanComponent nonelectronicRecord = FilePlanComponent.builder()
|
||||||
|
.properties(FilePlanComponentProperties.builder()
|
||||||
|
.description("Description")
|
||||||
|
.title("Title")
|
||||||
|
.build())
|
||||||
|
.name(NONELECTRONIC_RECORD_NAME)
|
||||||
|
.nodeType(NON_ELECTRONIC_RECORD_TYPE.toString())
|
||||||
|
.build();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given a record category or a container which can't contain records
|
||||||
|
* When I try to read the children filtering the results to records
|
||||||
|
* Then I receive an empty list
|
||||||
|
*/
|
||||||
|
@DataProvider(name="invalidContainersForRecords")
|
||||||
|
public Object[][] getContainers() throws Exception
|
||||||
|
{
|
||||||
|
return new Object[][] {
|
||||||
|
{ FILE_PLAN_ALIAS.toString() },
|
||||||
|
{ TRANSFERS_ALIAS.toString() },
|
||||||
|
{ HOLDS_ALIAS.toString() },
|
||||||
|
{ createCategory(FILE_PLAN_ALIAS.toString(), CATEGORY_NAME).getId()}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
(
|
||||||
|
dataProvider ="invalidContainersForRecords",
|
||||||
|
description ="Reading records from invalid containers"
|
||||||
|
)
|
||||||
|
public void readRecordsFromInvalidContainers(String container) throws Exception
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||||
|
|
||||||
|
FilePlanComponent electronicRecord = FilePlanComponent.builder()
|
||||||
|
.name(ELECTRONIC_RECORD_NAME)
|
||||||
|
.nodeType(CONTENT_TYPE.toString())
|
||||||
|
.content(FilePlanComponentContent.builder().mimeType("text/plain").build())
|
||||||
|
.build();
|
||||||
|
FilePlanComponent nonelectronicRecord= FilePlanComponent.builder()
|
||||||
|
.properties(FilePlanComponentProperties.builder()
|
||||||
|
.description("Description")
|
||||||
|
.title("Title")
|
||||||
|
.build())
|
||||||
|
.name(NONELECTRONIC_RECORD_NAME)
|
||||||
|
.nodeType(NON_ELECTRONIC_RECORD_TYPE.toString())
|
||||||
|
.build();
|
||||||
|
//create records
|
||||||
|
filePlanComponentAPI.createFilePlanComponent(electronicRecord,container);
|
||||||
|
filePlanComponentAPI.createFilePlanComponent(nonelectronicRecord, container);
|
||||||
|
|
||||||
|
// List children from API
|
||||||
|
filePlanComponentAPI.withParams("where=(isFile=true)").listChildComponents(container)
|
||||||
|
//check the list returned is empty
|
||||||
|
.assertThat().entriesListIsEmpty().assertThat().paginationExist();
|
||||||
|
// Check status code
|
||||||
|
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(OK);
|
||||||
|
}
|
||||||
|
//TODO MAYBE Update AC ??
|
||||||
|
/**
|
||||||
|
* Given a record
|
||||||
|
* When I try to read the children
|
||||||
|
* Then I receive error
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void readChildrenOnRecordsString() throws Exception
|
||||||
|
{
|
||||||
|
String ELECTRONIC_RECORD_NAME = "Record electronic" + getRandomAlphanumeric();
|
||||||
|
String NONELECTRONIC_RECORD_NAME = "Record nonelectronic" + getRandomAlphanumeric();
|
||||||
|
String RELATIVE_PATH="CATEGORY"+ getRandomAlphanumeric()+"/FOLDER";
|
||||||
|
|
||||||
|
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||||
|
|
||||||
|
|
||||||
|
//create records in Unfiled Container
|
||||||
|
FilePlanComponent recordElecInUnfiled = filePlanComponentAPI.createFilePlanComponent(electronicRecord, UNFILED_RECORDS_CONTAINER_ALIAS.toString());
|
||||||
|
FilePlanComponent recordNonElecInUnfiled = filePlanComponentAPI.createFilePlanComponent(nonelectronicRecord, UNFILED_RECORDS_CONTAINER_ALIAS.toString());
|
||||||
|
|
||||||
|
// List children for the electronic Record
|
||||||
|
filePlanComponentAPI.withParams("where=(isFile=true)").listChildComponents(recordElecInUnfiled.getId())
|
||||||
|
//check the list returned is empty
|
||||||
|
.assertThat().entriesListIsEmpty().assertThat().paginationExist();
|
||||||
|
// Check status code
|
||||||
|
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(OK);
|
||||||
|
|
||||||
|
// List children for the nonElectronic Record
|
||||||
|
filePlanComponentAPI.withParams("where=(isFile=true)").listChildComponents(recordNonElecInUnfiled.getId())
|
||||||
|
//check the list returned is empty
|
||||||
|
.assertThat().entriesListIsEmpty().assertThat().paginationExist();
|
||||||
|
// Check status code
|
||||||
|
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(OK);
|
||||||
|
|
||||||
|
//Update the Records objects
|
||||||
|
electronicRecord.setRelativePath(RELATIVE_PATH);
|
||||||
|
nonelectronicRecord.setRelativePath(RELATIVE_PATH);
|
||||||
|
|
||||||
|
//create records in Unfiled Container
|
||||||
|
FilePlanComponent recordElecFromRecordFolder = filePlanComponentAPI.createFilePlanComponent(electronicRecord, FILE_PLAN_ALIAS.toString());
|
||||||
|
FilePlanComponent recordNonElecFromRecordFolder = filePlanComponentAPI.createFilePlanComponent(nonelectronicRecord, FILE_PLAN_ALIAS.toString());
|
||||||
|
|
||||||
|
// List children for the electronic Record
|
||||||
|
filePlanComponentAPI.withParams("where=(isFile=true)").listChildComponents(recordElecFromRecordFolder.getId())
|
||||||
|
//check the list returned is empty
|
||||||
|
.assertThat().entriesListIsEmpty().assertThat().paginationExist();
|
||||||
|
// Check status code
|
||||||
|
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(OK);
|
||||||
|
|
||||||
|
// List children for the nonElectronic Record
|
||||||
|
filePlanComponentAPI.withParams("where=(isFile=true)").listChildComponents(recordNonElecFromRecordFolder.getId())
|
||||||
|
//check the list returned is empty
|
||||||
|
.assertThat().entriesListIsEmpty().assertThat().paginationExist();
|
||||||
|
// Check status code
|
||||||
|
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given a record
|
||||||
|
* When I try to read the meta-data
|
||||||
|
* Then I successfully receive the meta-data values for that record
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void readRecordMetadata() throws Exception
|
||||||
|
{
|
||||||
|
recordsAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||||
|
logger.info("NEW TEST" + recordsAPI.getRecordContentText("05978b97-bc84-4693-9f3f-f1b0502cfa7b").toString());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given an electronic record
|
||||||
|
* When I try to read the content
|
||||||
|
* Then I successfully receive the content of the record
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void readRecordContent() throws Exception
|
||||||
|
{
|
||||||
|
String RECORD_ELECTRONIC= "Record " + getRandomAlphanumeric();
|
||||||
|
String RELATIVE_PATH="/"+CATEGORY_NAME+ getRandomAlphanumeric()+"/folder";
|
||||||
|
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||||
|
//create the containers from the relativePath
|
||||||
|
FilePlanComponent recordFolder = FilePlanComponent.builder()
|
||||||
|
.name(FOLDER_NAME)
|
||||||
|
.nodeType(RECORD_FOLDER_TYPE.toString())
|
||||||
|
.relativePath(RELATIVE_PATH)
|
||||||
|
.build();
|
||||||
|
String folderId=filePlanComponentAPI.createFilePlanComponent(recordFolder,FILE_PLAN_ALIAS.toString()).getId();
|
||||||
|
//
|
||||||
|
FilePlanComponent record = FilePlanComponent.builder()
|
||||||
|
.name(RECORD_ELECTRONIC)
|
||||||
|
.nodeType(CONTENT_TYPE.toString())
|
||||||
|
.build();
|
||||||
|
String recordId =filePlanComponentAPI.createElectronicRecord(record, createTempFile(RECORD_ELECTRONIC, RECORD_ELECTRONIC), folderId).getId();
|
||||||
|
|
||||||
|
recordsAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||||
|
|
||||||
|
assertEquals(recordsAPI.getRecordContentText(recordId),RECORD_ELECTRONIC);
|
||||||
|
// Check status code
|
||||||
|
recordsAPI.usingRestWrapper().assertStatusCodeIs(OK);
|
||||||
|
|
||||||
|
FilePlanComponent recordNoContent = FilePlanComponent.builder()
|
||||||
|
.name(RECORD_ELECTRONIC)
|
||||||
|
.nodeType(CONTENT_TYPE.toString())
|
||||||
|
.build();
|
||||||
|
String recordNoContentId=filePlanComponentAPI.createFilePlanComponent(recordNoContent,folderId).getId();
|
||||||
|
assertTrue(recordsAPI.getRecordContentText(recordNoContentId).toString().isEmpty());
|
||||||
|
recordsAPI.usingRestWrapper().assertStatusCodeIs(OK);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Given a non-electronic record
|
||||||
|
* When I try to read the content
|
||||||
|
* Then I am informed that the record has no content
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void readRecordNonElectronicContent() throws Exception
|
||||||
|
{
|
||||||
|
|
||||||
|
String NONELECTRONIC_RECORD_NAME = "Record nonelectronic" + getRandomAlphanumeric();
|
||||||
|
FilePlanComponent record = FilePlanComponent.builder()
|
||||||
|
.name(NONELECTRONIC_RECORD_NAME)
|
||||||
|
.nodeType(NON_ELECTRONIC_RECORD_TYPE.toString())
|
||||||
|
.relativePath("/"+CATEGORY_NAME+"/"+FOLDER_NAME)
|
||||||
|
.build();
|
||||||
|
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||||
|
String nonElectronicRecord=filePlanComponentAPI.createFilePlanComponent(record,FILE_PLAN_ALIAS.toString()).getId();
|
||||||
|
recordsAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||||
|
assertTrue(recordsAPI.getRecordContentText(nonElectronicRecord).toString().isEmpty());
|
||||||
|
recordsAPI.usingRestWrapper().assertStatusCodeIs(OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given a container (eg record folder, record category, etc)
|
||||||
|
* When I try to read the content
|
||||||
|
* Then I receive an error
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
(
|
||||||
|
dataProvider = "getContainers",
|
||||||
|
dataProviderClass = TestData.class,
|
||||||
|
description = "Reading records from invalid containers"
|
||||||
|
)
|
||||||
|
public void readContainFromInvalidContainers(String container) throws Exception
|
||||||
|
{
|
||||||
|
recordsAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||||
|
recordsAPI.getRecordContentText(container).toString();
|
||||||
|
recordsAPI.usingRestWrapper().assertStatusCodeIs(BAD_REQUEST);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given a container that is a record folder
|
||||||
|
* When I try to record the containers records
|
||||||
|
* Then I receive a list of all the records contained within the record folder
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given a container this an unfiled record folder or the unfiled record container root
|
||||||
|
* When I try to record the containers records
|
||||||
|
* Then I receive a list of all the records contained within the unfiled record folder or the unfiled record container root
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Reference in New Issue
Block a user