mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merge branch 'master' into feature/RM-3964_Record_Category_CRUD_2
This commit is contained in:
@@ -9,7 +9,7 @@
|
|||||||
* agreement is prohibited.
|
* agreement is prohibited.
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
package org.alfresco.rest.model;
|
package org.alfresco.rest.model.fileplancomponents;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
@@ -9,7 +9,7 @@
|
|||||||
* agreement is prohibited.
|
* agreement is prohibited.
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
package org.alfresco.rest.model;
|
package org.alfresco.rest.model.fileplancomponents;
|
||||||
|
|
||||||
import org.alfresco.rest.core.RestModels;
|
import org.alfresco.rest.core.RestModels;
|
||||||
|
|
@@ -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.FilePlanComponentsCollection;
|
|
||||||
import org.alfresco.rest.model.fileplancomponents.FilePlanComponent;
|
import org.alfresco.rest.model.fileplancomponents.FilePlanComponent;
|
||||||
|
import org.alfresco.rest.model.fileplancomponents.FilePlanComponentsCollection;
|
||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@@ -41,21 +41,21 @@ import org.testng.annotations.BeforeClass;
|
|||||||
* @since 1.0
|
* @since 1.0
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
@PropertySource("classpath:config.properties")
|
@PropertySource("classpath:default.properties")
|
||||||
@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.scheme}")
|
||||||
private String scheme;
|
private String scheme;
|
||||||
|
|
||||||
@Value ("${alfresco.rm.host}")
|
@Value ("${alfresco.server}")
|
||||||
private String host;
|
private String server;
|
||||||
|
|
||||||
@Value ("${alfresco.rm.port}")
|
@Value ("${alfresco.port}")
|
||||||
private String port;
|
private String port;
|
||||||
|
|
||||||
@Value ("${alfresco.rm.basePath}")
|
@Value ("${rest.rmPath}")
|
||||||
private String basePath;
|
private String restRmPath;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public RMSiteAPI rmSiteAPI;
|
public RMSiteAPI rmSiteAPI;
|
||||||
@@ -75,9 +75,9 @@ public class BaseRestTest extends RestTest
|
|||||||
@BeforeClass(alwaysRun = true)
|
@BeforeClass(alwaysRun = true)
|
||||||
public void checkServerHealth() throws Exception
|
public void checkServerHealth() throws Exception
|
||||||
{
|
{
|
||||||
RestAssured.baseURI = scheme + "://" + host;
|
RestAssured.baseURI = scheme + "://" + server;
|
||||||
RestAssured.port = parseInt(port);
|
RestAssured.port = parseInt(port);
|
||||||
RestAssured.basePath = basePath;
|
RestAssured.basePath = restRmPath;
|
||||||
|
|
||||||
//create RM Site if not exist
|
//create RM Site if not exist
|
||||||
createRMSiteIfNotExists();
|
createRMSiteIfNotExists();
|
||||||
|
21
src/test/java/org/alfresco/rest/TestData.java
Normal file
21
src/test/java/org/alfresco/rest/TestData.java
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
package org.alfresco.rest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test data used in tests
|
||||||
|
*
|
||||||
|
* @author Rodica Sutu
|
||||||
|
*/
|
||||||
|
public interface TestData
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* A user with ALFRESCO_ADMINISTRATORS role.
|
||||||
|
* <p>"GROUP_ANOTHER_ADMIN_EXISTS" The ANOTHER_ADMIN user has been created.
|
||||||
|
*/
|
||||||
|
public static final String ANOTHER_ADMIN = "another_admin";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The default password used when creating test users.
|
||||||
|
*/
|
||||||
|
public static final String DEFAULT_PASSWORD = "password";
|
||||||
|
public static final String DEFAULT_EMAIL = "default@alfresco.com";
|
||||||
|
}
|
@@ -39,9 +39,9 @@ import com.google.gson.JsonObject;
|
|||||||
import org.alfresco.com.fileplancomponents.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.FilePlanComponentsCollection;
|
|
||||||
import org.alfresco.rest.model.fileplancomponents.FilePlanComponent;
|
import org.alfresco.rest.model.fileplancomponents.FilePlanComponent;
|
||||||
import org.alfresco.rest.model.fileplancomponents.FilePlanComponentProperties;
|
import org.alfresco.rest.model.fileplancomponents.FilePlanComponentProperties;
|
||||||
|
import org.alfresco.rest.model.fileplancomponents.FilePlanComponentsCollection;
|
||||||
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;
|
||||||
|
@@ -9,12 +9,16 @@
|
|||||||
* agreement is prohibited.
|
* agreement is prohibited.
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
package org.alfresco.rest.fileplancomponents;
|
package org.alfresco.rest.site;
|
||||||
|
|
||||||
|
import static org.alfresco.com.site.RMSiteCompliance.DOD5015;
|
||||||
import static org.alfresco.com.site.RMSiteCompliance.STANDARD;
|
import static org.alfresco.com.site.RMSiteCompliance.STANDARD;
|
||||||
import static org.alfresco.com.site.RMSiteFields.COMPLIANCE;
|
import static org.alfresco.com.site.RMSiteFields.COMPLIANCE;
|
||||||
import static org.alfresco.com.site.RMSiteFields.DESCRIPTION;
|
import static org.alfresco.com.site.RMSiteFields.DESCRIPTION;
|
||||||
import static org.alfresco.com.site.RMSiteFields.TITLE;
|
import static org.alfresco.com.site.RMSiteFields.TITLE;
|
||||||
|
import static org.alfresco.rest.TestData.ANOTHER_ADMIN;
|
||||||
|
import static org.alfresco.rest.TestData.DEFAULT_EMAIL;
|
||||||
|
import static org.alfresco.rest.TestData.DEFAULT_PASSWORD;
|
||||||
import static org.jglue.fluentjson.JsonBuilderFactory.buildObject;
|
import static org.jglue.fluentjson.JsonBuilderFactory.buildObject;
|
||||||
import static org.springframework.http.HttpStatus.CONFLICT;
|
import static org.springframework.http.HttpStatus.CONFLICT;
|
||||||
import static org.springframework.http.HttpStatus.CREATED;
|
import static org.springframework.http.HttpStatus.CREATED;
|
||||||
@@ -26,9 +30,13 @@ import static org.testng.Assert.assertEquals;
|
|||||||
|
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
|
|
||||||
|
import org.alfresco.dataprep.UserService;
|
||||||
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.fileplancomponents.RecordCategoryTest;
|
||||||
import org.alfresco.rest.model.site.RMSite;
|
import org.alfresco.rest.model.site.RMSite;
|
||||||
|
import org.alfresco.utility.model.UserModel;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -36,37 +44,39 @@ import org.testng.annotations.Test;
|
|||||||
* FIXME: Should we use dependent tests or not?
|
* FIXME: Should we use dependent tests or not?
|
||||||
* They were removed here but there is no guarantee for the test execution order.
|
* 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.
|
* In {@link RecordCategoryTest} we create a record category first to delete it.
|
||||||
* Probably something to think about again.
|
* Probbaly something to think about again.
|
||||||
*
|
*
|
||||||
* @author Rodica Sutu
|
* @author Rodica Sutu
|
||||||
* @since 1.0
|
* @since 1.0
|
||||||
*/
|
*/
|
||||||
public class RMSiteTests extends BaseRestTest
|
public class RMSiteTests extends BaseRestTest
|
||||||
{
|
{
|
||||||
|
@Autowired
|
||||||
|
private UserService userService;
|
||||||
@Test
|
@Test
|
||||||
(
|
(
|
||||||
description = "Create RM site as admin user with standard Compliance"
|
description = "Create RM site as admin user with Standard Compliance"
|
||||||
)
|
)
|
||||||
public void createRMSiteAsAdminUser() throws Exception
|
public void createRMSiteAsAdminUser() throws Exception
|
||||||
{
|
{
|
||||||
RestWrapper restWrapper = rmSiteAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
rmSiteAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||||
if (siteRMExist())
|
if (siteRMExist())
|
||||||
{
|
{
|
||||||
// Delete the RM site
|
// Delete the RM site
|
||||||
rmSiteAPI.deleteRMSite();
|
rmSiteAPI.deleteRMSite();
|
||||||
}
|
}
|
||||||
// Build the RM site properties
|
// Build the RM site properties
|
||||||
JsonObject rmSiteProperties = buildObject().
|
JsonObject rmSiteProperties = buildObject()
|
||||||
add(TITLE, RM_TITLE).
|
.add(TITLE, RM_TITLE)
|
||||||
add(DESCRIPTION, RM_DESCRIPTION).
|
.add(DESCRIPTION, RM_DESCRIPTION)
|
||||||
add(COMPLIANCE, STANDARD.toString()).
|
.add(COMPLIANCE, STANDARD.toString())
|
||||||
getJson();
|
.getJson();
|
||||||
|
|
||||||
// Create the RM site
|
// Create the RM site
|
||||||
RMSite rmSite = rmSiteAPI.createRMSite(rmSiteProperties);
|
RMSite rmSite = rmSiteAPI.createRMSite(rmSiteProperties);
|
||||||
|
|
||||||
// Verify the status code
|
// Verify the status code
|
||||||
restWrapper.assertStatusCodeIs(CREATED);
|
rmSiteAPI.usingRestWrapper().assertStatusCodeIs(CREATED);
|
||||||
|
|
||||||
// Verify the returned file plan component
|
// Verify the returned file plan component
|
||||||
assertEquals(rmSite.getId(), RM_ID);
|
assertEquals(rmSite.getId(), RM_ID);
|
||||||
@@ -91,11 +101,11 @@ public class RMSiteTests extends BaseRestTest
|
|||||||
String newDescription = RM_DESCRIPTION + "createRMSiteWhenSiteExists";
|
String newDescription = RM_DESCRIPTION + "createRMSiteWhenSiteExists";
|
||||||
|
|
||||||
// Build the RM site properties
|
// Build the RM site properties
|
||||||
JsonObject rmSiteProperties = buildObject().
|
JsonObject rmSiteProperties = buildObject()
|
||||||
add(TITLE, newTitle).
|
.add(TITLE, newTitle)
|
||||||
add(DESCRIPTION, newDescription).
|
.add(DESCRIPTION, newDescription)
|
||||||
add(COMPLIANCE, STANDARD.toString()).
|
.add(COMPLIANCE, STANDARD.toString())
|
||||||
getJson();
|
.getJson();
|
||||||
|
|
||||||
// Create the RM site
|
// Create the RM site
|
||||||
rmSiteAPI.createRMSite(rmSiteProperties);
|
rmSiteAPI.createRMSite(rmSiteProperties);
|
||||||
@@ -129,7 +139,6 @@ public class RMSiteTests extends BaseRestTest
|
|||||||
|
|
||||||
// Get the RM site
|
// Get the RM site
|
||||||
RMSite rmSite = rmSiteAPI.getSite();
|
RMSite rmSite = rmSiteAPI.getSite();
|
||||||
|
|
||||||
if (!siteRMExist())
|
if (!siteRMExist())
|
||||||
{
|
{
|
||||||
// Verify the status code
|
// Verify the status code
|
||||||
@@ -145,4 +154,47 @@ public class RMSiteTests extends BaseRestTest
|
|||||||
assertEquals(rmSite.getVisibility(), PUBLIC);
|
assertEquals(rmSite.getVisibility(), PUBLIC);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@Test
|
||||||
|
(
|
||||||
|
description = "Create RM site as an admin user created with DOD compliance"
|
||||||
|
)
|
||||||
|
public void createRMSiteAsAnotherAdminUser() throws Exception
|
||||||
|
{
|
||||||
|
rmSiteAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||||
|
if (siteRMExist())
|
||||||
|
{
|
||||||
|
//Delete the RM site
|
||||||
|
rmSiteAPI.deleteRMSite();
|
||||||
|
}
|
||||||
|
rmSiteAPI.usingRestWrapper().disconnect();
|
||||||
|
userService.create(dataUser.getAdminUser().getUsername(),
|
||||||
|
dataUser.getAdminUser().getPassword(),
|
||||||
|
ANOTHER_ADMIN,
|
||||||
|
DEFAULT_PASSWORD,
|
||||||
|
DEFAULT_EMAIL,
|
||||||
|
ANOTHER_ADMIN,
|
||||||
|
ANOTHER_ADMIN);
|
||||||
|
UserModel userModel=new UserModel(ANOTHER_ADMIN,DEFAULT_PASSWORD);
|
||||||
|
rmSiteAPI.usingRestWrapper().authenticateUser(userModel);
|
||||||
|
// Build the RM site properties
|
||||||
|
JsonObject rmSiteProperties = buildObject()
|
||||||
|
.add(TITLE, RM_TITLE)
|
||||||
|
.add(DESCRIPTION, RM_DESCRIPTION)
|
||||||
|
.add(COMPLIANCE, DOD5015.toString())
|
||||||
|
.getJson();
|
||||||
|
|
||||||
|
// Create the RM site
|
||||||
|
RMSite rmSite = rmSiteAPI.createRMSite(rmSiteProperties);
|
||||||
|
|
||||||
|
// Verify the status code
|
||||||
|
rmSiteAPI.usingRestWrapper().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(), DOD5015);
|
||||||
|
assertEquals(rmSite.getVisibility(), PUBLIC);
|
||||||
|
}
|
||||||
|
}
|
@@ -1,4 +0,0 @@
|
|||||||
alfresco.rm.scheme=http
|
|
||||||
alfresco.rm.host=localhost
|
|
||||||
alfresco.rm.port=8080
|
|
||||||
alfresco.rm.basePath=alfresco/api/-default-/public/ig/versions/1
|
|
20
src/test/resources/default.properties
Normal file
20
src/test/resources/default.properties
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
#########################################################################
|
||||||
|
# Original property values from default.properties #
|
||||||
|
#########################################################################
|
||||||
|
|
||||||
|
# dataprep related
|
||||||
|
alfresco.scheme=http
|
||||||
|
alfresco.server=localhost
|
||||||
|
alfresco.port=8080
|
||||||
|
|
||||||
|
# credentials
|
||||||
|
admin.user=admin
|
||||||
|
admin.password=admin
|
||||||
|
|
||||||
|
# rest related
|
||||||
|
rest.basePath=alfresco/api/-default-/public/alfresco/versions/1
|
||||||
|
rest.workflowPath=alfresco/api/-default-/public/workflow/versions/1
|
||||||
|
|
||||||
|
#########################################################################
|
||||||
|
|
||||||
|
rest.rmPath=alfresco/api/-default-/public/ig/versions/1
|
Reference in New Issue
Block a user