Merge branch 'master' into feature/RM-3964_Record_Category_CRUD_2

This commit is contained in:
Kristijan Conkas
2016-10-27 15:36:35 +01:00
15 changed files with 481 additions and 41 deletions

View File

@@ -9,7 +9,7 @@
* agreement is prohibited. * agreement is prohibited.
* #L% * #L%
*/ */
package org.alfresco.com; package org.alfresco.com.fileplancomponents;
/** /**
* File plan component alias enumeration * File plan component alias enumeration

View File

@@ -9,7 +9,7 @@
* agreement is prohibited. * agreement is prohibited.
* #L% * #L%
*/ */
package org.alfresco.com; package org.alfresco.com.fileplancomponents;
/** /**
* FIXME: Document me :) * FIXME: Document me :)

View File

@@ -9,7 +9,7 @@
* agreement is prohibited. * agreement is prohibited.
* #L% * #L%
*/ */
package org.alfresco.com; package org.alfresco.com.fileplancomponents;
/** /**
* File plan component type enumeration * File plan component type enumeration

View File

@@ -0,0 +1,24 @@
/*
* #%L
* Alfresco Records Management Module
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* License rights for this program may be obtained from Alfresco Software, Ltd.
* pursuant to a written agreement and any use of this program without such an
* agreement is prohibited.
* #L%
*/
package org.alfresco.com.site;
/**
* RM Site compliance
*
* @author Tuna Aksoy
* @since 1.0
*/
public enum RMSiteCompliance
{
STANDARD,
DOD5015
}

View File

@@ -0,0 +1,37 @@
/*
* #%L
* Alfresco Records Management Module
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* License rights for this program may be obtained from Alfresco Software, Ltd.
* pursuant to a written agreement and any use of this program without such an
* agreement is prohibited.
* #L%
*/
package org.alfresco.com.site;
/**
*RM Site properties from the RM Model Schema
*"entry": {
* "id": "string",
* "guid": "string",
* "title": "string",
* "description": "string",
* "visibility": "{@link org.springframework.social.alfresco.api.entities.Site.Visibility}",
* "compliance": "{@link RMSiteCompliance}",
* "role": "{@link org.alfresco.utility.constants.UserRole}"
*}
* @author Tuna Aksoy
* @author Rodica Sutu
* @since 1.0
*/
public class RMSiteFields
{
public static final String ID = "id";
public static final String COMPLIANCE = "compliance";
public static final String TITLE = "title";
public static final String DESCRIPTION = "description";
public static final String VISIBILITY ="visibility";
public static final String ROLE = "role";
}

View File

@@ -14,6 +14,7 @@ package org.alfresco.rest.model;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import org.alfresco.rest.core.RestModels; import org.alfresco.rest.core.RestModels;
import org.alfresco.rest.model.fileplancomponents.FilePlanComponent;
/** /**
* POJO for file plan component entry * POJO for file plan component entry

View File

@@ -9,9 +9,9 @@
* agreement is prohibited. * agreement is prohibited.
* #L% * #L%
*/ */
package org.alfresco.rest.model; package org.alfresco.rest.model.fileplancomponents;
import static org.alfresco.com.FilePlanComponentFields.PROPERTIES; import static org.alfresco.com.fileplancomponents.FilePlanComponentFields.PROPERTIES;
import java.util.List; import java.util.List;

View File

@@ -9,7 +9,7 @@
* agreement is prohibited. * agreement is prohibited.
* #L% * #L%
*/ */
package org.alfresco.rest.model; package org.alfresco.rest.model.fileplancomponents;
/** /**
* POJO for file plan component created by object * POJO for file plan component created by object

View File

@@ -9,11 +9,11 @@
* agreement is prohibited. * agreement is prohibited.
* #L% * #L%
*/ */
package org.alfresco.rest.model; package org.alfresco.rest.model.fileplancomponents;
import static org.alfresco.com.FilePlanComponentFields.PROPERTIES_HOLD_REASON; import static org.alfresco.com.fileplancomponents.FilePlanComponentFields.PROPERTIES_HOLD_REASON;
import static org.alfresco.com.FilePlanComponentFields.PROPERTIES_TITLE; import static org.alfresco.com.fileplancomponents.FilePlanComponentFields.PROPERTIES_TITLE;
import static org.alfresco.com.FilePlanComponentFields.PROPERTIES_VITAL_RECORD_INDICATOR; import static org.alfresco.com.fileplancomponents.FilePlanComponentFields.PROPERTIES_VITAL_RECORD_INDICATOR;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;

View File

@@ -0,0 +1,47 @@
/*
* #%L
* Alfresco Records Management Module
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* License rights for this program may be obtained from Alfresco Software, Ltd.
* pursuant to a written agreement and any use of this program without such an
* agreement is prohibited.
* #L%
*/
package org.alfresco.rest.model.site;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.alfresco.com.site.RMSiteCompliance;
import org.alfresco.rest.model.RestSiteModel;
/**
* POJO for RM Site component
*
* @author Rodica Sutu
* @since 1.0
*/
public class RMSite extends RestSiteModel
{
@JsonProperty (required = true)
private RMSiteCompliance compliance;
/**
* Helper method to set RM site compliance
* @param compliance {@link RMSiteCompliance} the compliance to set
*/
public void setCompliance(RMSiteCompliance compliance)
{
this.compliance = compliance;
}
/**
* Helper method to get RM site compliance
* @return compliance the RM Site compliance to get
*/
public RMSiteCompliance getCompliance()
{
return compliance;
}
}

View File

@@ -23,8 +23,8 @@ import static org.springframework.http.HttpMethod.PUT;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import org.alfresco.rest.core.RestAPI; import org.alfresco.rest.core.RestAPI;
import org.alfresco.rest.model.FilePlanComponent;
import org.alfresco.rest.model.FilePlanComponentsCollection; import org.alfresco.rest.model.FilePlanComponentsCollection;
import org.alfresco.rest.model.fileplancomponents.FilePlanComponent;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@@ -84,7 +84,7 @@ public class FilePlanComponentApi extends RestAPI
filePlanComponentId filePlanComponentId
)); ));
} }
/** /**
* Creates a file plan component with the given properties under the parent node with the given id * Creates a file plan component with the given properties under the parent node with the given id
* *

View File

@@ -0,0 +1,123 @@
/*
* #%L
* Alfresco Records Management Module
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* License rights for this program may be obtained from Alfresco Software, Ltd.
* pursuant to a written agreement and any use of this program without such an
* agreement is prohibited.
* #L%
*/
package org.alfresco.rest.requests;
import static org.alfresco.rest.core.RestRequest.requestWithBody;
import static org.alfresco.rest.core.RestRequest.simpleRequest;
import static org.springframework.http.HttpMethod.DELETE;
import static org.springframework.http.HttpMethod.GET;
import static org.springframework.http.HttpMethod.POST;
import static org.springframework.http.HttpMethod.PUT;
import com.google.gson.JsonObject;
import org.alfresco.rest.core.RestAPI;
import org.alfresco.rest.model.site.RMSite;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
/**
* File plan component REST API Wrapper
*
* @author Tuna Aksoy
* @author Rodica Sutu
* @since 1.0
*/
@Component
@Scope (value = "prototype")
public class RMSiteAPI extends RestAPI
{
/**
* Get the RM site
*
* @return The {@link RMSite} for the given file plan component id
* @throws Exception for the following cases:
* <ul>
* <li>Api Response code 400 Invalid parameter: GET request is supported only for the RM site</li>
* <li>Api Response code 401 If authentication failed</li>
* <li>Api Response code 409 If RM Site does not exist</li>
* <li>Api Response code default Unexpected error</li>
* </ul>
*/
public RMSite getSite() throws Exception
{
return usingRestWrapper().processModel(RMSite.class, simpleRequest(
GET,
"sites/rm"
));
}
/**
* Create the RM site
*
* @param rmSiteProperties The properties of the rm site to be created
* @return The {@link RMSite} with the given properties
* @throws Exception for the following cases:
* <ul>
* <li>Api Response code 400 Invalid parameter: title, or description exceed the maximum length; or siteBodyCreate invalid</li>
* <li>Api Response code 401 If authentication failed</
* <li>Api Response code 409 RM Site already exists</li>
* <li>Api Response code default Unexpected error</li>
* </ul>
*/
public RMSite createRMSite(JsonObject rmSiteProperties) throws Exception
{
return usingRestWrapper().processModel(RMSite.class, requestWithBody(
POST,
rmSiteProperties.toString(),
"sites"
));
}
/**
* Delete RM site
* @throws Exception for the following cases:
* <ul>
* <li>Api Response code 400 Invalid parameter: DELETE request is supported only for the RM site</li>
* <li>Api Response code 401 If authentication failed</
* <li>Api Response code 403 Current user does not have permission to delete the site that is visible to them.</li>
* <li>Api Response code 404 RM site does not exist</li>
* <li>Api Response code default Unexpected error</li>
* </ul>
*/
public void deleteRMSite() throws Exception
{
usingRestWrapper().processEmptyModel(simpleRequest(
DELETE,
"sites/rm"
));
}
/**
* Update RM site
*
* @param rmSiteProperties The properties to be updated
* @return The updated {@link RMSite}
* @throws Exception for the following cases:
* <ul>
* <li>Api Response code 400 the update request is invalid {@code rmSiteProperties} is invalid</li>
* <li>Api Response code 401 If authentication fails</li>
* <li>Api Response code 403 does not have permission to update {@code RMSite}</li>
* <li>Api Response code 404 {@code RMSite} does not exist</li>
* <li>Api Response code default Unexpected error,model integrity exception</li>
* </ul>
*/
public RMSite updateRMSite(JsonObject rmSiteProperties) throws Exception
{
return usingRestWrapper().processModel(RMSite.class, requestWithBody(
PUT,
rmSiteProperties.toString(),
"sites/rm"
));
}
}

View File

@@ -13,8 +13,21 @@ package org.alfresco.rest;
import static java.lang.Integer.parseInt; import static java.lang.Integer.parseInt;
import static org.alfresco.com.site.RMSiteCompliance.STANDARD;
import static org.alfresco.com.site.RMSiteFields.COMPLIANCE;
import static org.alfresco.com.site.RMSiteFields.DESCRIPTION;
import static org.alfresco.com.site.RMSiteFields.TITLE;
import static org.jglue.fluentjson.JsonBuilderFactory.buildObject;
import static org.springframework.http.HttpStatus.CREATED;
import static org.springframework.http.HttpStatus.OK;
import com.google.gson.JsonObject;
import com.jayway.restassured.RestAssured; import com.jayway.restassured.RestAssured;
import org.alfresco.rest.core.RestWrapper;
import org.alfresco.rest.requests.RMSiteAPI;
import org.alfresco.utility.data.DataUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource; import org.springframework.context.annotation.PropertySource;
@@ -32,18 +45,29 @@ import org.testng.annotations.BeforeClass;
@PropertySource(value = "classpath:local.properties", ignoreResourceNotFound = true) @PropertySource(value = "classpath:local.properties", ignoreResourceNotFound = true)
public class BaseRestTest extends RestTest public class BaseRestTest extends RestTest
{ {
@Value("${alfresco.rm.scheme}") @Value ("${alfresco.rm.scheme}")
private String scheme; private String scheme;
@Value("${alfresco.rm.host}") @Value ("${alfresco.rm.host}")
private String host; private String host;
@Value("${alfresco.rm.port}") @Value ("${alfresco.rm.port}")
private String port; private String port;
@Value("${alfresco.rm.basePath}") @Value ("${alfresco.rm.basePath}")
private String basePath; private String basePath;
@Autowired
public RMSiteAPI rmSiteAPI;
@Autowired
public DataUser dataUser;
// Constants
public static final String RM_ID = "rm";
public static final String RM_TITLE = "Records Management";
public static final String RM_DESCRIPTION = "Records Management Site";
/** /**
* @see org.alfresco.rest.RestTest#checkServerHealth() * @see org.alfresco.rest.RestTest#checkServerHealth()
*/ */
@@ -54,5 +78,43 @@ public class BaseRestTest extends RestTest
RestAssured.baseURI = scheme + "://" + host; RestAssured.baseURI = scheme + "://" + host;
RestAssured.port = parseInt(port); RestAssured.port = parseInt(port);
RestAssured.basePath = basePath; RestAssured.basePath = basePath;
//create RM Site if not exist
createRMSiteIfNotExists();
} }
} /**
* Helper method to create the RM Site via the POST request
* if the site doesn't exist
*/
public void createRMSiteIfNotExists() throws Exception
{
//check RM site doesn't exist
if (!siteRMExist())
{
rmSiteAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
// Build the RM site properties
JsonObject rmSiteProperties = buildObject()
.add(TITLE, RM_TITLE)
.add(DESCRIPTION, RM_DESCRIPTION)
.add(COMPLIANCE, STANDARD.toString())
.getJson();
// Create the RM site
rmSiteAPI.createRMSite(rmSiteProperties);
// Verify the status code
rmSiteAPI.usingRestWrapper().assertStatusCodeIs(CREATED);
}
}
/**
* Check the RM site exist via the GET request
*/
public boolean siteRMExist() throws Exception
{
RestWrapper restWrapper = rmSiteAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
rmSiteAPI.getSite();
return restWrapper.getStatusCode().equals(OK.toString());
}
}

View File

@@ -0,0 +1,148 @@
/*
* #%L
* Alfresco Records Management Module
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* License rights for this program may be obtained from Alfresco Software, Ltd.
* pursuant to a written agreement and any use of this program without such an
* agreement is prohibited.
* #L%
*/
package org.alfresco.rest.fileplancomponents;
import static org.alfresco.com.site.RMSiteCompliance.STANDARD;
import static org.alfresco.com.site.RMSiteFields.COMPLIANCE;
import static org.alfresco.com.site.RMSiteFields.DESCRIPTION;
import static org.alfresco.com.site.RMSiteFields.TITLE;
import static org.jglue.fluentjson.JsonBuilderFactory.buildObject;
import static org.springframework.http.HttpStatus.CONFLICT;
import static org.springframework.http.HttpStatus.CREATED;
import static org.springframework.http.HttpStatus.NOT_FOUND;
import static org.springframework.http.HttpStatus.NO_CONTENT;
import static org.springframework.http.HttpStatus.OK;
import static org.springframework.social.alfresco.api.entities.Site.Visibility.PUBLIC;
import static org.testng.Assert.assertEquals;
import com.google.gson.JsonObject;
import org.alfresco.rest.BaseRestTest;
import org.alfresco.rest.core.RestWrapper;
import org.alfresco.rest.model.site.RMSite;
import org.testng.annotations.Test;
/**
* FIXME: Document me :)
* FIXME: Should we use dependent tests or not?
* They were removed here but there is no guarantee for the test execution order.
* In {@link RecordCategoryTest} we create a record category first to delete it.
* Probably something to think about again.
*
* @author Rodica Sutu
* @since 1.0
*/
public class RMSiteTests extends BaseRestTest
{
@Test
(
description = "Create RM site as admin user with standard Compliance"
)
public void createRMSiteAsAdminUser() throws Exception
{
RestWrapper restWrapper = rmSiteAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
if (siteRMExist())
{
// Delete the RM site
rmSiteAPI.deleteRMSite();
}
// Build the RM site properties
JsonObject rmSiteProperties = buildObject().
add(TITLE, RM_TITLE).
add(DESCRIPTION, RM_DESCRIPTION).
add(COMPLIANCE, STANDARD.toString()).
getJson();
// Create the RM site
RMSite rmSite = rmSiteAPI.createRMSite(rmSiteProperties);
// Verify the status code
restWrapper.assertStatusCodeIs(CREATED);
// Verify the returned file plan component
assertEquals(rmSite.getId(), RM_ID);
assertEquals(rmSite.getTitle(), RM_TITLE);
assertEquals(rmSite.getDescription(), RM_DESCRIPTION);
assertEquals(rmSite.getCompliance(), STANDARD);
assertEquals(rmSite.getVisibility(), PUBLIC);
}
@Test
(
description = "Create RM site when site already exist with admin user"
)
public void createRMSiteWhenSiteExists() throws Exception
{
rmSiteAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
createRMSiteIfNotExists();
RestWrapper restWrapper = rmSiteAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
// Construct new properties
String newTitle = RM_TITLE + "createRMSiteWhenSiteExists";
String newDescription = RM_DESCRIPTION + "createRMSiteWhenSiteExists";
// Build the RM site properties
JsonObject rmSiteProperties = buildObject().
add(TITLE, newTitle).
add(DESCRIPTION, newDescription).
add(COMPLIANCE, STANDARD.toString()).
getJson();
// Create the RM site
rmSiteAPI.createRMSite(rmSiteProperties);
// Verify the status code
restWrapper.assertStatusCodeIs(CONFLICT);
}
@Test
(
description = "Delete RM site as admin user"
)
public void deleteRMSite() throws Exception
{
RestWrapper restWrapper = rmSiteAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
// Delete the RM site
rmSiteAPI.deleteRMSite();
// Verify the status code
restWrapper.assertStatusCodeIs(NO_CONTENT);
}
@Test
(
description = "GET RM site as admin user"
)
public void getRMSite() throws Exception
{
RestWrapper restWrapper = rmSiteAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
// Get the RM site
RMSite rmSite = rmSiteAPI.getSite();
if (!siteRMExist())
{
// Verify the status code
restWrapper.assertStatusCodeIs(NOT_FOUND);
}
else
{
// Verify the status code
restWrapper.assertStatusCodeIs(OK);
assertEquals(rmSite.getId(), RM_ID);
assertEquals(rmSite.getDescription(), RM_DESCRIPTION);
assertEquals(rmSite.getCompliance(), STANDARD);
assertEquals(rmSite.getVisibility(), PUBLIC);
}
}
}

View File

@@ -13,13 +13,13 @@ package org.alfresco.rest.fileplancomponents;
import static java.util.UUID.randomUUID; import static java.util.UUID.randomUUID;
import static org.alfresco.com.FilePlanComponentAlias.FILE_PLAN_ALIAS; import static org.alfresco.com.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS;
import static org.alfresco.com.FilePlanComponentFields.NAME; import static org.alfresco.com.fileplancomponents.FilePlanComponentFields.NAME;
import static org.alfresco.com.FilePlanComponentFields.NODE_TYPE; import static org.alfresco.com.fileplancomponents.FilePlanComponentFields.NODE_TYPE;
import static org.alfresco.com.FilePlanComponentFields.PROPERTIES; import static org.alfresco.com.fileplancomponents.FilePlanComponentFields.PROPERTIES;
import static org.alfresco.com.FilePlanComponentFields.PROPERTIES_TITLE; import static org.alfresco.com.fileplancomponents.FilePlanComponentFields.PROPERTIES_TITLE;
import static org.alfresco.com.FilePlanComponentType.RECORD_CATEGORY_TYPE; import static org.alfresco.com.fileplancomponents.FilePlanComponentType.RECORD_CATEGORY_TYPE;
import static org.alfresco.com.FilePlanComponentType.RECORD_FOLDER_TYPE; import static org.alfresco.com.fileplancomponents.FilePlanComponentType.RECORD_FOLDER_TYPE;
import static org.jglue.fluentjson.JsonBuilderFactory.buildObject; import static org.jglue.fluentjson.JsonBuilderFactory.buildObject;
import static org.springframework.http.HttpStatus.CREATED; import static org.springframework.http.HttpStatus.CREATED;
import static org.springframework.http.HttpStatus.NOT_FOUND; import static org.springframework.http.HttpStatus.NOT_FOUND;
@@ -36,12 +36,12 @@ import java.util.NoSuchElementException;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import org.alfresco.com.FilePlanComponentType; import org.alfresco.com.fileplancomponents.FilePlanComponentType;
import org.alfresco.rest.BaseRestTest; import org.alfresco.rest.BaseRestTest;
import org.alfresco.rest.core.RestWrapper; import org.alfresco.rest.core.RestWrapper;
import org.alfresco.rest.model.FilePlanComponent;
import org.alfresco.rest.model.FilePlanComponentProperties;
import org.alfresco.rest.model.FilePlanComponentsCollection; import org.alfresco.rest.model.FilePlanComponentsCollection;
import org.alfresco.rest.model.fileplancomponents.FilePlanComponent;
import org.alfresco.rest.model.fileplancomponents.FilePlanComponentProperties;
import org.alfresco.rest.requests.FilePlanComponentApi; import org.alfresco.rest.requests.FilePlanComponentApi;
import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser;
import org.alfresco.utility.data.RandomData; import org.alfresco.utility.data.RandomData;
@@ -62,7 +62,7 @@ public class RecordCategoryTest extends BaseRestTest
@Autowired @Autowired
private DataUser dataUser; private DataUser dataUser;
// for children creation test // for children creation test
private static final int NUMBER_OF_CHILDREN = 10; private static final int NUMBER_OF_CHILDREN = 10;
@@ -208,7 +208,7 @@ public class RecordCategoryTest extends BaseRestTest
filePlanComponentApi.getFilePlanComponent(filePlanComponent.getId()); filePlanComponentApi.getFilePlanComponent(filePlanComponent.getId());
restWrapper.assertStatusCodeIs(NOT_FOUND); restWrapper.assertStatusCodeIs(NOT_FOUND);
} }
/** /**
* <pre> * <pre>
* Given that a record category exists * Given that a record category exists
@@ -224,10 +224,10 @@ public class RecordCategoryTest extends BaseRestTest
// create root level category // create root level category
FilePlanComponent rootCategory = createCategory(FILE_PLAN_ALIAS.toString(), RandomData.getRandomAlphanumeric()); FilePlanComponent rootCategory = createCategory(FILE_PLAN_ALIAS.toString(), RandomData.getRandomAlphanumeric());
assertNotNull(rootCategory.getId()); assertNotNull(rootCategory.getId());
// create subcategory as a child of rootCategory // create subcategory as a child of rootCategory
FilePlanComponent childCategory = createCategory(rootCategory.getId(), RandomData.getRandomAlphanumeric()); FilePlanComponent childCategory = createCategory(rootCategory.getId(), RandomData.getRandomAlphanumeric());
// child category created? // child category created?
assertNotNull(childCategory.getId()); assertNotNull(childCategory.getId());
@@ -238,7 +238,7 @@ public class RecordCategoryTest extends BaseRestTest
assertFalse(childCategory.isIsRecordFolder()); assertFalse(childCategory.isIsRecordFolder());
assertEquals(childCategory.getNodeType(), RECORD_CATEGORY_TYPE.toString()); assertEquals(childCategory.getNodeType(), RECORD_CATEGORY_TYPE.toString());
} }
/** /**
* <pre> * <pre>
* Given that a record category exists * Given that a record category exists
@@ -256,25 +256,24 @@ public class RecordCategoryTest extends BaseRestTest
// create root level category // create root level category
FilePlanComponent rootCategory = createCategory(FILE_PLAN_ALIAS.toString(), RandomData.getRandomAlphanumeric()); FilePlanComponent rootCategory = createCategory(FILE_PLAN_ALIAS.toString(), RandomData.getRandomAlphanumeric());
assertNotNull(rootCategory.getId()); assertNotNull(rootCategory.getId());
// add child categories/folders // add child categories/folders
ArrayList<FilePlanComponent> children = new ArrayList<FilePlanComponent>(); ArrayList<FilePlanComponent> children = new ArrayList<FilePlanComponent>();
for(int i=0; i < NUMBER_OF_CHILDREN; i++) for (int i=0; i < NUMBER_OF_CHILDREN; i++)
{ {
// create a child // create a child
FilePlanComponent child = createComponent(rootCategory.getId(), FilePlanComponent child = createComponent(rootCategory.getId(),
RandomData.getRandomAlphanumeric(), RandomData.getRandomAlphanumeric(),
// half of the children should be subcategories, the other subfolders // half of the children should be subcategories, the other subfolders
(i <= NUMBER_OF_CHILDREN / 2) ? RECORD_CATEGORY_TYPE : RECORD_FOLDER_TYPE); (i <= NUMBER_OF_CHILDREN / 2) ? RECORD_CATEGORY_TYPE : RECORD_FOLDER_TYPE);
assertNotNull(child.getId()); assertNotNull(child.getId());
children.add(child); children.add(child);
} }
// list children from API // list children from API
RestWrapper restWrapper = filePlanComponentApi.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); RestWrapper restWrapper = filePlanComponentApi.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
FilePlanComponentsCollection apiChildren = filePlanComponentApi.listChildComponents(rootCategory.getId()); FilePlanComponentsCollection apiChildren = filePlanComponentApi.listChildComponents(rootCategory.getId());
restWrapper.assertStatusCodeIs(OK); restWrapper.assertStatusCodeIs(OK);
logger.info("parent: " + rootCategory.getId()); logger.info("parent: " + rootCategory.getId());
// check listed children against created list // check listed children against created list
@@ -291,7 +290,7 @@ public class RecordCategoryTest extends BaseRestTest
.filter(child -> child.getId().equals(filePlanComponent.getId())) .filter(child -> child.getId().equals(filePlanComponent.getId()))
.findFirst() .findFirst()
.get(); .get();
// created by // created by
assertEquals(filePlanComponent.getCreatedByUser().getId(), dataUser.getAdminUser().getUsername()); assertEquals(filePlanComponent.getCreatedByUser().getId(), dataUser.getAdminUser().getUsername());
@@ -319,7 +318,6 @@ public class RecordCategoryTest extends BaseRestTest
assertEquals(createdComponent.getNodeType(), filePlanComponent.getNodeType()); assertEquals(createdComponent.getNodeType(), filePlanComponent.getNodeType());
// verify properties // verify properties
//assertEquals(createdComponent.getProperties().getTitle(), filePlanComponent.getProperties().getTitle());
} }
catch (NoSuchElementException e) catch (NoSuchElementException e)
{ {
@@ -327,7 +325,7 @@ public class RecordCategoryTest extends BaseRestTest
} }
}); });
} }
/** /**
* Helper method to create child category * Helper method to create child category
* @param parentCategoryId * @param parentCategoryId
@@ -338,7 +336,7 @@ public class RecordCategoryTest extends BaseRestTest
{ {
return createComponent(parentCategoryId, categoryName, RECORD_CATEGORY_TYPE); return createComponent(parentCategoryId, categoryName, RECORD_CATEGORY_TYPE);
} }
/** /**
* Helper method to create generic child component * Helper method to create generic child component
* @param parentComponentId * @param parentComponentId