mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Fixed compilation issues.
This commit is contained in:
@@ -14,6 +14,7 @@ package org.alfresco.rest.model;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.alfresco.rest.core.RestModels;
|
||||
import org.alfresco.rest.model.fileplancomponents.FilePlanComponent;
|
||||
|
||||
/**
|
||||
* POJO for file plan component entry
|
||||
|
@@ -18,9 +18,6 @@ import static org.alfresco.com.fileplancomponents.FilePlanComponentFields.PROPER
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* POJO for file plan component properties
|
||||
*
|
||||
|
@@ -23,8 +23,8 @@ import static org.springframework.http.HttpMethod.PUT;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import org.alfresco.rest.core.RestAPI;
|
||||
import org.alfresco.rest.model.FilePlanComponent;
|
||||
import org.alfresco.rest.model.FilePlanComponentsCollection;
|
||||
import org.alfresco.rest.model.fileplancomponents.FilePlanComponent;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -84,7 +84,7 @@ public class FilePlanComponentApi extends RestAPI
|
||||
filePlanComponentId
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a file plan component with the given properties under the parent node with the given id
|
||||
*
|
||||
|
@@ -19,11 +19,11 @@ 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 org.alfresco.dataprep.SiteService;
|
||||
import org.alfresco.rest.core.RestWrapper;
|
||||
import org.alfresco.rest.requests.RMSiteAPI;
|
||||
import org.alfresco.utility.data.DataUser;
|
||||
@@ -31,7 +31,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
|
||||
/**
|
||||
@@ -64,10 +63,10 @@ public class BaseRestTest extends RestTest
|
||||
@Autowired
|
||||
public DataUser dataUser;
|
||||
|
||||
private static final String RM_ID = "rm";
|
||||
|
||||
@Autowired
|
||||
private SiteService siteService;
|
||||
// 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()
|
||||
@@ -79,6 +78,7 @@ public class BaseRestTest extends RestTest
|
||||
RestAssured.baseURI = scheme + "://" + host;
|
||||
RestAssured.port = parseInt(port);
|
||||
RestAssured.basePath = basePath;
|
||||
|
||||
//create RM Site if not exist
|
||||
createRMSiteIfNotExists();
|
||||
}
|
||||
@@ -88,18 +88,18 @@ public class BaseRestTest extends RestTest
|
||||
*/
|
||||
public void createRMSiteIfNotExists() throws Exception
|
||||
{
|
||||
final String RM_TITLE = "Records Management";
|
||||
final String RM_DESCRIPTION = "Records Management Site";
|
||||
//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);
|
||||
|
||||
@@ -108,14 +108,13 @@ public class BaseRestTest extends RestTest
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check the RM site exist via the GET request
|
||||
*/
|
||||
public boolean siteRMExist() throws Exception
|
||||
{
|
||||
RestWrapper restWrapper=rmSiteAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
RestWrapper restWrapper = rmSiteAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
rmSiteAPI.getSite();
|
||||
return restWrapper.getStatusCode().equals(HttpStatus.OK.toString());
|
||||
return restWrapper.getStatusCode().equals(OK.toString());
|
||||
}
|
||||
}
|
@@ -36,19 +36,13 @@ import org.testng.annotations.Test;
|
||||
* 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.
|
||||
* Probbaly something to think about again.
|
||||
* Probably something to think about again.
|
||||
*
|
||||
* @author Rodica Sutu
|
||||
* @since 1.0
|
||||
*/
|
||||
public class RMSiteTests extends BaseRestTest
|
||||
{
|
||||
|
||||
// Constants
|
||||
private static final String RM_ID = "rm";
|
||||
private static final String RM_TITLE = "Records Management";
|
||||
private static final String RM_DESCRIPTION = "Records Management Site";
|
||||
|
||||
@Test
|
||||
(
|
||||
description = "Create RM site as admin user with standard Compliance"
|
||||
@@ -58,7 +52,7 @@ public class RMSiteTests extends BaseRestTest
|
||||
RestWrapper restWrapper = rmSiteAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
if (siteRMExist())
|
||||
{
|
||||
//Delete the RM site
|
||||
// Delete the RM site
|
||||
rmSiteAPI.deleteRMSite();
|
||||
}
|
||||
// Build the RM site properties
|
||||
@@ -72,7 +66,7 @@ public class RMSiteTests extends BaseRestTest
|
||||
RMSite rmSite = rmSiteAPI.createRMSite(rmSiteProperties);
|
||||
|
||||
// Verify the status code
|
||||
rmSiteAPI.usingRestWrapper().assertStatusCodeIs(CREATED);
|
||||
restWrapper.assertStatusCodeIs(CREATED);
|
||||
|
||||
// Verify the returned file plan component
|
||||
assertEquals(rmSite.getId(), RM_ID);
|
||||
@@ -126,15 +120,15 @@ public class RMSiteTests extends BaseRestTest
|
||||
}
|
||||
|
||||
@Test
|
||||
(
|
||||
description = "GET RM site as admin user"
|
||||
)
|
||||
(
|
||||
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();
|
||||
RMSite rmSite = rmSiteAPI.getSite();
|
||||
|
||||
if (!siteRMExist())
|
||||
{
|
||||
@@ -150,6 +144,5 @@ public class RMSiteTests extends BaseRestTest
|
||||
assertEquals(rmSite.getCompliance(), STANDARD);
|
||||
assertEquals(rmSite.getVisibility(), PUBLIC);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -13,13 +13,13 @@ package org.alfresco.rest.fileplancomponents;
|
||||
|
||||
import static java.util.UUID.randomUUID;
|
||||
|
||||
import static org.alfresco.com.FilePlanComponentAlias.FILE_PLAN_ALIAS;
|
||||
import static org.alfresco.com.FilePlanComponentFields.NAME;
|
||||
import static org.alfresco.com.FilePlanComponentFields.NODE_TYPE;
|
||||
import static org.alfresco.com.FilePlanComponentFields.PROPERTIES;
|
||||
import static org.alfresco.com.FilePlanComponentFields.PROPERTIES_TITLE;
|
||||
import static org.alfresco.com.FilePlanComponentType.RECORD_CATEGORY_TYPE;
|
||||
import static org.alfresco.com.FilePlanComponentType.RECORD_FOLDER_TYPE;
|
||||
import static org.alfresco.com.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS;
|
||||
import static org.alfresco.com.fileplancomponents.FilePlanComponentFields.NAME;
|
||||
import static org.alfresco.com.fileplancomponents.FilePlanComponentFields.NODE_TYPE;
|
||||
import static org.alfresco.com.fileplancomponents.FilePlanComponentFields.PROPERTIES;
|
||||
import static org.alfresco.com.fileplancomponents.FilePlanComponentFields.PROPERTIES_TITLE;
|
||||
import static org.alfresco.com.fileplancomponents.FilePlanComponentType.RECORD_CATEGORY_TYPE;
|
||||
import static org.alfresco.com.fileplancomponents.FilePlanComponentType.RECORD_FOLDER_TYPE;
|
||||
import static org.jglue.fluentjson.JsonBuilderFactory.buildObject;
|
||||
import static org.springframework.http.HttpStatus.CREATED;
|
||||
import static org.springframework.http.HttpStatus.NO_CONTENT;
|
||||
@@ -35,13 +35,13 @@ import java.util.NoSuchElementException;
|
||||
|
||||
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.core.RestWrapper;
|
||||
import org.alfresco.rest.model.FilePlanComponentEntry;
|
||||
import org.alfresco.rest.model.FilePlanComponent;
|
||||
import org.alfresco.rest.model.FilePlanComponentProperties;
|
||||
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.utility.data.DataUser;
|
||||
import org.alfresco.utility.data.RandomData;
|
||||
@@ -62,7 +62,7 @@ public class RecordCategoryTest extends BaseRestTest
|
||||
|
||||
@Autowired
|
||||
private DataUser dataUser;
|
||||
|
||||
|
||||
// for children creation test
|
||||
private static final int NUMBER_OF_CHILDREN = 10;
|
||||
|
||||
@@ -193,7 +193,7 @@ public class RecordCategoryTest extends BaseRestTest
|
||||
// Verify the status code
|
||||
restWrapper.assertStatusCodeIs(NO_CONTENT);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* Given that a record category exists
|
||||
@@ -209,14 +209,14 @@ public class RecordCategoryTest extends BaseRestTest
|
||||
// create root level category
|
||||
FilePlanComponent rootCategory = createCategory(FILE_PLAN_ALIAS.toString(), RandomData.getRandomAlphanumeric());
|
||||
assertNotNull(rootCategory.getId());
|
||||
|
||||
|
||||
// create subcategory as a child of rootCategory
|
||||
FilePlanComponent childCategory = createCategory(rootCategory.getId(), RandomData.getRandomAlphanumeric());
|
||||
|
||||
|
||||
// child category created?
|
||||
assertNotNull(childCategory.getId());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* Given that a record category exists
|
||||
@@ -234,53 +234,53 @@ public class RecordCategoryTest extends BaseRestTest
|
||||
// create root level category
|
||||
FilePlanComponent rootCategory = createCategory(FILE_PLAN_ALIAS.toString(), RandomData.getRandomAlphanumeric());
|
||||
assertNotNull(rootCategory.getId());
|
||||
|
||||
|
||||
// add child categories/folders
|
||||
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
|
||||
FilePlanComponent child = createComponent(rootCategory.getId(),
|
||||
FilePlanComponent child = createComponent(rootCategory.getId(),
|
||||
RandomData.getRandomAlphanumeric(),
|
||||
// half of the children should be subcategories, the other subfolders
|
||||
(i <= NUMBER_OF_CHILDREN / 2) ? RECORD_CATEGORY_TYPE : RECORD_FOLDER_TYPE);
|
||||
assertNotNull(child.getId());
|
||||
children.add(child);
|
||||
}
|
||||
|
||||
|
||||
// list children from API
|
||||
RestWrapper restWrapper = filePlanComponentApi.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
FilePlanComponentsCollection apiChildren = filePlanComponentApi.listChildComponents(rootCategory.getId());
|
||||
restWrapper.assertStatusCodeIs(OK);
|
||||
|
||||
|
||||
// check listed children against created list
|
||||
List<FilePlanComponentEntry> childrenApi = apiChildren.getEntries();
|
||||
childrenApi.forEach(c ->
|
||||
childrenApi.forEach(c ->
|
||||
{
|
||||
FilePlanComponent filePlanComponent = c.getFilePlanComponent();
|
||||
assertNotNull(filePlanComponent.getId());
|
||||
|
||||
|
||||
logger.info(c + " id=" + filePlanComponent.getId() + " name=" + filePlanComponent.getName() + " properties=" + filePlanComponent.getProperties());
|
||||
|
||||
try
|
||||
|
||||
try
|
||||
{
|
||||
FilePlanComponent createdComponent = children.stream()
|
||||
.filter(child -> child.getId().compareTo(filePlanComponent.getId()) == 0)
|
||||
.findFirst()
|
||||
.get();
|
||||
|
||||
|
||||
// does returned object have the same contents as the created one?
|
||||
assertEquals(createdComponent.getName(), filePlanComponent.getName());
|
||||
assertEquals(createdComponent.getNodeType(), filePlanComponent.getNodeType());
|
||||
assertEquals(createdComponent.getProperties().getTitle(), filePlanComponent.getProperties().getTitle());
|
||||
}
|
||||
//assertEquals(createdComponent.getProperties().getTitle(), filePlanComponent.getProperties().getTitle());
|
||||
}
|
||||
catch (NoSuchElementException e)
|
||||
{
|
||||
fail("No child element for " + filePlanComponent.getId());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper method to create child category
|
||||
* @param parentCategoryId
|
||||
@@ -291,18 +291,18 @@ public class RecordCategoryTest extends BaseRestTest
|
||||
{
|
||||
return createComponent(parentCategoryId, categoryName, RECORD_CATEGORY_TYPE);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper method to create child folder
|
||||
* @param parentComponentId parent category or folder id
|
||||
* @param folderName new folder name
|
||||
* @throws Exception on unsuccessful folder creation
|
||||
*/
|
||||
private FilePlanComponent createFolder(String parentComponentId, String folderName) throws Exception
|
||||
{
|
||||
return createComponent(parentComponentId, folderName, RECORD_FOLDER_TYPE);
|
||||
}
|
||||
|
||||
// private FilePlanComponent createFolder(String parentComponentId, String folderName) throws Exception
|
||||
// {
|
||||
// return createComponent(parentComponentId, folderName, RECORD_FOLDER_TYPE);
|
||||
// }
|
||||
|
||||
/**
|
||||
* Helper method to create generic child component
|
||||
* @param parentComponentId
|
||||
|
Reference in New Issue
Block a user