mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-4488 (Refactor REST API Automation test code according to the latest changes)
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<maven.build.sourceVersion>1.8</maven.build.sourceVersion>
|
||||
<alfresco.rm.share>alfresco-rm-community-share</alfresco.rm.share>
|
||||
<alfresco.rm.repo>alfresco-rm-community-repo</alfresco.rm.repo>
|
||||
<tas.restapi.version>5.2.0-0</tas.restapi.version>
|
||||
|
@@ -1,23 +0,0 @@
|
||||
/*
|
||||
* #%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.core;
|
||||
|
||||
/**
|
||||
* FIXME!!!
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.6
|
||||
*/
|
||||
public class ExtendedRestProperties extends RestProperties
|
||||
{
|
||||
|
||||
}
|
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
* #%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.core;
|
||||
|
||||
import org.alfresco.rest.core.RestWrapper;
|
||||
import org.alfresco.rest.rm.community.requests.igCoreAPI.RestIGCoreAPI;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* FIXME!!!
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.6
|
||||
*/
|
||||
public class ExtendedRestWrapper extends RestWrapper
|
||||
{
|
||||
@Autowired
|
||||
private ExtendedRestProperties extendedRestProperties;
|
||||
|
||||
public RestIGCoreAPI withIGCoreAPI()
|
||||
{
|
||||
return new RestIGCoreAPI(this, extendedRestProperties);
|
||||
}
|
||||
}
|
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2016 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.core;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
|
||||
/**
|
||||
* FIXME!!!
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.6
|
||||
*/
|
||||
@Configuration
|
||||
@PropertySource(value = {"classpath:default.properties", "classpath:config.properties"})
|
||||
@PropertySource(value = "classpath:module.properties", ignoreResourceNotFound = true)
|
||||
@PropertySource(value = "classpath:local.properties", ignoreResourceNotFound = true)
|
||||
public class RMRestProperties extends RestProperties
|
||||
{
|
||||
@Value ("${alfresco.scheme}")
|
||||
private String scheme;
|
||||
|
||||
@Value ("${alfresco.server}")
|
||||
private String server;
|
||||
|
||||
@Value ("${alfresco.port}")
|
||||
private String port;
|
||||
|
||||
@Value ("${rest.rmPath}")
|
||||
private String restRmPath;
|
||||
|
||||
/**
|
||||
* @return the scheme
|
||||
*/
|
||||
public String getScheme()
|
||||
{
|
||||
return this.scheme;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the server
|
||||
*/
|
||||
public String getServer()
|
||||
{
|
||||
return this.server;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the port
|
||||
*/
|
||||
public String getPort()
|
||||
{
|
||||
return this.port;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the restRmPath
|
||||
*/
|
||||
public String getRestRmPath()
|
||||
{
|
||||
return this.restRmPath;
|
||||
}
|
||||
}
|
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2016 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.core;
|
||||
|
||||
import org.alfresco.rest.rm.community.requests.igCoreAPI.RestIGCoreAPI;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* FIXME!!!
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.6
|
||||
*/
|
||||
public class RMRestWrapper extends RestWrapper
|
||||
{
|
||||
@Autowired
|
||||
private RMRestProperties rmRestProperties;
|
||||
|
||||
public RestIGCoreAPI withIGCoreAPI()
|
||||
{
|
||||
return new RestIGCoreAPI(this, rmRestProperties);
|
||||
}
|
||||
}
|
@@ -1,117 +0,0 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2016 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.model.fileplancomponents;
|
||||
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.ALLOWABLE_OPERATIONS;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.IS_CLOSED;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PATH;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.RELATIVE_PATH;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* POJO for file plan component
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @author Rodica Sutu
|
||||
* @since 2.6
|
||||
*/
|
||||
@Builder
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class FilePlanComponent
|
||||
{
|
||||
@JsonProperty (required = true)
|
||||
private String id;
|
||||
|
||||
@JsonProperty (required = true)
|
||||
private String parentId;
|
||||
|
||||
@JsonProperty (required = true)
|
||||
private String name;
|
||||
|
||||
@JsonProperty (required = true)
|
||||
private String nodeType;
|
||||
|
||||
@JsonProperty (required = true)
|
||||
private Boolean isCategory;
|
||||
|
||||
@JsonProperty (required = true)
|
||||
private Boolean isRecordFolder;
|
||||
|
||||
@JsonProperty (required = true)
|
||||
private Boolean isFile;
|
||||
|
||||
@JsonProperty
|
||||
private Boolean hasRetentionSchedule;
|
||||
|
||||
@JsonProperty(value = IS_CLOSED)
|
||||
private Boolean isClosed;
|
||||
|
||||
@JsonProperty
|
||||
private Boolean isCompleted;
|
||||
|
||||
@JsonProperty (required = true)
|
||||
private List<String> aspectNames;
|
||||
|
||||
@JsonProperty (required = true)
|
||||
private FilePlanComponentUserInfo createdByUser;
|
||||
|
||||
@JsonProperty(value = PROPERTIES, required = true)
|
||||
private FilePlanComponentProperties properties;
|
||||
|
||||
@JsonProperty (value = ALLOWABLE_OPERATIONS)
|
||||
private List<String> allowableOperations;
|
||||
|
||||
@JsonProperty (required = false)
|
||||
private FilePlanComponentContent content;
|
||||
|
||||
@JsonProperty (value = PATH)
|
||||
private FilePlanComponentPath path;
|
||||
|
||||
@JsonProperty (required = true)
|
||||
private String modifiedAt;
|
||||
|
||||
@JsonProperty (required = true)
|
||||
private String createdAt;
|
||||
|
||||
@JsonProperty (required = true)
|
||||
private FilePlanComponentUserInfo modifiedByUser;
|
||||
|
||||
@JsonProperty (value = RELATIVE_PATH)
|
||||
private String relativePath;
|
||||
|
||||
}
|
@@ -26,58 +26,16 @@
|
||||
*/
|
||||
package org.alfresco.rest.rm.community.model.fileplancomponents;
|
||||
|
||||
import static org.alfresco.rest.rm.community.util.ParameterCheck.mandatoryString;
|
||||
|
||||
/**
|
||||
* File plan component alias enumeration
|
||||
* File plan component alias
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.6
|
||||
*/
|
||||
public enum FilePlanComponentAlias
|
||||
public class FilePlanComponentAlias
|
||||
{
|
||||
FILE_PLAN_ALIAS("-filePlan-"),
|
||||
TRANSFERS_ALIAS("-transfers-"),
|
||||
UNFILED_RECORDS_CONTAINER_ALIAS("-unfiled-"),
|
||||
HOLDS_ALIAS("-holds-");
|
||||
|
||||
private String alias;
|
||||
|
||||
private FilePlanComponentAlias(String alias)
|
||||
{
|
||||
this.alias = alias;
|
||||
}
|
||||
|
||||
public static final FilePlanComponentAlias getFilePlanComponentAlias(String alias)
|
||||
{
|
||||
mandatoryString("alias", alias);
|
||||
|
||||
FilePlanComponentAlias result = null;
|
||||
FilePlanComponentAlias[] values = values();
|
||||
|
||||
for (FilePlanComponentAlias filePlanComponentAlias : values)
|
||||
{
|
||||
if (filePlanComponentAlias.toString().equals(alias))
|
||||
{
|
||||
result = filePlanComponentAlias;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
throw new IllegalArgumentException("Invalid file plan component alias enum value: '" + alias + "'.");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.lang.Enum#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.alias;
|
||||
}
|
||||
public static final String FILE_PLAN_ALIAS = "-filePlan-";
|
||||
public static final String TRANSFERS_ALIAS = "-transfers-";
|
||||
public static final String UNFILED_RECORDS_CONTAINER_ALIAS = "-unfiled-";
|
||||
public static final String HOLDS_ALIAS = "-holds-";
|
||||
}
|
||||
|
@@ -30,6 +30,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* POJO for FilePlanComponent content field
|
||||
*
|
||||
* @author Kristijan Conkas
|
||||
* @since 2.6
|
||||
*/
|
||||
@@ -46,5 +47,4 @@ public class FilePlanComponentContent
|
||||
|
||||
@JsonProperty (required = true)
|
||||
private Integer sizeInBytes;
|
||||
|
||||
}
|
||||
|
@@ -30,11 +30,13 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.alfresco.rest.core.RestModels;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.alfresco.rest.core.RestModels;
|
||||
|
||||
/**
|
||||
* POJO for file plan component entry
|
||||
@@ -44,11 +46,11 @@ import org.alfresco.rest.core.RestModels;
|
||||
*/
|
||||
@Builder
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class FilePlanComponentEntry extends RestModels<FilePlanComponent, FilePlanComponentEntry>
|
||||
public class FilePlanComponentEntry extends RestModels<FilePlanComponentModel, FilePlanComponentEntry>
|
||||
{
|
||||
@JsonProperty(ENTRY)
|
||||
FilePlanComponent filePlanComponent;
|
||||
|
||||
FilePlanComponentModel filePlanComponentModel;
|
||||
}
|
||||
|
@@ -45,5 +45,4 @@ public class FilePlanComponentIdNamePair
|
||||
{
|
||||
public String id;
|
||||
public String name;
|
||||
|
||||
}
|
||||
|
@@ -28,7 +28,9 @@ package org.alfresco.rest.rm.community.model.fileplancomponents;
|
||||
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.ALLOWABLE_OPERATIONS;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.IS_CLOSED;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PATH;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.RELATIVE_PATH;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -36,6 +38,12 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* POJO for file plan component
|
||||
*
|
||||
@@ -43,6 +51,11 @@ import org.alfresco.utility.model.TestModel;
|
||||
* @author Rodica Sutu
|
||||
* @since 2.6
|
||||
*/
|
||||
@Builder
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class FilePlanComponentModel extends TestModel
|
||||
{
|
||||
@JsonProperty (required = true)
|
||||
@@ -87,6 +100,10 @@ public class FilePlanComponentModel extends TestModel
|
||||
@JsonProperty (value = ALLOWABLE_OPERATIONS)
|
||||
private List<String> allowableOperations;
|
||||
|
||||
@JsonProperty (required = false)
|
||||
private FilePlanComponentContent content;
|
||||
|
||||
@JsonProperty (value = PATH)
|
||||
private FilePlanComponentPath path;
|
||||
|
||||
@JsonProperty (required = true)
|
||||
@@ -98,324 +115,6 @@ public class FilePlanComponentModel extends TestModel
|
||||
@JsonProperty (required = true)
|
||||
private FilePlanComponentUserInfo modifiedByUser;
|
||||
|
||||
|
||||
/**Helper constructor for creating the file plan component using
|
||||
*
|
||||
* @param name File Plan Component name
|
||||
* @param nodeType File Plan Component node type
|
||||
* @param properties File Plan Component properties
|
||||
*/
|
||||
public FilePlanComponentModel(String name, String nodeType, FilePlanComponentProperties properties)
|
||||
{
|
||||
this.name = name;
|
||||
this.nodeType = nodeType;
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper constructor to create empty file plan component
|
||||
*/
|
||||
public FilePlanComponentModel() { }
|
||||
|
||||
/**
|
||||
* Helper constructor for creating the file plan component using
|
||||
*
|
||||
* @param name File Plan Component name
|
||||
*/
|
||||
public FilePlanComponentModel(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper constructor for creating the file plan component using
|
||||
*
|
||||
* @param name File Plan Component name
|
||||
* @param properties File Plan Component properties
|
||||
*/
|
||||
public FilePlanComponentModel(String name, FilePlanComponentProperties properties)
|
||||
{
|
||||
this.name = name;
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the id
|
||||
*/
|
||||
public String getId()
|
||||
{
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id the id to set
|
||||
*/
|
||||
public void setId(String id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the parentId
|
||||
*/
|
||||
public String getParentId()
|
||||
{
|
||||
return this.parentId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param parentId the parentId to set
|
||||
*/
|
||||
public void setParentId(String parentId)
|
||||
{
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name the name to set
|
||||
*/
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the nodeType
|
||||
*/
|
||||
public String getNodeType()
|
||||
{
|
||||
return this.nodeType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nodeType the nodeType to set
|
||||
*/
|
||||
public void setNodeType(String nodeType)
|
||||
{
|
||||
this.nodeType = nodeType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the isCategory
|
||||
*/
|
||||
public Boolean isCategory()
|
||||
{
|
||||
return this.isCategory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param isCategory the isCategory to set
|
||||
*/
|
||||
public void setCategory(Boolean isCategory)
|
||||
{
|
||||
this.isCategory = isCategory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the isRecordFolder
|
||||
*/
|
||||
public Boolean isRecordFolder()
|
||||
{
|
||||
return this.isRecordFolder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param isRecordFolder the isRecordFolder to set
|
||||
*/
|
||||
public void setRecordFolder(Boolean isRecordFolder)
|
||||
{
|
||||
this.isRecordFolder = isRecordFolder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the isFile
|
||||
*/
|
||||
public Boolean isFile()
|
||||
{
|
||||
return this.isFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param isFile the isFile to set
|
||||
*/
|
||||
public void setFile(Boolean isFile)
|
||||
{
|
||||
this.isFile = isFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the hasRetentionSchedule
|
||||
*/
|
||||
public Boolean hasRetentionSchedule()
|
||||
{
|
||||
return this.hasRetentionSchedule;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param hasRetentionSchedule the hasRetentionSchedule to set
|
||||
*/
|
||||
public void setHasRetentionSchedule(Boolean hasRetentionSchedule)
|
||||
{
|
||||
this.hasRetentionSchedule = hasRetentionSchedule;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the properties
|
||||
*/
|
||||
public FilePlanComponentProperties getProperties()
|
||||
{
|
||||
return properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param properties the properties to set
|
||||
*/
|
||||
public void setProperties(FilePlanComponentProperties properties)
|
||||
{
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the aspectNames
|
||||
*/
|
||||
public List<String> getAspectNames()
|
||||
{
|
||||
return this.aspectNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param aspectNames the aspectNames to set
|
||||
*/
|
||||
public void setAspectNames(List<String> aspectNames)
|
||||
{
|
||||
this.aspectNames = aspectNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the createdByUser
|
||||
*/
|
||||
public FilePlanComponentUserInfo getCreatedByUser()
|
||||
{
|
||||
return this.createdByUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param createdByUser the createdByUser to set
|
||||
*/
|
||||
public void setCreatedByUser(FilePlanComponentUserInfo createdByUser)
|
||||
{
|
||||
this.createdByUser = createdByUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the allowableOperations
|
||||
*/
|
||||
public List<String> getAllowableOperations()
|
||||
{
|
||||
return this.allowableOperations;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the path
|
||||
*/
|
||||
public FilePlanComponentPath getPath()
|
||||
{
|
||||
return this.path;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param path the path to set
|
||||
*/
|
||||
public void setPath(FilePlanComponentPath path)
|
||||
{
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param modifiedAt the modifiedAt to set
|
||||
*/
|
||||
public void setModifiedAt(String modifiedAt)
|
||||
{
|
||||
this.modifiedAt = modifiedAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param createdAt the createdAt to set
|
||||
*/
|
||||
public void setCreatedAt(String createdAt)
|
||||
{
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param modifiedByUser the modifiedByUser to set
|
||||
*/
|
||||
public void setModifiedByUser(FilePlanComponentUserInfo modifiedByUser)
|
||||
{
|
||||
this.modifiedByUser = modifiedByUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the modifiedAt
|
||||
*/
|
||||
public String getModifiedAt()
|
||||
{
|
||||
return this.modifiedAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the createdAt
|
||||
*/
|
||||
public String getCreatedAt()
|
||||
{
|
||||
return this.createdAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the modifiedByUser
|
||||
*/
|
||||
public FilePlanComponentUserInfo getModifiedByUser()
|
||||
{
|
||||
return this.modifiedByUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the isClosed
|
||||
*/
|
||||
public Boolean isClosed()
|
||||
{
|
||||
return this.isClosed;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param closed the isClosed to set
|
||||
*/
|
||||
public void setClosed(Boolean closed)
|
||||
{
|
||||
this.isClosed = closed;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the isCompleted
|
||||
*/
|
||||
public Boolean isCompleted()
|
||||
{
|
||||
return this.isCompleted;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param completed the isCompleted to set
|
||||
*/
|
||||
public void setCompleted(Boolean completed)
|
||||
{
|
||||
this.isCompleted = completed;
|
||||
}
|
||||
@JsonProperty (value = RELATIVE_PATH)
|
||||
private String relativePath;
|
||||
}
|
||||
|
@@ -37,7 +37,7 @@ import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* POJO for FilePlanComponent path parameter
|
||||
* <br>
|
||||
*
|
||||
* @author Kristijan Conkas
|
||||
* @since 2.6
|
||||
*/
|
||||
@@ -51,5 +51,4 @@ public class FilePlanComponentPath
|
||||
private String name;
|
||||
private Boolean isComplete;
|
||||
private List<FilePlanComponentIdNamePair> elements;
|
||||
|
||||
}
|
||||
|
@@ -67,7 +67,6 @@ import lombok.NoArgsConstructor;
|
||||
@AllArgsConstructor
|
||||
public class FilePlanComponentProperties
|
||||
{
|
||||
|
||||
@JsonProperty(PROPERTIES_VITAL_RECORD_INDICATOR)
|
||||
private Boolean vitalRecord;
|
||||
|
||||
@@ -92,21 +91,19 @@ public class FilePlanComponentProperties
|
||||
|
||||
@JsonProperty(value = PROPERTIES_IS_CLOSED, required = false)
|
||||
private Boolean isClosed;
|
||||
|
||||
|
||||
@JsonProperty(value = PROPERTIES_BOX, required = false)
|
||||
private String box;
|
||||
|
||||
|
||||
@JsonProperty(value = PROPERTIES_FILE, required = false)
|
||||
private String file;
|
||||
|
||||
|
||||
@JsonProperty(value = PROPERTIES_SHELF, required = false)
|
||||
private String shelf;
|
||||
|
||||
|
||||
@JsonProperty(value = PROPERTIES_NUMBER_OF_COPIES, required = false)
|
||||
private Integer numberOfCopies;
|
||||
|
||||
|
||||
@JsonProperty(value = PROPERTIES_PHYSICAL_SIZE, required = false)
|
||||
private Integer physicalSize;
|
||||
|
||||
|
||||
}
|
||||
|
@@ -26,66 +26,24 @@
|
||||
*/
|
||||
package org.alfresco.rest.rm.community.model.fileplancomponents;
|
||||
|
||||
import static org.alfresco.rest.rm.community.util.ParameterCheck.mandatoryString;
|
||||
|
||||
/**
|
||||
* File plan component type enumeration
|
||||
* File plan component type
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.6
|
||||
*/
|
||||
public enum FilePlanComponentType
|
||||
public class FilePlanComponentType
|
||||
{
|
||||
FILE_PLAN_TYPE("rma:filePlan"),
|
||||
RECORD_CATEGORY_TYPE("rma:recordCategory"),
|
||||
RECORD_FOLDER_TYPE("rma:recordFolder"),
|
||||
HOLD_TYPE("rma:hold"),
|
||||
UNFILED_RECORD_FOLDER_TYPE("rma:unfiledRecordFolder"),
|
||||
HOLD_CONTAINER_TYPE("rma:holdContainer"),
|
||||
TRANSFER_TYPE("rma:transfer"),
|
||||
TRANSFER_CONTAINER_TYPE("rma:transferContainer"),
|
||||
UNFILED_CONTAINER_TYPE("rma:unfiledRecordContainer"),
|
||||
FOLDER_TYPE("cm:folder"),
|
||||
CONTENT_TYPE("cm:content"),
|
||||
NON_ELECTRONIC_RECORD_TYPE("rma:nonElectronicDocument");
|
||||
|
||||
private String type;
|
||||
|
||||
private FilePlanComponentType(String type)
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public static final FilePlanComponentType getFilePlanComponentType(String type)
|
||||
{
|
||||
mandatoryString("type", type);
|
||||
|
||||
FilePlanComponentType result = null;
|
||||
FilePlanComponentType[] values = values();
|
||||
|
||||
for (FilePlanComponentType filePlanComponentType : values)
|
||||
{
|
||||
if (filePlanComponentType.toString().equals(filePlanComponentType))
|
||||
{
|
||||
result = filePlanComponentType;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
throw new IllegalArgumentException("Invalid file plan component type enum value: '" + type + "'.");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.lang.Enum#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.type;
|
||||
}
|
||||
public static final String FILE_PLAN_TYPE = "rma:filePlan";
|
||||
public static final String RECORD_CATEGORY_TYPE = "rma:recordCategory";
|
||||
public static final String RECORD_FOLDER_TYPE = "rma:recordFolder";
|
||||
public static final String HOLD_TYPE = "rma:hold";
|
||||
public static final String UNFILED_RECORD_FOLDER_TYPE = "rma:unfiledRecordFolder";
|
||||
public static final String HOLD_CONTAINER_TYPE = "rma:holdContainer";
|
||||
public static final String TRANSFER_TYPE = "rma:transfer";
|
||||
public static final String TRANSFER_CONTAINER_TYPE = "rma:transferContainer";
|
||||
public static final String UNFILED_CONTAINER_TYPE = "rma:unfiledRecordContainer";
|
||||
public static final String FOLDER_TYPE = "cm:folder";
|
||||
public static final String CONTENT_TYPE = "cm:content";
|
||||
public static final String NON_ELECTRONIC_RECORD_TYPE = "rma:nonElectronicDocument";
|
||||
}
|
||||
|
@@ -45,5 +45,4 @@ public class FilePlanComponentUserInfo
|
||||
{
|
||||
private String id;
|
||||
private String displayName;
|
||||
|
||||
}
|
||||
|
@@ -30,11 +30,13 @@ import static org.alfresco.rest.rm.community.model.site.RMSiteFields.COMPLIANCE;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.alfresco.rest.model.RestSiteModel;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.alfresco.rest.model.RestSiteModel;
|
||||
|
||||
/**
|
||||
* POJO for RM Site component
|
||||
@@ -44,11 +46,11 @@ import org.alfresco.rest.model.RestSiteModel;
|
||||
*/
|
||||
@Builder
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class RMSite extends RestSiteModel
|
||||
public class RMSiteModel extends RestSiteModel
|
||||
{
|
||||
@JsonProperty (value = COMPLIANCE,required = true)
|
||||
@JsonProperty (value = COMPLIANCE, required = true)
|
||||
private RMSiteCompliance compliance;
|
||||
|
||||
}
|
@@ -1,275 +0,0 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2016 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.basic;
|
||||
import static com.jayway.restassured.RestAssured.given;
|
||||
|
||||
import static org.alfresco.rest.core.RestRequest.requestWithBody;
|
||||
import static org.alfresco.rest.core.RestRequest.simpleRequest;
|
||||
import static org.alfresco.rest.rm.community.util.ParameterCheck.mandatoryObject;
|
||||
import static org.alfresco.rest.rm.community.util.ParameterCheck.mandatoryString;
|
||||
import static org.alfresco.rest.rm.community.util.PojoUtility.toJson;
|
||||
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 static org.testng.Assert.fail;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Iterator;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.google.common.io.Resources;
|
||||
import com.jayway.restassured.builder.RequestSpecBuilder;
|
||||
import com.jayway.restassured.http.ContentType;
|
||||
import com.jayway.restassured.response.Response;
|
||||
|
||||
import org.alfresco.rest.core.RestAPI;
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent;
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType;
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentsCollection;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* File plan component REST API Wrapper
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @author Kristijan Conkas
|
||||
* @since 2.6
|
||||
*/
|
||||
@Component
|
||||
@Scope(value = "prototype")
|
||||
public class FilePlanComponentAPI extends RestAPI<FilePlanComponentAPI>
|
||||
{
|
||||
/**
|
||||
* Get a file plan component
|
||||
*
|
||||
* @param filePlanComponentId The id of the file plan component to get
|
||||
* @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 FilePlanComponent getFilePlanComponent(String filePlanComponentId) throws Exception
|
||||
{
|
||||
mandatoryString("filePlanComponentId", filePlanComponentId);
|
||||
|
||||
return usingRestWrapper().processModel(FilePlanComponent.class, simpleRequest(
|
||||
GET,
|
||||
"fileplan-components/{fileplanComponentId}?{parameters}",
|
||||
filePlanComponentId, getParameters()
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* List child components of a file plan component
|
||||
*
|
||||
* @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) throws Exception
|
||||
{
|
||||
mandatoryString("filePlanComponentId", filePlanComponentId);
|
||||
|
||||
return usingRestWrapper().processModels(FilePlanComponentsCollection.class, simpleRequest(
|
||||
GET,
|
||||
"fileplan-components/{fileplanComponentId}/children",
|
||||
filePlanComponentId
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a file plan component with the given properties under the parent node with the given id
|
||||
*
|
||||
* @param filePlanComponentModel The properties of the file plan component to be created
|
||||
* @param parentId The id of the parent where the new file plan component should be created
|
||||
* @return The {@link FilePlanComponent} with the given properties
|
||||
* @throws Exception for the following cases:
|
||||
* <ul>
|
||||
* <li>{@code fileplanComponentId} is not a valid format</li>
|
||||
* <li>authentication fails</li>
|
||||
* <li>current user does not have permission to add children to {@code fileplanComponentId}</li>
|
||||
* <li>{@code fileplanComponentId} does not exist</li>
|
||||
* <li>new name clashes with an existing node in the current parent container</li>
|
||||
* <li>model integrity exception, including node name with invalid characters</li>
|
||||
* </ul>
|
||||
*/
|
||||
public FilePlanComponent createFilePlanComponent(FilePlanComponent filePlanComponentModel, String parentId) throws Exception
|
||||
{
|
||||
mandatoryObject("filePlanComponentProperties", filePlanComponentModel);
|
||||
mandatoryString("parentId", parentId);
|
||||
|
||||
return usingRestWrapper().processModel(FilePlanComponent.class, requestWithBody(
|
||||
POST,
|
||||
toJson(filePlanComponentModel),
|
||||
"fileplan-components/{fileplanComponentId}/children?{parameters}",
|
||||
parentId,
|
||||
getParameters()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create electronic record from file resource
|
||||
* @param electronicRecordModel {@link FilePlanComponent} for electronic record to be created
|
||||
* @param fileName the name of the resource file
|
||||
* @param parentId parent container id
|
||||
* @return newly created {@link FilePlanComponent}
|
||||
* @throws Exception if operation failed
|
||||
*/
|
||||
public FilePlanComponent createElectronicRecord(FilePlanComponent electronicRecordModel, String fileName, String parentId) throws Exception
|
||||
{
|
||||
return createElectronicRecord(electronicRecordModel, new File(Resources.getResource(fileName).getFile()), parentId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create electronic record from file resource
|
||||
* @param electronicRecordModel {@link FilePlanComponent} for electronic record to be created
|
||||
* @param recordContent {@link File} pointing to the content of the electronic record to be created
|
||||
* @param parentId parent container id
|
||||
* @return newly created {@link FilePlanComponent}
|
||||
* @throws Exception if operation failed
|
||||
*/
|
||||
public FilePlanComponent createElectronicRecord(FilePlanComponent electronicRecordModel, File recordContent, String parentId) throws Exception
|
||||
{
|
||||
mandatoryObject("filePlanComponentProperties", electronicRecordModel);
|
||||
mandatoryString("parentId", parentId);
|
||||
if (!electronicRecordModel.getNodeType().equals(FilePlanComponentType.CONTENT_TYPE.toString()))
|
||||
{
|
||||
fail("Only electronic records are supported");
|
||||
}
|
||||
|
||||
UserModel currentUser = usingRestWrapper().getTestUser();
|
||||
|
||||
/*
|
||||
* For file uploads nodeBodyCreate is ignored hence can't be used. Append all FilePlanComponent fields
|
||||
* to the request.
|
||||
*/
|
||||
RequestSpecBuilder builder = new RequestSpecBuilder();
|
||||
builder.setAuth(basic(currentUser.getUsername(), currentUser.getPassword()));
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
JsonNode root = mapper.readTree(toJson(electronicRecordModel));
|
||||
|
||||
Iterator<String> fieldNames = root.fieldNames();
|
||||
while (fieldNames.hasNext())
|
||||
{
|
||||
String f = fieldNames.next();
|
||||
try
|
||||
{
|
||||
builder.addMultiPart(f, root.get(f).asText(), ContentType.JSON.name());
|
||||
}
|
||||
catch (Exception error)
|
||||
{
|
||||
LOG.error("Failed to set " + f + " error: " + error);
|
||||
}
|
||||
}
|
||||
|
||||
builder.addMultiPart("filedata", recordContent, ContentType.BINARY.name());
|
||||
|
||||
/*
|
||||
* RestWrapper adds some headers which break multipart/form-data uploads and also assumes json POST requests.
|
||||
* Upload the file using RestAssured library.
|
||||
*/
|
||||
Response response = given()
|
||||
.spec(builder.build())
|
||||
.when()
|
||||
.post("fileplan-components/{fileplanComponentId}/children?{parameters}", parentId, getParameters())
|
||||
.andReturn();
|
||||
usingRestWrapper().setStatusCode(Integer.toString(response.getStatusCode()));
|
||||
LOG.info("electronic record created: " + response.getBody().prettyPrint());
|
||||
|
||||
/* return a FilePlanComponent object representing Response */
|
||||
return response.jsonPath().getObject("entry", FilePlanComponent.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates a file plan component
|
||||
*
|
||||
* @param filePlanComponent The properties to be updated
|
||||
* @param filePlanComponentId The id of the file plan component which will be updated
|
||||
* @param returns The updated {@link FilePlanComponent}
|
||||
* @throws Exception for the following cases:
|
||||
* <ul>
|
||||
* <li>the update request is invalid or {@code fileplanComponentId} is not a valid format or {@code filePlanComponentProperties} is invalid</li>
|
||||
* <li>authentication fails</li>
|
||||
* <li>current user does not have permission to update {@code fileplanComponentId}</li>
|
||||
* <li>{@code fileplanComponentId} does not exist</li>
|
||||
* <li>the updated name clashes with an existing node in the current parent folder</li>
|
||||
* <li>model integrity exception, including node name with invalid characters</li>
|
||||
* </ul>
|
||||
*/
|
||||
public FilePlanComponent updateFilePlanComponent(FilePlanComponent filePlanComponent, String filePlanComponentId) throws Exception
|
||||
{
|
||||
mandatoryObject("filePlanComponentProperties", filePlanComponent);
|
||||
mandatoryString("filePlanComponentId", filePlanComponentId);
|
||||
|
||||
return usingRestWrapper().processModel(FilePlanComponent.class, requestWithBody(
|
||||
PUT,
|
||||
toJson(filePlanComponent),
|
||||
"fileplan-components/{fileplanComponentId}?{parameters}",
|
||||
filePlanComponentId,
|
||||
getParameters()
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete file plan component
|
||||
*
|
||||
* @param filePlanComponentId The id of the file plan component to be deleted
|
||||
* @throws Exception for the following cases:
|
||||
* <ul>
|
||||
* <li>{@code fileplanComponentId} is not a valid format</li>
|
||||
* <li>authentication fails</li>
|
||||
* <li>current user does not have permission to delete {@code fileplanComponentId}</li>
|
||||
* <li>{@code fileplanComponentId} does not exist</li>
|
||||
* <li>{@code fileplanComponentId} is locked and cannot be deleted</li>
|
||||
* </ul>
|
||||
*/
|
||||
public void deleteFilePlanComponent(String filePlanComponentId) throws Exception
|
||||
{
|
||||
mandatoryString("filePlanComponentId", filePlanComponentId);
|
||||
|
||||
usingRestWrapper().processEmptyModel(simpleRequest(
|
||||
DELETE,
|
||||
"fileplan-components/{fileplanComponentId}",
|
||||
filePlanComponentId
|
||||
));
|
||||
}
|
||||
|
||||
}
|
@@ -4,28 +4,58 @@
|
||||
* %%
|
||||
* 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.
|
||||
* 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.basic;
|
||||
import static com.jayway.restassured.RestAssured.given;
|
||||
|
||||
import static org.alfresco.rest.core.RestRequest.requestWithBody;
|
||||
import static org.alfresco.rest.core.RestRequest.simpleRequest;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.CONTENT_TYPE;
|
||||
import static org.alfresco.rest.rm.community.util.ParameterCheck.mandatoryObject;
|
||||
import static org.alfresco.rest.rm.community.util.ParameterCheck.mandatoryString;
|
||||
import static org.alfresco.rest.rm.community.util.PojoUtility.toJson;
|
||||
import static org.apache.commons.lang3.StringUtils.EMPTY;
|
||||
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 static org.testng.Assert.fail;
|
||||
|
||||
import org.alfresco.rest.core.RestWrapper;
|
||||
import org.alfresco.rest.requests.ModelRequest;
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent;
|
||||
import java.io.File;
|
||||
import java.util.Iterator;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.google.common.io.Resources;
|
||||
import com.jayway.restassured.builder.RequestSpecBuilder;
|
||||
import com.jayway.restassured.http.ContentType;
|
||||
import com.jayway.restassured.response.Response;
|
||||
|
||||
import org.alfresco.rest.core.RMRestWrapper;
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentModel;
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentsCollection;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
|
||||
/**
|
||||
* FIXME!!!
|
||||
@@ -33,24 +63,21 @@ import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.6
|
||||
*/
|
||||
public class FilePlanComponents extends ModelRequest
|
||||
public class FilePlanComponents extends RMModelRequest
|
||||
{
|
||||
private FilePlanComponentModel filePlanComponentModel;
|
||||
|
||||
/**
|
||||
* @param restWrapper
|
||||
*/
|
||||
public FilePlanComponents(FilePlanComponentModel filePlanComponentModel, RestWrapper restWrapper)
|
||||
public FilePlanComponents(RMRestWrapper rmRestWrapper)
|
||||
{
|
||||
super(restWrapper);
|
||||
this.filePlanComponentModel = filePlanComponentModel;
|
||||
super(rmRestWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a file plan component
|
||||
*
|
||||
* @param filePlanComponentId The id of the file plan component to get
|
||||
* @return The {@link FilePlanComponent} for the given file plan component id
|
||||
* @return The {@link FilePlanComponentModel} for the given file plan component id
|
||||
* @throws Exception for the following cases:
|
||||
* <ul>
|
||||
* <li>{@code fileplanComponentId} is not a valid format</li>
|
||||
@@ -58,21 +85,30 @@ public class FilePlanComponents extends ModelRequest
|
||||
* <li>{@code fileplanComponentId} does not exist</li>
|
||||
* </ul>
|
||||
*/
|
||||
public FilePlanComponent getFilePlanComponent(String filePlanComponentId) throws Exception
|
||||
public FilePlanComponentModel getFilePlanComponent(String filePlanComponentId) throws Exception
|
||||
{
|
||||
mandatoryString("filePlanComponentId", filePlanComponentId);
|
||||
|
||||
/*
|
||||
return restWrapper.processModel(FilePlanComponent.class, simpleRequest(
|
||||
return getFilePlanComponent(filePlanComponentId, EMPTY);
|
||||
}
|
||||
|
||||
/**
|
||||
* FIXME!!!
|
||||
*
|
||||
* @param filePlanComponentId FIXME!!!
|
||||
* @param parameters FIXME!!!
|
||||
* @return FIXME!!!
|
||||
* @throws Exception FIXME!!!
|
||||
*/
|
||||
public FilePlanComponentModel getFilePlanComponent(String filePlanComponentId, String parameters) throws Exception
|
||||
{
|
||||
mandatoryString("filePlanComponentId", filePlanComponentId);
|
||||
|
||||
return getRMRestWrapper().processModel(FilePlanComponentModel.class, simpleRequest(
|
||||
GET,
|
||||
"fileplan-components/{fileplanComponentId}?{parameters}",
|
||||
filePlanComponentId, getParameters()
|
||||
*/
|
||||
// FIXME!!!
|
||||
return restWrapper.processModel(FilePlanComponent.class, simpleRequest(
|
||||
GET,
|
||||
"fileplan-components/{fileplanComponentId}",
|
||||
filePlanComponentId
|
||||
filePlanComponentId,
|
||||
parameters
|
||||
));
|
||||
}
|
||||
|
||||
@@ -92,7 +128,7 @@ public class FilePlanComponents extends ModelRequest
|
||||
{
|
||||
mandatoryString("filePlanComponentId", filePlanComponentId);
|
||||
|
||||
return restWrapper.processModels(FilePlanComponentsCollection.class, simpleRequest(
|
||||
return getRMRestWrapper().processModels(FilePlanComponentsCollection.class, simpleRequest(
|
||||
GET,
|
||||
"fileplan-components/{fileplanComponentId}/children",
|
||||
filePlanComponentId
|
||||
@@ -104,7 +140,7 @@ public class FilePlanComponents extends ModelRequest
|
||||
*
|
||||
* @param filePlanComponentModel The properties of the file plan component to be created
|
||||
* @param parentId The id of the parent where the new file plan component should be created
|
||||
* @return The {@link FilePlanComponent} with the given properties
|
||||
* @return The {@link FilePlanComponentModel} with the given properties
|
||||
* @throws Exception for the following cases:
|
||||
* <ul>
|
||||
* <li>{@code fileplanComponentId} is not a valid format</li>
|
||||
@@ -115,23 +151,107 @@ public class FilePlanComponents extends ModelRequest
|
||||
* <li>model integrity exception, including node name with invalid characters</li>
|
||||
* </ul>
|
||||
*/
|
||||
public FilePlanComponent createFilePlanComponent(FilePlanComponent filePlanComponentModel, String parentId) throws Exception
|
||||
public FilePlanComponentModel createFilePlanComponent(FilePlanComponentModel filePlanComponentModel, String parentId) throws Exception
|
||||
{
|
||||
mandatoryObject("filePlanComponentProperties", filePlanComponentModel);
|
||||
mandatoryString("parentId", parentId);
|
||||
|
||||
return restWrapper.processModel(FilePlanComponent.class, requestWithBody(
|
||||
return createFilePlanComponent(filePlanComponentModel, parentId, EMPTY);
|
||||
}
|
||||
|
||||
/**
|
||||
* FIXME!!!
|
||||
*
|
||||
* @param filePlanComponentModel FIXME!!!
|
||||
* @param parentId FIXME!!!
|
||||
* @param parameters FIXME!!!
|
||||
* @return FIXME!!!
|
||||
* @throws Exception FIXME!!!
|
||||
*/
|
||||
public FilePlanComponentModel createFilePlanComponent(FilePlanComponentModel filePlanComponentModel, String parentId, String parameters) throws Exception
|
||||
{
|
||||
mandatoryObject("filePlanComponentProperties", filePlanComponentModel);
|
||||
mandatoryString("parentId", parentId);
|
||||
|
||||
return getRMRestWrapper().processModel(FilePlanComponentModel.class, requestWithBody(
|
||||
POST,
|
||||
toJson(filePlanComponentModel),
|
||||
"fileplan-components/{fileplanComponentId}/children",
|
||||
parentId
|
||||
));
|
||||
"fileplan-components/{fileplanComponentId}/children?{parameters}",
|
||||
parentId,
|
||||
parameters
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create electronic record from file resource
|
||||
* @param electronicRecordModel {@link FilePlanComponent} for electronic record to be created
|
||||
* @param fileName the name of the resource file
|
||||
* @param parentId parent container id
|
||||
* @return newly created {@link FilePlanComponent}
|
||||
* @throws Exception if operation failed
|
||||
*/
|
||||
public FilePlanComponentModel createElectronicRecord(FilePlanComponentModel electronicRecordModel, String fileName, String parentId) throws Exception
|
||||
{
|
||||
return createElectronicRecord(electronicRecordModel, new File(Resources.getResource(fileName).getFile()), parentId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create electronic record from file resource
|
||||
* @param electronicRecordModel {@link FilePlanComponent} for electronic record to be created
|
||||
* @param recordContent {@link File} pointing to the content of the electronic record to be created
|
||||
* @param parentId parent container id
|
||||
* @return newly created {@link FilePlanComponent}
|
||||
* @throws Exception if operation failed
|
||||
*/
|
||||
public FilePlanComponentModel createElectronicRecord(FilePlanComponentModel electronicRecordModel, File recordContent, String parentId) throws Exception
|
||||
{
|
||||
mandatoryObject("filePlanComponentProperties", electronicRecordModel);
|
||||
mandatoryString("parentId", parentId);
|
||||
if (!electronicRecordModel.getNodeType().equals(CONTENT_TYPE))
|
||||
{
|
||||
fail("Only electronic records are supported");
|
||||
}
|
||||
|
||||
UserModel currentUser = getRMRestWrapper().getTestUser();
|
||||
|
||||
/*
|
||||
* For file uploads nodeBodyCreate is ignored hence can't be used. Append all FilePlanComponent fields
|
||||
* to the request.
|
||||
*/
|
||||
RequestSpecBuilder builder = new RequestSpecBuilder();
|
||||
builder.setAuth(basic(currentUser.getUsername(), currentUser.getPassword()));
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
JsonNode root = mapper.readTree(toJson(electronicRecordModel));
|
||||
|
||||
Iterator<String> fieldNames = root.fieldNames();
|
||||
while (fieldNames.hasNext())
|
||||
{
|
||||
String fieldName = fieldNames.next();
|
||||
builder.addMultiPart(fieldName, root.get(fieldName).asText(), ContentType.JSON.name());
|
||||
}
|
||||
|
||||
builder.addMultiPart("filedata", recordContent, ContentType.BINARY.name());
|
||||
|
||||
/*
|
||||
* RestWrapper adds some headers which break multipart/form-data uploads and also assumes json POST requests.
|
||||
* Upload the file using RestAssured library.
|
||||
*/
|
||||
Response response = given()
|
||||
.spec(builder.build())
|
||||
.when()
|
||||
.post("fileplan-components/{fileplanComponentId}/children?{parameters}", parentId, getRMRestWrapper().getParameters())
|
||||
.andReturn();
|
||||
getRMRestWrapper().setStatusCode(Integer.toString(response.getStatusCode()));
|
||||
|
||||
/* return a FilePlanComponent object representing Response */
|
||||
return response.jsonPath().getObject("entry", FilePlanComponentModel.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates a file plan component
|
||||
*
|
||||
* @param filePlanComponent The properties to be updated
|
||||
* @param filePlanComponentModel The properties to be updated
|
||||
* @param filePlanComponentId The id of the file plan component which will be updated
|
||||
* @param returns The updated {@link FilePlanComponent}
|
||||
* @throws Exception for the following cases:
|
||||
@@ -144,17 +264,26 @@ public class FilePlanComponents extends ModelRequest
|
||||
* <li>model integrity exception, including node name with invalid characters</li>
|
||||
* </ul>
|
||||
*/
|
||||
public FilePlanComponent updateFilePlanComponent(FilePlanComponent filePlanComponent, String filePlanComponentId) throws Exception
|
||||
public FilePlanComponentModel updateFilePlanComponent(FilePlanComponentModel filePlanComponentModel, String filePlanComponentId) throws Exception
|
||||
{
|
||||
mandatoryObject("filePlanComponentProperties", filePlanComponentModel);
|
||||
mandatoryString("filePlanComponentId", filePlanComponentId);
|
||||
|
||||
return updateFilePlanComponent(filePlanComponentModel, filePlanComponentId, EMPTY);
|
||||
}
|
||||
|
||||
public FilePlanComponentModel updateFilePlanComponent(FilePlanComponentModel filePlanComponent, String filePlanComponentId, String parameters) throws Exception
|
||||
{
|
||||
mandatoryObject("filePlanComponentProperties", filePlanComponent);
|
||||
mandatoryString("filePlanComponentId", filePlanComponentId);
|
||||
|
||||
return restWrapper.processModel(FilePlanComponent.class, requestWithBody(
|
||||
return getRMRestWrapper().processModel(FilePlanComponentModel.class, requestWithBody(
|
||||
PUT,
|
||||
toJson(filePlanComponent),
|
||||
"fileplan-components/{fileplanComponentId}",
|
||||
filePlanComponentId
|
||||
));
|
||||
"fileplan-components/{fileplanComponentId}?{parameters}",
|
||||
filePlanComponentId,
|
||||
parameters
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -174,7 +303,7 @@ public class FilePlanComponents extends ModelRequest
|
||||
{
|
||||
mandatoryString("filePlanComponentId", filePlanComponentId);
|
||||
|
||||
restWrapper.processEmptyModel(simpleRequest(
|
||||
getRMRestWrapper().processEmptyModel(simpleRequest(
|
||||
DELETE,
|
||||
"fileplan-components/{fileplanComponentId}",
|
||||
filePlanComponentId
|
||||
|
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2016 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 org.alfresco.rest.core.RMRestWrapper;
|
||||
import org.alfresco.rest.requests.ModelRequest;
|
||||
|
||||
/**
|
||||
* FIXME!!!
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.6
|
||||
*/
|
||||
public abstract class RMModelRequest extends ModelRequest
|
||||
{
|
||||
private RMRestWrapper rmRestWrapper;
|
||||
|
||||
/**
|
||||
* @return the rmRestWrapper
|
||||
*/
|
||||
protected RMRestWrapper getRMRestWrapper()
|
||||
{
|
||||
return this.rmRestWrapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param restWrapper
|
||||
*/
|
||||
public RMModelRequest(RMRestWrapper rmRestWrapper)
|
||||
{
|
||||
super(rmRestWrapper);
|
||||
}
|
||||
}
|
@@ -36,31 +36,35 @@ import static org.springframework.http.HttpMethod.POST;
|
||||
import static org.springframework.http.HttpMethod.PUT;
|
||||
import static org.springframework.http.HttpStatus.OK;
|
||||
|
||||
import org.alfresco.rest.core.RestAPI;
|
||||
import org.alfresco.rest.rm.community.model.site.RMSite;
|
||||
import org.alfresco.rest.core.RMRestWrapper;
|
||||
import org.alfresco.rest.rm.community.model.site.RMSiteModel;
|
||||
import org.alfresco.utility.data.DataUser;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* File plan component REST API Wrapper
|
||||
* FIXME!!!
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @author Rodica Sutu
|
||||
* @since 2.6
|
||||
*/
|
||||
@Component
|
||||
@Scope (value = "prototype")
|
||||
public class RMSiteAPI extends RestAPI<RMSiteAPI>
|
||||
public class RMSite extends RMModelRequest
|
||||
{
|
||||
// FIXME!!!
|
||||
@Autowired
|
||||
private DataUser dataUser;
|
||||
|
||||
/**
|
||||
* @param restWrapper
|
||||
*/
|
||||
public RMSite(RMRestWrapper rmRestWrapper)
|
||||
{
|
||||
super(rmRestWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the RM site
|
||||
*
|
||||
* @return The {@link RMSite} for the given file plan component id
|
||||
* @return The {@link RMSiteModel} 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>
|
||||
@@ -69,9 +73,9 @@ public class RMSiteAPI extends RestAPI<RMSiteAPI>
|
||||
* <li>Api Response code default Unexpected error</li>
|
||||
* </ul>
|
||||
*/
|
||||
public RMSite getSite() throws Exception
|
||||
public RMSiteModel getSite() throws Exception
|
||||
{
|
||||
return usingRestWrapper().processModel(RMSite.class, simpleRequest(
|
||||
return getRMRestWrapper().processModel(RMSiteModel.class, simpleRequest(
|
||||
GET,
|
||||
"ig-sites/rm"
|
||||
));
|
||||
@@ -81,7 +85,7 @@ public class RMSiteAPI extends RestAPI<RMSiteAPI>
|
||||
* Create the RM site
|
||||
*
|
||||
* @param rmSite The properties of the rm site to be created
|
||||
* @return The {@link RMSite} with the given properties
|
||||
* @return The {@link RMSiteModel} 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>
|
||||
@@ -90,13 +94,13 @@ public class RMSiteAPI extends RestAPI<RMSiteAPI>
|
||||
* <li>Api Response code default Unexpected error</li>
|
||||
* </ul>
|
||||
*/
|
||||
public RMSite createRMSite(RMSite rmSite) throws Exception
|
||||
public RMSiteModel createRMSite(RMSiteModel rmSiteModel) throws Exception
|
||||
{
|
||||
mandatoryObject("rmSiteProperties", rmSite);
|
||||
mandatoryObject("rmSiteModel", rmSiteModel);
|
||||
|
||||
return usingRestWrapper().processModel(RMSite.class, requestWithBody(
|
||||
return getRMRestWrapper().processModel(RMSiteModel.class, requestWithBody(
|
||||
POST,
|
||||
toJson(rmSite),
|
||||
toJson(rmSiteModel),
|
||||
"ig-sites"
|
||||
));
|
||||
}
|
||||
@@ -114,7 +118,7 @@ public class RMSiteAPI extends RestAPI<RMSiteAPI>
|
||||
*/
|
||||
public void deleteRMSite() throws Exception
|
||||
{
|
||||
usingRestWrapper().processEmptyModel(simpleRequest(
|
||||
getRMRestWrapper().processEmptyModel(simpleRequest(
|
||||
DELETE,
|
||||
"ig-sites/rm"
|
||||
));
|
||||
@@ -124,23 +128,23 @@ public class RMSiteAPI extends RestAPI<RMSiteAPI>
|
||||
* Update RM site
|
||||
*
|
||||
* @param rmSiteProperties The properties to be updated
|
||||
* @return The updated {@link RMSite}
|
||||
* @return The updated {@link RMSiteModel}
|
||||
* @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 400 the update request is invalid {@code rmSiteModel} 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 404 {@code RMSiteModel} does not exist</li>
|
||||
* <li>Api Response code default Unexpected error,model integrity exception</li>
|
||||
* </ul>
|
||||
*/
|
||||
public RMSite updateRMSite(RMSite rmSiteProperties) throws Exception
|
||||
public RMSiteModel updateRMSite(RMSiteModel rmSiteModel) throws Exception
|
||||
{
|
||||
mandatoryObject("rmSiteProperties", rmSiteProperties);
|
||||
mandatoryObject("rmSiteProperties", rmSiteModel);
|
||||
|
||||
return usingRestWrapper().processModel(RMSite.class, requestWithBody(
|
||||
return getRMRestWrapper().processModel(RMSiteModel.class, requestWithBody(
|
||||
PUT,
|
||||
toJson(rmSiteProperties),
|
||||
toJson(rmSiteModel),
|
||||
"ig-sites/rm"
|
||||
));
|
||||
}
|
||||
@@ -159,8 +163,8 @@ public class RMSiteAPI extends RestAPI<RMSiteAPI>
|
||||
*/
|
||||
public boolean existsRMSite() throws Exception
|
||||
{
|
||||
usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
getRMRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
getSite();
|
||||
return usingRestWrapper().getStatusCode().equals(OK.toString());
|
||||
return getRMRestWrapper().getStatusCode().equals(OK.toString());
|
||||
}
|
||||
}
|
@@ -42,12 +42,12 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* RM user management API
|
||||
*
|
||||
*
|
||||
* @author Kristijan Conkas
|
||||
* @since 2.6
|
||||
*/
|
||||
// FIXME: As of December 2016 there is no v1-style API for managing RM users and users'
|
||||
// roles. Until such APIs have become available, methods in this class are just proxies to
|
||||
// FIXME: As of December 2016 there is no v1-style API for managing RM users and users'
|
||||
// roles. Until such APIs have become available, methods in this class are just proxies to
|
||||
// "old-style" API calls.
|
||||
@Component
|
||||
@Scope (value = "prototype")
|
||||
@@ -55,21 +55,21 @@ public class RMUserAPI extends RestAPI<RMUserAPI>
|
||||
{
|
||||
@Autowired
|
||||
private DataUser dataUser;
|
||||
|
||||
|
||||
@Autowired
|
||||
private AlfrescoHttpClientFactory alfrescoHttpClientFactory;
|
||||
|
||||
|
||||
public void assignRoleToUser(String userName, String userRole) throws Exception
|
||||
{
|
||||
// get an "old-style" REST API client
|
||||
AlfrescoHttpClient client = alfrescoHttpClientFactory.getObject();
|
||||
|
||||
|
||||
// override v1 baseURI and basePath
|
||||
RequestSpecification spec = new RequestSpecBuilder()
|
||||
.setBaseUri(client.getApiUrl())
|
||||
.setBasePath("/")
|
||||
.build();
|
||||
|
||||
|
||||
Response response = given()
|
||||
.spec(spec)
|
||||
.log().all()
|
||||
|
@@ -4,42 +4,83 @@
|
||||
* %%
|
||||
* 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.
|
||||
* 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.igCoreAPI;
|
||||
|
||||
import static java.lang.Integer.parseInt;
|
||||
import static java.lang.String.format;
|
||||
|
||||
import com.jayway.restassured.RestAssured;
|
||||
|
||||
import org.alfresco.rest.core.ExtendedRestProperties;
|
||||
import org.alfresco.rest.core.RestWrapper;
|
||||
import org.alfresco.rest.requests.ModelRequest;
|
||||
import org.alfresco.rest.core.RMRestProperties;
|
||||
import org.alfresco.rest.core.RMRestWrapper;
|
||||
import org.alfresco.rest.rm.community.requests.FilePlanComponents;
|
||||
import org.alfresco.rest.rm.community.requests.RMModelRequest;
|
||||
import org.alfresco.rest.rm.community.requests.RMSite;
|
||||
|
||||
/**
|
||||
* FIXME!!!
|
||||
* Defines the entire IG Core API
|
||||
* {@link http://host:port/ig-api-explorer} select "IG Core API"
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.6
|
||||
*/
|
||||
public class RestIGCoreAPI extends ModelRequest
|
||||
public class RestIGCoreAPI extends RMModelRequest
|
||||
{
|
||||
private ExtendedRestProperties extendedRestProperties;
|
||||
@SuppressWarnings("unused")
|
||||
private RMRestProperties rmRestProperties;
|
||||
|
||||
/**
|
||||
* FIXME!!!
|
||||
*
|
||||
* @param restWrapper FIXME!!!
|
||||
* @param restProperties FIXME!!!
|
||||
* @param rmRestWrapper FIXME!!!
|
||||
* @param rmRestProperties FIXME!!!
|
||||
*/
|
||||
public RestIGCoreAPI(RestWrapper restWrapper, ExtendedRestProperties extendedRestProperties)
|
||||
public RestIGCoreAPI(RMRestWrapper rmRestWrapper, RMRestProperties rmRestProperties)
|
||||
{
|
||||
super(restWrapper);
|
||||
this.extendedRestProperties = extendedRestProperties;
|
||||
// FIXME
|
||||
RestAssured.baseURI = extendedRestProperties.envProperty().getTestServerUrl();
|
||||
RestAssured.port = extendedRestProperties.envProperty().getPort();
|
||||
RestAssured.basePath = extendedRestProperties.getRestWorkflowPath();
|
||||
super(rmRestWrapper);
|
||||
this.rmRestProperties = rmRestProperties;
|
||||
RestAssured.baseURI = format("%s://%s", rmRestProperties.getScheme(), rmRestProperties.getServer());
|
||||
RestAssured.port = parseInt(rmRestProperties.getPort());
|
||||
RestAssured.basePath = rmRestProperties.getRestRmPath();
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides DSL on all REST calls under <code>ig-sites/rm/...</code> API path
|
||||
*
|
||||
* @return {@link RMSite}
|
||||
*/
|
||||
public RMSite usingRMSite()
|
||||
{
|
||||
return new RMSite(getRMRestWrapper());
|
||||
}
|
||||
|
||||
/**
|
||||
* FIXME!!!
|
||||
*
|
||||
* @return FIXME!!!
|
||||
*/
|
||||
public FilePlanComponents usingFilePlanComponents()
|
||||
{
|
||||
return new FilePlanComponents(getRMRestWrapper());
|
||||
}
|
||||
}
|
||||
|
@@ -57,7 +57,6 @@ public class PojoUtility
|
||||
{
|
||||
//return the json object
|
||||
return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(model);
|
||||
|
||||
}
|
||||
catch (JsonGenerationException e)
|
||||
{
|
||||
|
@@ -35,7 +35,6 @@ import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.ReviewPeriod;
|
||||
|
||||
|
||||
/**
|
||||
* Utility class for serializing the Review Period type
|
||||
*
|
||||
@@ -44,7 +43,6 @@ import org.alfresco.rest.rm.community.model.fileplancomponents.ReviewPeriod;
|
||||
*/
|
||||
public class ReviewPeriodSerializer extends JsonSerializer<ReviewPeriod>
|
||||
{
|
||||
|
||||
/**
|
||||
* @param value The Review Period value that is being serialized.
|
||||
* @param gen Jackson utility is responsible for writing JSON
|
||||
@@ -57,8 +55,5 @@ public class ReviewPeriodSerializer extends JsonSerializer<ReviewPeriod>
|
||||
{
|
||||
//create the custom string value for the Review Period type
|
||||
gen.writeString(new StringBuilder().append(value.getPeriodType()).append("|").append(value.getExpression()).toString());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -26,8 +26,6 @@
|
||||
*/
|
||||
package org.alfresco.rest.rm.community.base;
|
||||
|
||||
import static java.lang.Integer.parseInt;
|
||||
|
||||
import static com.jayway.restassured.RestAssured.given;
|
||||
|
||||
import static org.alfresco.rest.rm.community.base.TestData.CATEGORY_TITLE;
|
||||
@@ -44,7 +42,6 @@ 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.builder.RequestSpecBuilder;
|
||||
import com.jayway.restassured.http.ContentType;
|
||||
import com.jayway.restassured.response.Response;
|
||||
@@ -53,19 +50,17 @@ import com.jayway.restassured.specification.RequestSpecification;
|
||||
import org.alfresco.dataprep.AlfrescoHttpClient;
|
||||
import org.alfresco.dataprep.AlfrescoHttpClientFactory;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.core.RestWrapper;
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent;
|
||||
import org.alfresco.rest.core.RMRestWrapper;
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentModel;
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentProperties;
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType;
|
||||
import org.alfresco.rest.rm.community.model.site.RMSite;
|
||||
import org.alfresco.rest.rm.community.requests.FilePlanComponentAPI;
|
||||
import org.alfresco.rest.rm.community.requests.RMSiteAPI;
|
||||
import org.alfresco.rest.rm.community.model.site.RMSiteModel;
|
||||
import org.alfresco.rest.rm.community.model.user.UserPermissions;
|
||||
import org.alfresco.rest.rm.community.requests.FilePlanComponents;
|
||||
import org.alfresco.rest.rm.community.requests.RMSite;
|
||||
import org.alfresco.utility.data.DataUser;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
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;
|
||||
import org.testng.annotations.DataProvider;
|
||||
|
||||
@@ -76,39 +71,49 @@ import org.testng.annotations.DataProvider;
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.6
|
||||
*/
|
||||
@Configuration
|
||||
@PropertySource(value = {"classpath:default.properties", "classpath:config.properties"})
|
||||
@PropertySource(value = "classpath:module.properties", ignoreResourceNotFound = true)
|
||||
@PropertySource(value = "classpath:local.properties", ignoreResourceNotFound = true)
|
||||
public class BaseRestTest extends RestTest
|
||||
{
|
||||
@Value ("${alfresco.scheme}")
|
||||
private String scheme;
|
||||
|
||||
@Value ("${alfresco.server}")
|
||||
private String server;
|
||||
|
||||
@Value ("${alfresco.port}")
|
||||
private String port;
|
||||
|
||||
@Value ("${rest.rmPath}")
|
||||
private String restRmPath;
|
||||
|
||||
@Value ("${rest.basePath}")
|
||||
private String restCorePath;
|
||||
|
||||
@Autowired
|
||||
private RMSiteAPI rmSiteAPI;
|
||||
|
||||
private RMRestWrapper rmRestWrapper;
|
||||
|
||||
@Autowired
|
||||
private DataUser dataUser;
|
||||
|
||||
@Autowired
|
||||
public FilePlanComponentAPI filePlanComponentAPI;
|
||||
|
||||
@Autowired
|
||||
private AlfrescoHttpClientFactory alfrescoHttpClientFactory;
|
||||
|
||||
|
||||
private RMSite rmSite;
|
||||
|
||||
private FilePlanComponents filePlanComponents;
|
||||
|
||||
protected RMSite getRMSiteAPI()
|
||||
{
|
||||
if (rmSite == null)
|
||||
{
|
||||
rmSite = getRmRestWrapper().withIGCoreAPI().usingRMSite();
|
||||
}
|
||||
|
||||
return rmSite;
|
||||
}
|
||||
|
||||
protected FilePlanComponents getFilePlanComponentsAPI()
|
||||
{
|
||||
if (filePlanComponents == null)
|
||||
{
|
||||
filePlanComponents = getRmRestWrapper().withIGCoreAPI().usingFilePlanComponents();
|
||||
}
|
||||
|
||||
return filePlanComponents;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the rmRestWrapper
|
||||
*/
|
||||
protected RMRestWrapper getRmRestWrapper()
|
||||
{
|
||||
return this.rmRestWrapper;
|
||||
}
|
||||
|
||||
// Constants
|
||||
public static final String RM_ID = "rm";
|
||||
public static final String RM_TITLE = "Records Management";
|
||||
@@ -116,14 +121,16 @@ public class BaseRestTest extends RestTest
|
||||
|
||||
/** Valid root containers where electronic and non-electronic records can be created */
|
||||
@DataProvider(name = "validRootContainers")
|
||||
public Object[][] getValidRootContainers() throws Exception {
|
||||
return new Object[][] {
|
||||
public Object[][] getValidRootContainers() throws Exception
|
||||
{
|
||||
return new Object[][]
|
||||
{
|
||||
// an arbitrary record folder
|
||||
{ createCategoryFolderInFilePlan(dataUser.getAdminUser(), FILE_PLAN_ALIAS.toString()) },
|
||||
{ createCategoryFolderInFilePlan(dataUser.getAdminUser(), FILE_PLAN_ALIAS) },
|
||||
// unfiled records root
|
||||
{ getFilePlanComponentAsUser(dataUser.getAdminUser(), UNFILED_RECORDS_CONTAINER_ALIAS.toString()) },
|
||||
{ getFilePlanComponentAsUser(dataUser.getAdminUser(), UNFILED_RECORDS_CONTAINER_ALIAS) },
|
||||
// an arbitrary unfiled records folder
|
||||
{ createUnfiledRecordsFolder(UNFILED_RECORDS_CONTAINER_ALIAS.toString(), "Unfiled Folder " + getRandomAlphanumeric()) }
|
||||
{ createUnfiledRecordsFolder(UNFILED_RECORDS_CONTAINER_ALIAS, "Unfiled Folder " + getRandomAlphanumeric()) }
|
||||
};
|
||||
}
|
||||
|
||||
@@ -134,14 +141,30 @@ public class BaseRestTest extends RestTest
|
||||
@BeforeClass (alwaysRun = true)
|
||||
public void checkServerHealth() throws Exception
|
||||
{
|
||||
RestAssured.baseURI = scheme + "://" + server;
|
||||
RestAssured.port = parseInt(port);
|
||||
RestAssured.basePath = restRmPath;
|
||||
|
||||
// Create RM Site if not exist
|
||||
createRMSiteIfNotExists();
|
||||
}
|
||||
|
||||
/**
|
||||
* FIXME!!!
|
||||
*
|
||||
* @param userModel FIXME!!!
|
||||
*/
|
||||
protected void authenticateUser(UserModel userModel)
|
||||
{
|
||||
getRmRestWrapper().authenticateUser(userModel);
|
||||
}
|
||||
|
||||
protected void assertStatusCodeIs(HttpStatus httpStatus)
|
||||
{
|
||||
getRmRestWrapper().assertStatusCodeIs(httpStatus);
|
||||
}
|
||||
|
||||
protected void disconnect()
|
||||
{
|
||||
getRmRestWrapper().disconnect();
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to create the RM Site via the POST request
|
||||
* if the site doesn't exist
|
||||
@@ -149,18 +172,18 @@ public class BaseRestTest extends RestTest
|
||||
public void createRMSiteIfNotExists() throws Exception
|
||||
{
|
||||
// Check RM site doesn't exist
|
||||
if (!rmSiteAPI.existsRMSite())
|
||||
if (!rmSite.existsRMSite())
|
||||
{
|
||||
rmSiteAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// Create the RM site
|
||||
RMSite rmSite = RMSite.builder().compliance(STANDARD).build();
|
||||
rmSite.setTitle(RM_TITLE);
|
||||
rmSite.setDescription(RM_DESCRIPTION);
|
||||
rmSiteAPI.createRMSite(rmSite);
|
||||
RMSiteModel rmSiteModel = RMSiteModel.builder().compliance(STANDARD).build();
|
||||
rmSiteModel.setTitle(RM_TITLE);
|
||||
rmSiteModel.setDescription(RM_DESCRIPTION);
|
||||
rmSite.createRMSite(rmSiteModel);
|
||||
|
||||
// Verify the status code
|
||||
rmSiteAPI.usingRestWrapper().assertStatusCodeIs(CREATED);
|
||||
assertStatusCodeIs(CREATED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,7 +195,7 @@ public class BaseRestTest extends RestTest
|
||||
* @return The created category
|
||||
* @throws Exception on unsuccessful component creation
|
||||
*/
|
||||
public FilePlanComponent createCategory(String parentCategoryId, String categoryName) throws Exception
|
||||
public FilePlanComponentModel createCategory(String parentCategoryId, String categoryName) throws Exception
|
||||
{
|
||||
return createComponent(parentCategoryId, categoryName, RECORD_CATEGORY_TYPE, CATEGORY_TITLE);
|
||||
}
|
||||
@@ -185,7 +208,7 @@ public class BaseRestTest extends RestTest
|
||||
* @return The created category
|
||||
* @throws Exception on unsuccessful component creation
|
||||
*/
|
||||
public FilePlanComponent createFolder(String parentCategoryId, String folderName) throws Exception
|
||||
public FilePlanComponentModel createFolder(String parentCategoryId, String folderName) throws Exception
|
||||
{
|
||||
return createComponent(parentCategoryId, folderName, RECORD_FOLDER_TYPE, FOLDER_TITLE);
|
||||
}
|
||||
@@ -198,7 +221,7 @@ public class BaseRestTest extends RestTest
|
||||
* @return The created folder
|
||||
* @throws Exception on unsuccessful component creation
|
||||
*/
|
||||
public FilePlanComponent createUnfiledRecordsFolder(String parentId, String folderName) throws Exception
|
||||
public FilePlanComponentModel createUnfiledRecordsFolder(String parentId, String folderName) throws Exception
|
||||
{
|
||||
return createComponent(parentId, folderName, UNFILED_RECORD_FOLDER_TYPE, FOLDER_TITLE);
|
||||
}
|
||||
@@ -213,20 +236,21 @@ public class BaseRestTest extends RestTest
|
||||
* @return The created file plan component
|
||||
* @throws Exception
|
||||
*/
|
||||
private FilePlanComponent createComponent(String parentComponentId, String componentName, FilePlanComponentType componentType, String componentTitle) throws Exception
|
||||
private FilePlanComponentModel createComponent(String parentComponentId, String componentName, String componentType, String componentTitle) throws Exception
|
||||
{
|
||||
RestWrapper restWrapper = filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
FilePlanComponent filePlanComponent = FilePlanComponent.builder()
|
||||
FilePlanComponentModel filePlanComponent = FilePlanComponentModel.builder()
|
||||
.name(componentName)
|
||||
.nodeType(componentType.toString())
|
||||
.nodeType(componentType)
|
||||
.properties(FilePlanComponentProperties.builder()
|
||||
.title(componentTitle)
|
||||
.build())
|
||||
.build();
|
||||
|
||||
FilePlanComponent fpc = filePlanComponentAPI.createFilePlanComponent(filePlanComponent, parentComponentId);
|
||||
restWrapper.assertStatusCodeIs(CREATED);
|
||||
FilePlanComponentModel fpc = getFilePlanComponentsAPI().createFilePlanComponent(filePlanComponent, parentComponentId);
|
||||
assertStatusCodeIs(CREATED);
|
||||
|
||||
return fpc;
|
||||
}
|
||||
|
||||
@@ -236,21 +260,21 @@ public class BaseRestTest extends RestTest
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public FilePlanComponent closeFolder(String folderId) throws Exception
|
||||
public FilePlanComponentModel closeFolder(String folderId) throws Exception
|
||||
{
|
||||
RestWrapper restWrapper = filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// build fileplan component + properties for update request
|
||||
FilePlanComponentProperties properties = new FilePlanComponentProperties();
|
||||
properties.setIsClosed(true);
|
||||
FilePlanComponent filePlanComponent = new FilePlanComponent();
|
||||
FilePlanComponentModel filePlanComponent = new FilePlanComponentModel();
|
||||
filePlanComponent.setProperties(properties);
|
||||
|
||||
FilePlanComponent updatedComponent = filePlanComponentAPI.updateFilePlanComponent(filePlanComponent, folderId);
|
||||
restWrapper.assertStatusCodeIs(OK);
|
||||
|
||||
FilePlanComponentModel updatedComponent = getFilePlanComponentsAPI().updateFilePlanComponent(filePlanComponent, folderId);
|
||||
assertStatusCodeIs(OK);
|
||||
return updatedComponent;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
||||
@@ -258,17 +282,17 @@ public class BaseRestTest extends RestTest
|
||||
* @return record folder
|
||||
* @throws Exception on failed creation
|
||||
*/
|
||||
public FilePlanComponent createCategoryFolderInFilePlan(UserModel user, String parentId) throws Exception
|
||||
public FilePlanComponentModel createCategoryFolderInFilePlan(UserModel user, String parentId) throws Exception
|
||||
{
|
||||
filePlanComponentAPI.usingRestWrapper().authenticateUser(user);
|
||||
|
||||
authenticateUser(user);
|
||||
|
||||
// create root category
|
||||
FilePlanComponent recordCategory = createCategory(parentId, "Category " + getRandomAlphanumeric());
|
||||
|
||||
FilePlanComponentModel recordCategory = createCategory(parentId, "Category " + getRandomAlphanumeric());
|
||||
|
||||
// and return a folder underneath
|
||||
return createFolder(recordCategory.getId(), "Folder " + getRandomAlphanumeric());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper method to retieve a fileplan component with user's privilege
|
||||
* @param user user under whose privileges a component is to be read
|
||||
@@ -276,12 +300,12 @@ public class BaseRestTest extends RestTest
|
||||
* @return {@link FilePlanComponent} for given componentId
|
||||
* @throws Exception if user doesn't have sufficient privileges
|
||||
*/
|
||||
public FilePlanComponent getFilePlanComponentAsUser(UserModel user, String componentId) throws Exception
|
||||
public FilePlanComponentModel getFilePlanComponentAsUser(UserModel user, String componentId) throws Exception
|
||||
{
|
||||
filePlanComponentAPI.usingRestWrapper().authenticateUser(user);
|
||||
return filePlanComponentAPI.getFilePlanComponent(componentId);
|
||||
authenticateUser(user);
|
||||
return getFilePlanComponentsAPI().getFilePlanComponent(componentId);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper method to add permission on a component to user
|
||||
* @param component {@link FilePlanComponent} on which permission should be given
|
||||
@@ -291,11 +315,11 @@ public class BaseRestTest extends RestTest
|
||||
// FIXME: As of December 2016 there is no v1-style API for managing RM permissions.
|
||||
// Until such APIs have become available, this method is just a proxy to an "old-style"
|
||||
// API call.
|
||||
public void addUserPermission(FilePlanComponent component, UserModel user, String permission)
|
||||
public void addUserPermission(FilePlanComponentModel component, UserModel user, String permission)
|
||||
{
|
||||
// get an "old-style" REST API client
|
||||
AlfrescoHttpClient client = alfrescoHttpClientFactory.getObject();
|
||||
|
||||
|
||||
JsonObject bodyJson = buildObject()
|
||||
.addArray("permissions")
|
||||
.addObject()
|
||||
@@ -309,7 +333,7 @@ public class BaseRestTest extends RestTest
|
||||
.setBaseUri(client.getApiUrl())
|
||||
.setBasePath("/")
|
||||
.build();
|
||||
|
||||
|
||||
// execute an "old-style" API call
|
||||
Response response = given()
|
||||
.spec(spec)
|
||||
@@ -322,6 +346,6 @@ public class BaseRestTest extends RestTest
|
||||
.post("/node/workspace/SpacesStore/{nodeId}/rmpermissions")
|
||||
.prettyPeek()
|
||||
.andReturn();
|
||||
filePlanComponentAPI.usingRestWrapper().setStatusCode(Integer.toString(response.getStatusCode()));
|
||||
rmRestWrapper.setStatusCode(Integer.toString(response.getStatusCode()));
|
||||
}
|
||||
}
|
@@ -50,7 +50,7 @@ import org.testng.annotations.DataProvider;
|
||||
* @since 2.6
|
||||
*/
|
||||
public interface TestData
|
||||
{
|
||||
{
|
||||
/**
|
||||
* A user with ALFRESCO_ADMINISTRATORS role.
|
||||
* <p>"GROUP_ANOTHER_ADMIN_EXISTS" The ANOTHER_ADMIN user has been created.
|
||||
@@ -75,10 +75,10 @@ public interface TestData
|
||||
public static Object[][] getContainers()
|
||||
{
|
||||
return new Object[][] {
|
||||
{ FILE_PLAN_ALIAS.toString() },
|
||||
{ TRANSFERS_ALIAS.toString() },
|
||||
{ HOLDS_ALIAS.toString() },
|
||||
{ UNFILED_RECORDS_CONTAINER_ALIAS.toString() },
|
||||
{ FILE_PLAN_ALIAS },
|
||||
{ TRANSFERS_ALIAS },
|
||||
{ HOLDS_ALIAS },
|
||||
{ UNFILED_RECORDS_CONTAINER_ALIAS },
|
||||
};
|
||||
}
|
||||
|
||||
@@ -130,15 +130,15 @@ public interface TestData
|
||||
public static Object[][] childrenNotAllowedForCategory()
|
||||
{
|
||||
return new Object[][] {
|
||||
{ FILE_PLAN_TYPE.toString() },
|
||||
{ TRANSFER_CONTAINER_TYPE.toString() },
|
||||
{ HOLD_CONTAINER_TYPE.toString() },
|
||||
{ UNFILED_CONTAINER_TYPE.toString() },
|
||||
{ UNFILED_RECORD_FOLDER_TYPE.toString()},
|
||||
{ HOLD_TYPE.toString()},
|
||||
{ TRANSFER_TYPE.toString()},
|
||||
{ FOLDER_TYPE.toString()},
|
||||
{ CONTENT_TYPE.toString()}
|
||||
{ FILE_PLAN_TYPE },
|
||||
{ TRANSFER_CONTAINER_TYPE },
|
||||
{ HOLD_CONTAINER_TYPE },
|
||||
{ UNFILED_CONTAINER_TYPE },
|
||||
{ UNFILED_RECORD_FOLDER_TYPE },
|
||||
{ HOLD_TYPE },
|
||||
{ TRANSFER_TYPE },
|
||||
{ FOLDER_TYPE },
|
||||
{ CONTENT_TYPE }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -38,11 +38,9 @@ import static org.springframework.http.HttpStatus.NO_CONTENT;
|
||||
import static org.springframework.http.HttpStatus.OK;
|
||||
|
||||
import org.alfresco.rest.rm.community.base.BaseRestTest;
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent;
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentModel;
|
||||
import org.alfresco.rest.rm.community.model.user.UserPermissions;
|
||||
import org.alfresco.rest.rm.community.model.user.UserRoles;
|
||||
import org.alfresco.rest.rm.community.requests.FilePlanComponentAPI;
|
||||
import org.alfresco.rest.rm.community.requests.RMSiteAPI;
|
||||
import org.alfresco.rest.rm.community.requests.RMUserAPI;
|
||||
import org.alfresco.test.AlfrescoTest;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
@@ -64,16 +62,10 @@ import org.testng.annotations.Test;
|
||||
public class DeleteRecordTests extends BaseRestTest
|
||||
{
|
||||
@Autowired
|
||||
private FilePlanComponentAPI filePlanComponentAPI;
|
||||
private RMUserAPI rmUserAPI;
|
||||
|
||||
@Autowired
|
||||
private RMUserAPI rmUserAPI;
|
||||
|
||||
@Autowired
|
||||
private DataUser dataUser;
|
||||
|
||||
@Autowired
|
||||
private RMSiteAPI rmSiteAPI;
|
||||
|
||||
/** image resource file to be used for records body */
|
||||
private static final String IMAGE_FILE = "money.JPG";
|
||||
@@ -86,7 +78,7 @@ public class DeleteRecordTests extends BaseRestTest
|
||||
* When I delete the record
|
||||
* Then it is deleted from the file plan
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* @param container
|
||||
* @throws Exception
|
||||
*/
|
||||
@@ -96,21 +88,21 @@ public class DeleteRecordTests extends BaseRestTest
|
||||
description = "Admin user can delete an electronic record"
|
||||
)
|
||||
@AlfrescoTest(jira="RM-4363")
|
||||
public void adminCanDeleteElectronicRecord(FilePlanComponent container) throws Exception
|
||||
public void adminCanDeleteElectronicRecord(FilePlanComponentModel container) throws Exception
|
||||
{
|
||||
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// create an electronic record
|
||||
FilePlanComponent record = FilePlanComponent.builder()
|
||||
FilePlanComponentModel record = FilePlanComponentModel.builder()
|
||||
.name("Record " + getRandomAlphanumeric())
|
||||
.nodeType(CONTENT_TYPE.toString())
|
||||
.nodeType(CONTENT_TYPE)
|
||||
.build();
|
||||
FilePlanComponent newRecord = filePlanComponentAPI.createElectronicRecord(record, IMAGE_FILE, container.getId());
|
||||
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(CREATED);
|
||||
FilePlanComponentModel newRecord = getFilePlanComponentsAPI().createElectronicRecord(record, IMAGE_FILE, container.getId());
|
||||
assertStatusCodeIs(CREATED);
|
||||
|
||||
deleteAndVerify(newRecord);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* Given a record
|
||||
@@ -119,7 +111,7 @@ public class DeleteRecordTests extends BaseRestTest
|
||||
* When I delete the record
|
||||
* Then it is deleted from the file plan
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* @param container
|
||||
* @throws Exception
|
||||
*/
|
||||
@@ -129,23 +121,23 @@ public class DeleteRecordTests extends BaseRestTest
|
||||
description = "Admin user can delete a non-electronic record"
|
||||
)
|
||||
@AlfrescoTest(jira="RM-4363")
|
||||
public void adminCanDeleteNonElectronicRecord(FilePlanComponent container) throws Exception
|
||||
public void adminCanDeleteNonElectronicRecord(FilePlanComponentModel container) throws Exception
|
||||
{
|
||||
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// create a non-electronic record
|
||||
FilePlanComponent record = FilePlanComponent.builder()
|
||||
FilePlanComponentModel record = FilePlanComponentModel.builder()
|
||||
.name("Record " + getRandomAlphanumeric())
|
||||
.nodeType(NON_ELECTRONIC_RECORD_TYPE.toString())
|
||||
.nodeType(NON_ELECTRONIC_RECORD_TYPE)
|
||||
.build();
|
||||
FilePlanComponent newRecord = filePlanComponentAPI.createFilePlanComponent(
|
||||
FilePlanComponentModel newRecord = getFilePlanComponentsAPI().createFilePlanComponent(
|
||||
record,
|
||||
container.getId());
|
||||
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(CREATED);
|
||||
assertStatusCodeIs(CREATED);
|
||||
|
||||
deleteAndVerify(newRecord);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* Given a record
|
||||
@@ -154,7 +146,7 @@ public class DeleteRecordTests extends BaseRestTest
|
||||
* Then nothing happens
|
||||
* And error gets reported
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* @param container
|
||||
* @throws Exception
|
||||
*/
|
||||
@@ -165,37 +157,37 @@ public class DeleteRecordTests extends BaseRestTest
|
||||
@AlfrescoTest(jira="RM-4363")
|
||||
public void userWithoutWritePermissionsCantDeleteRecord() throws Exception
|
||||
{
|
||||
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
rmSiteAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// create a non-electronic record in unfiled records
|
||||
FilePlanComponent record = FilePlanComponent.builder()
|
||||
FilePlanComponentModel record = FilePlanComponentModel.builder()
|
||||
.name("Record " + getRandomAlphanumeric())
|
||||
.nodeType(NON_ELECTRONIC_RECORD_TYPE.toString())
|
||||
.nodeType(NON_ELECTRONIC_RECORD_TYPE)
|
||||
.build();
|
||||
FilePlanComponent newRecord = filePlanComponentAPI.createFilePlanComponent(
|
||||
FilePlanComponentModel newRecord = getFilePlanComponentsAPI().createFilePlanComponent(
|
||||
record,
|
||||
UNFILED_RECORDS_CONTAINER_ALIAS.toString());
|
||||
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(CREATED);
|
||||
|
||||
UNFILED_RECORDS_CONTAINER_ALIAS);
|
||||
assertStatusCodeIs(CREATED);
|
||||
|
||||
// create test user and add it with collab. privileges
|
||||
UserModel deleteUser = dataUser.createRandomTestUser("delnoperm");
|
||||
deleteUser.setUserRole(UserRole.SiteCollaborator);
|
||||
logger.info("test user: " + deleteUser.getUsername());
|
||||
dataUser.addUserToSite(deleteUser, new SiteModel(rmSiteAPI.getSite().getId()), UserRole.SiteCollaborator);
|
||||
|
||||
dataUser.addUserToSite(deleteUser, new SiteModel(getRMSiteAPI().getSite().getId()), UserRole.SiteCollaborator);
|
||||
|
||||
// add RM role to user
|
||||
rmUserAPI.assignRoleToUser(deleteUser.getUsername(), UserRoles.ROLE_RM_POWER_USER);
|
||||
rmUserAPI.usingRestWrapper().assertStatusCodeIs(OK);
|
||||
|
||||
|
||||
// log in as deleteUser
|
||||
filePlanComponentAPI.usingRestWrapper().authenticateUser(deleteUser);
|
||||
|
||||
authenticateUser(deleteUser);
|
||||
|
||||
// try to delete newRecord
|
||||
filePlanComponentAPI.deleteFilePlanComponent(newRecord.getId());
|
||||
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(FORBIDDEN);
|
||||
getFilePlanComponentsAPI().deleteFilePlanComponent(newRecord.getId());
|
||||
assertStatusCodeIs(FORBIDDEN);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* Given a record
|
||||
@@ -204,7 +196,7 @@ public class DeleteRecordTests extends BaseRestTest
|
||||
* Then nothing happens
|
||||
* And error gets reported
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* @param container
|
||||
* @throws Exception
|
||||
*/
|
||||
@@ -215,66 +207,65 @@ public class DeleteRecordTests extends BaseRestTest
|
||||
@AlfrescoTest(jira="RM-4363")
|
||||
public void userWithoutDeleteRecordsCapabilityCantDeleteRecord() throws Exception
|
||||
{
|
||||
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
rmSiteAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// create test user and add it with collab. privileges
|
||||
UserModel deleteUser = dataUser.createRandomTestUser("delnoperm");
|
||||
deleteUser.setUserRole(UserRole.SiteCollaborator);
|
||||
dataUser.addUserToSite(deleteUser, new SiteModel(rmSiteAPI.getSite().getId()), UserRole.SiteCollaborator);
|
||||
dataUser.addUserToSite(deleteUser, new SiteModel(getRMSiteAPI().getSite().getId()), UserRole.SiteCollaborator);
|
||||
logger.info("test user: " + deleteUser.getUsername());
|
||||
|
||||
|
||||
// add RM role to user, RM Power User doesn't have the Delete Record capabilities
|
||||
rmUserAPI.assignRoleToUser(deleteUser.getUsername(), UserRoles.ROLE_RM_POWER_USER);
|
||||
rmUserAPI.usingRestWrapper().assertStatusCodeIs(OK);
|
||||
|
||||
|
||||
// create random folder
|
||||
FilePlanComponent randomFolder = createCategoryFolderInFilePlan(dataUser.getAdminUser(), FILE_PLAN_ALIAS.toString());
|
||||
FilePlanComponentModel randomFolder = createCategoryFolderInFilePlan(dataUser.getAdminUser(), FILE_PLAN_ALIAS);
|
||||
logger.info("random folder:" + randomFolder.getName());
|
||||
|
||||
|
||||
// grant deleteUser Filing privileges on randomFolder category, this will be
|
||||
// inherited to randomFolder
|
||||
addUserPermission(filePlanComponentAPI.getFilePlanComponent(randomFolder.getParentId()),
|
||||
addUserPermission(getFilePlanComponentsAPI().getFilePlanComponent(randomFolder.getParentId()),
|
||||
deleteUser, UserPermissions.PERMISSION_FILING);
|
||||
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(OK);
|
||||
|
||||
assertStatusCodeIs(OK);
|
||||
|
||||
// create a non-electronic record in randomFolder
|
||||
FilePlanComponent record = FilePlanComponent.builder()
|
||||
FilePlanComponentModel record = FilePlanComponentModel.builder()
|
||||
.name("Record " + getRandomAlphanumeric())
|
||||
.nodeType(NON_ELECTRONIC_RECORD_TYPE.toString())
|
||||
.nodeType(NON_ELECTRONIC_RECORD_TYPE)
|
||||
.build();
|
||||
FilePlanComponent newRecord = filePlanComponentAPI.createFilePlanComponent(
|
||||
FilePlanComponentModel newRecord = getFilePlanComponentsAPI().createFilePlanComponent(
|
||||
record,
|
||||
randomFolder.getId());
|
||||
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(CREATED);
|
||||
assertStatusCodeIs(CREATED);
|
||||
|
||||
// log in as deleteUser
|
||||
filePlanComponentAPI.usingRestWrapper().authenticateUser(deleteUser);
|
||||
|
||||
authenticateUser(deleteUser);
|
||||
|
||||
// verify the user can see the newRecord
|
||||
filePlanComponentAPI.getFilePlanComponent(newRecord.getId());
|
||||
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(OK);
|
||||
|
||||
getFilePlanComponentsAPI().getFilePlanComponent(newRecord.getId());
|
||||
assertStatusCodeIs(OK);
|
||||
|
||||
// try to delete newRecord
|
||||
filePlanComponentAPI.deleteFilePlanComponent(newRecord.getId());
|
||||
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(FORBIDDEN);
|
||||
getFilePlanComponentsAPI().deleteFilePlanComponent(newRecord.getId());
|
||||
assertStatusCodeIs(FORBIDDEN);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Utility method to delete a record and verify successful deletion
|
||||
* @param record
|
||||
* @throws Exception
|
||||
*/
|
||||
private void deleteAndVerify(FilePlanComponent record) throws Exception
|
||||
private void deleteAndVerify(FilePlanComponentModel record) throws Exception
|
||||
{
|
||||
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// delete it and verify status
|
||||
filePlanComponentAPI.deleteFilePlanComponent(record.getId());
|
||||
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(NO_CONTENT);
|
||||
|
||||
getFilePlanComponentsAPI().deleteFilePlanComponent(record.getId());
|
||||
assertStatusCodeIs(NO_CONTENT);
|
||||
|
||||
// try to get deleted file plan component
|
||||
filePlanComponentAPI.getFilePlanComponent(record.getId());
|
||||
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(NOT_FOUND);
|
||||
getFilePlanComponentsAPI().getFilePlanComponent(record.getId());
|
||||
assertStatusCodeIs(NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
@@ -40,8 +40,7 @@ import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import org.alfresco.rest.rm.community.base.BaseRestTest;
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent;
|
||||
import org.alfresco.rest.rm.community.requests.FilePlanComponentAPI;
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentModel;
|
||||
import org.alfresco.utility.data.DataUser;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.testng.annotations.DataProvider;
|
||||
@@ -58,9 +57,6 @@ import org.testng.annotations.Test;
|
||||
*/
|
||||
public class ElectronicRecordTests extends BaseRestTest
|
||||
{
|
||||
@Autowired
|
||||
private FilePlanComponentAPI filePlanComponentAPI;
|
||||
|
||||
@Autowired
|
||||
private DataUser dataUser;
|
||||
|
||||
@@ -73,13 +69,13 @@ public class ElectronicRecordTests extends BaseRestTest
|
||||
return new Object[][] {
|
||||
// record category
|
||||
{ getFilePlanComponentAsUser(dataUser.getAdminUser(),
|
||||
createCategoryFolderInFilePlan(dataUser.getAdminUser(), FILE_PLAN_ALIAS.toString()).getParentId()) },
|
||||
createCategoryFolderInFilePlan(dataUser.getAdminUser(), FILE_PLAN_ALIAS).getParentId()) },
|
||||
// file plan root
|
||||
{ getFilePlanComponentAsUser(dataUser.getAdminUser(), FILE_PLAN_ALIAS.toString()) },
|
||||
{ getFilePlanComponentAsUser(dataUser.getAdminUser(), FILE_PLAN_ALIAS) },
|
||||
// transfers
|
||||
{ getFilePlanComponentAsUser(dataUser.getAdminUser(), TRANSFERS_ALIAS.toString()) },
|
||||
{ getFilePlanComponentAsUser(dataUser.getAdminUser(), TRANSFERS_ALIAS) },
|
||||
// holds
|
||||
{ getFilePlanComponentAsUser(dataUser.getAdminUser(), HOLDS_ALIAS.toString()) },
|
||||
{ getFilePlanComponentAsUser(dataUser.getAdminUser(), HOLDS_ALIAS) },
|
||||
};
|
||||
}
|
||||
|
||||
@@ -98,19 +94,19 @@ public class ElectronicRecordTests extends BaseRestTest
|
||||
dataProvider = "invalidParentContainers",
|
||||
description = "Electronic records can't be created in invalid parent containers"
|
||||
)
|
||||
public void cantCreateElectronicRecordsInInvalidContainers(FilePlanComponent container) throws Exception
|
||||
public void cantCreateElectronicRecordsInInvalidContainers(FilePlanComponentModel container) throws Exception
|
||||
{
|
||||
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// Build object the filePlan
|
||||
FilePlanComponent record = FilePlanComponent.builder()
|
||||
FilePlanComponentModel record = FilePlanComponentModel.builder()
|
||||
.name("Record " + getRandomAlphanumeric())
|
||||
.nodeType(CONTENT_TYPE.toString())
|
||||
.nodeType(CONTENT_TYPE)
|
||||
.build();
|
||||
filePlanComponentAPI.createElectronicRecord(record, IMAGE_FILE, container.getId());
|
||||
getFilePlanComponentsAPI().createElectronicRecord(record, IMAGE_FILE, container.getId());
|
||||
|
||||
// verify the create request status code
|
||||
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(UNPROCESSABLE_ENTITY);
|
||||
assertStatusCodeIs(UNPROCESSABLE_ENTITY);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -126,8 +122,8 @@ public class ElectronicRecordTests extends BaseRestTest
|
||||
@Test(description = "Electronic record can't be created in closed record folder")
|
||||
public void cantCreateElectronicRecordInClosedFolder() throws Exception
|
||||
{
|
||||
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
FilePlanComponent recordFolder = createCategoryFolderInFilePlan(dataUser.getAdminUser(), FILE_PLAN_ALIAS.toString());
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
FilePlanComponentModel recordFolder = createCategoryFolderInFilePlan(dataUser.getAdminUser(), FILE_PLAN_ALIAS);
|
||||
|
||||
// the folder should be open
|
||||
assertFalse(recordFolder.getProperties().getIsClosed());
|
||||
@@ -136,14 +132,14 @@ public class ElectronicRecordTests extends BaseRestTest
|
||||
closeFolder(recordFolder.getId());
|
||||
|
||||
// try to create it, this should fail
|
||||
FilePlanComponent record = FilePlanComponent.builder()
|
||||
FilePlanComponentModel record = FilePlanComponentModel.builder()
|
||||
.name("Record " + getRandomAlphanumeric())
|
||||
.nodeType(CONTENT_TYPE.toString())
|
||||
.nodeType(CONTENT_TYPE)
|
||||
.build();
|
||||
filePlanComponentAPI.createElectronicRecord(record, IMAGE_FILE, recordFolder.getId());
|
||||
getFilePlanComponentsAPI().createElectronicRecord(record, IMAGE_FILE, recordFolder.getId());
|
||||
|
||||
// verify the status code
|
||||
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(UNPROCESSABLE_ENTITY);
|
||||
assertStatusCodeIs(UNPROCESSABLE_ENTITY);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -171,27 +167,27 @@ public class ElectronicRecordTests extends BaseRestTest
|
||||
dataProvider = "validRootContainers",
|
||||
description = "Electronic record can only be created if all mandatory properties are given"
|
||||
)
|
||||
public void canCreateElectronicRecordOnlyWithMandatoryProperties(FilePlanComponent container) throws Exception
|
||||
public void canCreateElectronicRecordOnlyWithMandatoryProperties(FilePlanComponentModel container) throws Exception
|
||||
{
|
||||
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
logger.info("Root container:\n" + toJson(container));
|
||||
if (container.getNodeType().equals(RECORD_FOLDER_TYPE.toString()))
|
||||
if (container.getNodeType().equals(RECORD_FOLDER_TYPE))
|
||||
{
|
||||
// only record folders can be open or closed
|
||||
assertFalse(container.getProperties().getIsClosed());
|
||||
}
|
||||
|
||||
// component without name
|
||||
FilePlanComponent record = FilePlanComponent.builder()
|
||||
.nodeType(CONTENT_TYPE.toString())
|
||||
FilePlanComponentModel record = FilePlanComponentModel.builder()
|
||||
.nodeType(CONTENT_TYPE)
|
||||
.build();
|
||||
|
||||
// try to create it
|
||||
filePlanComponentAPI.createFilePlanComponent(record, container.getId());
|
||||
getFilePlanComponentsAPI().createFilePlanComponent(record, container.getId());
|
||||
|
||||
// verify the status code is BAD_REQUEST
|
||||
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(BAD_REQUEST);
|
||||
assertStatusCodeIs(BAD_REQUEST);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -216,21 +212,21 @@ public class ElectronicRecordTests extends BaseRestTest
|
||||
dataProvider = "validRootContainers",
|
||||
description = "Electronic records can be created in unfiled record folder or unfiled record root"
|
||||
)
|
||||
public void canCreateElectronicRecordsInValidContainers(FilePlanComponent container) throws Exception
|
||||
public void canCreateElectronicRecordsInValidContainers(FilePlanComponentModel container) throws Exception
|
||||
{
|
||||
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
FilePlanComponent record = FilePlanComponent.builder()
|
||||
FilePlanComponentModel record = FilePlanComponentModel.builder()
|
||||
.name("Record " + getRandomAlphanumeric())
|
||||
.nodeType(CONTENT_TYPE.toString())
|
||||
.nodeType(CONTENT_TYPE)
|
||||
.build();
|
||||
String newRecordId = filePlanComponentAPI.createElectronicRecord(record, IMAGE_FILE, container.getId()).getId();
|
||||
String newRecordId = getFilePlanComponentsAPI().createElectronicRecord(record, IMAGE_FILE, container.getId()).getId();
|
||||
|
||||
// verify the create request status code
|
||||
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(CREATED);
|
||||
assertStatusCodeIs(CREATED);
|
||||
|
||||
// get newly created electonic record and verify its properties
|
||||
FilePlanComponent electronicRecord = filePlanComponentAPI.getFilePlanComponent(newRecordId);
|
||||
FilePlanComponentModel electronicRecord = getFilePlanComponentsAPI().getFilePlanComponent(newRecordId);
|
||||
// created record will have record identifier inserted in its name but will be prefixed with
|
||||
// the name it was created as
|
||||
assertTrue(electronicRecord.getName().startsWith(record.getName()));
|
||||
@@ -247,22 +243,22 @@ public class ElectronicRecordTests extends BaseRestTest
|
||||
dataProvider = "validRootContainers",
|
||||
description = "Electronic records can be created in unfiled record folder or unfiled record root"
|
||||
)
|
||||
public void recordNameDerivedFromFileName(FilePlanComponent container) throws Exception
|
||||
public void recordNameDerivedFromFileName(FilePlanComponentModel container) throws Exception
|
||||
{
|
||||
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// record object without name set
|
||||
FilePlanComponent record = FilePlanComponent.builder()
|
||||
.nodeType(CONTENT_TYPE.toString())
|
||||
FilePlanComponentModel record = FilePlanComponentModel.builder()
|
||||
.nodeType(CONTENT_TYPE)
|
||||
.build();
|
||||
|
||||
String newRecordId = filePlanComponentAPI.createElectronicRecord(record, IMAGE_FILE, container.getId()).getId();
|
||||
String newRecordId = getFilePlanComponentsAPI().createElectronicRecord(record, IMAGE_FILE, container.getId()).getId();
|
||||
|
||||
// verify the create request status code
|
||||
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(CREATED);
|
||||
assertStatusCodeIs(CREATED);
|
||||
|
||||
// get newly created electonic record and verify its properties
|
||||
FilePlanComponent electronicRecord = filePlanComponentAPI.getFilePlanComponent(newRecordId);
|
||||
FilePlanComponentModel electronicRecord = getFilePlanComponentsAPI().getFilePlanComponent(newRecordId);
|
||||
// record will have record identifier inserted in its name but will for sure start with file name
|
||||
// and end with its extension
|
||||
assertTrue(electronicRecord.getName().startsWith(IMAGE_FILE.substring(0, IMAGE_FILE.indexOf("."))));
|
||||
|
@@ -43,15 +43,10 @@ import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import org.alfresco.rest.core.RestWrapper;
|
||||
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.FilePlanComponentAlias;
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentModel;
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentProperties;
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType;
|
||||
import org.alfresco.rest.rm.community.requests.FilePlanComponentAPI;
|
||||
import org.alfresco.rest.rm.community.requests.RMSiteAPI;
|
||||
import org.alfresco.utility.data.DataUser;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.alfresco.utility.report.Bug;
|
||||
@@ -67,15 +62,6 @@ import org.testng.annotations.Test;
|
||||
*/
|
||||
public class FilePlanTests extends BaseRestTest
|
||||
{
|
||||
@Autowired
|
||||
private FilePlanComponentAPI filePlanComponentAPI;
|
||||
|
||||
@Autowired
|
||||
protected RestWrapper restWrapper;
|
||||
|
||||
@Autowired
|
||||
private RMSiteAPI rmSiteAPI;
|
||||
|
||||
@Autowired
|
||||
private DataUser dataUser;
|
||||
|
||||
@@ -90,23 +76,23 @@ public class FilePlanTests extends BaseRestTest
|
||||
dataProviderClass = TestData.class,
|
||||
dataProvider = "getContainers"
|
||||
)
|
||||
public void getFilePlanComponentWhenRMIsNotCreated(String filePlanAlias) throws Exception
|
||||
public void getFilePlanComponentWhenRMIsNotCreated(String filePlanComponentAlias) throws Exception
|
||||
{
|
||||
// Check RM Site Exist
|
||||
if (rmSiteAPI.existsRMSite())
|
||||
if (getRMSiteAPI().existsRMSite())
|
||||
{
|
||||
// Delete RM Site
|
||||
rmSiteAPI.deleteRMSite();
|
||||
getRMSiteAPI().deleteRMSite();
|
||||
}
|
||||
|
||||
// Authenticate with admin user
|
||||
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// Get the file plan component
|
||||
filePlanComponentAPI.getFilePlanComponent(filePlanAlias.toString());
|
||||
getFilePlanComponentsAPI().getFilePlanComponent(filePlanComponentAlias);
|
||||
|
||||
//check the response code is NOT_FOUND
|
||||
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(NOT_FOUND);
|
||||
assertStatusCodeIs(NOT_FOUND);
|
||||
}
|
||||
|
||||
|
||||
@@ -122,22 +108,22 @@ public class FilePlanTests extends BaseRestTest
|
||||
dataProviderClass = TestData.class,
|
||||
dataProvider = "getContainersAndTypes"
|
||||
)
|
||||
public void getFilePlanComponentWhenRMIsCreated(FilePlanComponentAlias filePlanAlias, FilePlanComponentType rmType) throws Exception
|
||||
public void getFilePlanComponentWhenRMIsCreated(String filePlanComponentAlias, String filePlanComponentType) throws Exception
|
||||
{
|
||||
// Create RM Site if doesn't exist
|
||||
createRMSiteIfNotExists();
|
||||
|
||||
// Authenticate with admin user
|
||||
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// Get the file plan special container
|
||||
FilePlanComponent filePlanComponent = filePlanComponentAPI.getFilePlanComponent(filePlanAlias.toString());
|
||||
FilePlanComponentModel filePlanComponent = getFilePlanComponentsAPI().getFilePlanComponent(filePlanComponentAlias);
|
||||
|
||||
// Check the response code
|
||||
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(OK);
|
||||
assertStatusCodeIs(OK);
|
||||
|
||||
// Check the response contains the right node type
|
||||
assertEquals(filePlanComponent.getNodeType(), rmType.toString());
|
||||
assertEquals(filePlanComponent.getNodeType(), filePlanComponentType);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -157,13 +143,13 @@ public class FilePlanTests extends BaseRestTest
|
||||
createRMSiteIfNotExists();
|
||||
|
||||
// Authenticate with admin user
|
||||
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// Get the file plan special containers with the optional parameter allowableOperations
|
||||
FilePlanComponent filePlanComponent = filePlanComponentAPI.withParams("include="+ ALLOWABLE_OPERATIONS).getFilePlanComponent(specialContainerAlias);
|
||||
FilePlanComponentModel filePlanComponent = getFilePlanComponentsAPI().getFilePlanComponent(specialContainerAlias, "include=" + ALLOWABLE_OPERATIONS);
|
||||
|
||||
// Check the list of allowableOperations returned
|
||||
if(specialContainerAlias.equals(TRANSFERS_ALIAS.toString()))
|
||||
if(specialContainerAlias.equals(TRANSFERS_ALIAS))
|
||||
{
|
||||
assertTrue(filePlanComponent.getAllowableOperations().containsAll(asList(UPDATE)),
|
||||
"Wrong list of the allowable operations is return" + filePlanComponent.getAllowableOperations().toString());
|
||||
@@ -196,10 +182,10 @@ public class FilePlanTests extends BaseRestTest
|
||||
createRMSiteIfNotExists();
|
||||
|
||||
// Authenticate with admin user
|
||||
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// Build object for updating the filePlan
|
||||
FilePlanComponent filePlanComponent = FilePlanComponent.builder()
|
||||
FilePlanComponentModel filePlanComponent = FilePlanComponentModel.builder()
|
||||
.properties(FilePlanComponentProperties.builder()
|
||||
.title(FILE_PLAN_TITLE)
|
||||
.description(FILE_PLAN_DESCRIPTION)
|
||||
@@ -207,10 +193,10 @@ public class FilePlanTests extends BaseRestTest
|
||||
.build();
|
||||
|
||||
// Update the record category
|
||||
FilePlanComponent renamedFilePlanComponent = filePlanComponentAPI.updateFilePlanComponent(filePlanComponent,FILE_PLAN_ALIAS.toString());
|
||||
FilePlanComponentModel renamedFilePlanComponent = getFilePlanComponentsAPI().updateFilePlanComponent(filePlanComponent, FILE_PLAN_ALIAS);
|
||||
|
||||
// Verify the response status code
|
||||
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(OK);
|
||||
assertStatusCodeIs(OK);
|
||||
|
||||
// Verify the returned description field for the file plan component
|
||||
assertEquals(renamedFilePlanComponent.getProperties().getDescription(), FILE_PLAN_DESCRIPTION);
|
||||
@@ -230,19 +216,19 @@ public class FilePlanTests extends BaseRestTest
|
||||
dataProviderClass = TestData.class,
|
||||
dataProvider = "getContainers"
|
||||
)
|
||||
public void deleteFilePlanSpecialComponents(String filePlanAlias) throws Exception
|
||||
public void deleteFilePlanSpecialComponents(String filePlanComponentAlias) throws Exception
|
||||
{
|
||||
// Create RM Site if doesn't exist
|
||||
createRMSiteIfNotExists();
|
||||
|
||||
// Authenticate with admin user
|
||||
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// Delete the file plan component
|
||||
filePlanComponentAPI.deleteFilePlanComponent(filePlanAlias.toString());
|
||||
getFilePlanComponentsAPI().deleteFilePlanComponent(filePlanComponentAlias);
|
||||
|
||||
// Check the DELETE response status code
|
||||
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(UNPROCESSABLE_ENTITY);
|
||||
assertStatusCodeIs(UNPROCESSABLE_ENTITY);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -256,27 +242,27 @@ public class FilePlanTests extends BaseRestTest
|
||||
dataProviderClass = TestData.class,
|
||||
dataProvider = "getContainers"
|
||||
)
|
||||
public void deleteFilePlanSpecialComponentsNonRMUser(String filePlanAlias) throws Exception
|
||||
public void deleteFilePlanSpecialComponentsNonRMUser(String filePlanComponentAlias) throws Exception
|
||||
{
|
||||
// Create RM Site if doesn't exist
|
||||
createRMSiteIfNotExists();
|
||||
|
||||
// Disconnect the current user from the API session
|
||||
rmSiteAPI.usingRestWrapper().disconnect();
|
||||
disconnect();
|
||||
// Authenticate admin user to Alfresco REST API
|
||||
restClient.authenticateUser(dataUser.getAdminUser());
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// Create a random user
|
||||
UserModel nonRMuser = dataUser.createRandomTestUser("testUser");
|
||||
|
||||
// Authenticate using the random user
|
||||
filePlanComponentAPI.usingRestWrapper().authenticateUser(nonRMuser);
|
||||
authenticateUser(nonRMuser);
|
||||
|
||||
// Delete the file plan component
|
||||
filePlanComponentAPI.deleteFilePlanComponent(filePlanAlias.toString());
|
||||
getFilePlanComponentsAPI().deleteFilePlanComponent(filePlanComponentAlias);
|
||||
|
||||
// Check the DELETE response status code
|
||||
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(FORBIDDEN);
|
||||
assertStatusCodeIs(FORBIDDEN);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -291,40 +277,40 @@ public class FilePlanTests extends BaseRestTest
|
||||
dataProvider = "getContainersAndTypes"
|
||||
)
|
||||
@Bug(id = "RM-4296")
|
||||
public void createFilePlanSpecialContainerWhenExists(FilePlanComponentAlias filePlanAlias, FilePlanComponentType rmType) throws Exception
|
||||
public void createFilePlanSpecialContainerWhenExists(String filePlanComponentAlias, String filePlanComponentType) throws Exception
|
||||
{
|
||||
// Create RM Site if doesn't exist
|
||||
createRMSiteIfNotExists();
|
||||
|
||||
// Authenticate with admin user
|
||||
rmSiteAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// Get the RM site ID
|
||||
String rmSiteId = rmSiteAPI.getSite().getGuid();
|
||||
String name = filePlanAlias + getRandomAlphanumeric();
|
||||
String rmSiteId = getRMSiteAPI().getSite().getGuid();
|
||||
String name = filePlanComponentAlias + getRandomAlphanumeric();
|
||||
|
||||
// Build the file plan root properties
|
||||
FilePlanComponent filePlanComponent = FilePlanComponent.builder()
|
||||
FilePlanComponentModel filePlanComponent = FilePlanComponentModel.builder()
|
||||
.name(name)
|
||||
.nodeType(rmType.toString())
|
||||
.nodeType(filePlanComponentType)
|
||||
.properties(FilePlanComponentProperties.builder()
|
||||
.build())
|
||||
.build();
|
||||
|
||||
// Authenticate with admin user
|
||||
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// Create the special containers into RM site - parent folder
|
||||
filePlanComponentAPI.createFilePlanComponent(filePlanComponent, rmSiteId);
|
||||
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(UNPROCESSABLE_ENTITY);
|
||||
getFilePlanComponentsAPI().createFilePlanComponent(filePlanComponent, rmSiteId);
|
||||
assertStatusCodeIs(UNPROCESSABLE_ENTITY);
|
||||
|
||||
// Create the special containers into RM site - parent folder
|
||||
filePlanComponentAPI.createFilePlanComponent(filePlanComponent, FILE_PLAN_ALIAS.toString());
|
||||
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(UNPROCESSABLE_ENTITY);
|
||||
getFilePlanComponentsAPI().createFilePlanComponent(filePlanComponent, FILE_PLAN_ALIAS);
|
||||
assertStatusCodeIs(UNPROCESSABLE_ENTITY);
|
||||
|
||||
// Create the special containers into the root of special containers containers
|
||||
filePlanComponentAPI.createFilePlanComponent(filePlanComponent, filePlanAlias.toString());
|
||||
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(UNPROCESSABLE_ENTITY);
|
||||
getFilePlanComponentsAPI().createFilePlanComponent(filePlanComponent, filePlanComponentAlias);
|
||||
assertStatusCodeIs(UNPROCESSABLE_ENTITY);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -338,13 +324,13 @@ public class FilePlanTests extends BaseRestTest
|
||||
dataProviderClass = TestData.class,
|
||||
dataProvider = "getContainers"
|
||||
)
|
||||
public void getSpecialFilePlanComponentsWithNonRMuser(String filePlanAlias) throws Exception
|
||||
public void getSpecialFilePlanComponentsWithNonRMuser(String filePlanComponentAlias) throws Exception
|
||||
{
|
||||
// Create RM Site if doesn't exist
|
||||
createRMSiteIfNotExists();
|
||||
|
||||
// Disconnect user from REST API session
|
||||
rmSiteAPI.usingRestWrapper().disconnect();
|
||||
disconnect();
|
||||
|
||||
// Authenticate admin user to Alfresco REST API
|
||||
restClient.authenticateUser(dataUser.getAdminUser());
|
||||
@@ -353,12 +339,12 @@ public class FilePlanTests extends BaseRestTest
|
||||
UserModel nonRMuser = dataUser.createRandomTestUser("testUser");
|
||||
|
||||
// Authenticate using the random user
|
||||
filePlanComponentAPI.usingRestWrapper().authenticateUser(nonRMuser);
|
||||
authenticateUser(nonRMuser);
|
||||
|
||||
// Get the special file plan components
|
||||
filePlanComponentAPI.getFilePlanComponent(filePlanAlias.toString());
|
||||
getFilePlanComponentsAPI().getFilePlanComponent(filePlanComponentAlias);
|
||||
|
||||
// Check the response status code is FORBIDDEN
|
||||
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(FORBIDDEN);
|
||||
assertStatusCodeIs(FORBIDDEN);
|
||||
}
|
||||
}
|
||||
|
@@ -46,10 +46,8 @@ import static org.testng.Assert.assertFalse;
|
||||
import java.util.Random;
|
||||
|
||||
import org.alfresco.rest.rm.community.base.BaseRestTest;
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent;
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentModel;
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentProperties;
|
||||
import org.alfresco.rest.rm.community.requests.FilePlanComponentAPI;
|
||||
import org.alfresco.rest.rm.community.requests.RMSiteAPI;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.data.DataUser;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
@@ -65,15 +63,9 @@ import org.testng.annotations.Test;
|
||||
*/
|
||||
public class NonElectronicRecordTests extends BaseRestTest
|
||||
{
|
||||
@Autowired
|
||||
private FilePlanComponentAPI filePlanComponentAPI;
|
||||
|
||||
@Autowired
|
||||
private DataUser dataUser;
|
||||
|
||||
@Autowired
|
||||
private RMSiteAPI rmSiteAPI;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* Given a parent container that is NOT a record folder or an unfiled record folder
|
||||
@@ -86,37 +78,37 @@ public class NonElectronicRecordTests extends BaseRestTest
|
||||
@Test(description = "Non-electronic record can't be created as a child of invalid parent Id")
|
||||
public void cantCreateForInvalidParentIds() throws Exception
|
||||
{
|
||||
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// non-electronic record object to be used for create tests
|
||||
FilePlanComponent nonElectronicRecord = FilePlanComponent.builder()
|
||||
FilePlanComponentModel nonElectronicRecord = FilePlanComponentModel.builder()
|
||||
.name("Record " + getRandomAlphanumeric())
|
||||
.nodeType(NON_ELECTRONIC_RECORD_TYPE.toString())
|
||||
.nodeType(NON_ELECTRONIC_RECORD_TYPE)
|
||||
.build();
|
||||
|
||||
// create record category, non-electronic records can't be its children
|
||||
FilePlanComponent recordCategoryModel = FilePlanComponent.builder()
|
||||
FilePlanComponentModel recordCategoryModel = FilePlanComponentModel.builder()
|
||||
.name("Category " + getRandomAlphanumeric())
|
||||
.nodeType(RECORD_CATEGORY_TYPE.toString())
|
||||
.nodeType(RECORD_CATEGORY_TYPE)
|
||||
.build();
|
||||
|
||||
FilePlanComponent recordCategory = filePlanComponentAPI.createFilePlanComponent(recordCategoryModel, FILE_PLAN_ALIAS.toString());
|
||||
FilePlanComponentModel recordCategory = getFilePlanComponentsAPI().createFilePlanComponent(recordCategoryModel, FILE_PLAN_ALIAS);
|
||||
|
||||
// iterate through all invalid parent containers and try to create/file an electronic record
|
||||
asList(FILE_PLAN_ALIAS.toString(), TRANSFERS_ALIAS.toString(), HOLDS_ALIAS.toString(), recordCategory.getId())
|
||||
asList(FILE_PLAN_ALIAS, TRANSFERS_ALIAS, HOLDS_ALIAS, recordCategory.getId())
|
||||
.stream()
|
||||
.forEach(id ->
|
||||
{
|
||||
try
|
||||
{
|
||||
filePlanComponentAPI.createFilePlanComponent(nonElectronicRecord, id);
|
||||
getFilePlanComponentsAPI().createFilePlanComponent(nonElectronicRecord, id);
|
||||
}
|
||||
catch (Exception error)
|
||||
{
|
||||
}
|
||||
|
||||
// Verify the status code
|
||||
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(UNPROCESSABLE_ENTITY);
|
||||
assertStatusCodeIs(UNPROCESSABLE_ENTITY);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -142,12 +134,12 @@ public class NonElectronicRecordTests extends BaseRestTest
|
||||
dataProvider = "validRootContainers",
|
||||
description = "Non-electronic records can be created in valid containers"
|
||||
)
|
||||
public void canCreateInValidContainers(FilePlanComponent container) throws Exception
|
||||
public void canCreateInValidContainers(FilePlanComponentModel container) throws Exception
|
||||
{
|
||||
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
logger.info("Root container:\n" + toJson(container));
|
||||
if (container.getNodeType().equals(RECORD_FOLDER_TYPE.toString()))
|
||||
if (container.getNodeType().equals(RECORD_FOLDER_TYPE))
|
||||
{
|
||||
// only record folders can be open or closed
|
||||
assertFalse(container.getProperties().getIsClosed());
|
||||
@@ -166,9 +158,9 @@ public class NonElectronicRecordTests extends BaseRestTest
|
||||
Integer size = random.nextInt(Integer.MAX_VALUE);
|
||||
|
||||
// set values of all available properties for the non electronic records
|
||||
FilePlanComponent filePlanComponent = FilePlanComponent.builder()
|
||||
FilePlanComponentModel filePlanComponent = FilePlanComponentModel.builder()
|
||||
.name("Record " + getRandomAlphanumeric())
|
||||
.nodeType(NON_ELECTRONIC_RECORD_TYPE.toString())
|
||||
.nodeType(NON_ELECTRONIC_RECORD_TYPE)
|
||||
.properties(FilePlanComponentProperties.builder()
|
||||
.title(title)
|
||||
.description(description)
|
||||
@@ -182,15 +174,15 @@ public class NonElectronicRecordTests extends BaseRestTest
|
||||
.build();
|
||||
|
||||
// create non-electronic record
|
||||
String nonElectronicId = filePlanComponentAPI.createFilePlanComponent(
|
||||
String nonElectronicId = getFilePlanComponentsAPI().createFilePlanComponent(
|
||||
filePlanComponent,
|
||||
container.getId()).getId();
|
||||
|
||||
// verify the create request status code
|
||||
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(CREATED);
|
||||
assertStatusCodeIs(CREATED);
|
||||
|
||||
// get newly created non-electonic record and verify its properties
|
||||
FilePlanComponent nonElectronicRecord = filePlanComponentAPI.getFilePlanComponent(nonElectronicId);
|
||||
FilePlanComponentModel nonElectronicRecord = getFilePlanComponentsAPI().getFilePlanComponent(nonElectronicId);
|
||||
|
||||
assertEquals(title, nonElectronicRecord.getProperties().getTitle());
|
||||
assertEquals(description, nonElectronicRecord.getProperties().getDescription());
|
||||
@@ -215,8 +207,8 @@ public class NonElectronicRecordTests extends BaseRestTest
|
||||
@Test(description = "Non-electronic record can't be created in closed record folder")
|
||||
public void cantCreateInClosedFolder() throws Exception
|
||||
{
|
||||
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
FilePlanComponent recordFolder = createCategoryFolderInFilePlan(dataUser.getAdminUser(), FILE_PLAN_ALIAS.toString());
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
FilePlanComponentModel recordFolder = createCategoryFolderInFilePlan(dataUser.getAdminUser(), FILE_PLAN_ALIAS);
|
||||
|
||||
// the folder should be open
|
||||
assertFalse(recordFolder.getProperties().getIsClosed());
|
||||
@@ -226,15 +218,15 @@ public class NonElectronicRecordTests extends BaseRestTest
|
||||
|
||||
// try to create it, this should fail and throw an exception
|
||||
|
||||
filePlanComponentAPI.createFilePlanComponent(FilePlanComponent.builder()
|
||||
getFilePlanComponentsAPI().createFilePlanComponent(FilePlanComponentModel.builder()
|
||||
.name("Record " + getRandomAlphanumeric())
|
||||
.nodeType(NON_ELECTRONIC_RECORD_TYPE.toString())
|
||||
.nodeType(NON_ELECTRONIC_RECORD_TYPE)
|
||||
.build(),
|
||||
recordFolder.getId())
|
||||
.getId();
|
||||
|
||||
// verify the status code
|
||||
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(UNPROCESSABLE_ENTITY);
|
||||
assertStatusCodeIs(UNPROCESSABLE_ENTITY);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -261,22 +253,22 @@ public class NonElectronicRecordTests extends BaseRestTest
|
||||
dataProvider = "validRootContainers",
|
||||
description = "Non-electronic record can only be created if all mandatory properties are given"
|
||||
)
|
||||
public void allMandatoryPropertiesRequired(FilePlanComponent container) throws Exception
|
||||
public void allMandatoryPropertiesRequired(FilePlanComponentModel container) throws Exception
|
||||
{
|
||||
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
logger.info("Root container:\n" + toJson(container));
|
||||
if (container.getNodeType().equals(RECORD_FOLDER_TYPE.toString()))
|
||||
if (container.getNodeType().equals(RECORD_FOLDER_TYPE))
|
||||
{
|
||||
// only record folders can be open or closed
|
||||
assertFalse(container.getProperties().getIsClosed());
|
||||
}
|
||||
|
||||
// component without name and title
|
||||
FilePlanComponent noNameOrTitle = getDummyNonElectronicRecord();
|
||||
FilePlanComponentModel noNameOrTitle = getDummyNonElectronicRecord();
|
||||
|
||||
// component with title only
|
||||
FilePlanComponent titleOnly = getDummyNonElectronicRecord();
|
||||
FilePlanComponentModel titleOnly = getDummyNonElectronicRecord();
|
||||
FilePlanComponentProperties properties = FilePlanComponentProperties.builder()
|
||||
.title("Title " + getRandomAlphanumeric())
|
||||
.build();
|
||||
@@ -296,14 +288,14 @@ public class NonElectronicRecordTests extends BaseRestTest
|
||||
// this should fail and throw an exception
|
||||
try
|
||||
{
|
||||
filePlanComponentAPI.createFilePlanComponent(c, container.getId());
|
||||
getFilePlanComponentsAPI().createFilePlanComponent(c, container.getId());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
|
||||
// verify the status code is BAD_REQUEST
|
||||
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(BAD_REQUEST);
|
||||
assertStatusCodeIs(BAD_REQUEST);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -321,45 +313,45 @@ public class NonElectronicRecordTests extends BaseRestTest
|
||||
dataProvider = "validRootContainers",
|
||||
description = "Non-electronic record can't be created if user doesn't have RM privileges"
|
||||
)
|
||||
public void cantCreateIfNoRmPrivileges(FilePlanComponent container) throws Exception
|
||||
public void cantCreateIfNoRmPrivileges(FilePlanComponentModel container) throws Exception
|
||||
{
|
||||
String username = "zzzuser";
|
||||
UserModel user = createUserWithRole(username, UserRole.SiteManager);
|
||||
|
||||
filePlanComponentAPI.usingRestWrapper().authenticateUser(user);
|
||||
authenticateUser(user);
|
||||
|
||||
// try to create a fileplan component
|
||||
FilePlanComponent record=FilePlanComponent.builder()
|
||||
FilePlanComponentModel record = FilePlanComponentModel.builder()
|
||||
.properties(FilePlanComponentProperties.builder()
|
||||
.description("Description")
|
||||
.title("Title")
|
||||
.build())
|
||||
.name("Record Name")
|
||||
.nodeType(NON_ELECTRONIC_RECORD_TYPE.toString())
|
||||
.nodeType(NON_ELECTRONIC_RECORD_TYPE)
|
||||
.build();
|
||||
|
||||
|
||||
// this should fail and throw an exception
|
||||
try
|
||||
{
|
||||
filePlanComponentAPI.createFilePlanComponent(record, container.getId());
|
||||
getFilePlanComponentsAPI().createFilePlanComponent(record, container.getId());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
|
||||
// user who isn't an RM site member can't access the container path
|
||||
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(FORBIDDEN);
|
||||
assertStatusCodeIs(FORBIDDEN);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to return an empty FilePlanComponent for non-electronic record
|
||||
* @return
|
||||
*/
|
||||
private FilePlanComponent getDummyNonElectronicRecord()
|
||||
private FilePlanComponentModel getDummyNonElectronicRecord()
|
||||
{
|
||||
FilePlanComponent component=FilePlanComponent.builder()
|
||||
.nodeType(NON_ELECTRONIC_RECORD_TYPE.toString())
|
||||
FilePlanComponentModel component = FilePlanComponentModel.builder()
|
||||
.nodeType(NON_ELECTRONIC_RECORD_TYPE)
|
||||
.build();
|
||||
return component;
|
||||
}
|
||||
@@ -378,8 +370,8 @@ public class NonElectronicRecordTests extends BaseRestTest
|
||||
*/
|
||||
private UserModel createUserWithRole(String userName, UserRole userRole) throws Exception
|
||||
{
|
||||
rmSiteAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
String siteId = rmSiteAPI.getSite().getId();
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
String siteId = getRMSiteAPI().getSite().getId();
|
||||
|
||||
// check if user exists
|
||||
UserModel user = new UserModel();
|
||||
|
@@ -44,14 +44,11 @@ import static org.testng.Assert.fail;
|
||||
import java.util.ArrayList;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
import org.alfresco.rest.core.RestWrapper;
|
||||
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.FilePlanComponentModel;
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentProperties;
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType;
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentsCollection;
|
||||
import org.alfresco.rest.rm.community.requests.FilePlanComponentAPI;
|
||||
import org.alfresco.utility.data.DataUser;
|
||||
import org.alfresco.utility.report.Bug;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -66,9 +63,6 @@ import org.testng.annotations.Test;
|
||||
*/
|
||||
public class RecordCategoryTest extends BaseRestTest
|
||||
{
|
||||
@Autowired
|
||||
private FilePlanComponentAPI filePlanComponentAPI;
|
||||
|
||||
@Autowired
|
||||
private DataUser dataUser;
|
||||
|
||||
@@ -88,15 +82,15 @@ public class RecordCategoryTest extends BaseRestTest
|
||||
public void createCategoryTest() throws Exception
|
||||
{
|
||||
// Authenticate with admin user
|
||||
RestWrapper restWrapper = filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
String categoryName = "Category name " + getRandomAlphanumeric();
|
||||
String categoryTitle = "Category title " + getRandomAlphanumeric();
|
||||
|
||||
// Build the record category properties
|
||||
FilePlanComponent recordCategory = FilePlanComponent.builder()
|
||||
FilePlanComponentModel recordCategory = FilePlanComponentModel.builder()
|
||||
.name(categoryName)
|
||||
.nodeType(RECORD_CATEGORY_TYPE.toString())
|
||||
.nodeType(RECORD_CATEGORY_TYPE)
|
||||
.properties(
|
||||
FilePlanComponentProperties.builder()
|
||||
.title(categoryTitle)
|
||||
@@ -104,10 +98,10 @@ public class RecordCategoryTest extends BaseRestTest
|
||||
.build();
|
||||
|
||||
// Create the record category
|
||||
FilePlanComponent filePlanComponent = filePlanComponentAPI.createFilePlanComponent(recordCategory, FILE_PLAN_ALIAS.toString());
|
||||
FilePlanComponentModel filePlanComponent = getFilePlanComponentsAPI().createFilePlanComponent(recordCategory, FILE_PLAN_ALIAS);
|
||||
|
||||
// Verify the status code
|
||||
restWrapper.assertStatusCodeIs(CREATED);
|
||||
assertStatusCodeIs(CREATED);
|
||||
|
||||
// Verify the returned file plan component
|
||||
assertTrue(filePlanComponent.getIsCategory());
|
||||
@@ -115,7 +109,7 @@ public class RecordCategoryTest extends BaseRestTest
|
||||
assertFalse(filePlanComponent.getIsRecordFolder());
|
||||
|
||||
assertEquals(filePlanComponent.getName(), categoryName);
|
||||
assertEquals(filePlanComponent.getNodeType(), RECORD_CATEGORY_TYPE.toString());
|
||||
assertEquals(filePlanComponent.getNodeType(), RECORD_CATEGORY_TYPE);
|
||||
|
||||
assertEquals(filePlanComponent.getCreatedByUser().getId(), dataUser.getAdminUser().getUsername());
|
||||
|
||||
@@ -139,16 +133,16 @@ public class RecordCategoryTest extends BaseRestTest
|
||||
public void renameCategory() throws Exception
|
||||
{
|
||||
// Authenticate with admin user
|
||||
RestWrapper restWrapper = filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// Create record category first
|
||||
String categoryName = "Category name " + getRandomAlphanumeric();
|
||||
String categoryTitle = "Category title " + getRandomAlphanumeric();
|
||||
|
||||
// Build the record category properties
|
||||
FilePlanComponent recordCategory = FilePlanComponent.builder()
|
||||
FilePlanComponentModel recordCategory = FilePlanComponentModel.builder()
|
||||
.name(categoryName)
|
||||
.nodeType(RECORD_CATEGORY_TYPE.toString())
|
||||
.nodeType(RECORD_CATEGORY_TYPE)
|
||||
.properties(
|
||||
FilePlanComponentProperties.builder()
|
||||
.title(categoryTitle)
|
||||
@@ -156,24 +150,24 @@ public class RecordCategoryTest extends BaseRestTest
|
||||
.build();
|
||||
|
||||
// Create the record category
|
||||
FilePlanComponent filePlanComponent = filePlanComponentAPI.createFilePlanComponent(recordCategory, FILE_PLAN_ALIAS.toString());
|
||||
FilePlanComponentModel filePlanComponent = getFilePlanComponentsAPI().createFilePlanComponent(recordCategory, FILE_PLAN_ALIAS);
|
||||
|
||||
String newCategoryName = "Rename " + categoryName;
|
||||
|
||||
// Build the properties which will be updated
|
||||
FilePlanComponent recordCategoryUpdated = FilePlanComponent.builder().name(newCategoryName).build();
|
||||
FilePlanComponentModel recordCategoryUpdated = FilePlanComponentModel.builder().name(newCategoryName).build();
|
||||
|
||||
// Update the record category
|
||||
FilePlanComponent renamedFilePlanComponent = filePlanComponentAPI.updateFilePlanComponent(recordCategoryUpdated, filePlanComponent.getId());
|
||||
FilePlanComponentModel renamedFilePlanComponent = getFilePlanComponentsAPI().updateFilePlanComponent(recordCategoryUpdated, filePlanComponent.getId());
|
||||
|
||||
// Verify the status code
|
||||
restWrapper.assertStatusCodeIs(OK);
|
||||
assertStatusCodeIs(OK);
|
||||
|
||||
// Verify the returned file plan component
|
||||
assertEquals(renamedFilePlanComponent.getName(), newCategoryName);
|
||||
|
||||
// Get actual FILE_PLAN_ALIAS id
|
||||
FilePlanComponent parentComponent = filePlanComponentAPI.getFilePlanComponent(FILE_PLAN_ALIAS.toString());
|
||||
FilePlanComponentModel parentComponent = getFilePlanComponentsAPI().getFilePlanComponent(FILE_PLAN_ALIAS);
|
||||
|
||||
// verify renamed component still has this parent
|
||||
assertEquals(renamedFilePlanComponent.getParentId(), parentComponent.getId());
|
||||
@@ -192,16 +186,16 @@ public class RecordCategoryTest extends BaseRestTest
|
||||
public void deleteCategory() throws Exception
|
||||
{
|
||||
// Authenticate with admin user
|
||||
RestWrapper restWrapper = filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// Create record category first
|
||||
String categoryName = "Category name " + getRandomAlphanumeric();
|
||||
String categoryTitle = "Category title " + getRandomAlphanumeric();
|
||||
|
||||
// Build the record category properties
|
||||
FilePlanComponent recordCategory = FilePlanComponent.builder()
|
||||
FilePlanComponentModel recordCategory = FilePlanComponentModel.builder()
|
||||
.name(categoryName)
|
||||
.nodeType(RECORD_CATEGORY_TYPE.toString())
|
||||
.nodeType(RECORD_CATEGORY_TYPE)
|
||||
.properties(
|
||||
FilePlanComponentProperties.builder()
|
||||
.title(categoryTitle)
|
||||
@@ -209,17 +203,17 @@ public class RecordCategoryTest extends BaseRestTest
|
||||
.build();
|
||||
|
||||
// Create the record category
|
||||
FilePlanComponent filePlanComponent = filePlanComponentAPI.createFilePlanComponent(recordCategory, FILE_PLAN_ALIAS.toString());
|
||||
FilePlanComponentModel filePlanComponent = getFilePlanComponentsAPI().createFilePlanComponent(recordCategory, FILE_PLAN_ALIAS);
|
||||
|
||||
// Delete the record category
|
||||
filePlanComponentAPI.deleteFilePlanComponent(filePlanComponent.getId());
|
||||
getFilePlanComponentsAPI().deleteFilePlanComponent(filePlanComponent.getId());
|
||||
|
||||
// Verify the status code
|
||||
restWrapper.assertStatusCodeIs(NO_CONTENT);
|
||||
assertStatusCodeIs(NO_CONTENT);
|
||||
|
||||
// Deleted component should no longer be retrievable
|
||||
filePlanComponentAPI.getFilePlanComponent(filePlanComponent.getId());
|
||||
restWrapper.assertStatusCodeIs(NOT_FOUND);
|
||||
getFilePlanComponentsAPI().getFilePlanComponent(filePlanComponent.getId());
|
||||
assertStatusCodeIs(NOT_FOUND);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -235,11 +229,11 @@ public class RecordCategoryTest extends BaseRestTest
|
||||
public void createSubcategory() throws Exception
|
||||
{
|
||||
// Create root level category
|
||||
FilePlanComponent rootCategory = createCategory(FILE_PLAN_ALIAS.toString(), getRandomAlphanumeric());
|
||||
FilePlanComponentModel rootCategory = createCategory(FILE_PLAN_ALIAS, getRandomAlphanumeric());
|
||||
assertNotNull(rootCategory.getId());
|
||||
|
||||
// Create subcategory as a child of rootCategory
|
||||
FilePlanComponent childCategory = createCategory(rootCategory.getId(), getRandomAlphanumeric());
|
||||
FilePlanComponentModel childCategory = createCategory(rootCategory.getId(), getRandomAlphanumeric());
|
||||
|
||||
// Child category created?
|
||||
assertNotNull(childCategory.getId());
|
||||
@@ -249,7 +243,7 @@ public class RecordCategoryTest extends BaseRestTest
|
||||
assertTrue(childCategory.getIsCategory());
|
||||
assertFalse(childCategory.getIsFile());
|
||||
assertFalse(childCategory.getIsRecordFolder());
|
||||
assertEquals(childCategory.getNodeType(), RECORD_CATEGORY_TYPE.toString());
|
||||
assertEquals(childCategory.getNodeType(), RECORD_CATEGORY_TYPE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -267,15 +261,15 @@ public class RecordCategoryTest extends BaseRestTest
|
||||
public void listChildren() throws Exception
|
||||
{
|
||||
// Create root level category
|
||||
FilePlanComponent rootCategory = createCategory(FILE_PLAN_ALIAS.toString(), getRandomAlphanumeric());
|
||||
FilePlanComponentModel rootCategory = createCategory(FILE_PLAN_ALIAS, getRandomAlphanumeric());
|
||||
assertNotNull(rootCategory.getId());
|
||||
|
||||
// Add child categories/folders
|
||||
ArrayList<FilePlanComponent> children = new ArrayList<FilePlanComponent>();
|
||||
ArrayList<FilePlanComponentModel> children = new ArrayList<FilePlanComponentModel>();
|
||||
for (int i=0; i < NUMBER_OF_CHILDREN; i++)
|
||||
{
|
||||
// Create a child
|
||||
FilePlanComponent child = createComponent(rootCategory.getId(),
|
||||
FilePlanComponentModel child = createComponent(rootCategory.getId(),
|
||||
getRandomAlphanumeric(),
|
||||
// half of the children should be subcategories, the other subfolders
|
||||
(i <= NUMBER_OF_CHILDREN / 2) ? RECORD_CATEGORY_TYPE : RECORD_FOLDER_TYPE);
|
||||
@@ -284,26 +278,26 @@ public class RecordCategoryTest extends BaseRestTest
|
||||
}
|
||||
|
||||
// Authenticate with admin user
|
||||
RestWrapper restWrapper = filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// List children from API
|
||||
FilePlanComponentsCollection apiChildren = filePlanComponentAPI.listChildComponents(rootCategory.getId());
|
||||
FilePlanComponentsCollection apiChildren = getFilePlanComponentsAPI().listChildComponents(rootCategory.getId());
|
||||
|
||||
// Check status code
|
||||
restWrapper.assertStatusCodeIs(OK);
|
||||
assertStatusCodeIs(OK);
|
||||
logger.info("parent: " + rootCategory.getId());
|
||||
|
||||
// Check listed children against created list
|
||||
apiChildren.getEntries().forEach(c ->
|
||||
{
|
||||
FilePlanComponent filePlanComponent = c.getFilePlanComponent();
|
||||
FilePlanComponentModel filePlanComponent = c.getFilePlanComponentModel();
|
||||
assertNotNull(filePlanComponent.getId());
|
||||
logger.info("Checking child " + filePlanComponent.getId());
|
||||
|
||||
try
|
||||
{
|
||||
// Find this child in created children list
|
||||
FilePlanComponent createdComponent = children.stream()
|
||||
FilePlanComponentModel createdComponent = children.stream()
|
||||
.filter(child -> child.getId().equals(filePlanComponent.getId()))
|
||||
.findFirst()
|
||||
.get();
|
||||
@@ -319,7 +313,7 @@ public class RecordCategoryTest extends BaseRestTest
|
||||
|
||||
// Boolean properties related to node type
|
||||
// Only RECORD_CATEGORY_TYPE and RECORD_FOLDER_TYPE have been created
|
||||
if (filePlanComponent.getNodeType().equals(RECORD_CATEGORY_TYPE.toString()))
|
||||
if (filePlanComponent.getNodeType().equals(RECORD_CATEGORY_TYPE))
|
||||
{
|
||||
assertTrue(filePlanComponent.getIsCategory());
|
||||
assertFalse(filePlanComponent.getIsRecordFolder());
|
||||
@@ -362,13 +356,13 @@ public class RecordCategoryTest extends BaseRestTest
|
||||
String COMPONENT_NAME = "Component"+getRandomAlphanumeric();
|
||||
|
||||
// Authenticate with admin user
|
||||
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
//Create the category
|
||||
FilePlanComponent category = createCategory(FILE_PLAN_ALIAS.toString(), COMPONENT_NAME);
|
||||
FilePlanComponentModel category = createCategory(FILE_PLAN_ALIAS, COMPONENT_NAME);
|
||||
|
||||
//Build node properties
|
||||
FilePlanComponent recordCategory = FilePlanComponent.builder()
|
||||
FilePlanComponentModel recordCategory = FilePlanComponentModel.builder()
|
||||
.name(COMPONENT_NAME)
|
||||
.nodeType(nodeType)
|
||||
.properties(
|
||||
@@ -378,8 +372,8 @@ public class RecordCategoryTest extends BaseRestTest
|
||||
.build();
|
||||
|
||||
//create the invalid node type
|
||||
filePlanComponentAPI.createFilePlanComponent(recordCategory, category.getId());
|
||||
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(UNPROCESSABLE_ENTITY);
|
||||
getFilePlanComponentsAPI().createFilePlanComponent(recordCategory, category.getId());
|
||||
assertStatusCodeIs(UNPROCESSABLE_ENTITY);
|
||||
}
|
||||
|
||||
|
||||
@@ -391,7 +385,7 @@ public class RecordCategoryTest extends BaseRestTest
|
||||
* @return The created category
|
||||
* @throws Exception on unsuccessful component creation
|
||||
*/
|
||||
public FilePlanComponent createCategory(String parentCategoryId, String categoryName) throws Exception
|
||||
public FilePlanComponentModel createCategory(String parentCategoryId, String categoryName) throws Exception
|
||||
{
|
||||
return createComponent(parentCategoryId, categoryName, RECORD_CATEGORY_TYPE);
|
||||
}
|
||||
@@ -405,20 +399,22 @@ public class RecordCategoryTest extends BaseRestTest
|
||||
* @return The created file plan component
|
||||
* @throws Exception
|
||||
*/
|
||||
private FilePlanComponent createComponent(String parentComponentId, String componentName, FilePlanComponentType componentType) throws Exception
|
||||
private FilePlanComponentModel createComponent(String parentComponentId, String componentName, String componentType) throws Exception
|
||||
{
|
||||
RestWrapper restWrapper = filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
//Build node properties
|
||||
FilePlanComponent component = FilePlanComponent.builder()
|
||||
FilePlanComponentModel component = FilePlanComponentModel.builder()
|
||||
.name(componentName)
|
||||
.nodeType(componentType.toString())
|
||||
.nodeType(componentType)
|
||||
.properties(FilePlanComponentProperties.builder()
|
||||
.title("Title for " + componentName)
|
||||
.build())
|
||||
.build();
|
||||
|
||||
FilePlanComponent fpc = filePlanComponentAPI.createFilePlanComponent(component, parentComponentId);
|
||||
restWrapper.assertStatusCodeIs(CREATED);
|
||||
FilePlanComponentModel fpc = getFilePlanComponentsAPI().createFilePlanComponent(component, parentComponentId);
|
||||
assertStatusCodeIs(CREATED);
|
||||
|
||||
return fpc;
|
||||
}
|
||||
}
|
||||
|
@@ -49,14 +49,12 @@ import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
import org.alfresco.rest.core.RestWrapper;
|
||||
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.FilePlanComponentModel;
|
||||
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.ReviewPeriod;
|
||||
import org.alfresco.rest.rm.community.requests.FilePlanComponentAPI;
|
||||
import org.alfresco.utility.data.DataUser;
|
||||
import org.alfresco.utility.report.Bug;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -72,9 +70,6 @@ import org.testng.annotations.Test;
|
||||
*/
|
||||
public class RecordFolderTests extends BaseRestTest
|
||||
{
|
||||
@Autowired
|
||||
public FilePlanComponentAPI filePlanComponentAPI;
|
||||
|
||||
@Autowired
|
||||
public DataUser dataUser;
|
||||
|
||||
@@ -92,22 +87,21 @@ public class RecordFolderTests extends BaseRestTest
|
||||
{
|
||||
String CATEGORY = CATEGORY_NAME + getRandomAlphanumeric();
|
||||
// Authenticate with admin user
|
||||
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
FilePlanComponent filePlanComponent = createCategory(FILE_PLAN_ALIAS.toString(), CATEGORY);
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
FilePlanComponentModel filePlanComponent = createCategory(FILE_PLAN_ALIAS, CATEGORY);
|
||||
|
||||
FilePlanComponent recordFolder = FilePlanComponent.builder()
|
||||
FilePlanComponentModel recordFolder = FilePlanComponentModel.builder()
|
||||
.name(FOLDER_NAME)
|
||||
.nodeType(RECORD_FOLDER_TYPE.toString())
|
||||
.nodeType(RECORD_FOLDER_TYPE)
|
||||
.properties(FilePlanComponentProperties.builder()
|
||||
.title(FOLDER_TITLE)
|
||||
.build())
|
||||
.build();
|
||||
|
||||
// Create the record folder
|
||||
FilePlanComponent folder = filePlanComponentAPI.createFilePlanComponent(recordFolder, filePlanComponent.getId());
|
||||
FilePlanComponentModel folder = getFilePlanComponentsAPI().createFilePlanComponent(recordFolder, filePlanComponent.getId());
|
||||
|
||||
|
||||
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(CREATED);
|
||||
assertStatusCodeIs(CREATED);
|
||||
|
||||
// Check folder has been created within the category created
|
||||
assertEquals(filePlanComponent.getId(),folder.getParentId());
|
||||
@@ -117,7 +111,7 @@ public class RecordFolderTests extends BaseRestTest
|
||||
assertTrue(folder.getIsRecordFolder());
|
||||
|
||||
assertEquals(folder.getName(), FOLDER_NAME);
|
||||
assertEquals(folder.getNodeType(), RECORD_FOLDER_TYPE.toString());
|
||||
assertEquals(folder.getNodeType(), RECORD_FOLDER_TYPE);
|
||||
assertEquals(folder.getCreatedByUser().getId(), dataUser.getAdminUser().getUsername());
|
||||
|
||||
// Verify the returned file plan component properties
|
||||
@@ -140,24 +134,24 @@ public class RecordFolderTests extends BaseRestTest
|
||||
public void createFolderIntoSpecialContainers(String filePlanComponent) throws Exception
|
||||
{
|
||||
// Authenticate with admin user
|
||||
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
String componentID = filePlanComponentAPI.getFilePlanComponent(filePlanComponent).getId();
|
||||
String componentID = getFilePlanComponentsAPI().getFilePlanComponent(filePlanComponent).getId();
|
||||
|
||||
// Build the record category properties
|
||||
FilePlanComponent recordFolder = FilePlanComponent.builder()
|
||||
FilePlanComponentModel recordFolder = FilePlanComponentModel.builder()
|
||||
.name(FOLDER_NAME)
|
||||
.nodeType(RECORD_FOLDER_TYPE.toString())
|
||||
.nodeType(RECORD_FOLDER_TYPE)
|
||||
.properties(FilePlanComponentProperties.builder()
|
||||
.title(FOLDER_TITLE)
|
||||
.build())
|
||||
.build();
|
||||
|
||||
// Create a record folder
|
||||
filePlanComponentAPI.createFilePlanComponent(recordFolder, componentID);
|
||||
getFilePlanComponentsAPI().createFilePlanComponent(recordFolder, componentID);
|
||||
|
||||
// Check the API Response code
|
||||
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(UNPROCESSABLE_ENTITY);
|
||||
assertStatusCodeIs(UNPROCESSABLE_ENTITY);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -173,14 +167,14 @@ public class RecordFolderTests extends BaseRestTest
|
||||
{
|
||||
String CATEGORY = CATEGORY_NAME + getRandomAlphanumeric();
|
||||
// Authenticate with admin user
|
||||
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
FilePlanComponent category = createCategory(FILE_PLAN_ALIAS.toString(), CATEGORY);
|
||||
FilePlanComponent folder = createFolder(category.getId(),FOLDER_NAME);
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
FilePlanComponentModel category = createCategory(FILE_PLAN_ALIAS, CATEGORY);
|
||||
FilePlanComponentModel folder = createFolder(category.getId(),FOLDER_NAME);
|
||||
|
||||
FilePlanComponent folderDetails = filePlanComponentAPI.withParams("include="+IS_CLOSED).getFilePlanComponent(folder.getId());
|
||||
FilePlanComponentModel folderDetails = getFilePlanComponentsAPI().getFilePlanComponent(folder.getId(), "include=" + IS_CLOSED);
|
||||
|
||||
// Verify the returned properties for the file plan component - record folder
|
||||
assertEquals(RECORD_FOLDER_TYPE.toString(),folderDetails.getNodeType());
|
||||
assertEquals(RECORD_FOLDER_TYPE, folderDetails.getNodeType());
|
||||
assertTrue(folderDetails.getIsRecordFolder());
|
||||
assertFalse(folderDetails.getIsCategory());
|
||||
assertFalse(folderDetails.getIsFile());
|
||||
@@ -190,7 +184,6 @@ public class RecordFolderTests extends BaseRestTest
|
||||
assertEquals(dataUser.getAdminUser().getUsername(),folderDetails.getCreatedByUser().getId());
|
||||
assertEquals(dataUser.getAdminUser().getUsername(), folderDetails.getModifiedByUser().getId());
|
||||
assertEquals(FOLDER_TITLE,folderDetails.getProperties().getTitle());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -208,13 +201,15 @@ public class RecordFolderTests extends BaseRestTest
|
||||
public void updateTheRecordFolderProperties() throws Exception
|
||||
{
|
||||
String CATEGORY = CATEGORY_NAME + getRandomAlphanumeric();
|
||||
|
||||
// Authenticate with admin user
|
||||
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
//Create a record category
|
||||
FilePlanComponent category = createCategory(FILE_PLAN_ALIAS.toString(), CATEGORY);
|
||||
FilePlanComponentModel category = createCategory(FILE_PLAN_ALIAS, CATEGORY);
|
||||
|
||||
//Create a record folder
|
||||
FilePlanComponent folder = createFolder(category.getId(), FOLDER_NAME);
|
||||
FilePlanComponentModel folder = createFolder(category.getId(), FOLDER_NAME);
|
||||
|
||||
// Create record category first
|
||||
String folderDescription = "The folder description is updated" + getRandomAlphanumeric();
|
||||
@@ -223,7 +218,7 @@ public class RecordFolderTests extends BaseRestTest
|
||||
String location = "Location"+getRandomAlphanumeric();
|
||||
|
||||
//Create the file plan component properties to update
|
||||
FilePlanComponent recordFolder = FilePlanComponent.builder()
|
||||
FilePlanComponentModel recordFolder = FilePlanComponentModel.builder()
|
||||
.name(folderName)
|
||||
.properties(FilePlanComponentProperties.builder()
|
||||
.title(folderTitle)
|
||||
@@ -235,10 +230,10 @@ public class RecordFolderTests extends BaseRestTest
|
||||
.build();
|
||||
|
||||
// Update the record category
|
||||
FilePlanComponent folderUpdated = filePlanComponentAPI.updateFilePlanComponent(recordFolder, folder.getId());
|
||||
FilePlanComponentModel folderUpdated = getFilePlanComponentsAPI().updateFilePlanComponent(recordFolder, folder.getId());
|
||||
|
||||
// Check the Response Status Code
|
||||
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(OK);
|
||||
assertStatusCodeIs(OK);
|
||||
|
||||
// Verify the returned properties for the file plan component - record folder
|
||||
assertEquals(folderName, folderUpdated.getName());
|
||||
@@ -265,21 +260,23 @@ public class RecordFolderTests extends BaseRestTest
|
||||
String CATEGORY = CATEGORY_NAME + getRandomAlphanumeric();
|
||||
|
||||
// Authenticate with admin user
|
||||
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// Create the record category
|
||||
FilePlanComponent category = createCategory(FILE_PLAN_ALIAS.toString(), CATEGORY);
|
||||
FilePlanComponentModel category = createCategory(FILE_PLAN_ALIAS, CATEGORY);
|
||||
|
||||
// Create the record folder
|
||||
FilePlanComponent folder = createFolder(category.getId(), FOLDER_NAME);
|
||||
FilePlanComponentModel folder = createFolder(category.getId(), FOLDER_NAME);
|
||||
|
||||
// Delete the Record folder
|
||||
filePlanComponentAPI.deleteFilePlanComponent(folder.getId());
|
||||
getFilePlanComponentsAPI().deleteFilePlanComponent(folder.getId());
|
||||
// Check the Response Status Code
|
||||
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(NO_CONTENT);
|
||||
assertStatusCodeIs(NO_CONTENT);
|
||||
|
||||
// Check the File Plan Component is not found
|
||||
filePlanComponentAPI.getFilePlanComponent(folder.getId());
|
||||
getFilePlanComponentsAPI().getFilePlanComponent(folder.getId());
|
||||
// Check the Response Status Code
|
||||
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(NOT_FOUND);
|
||||
assertStatusCodeIs(NOT_FOUND);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -299,40 +296,40 @@ public class RecordFolderTests extends BaseRestTest
|
||||
String CATEGORY = CATEGORY_NAME + getRandomAlphanumeric();
|
||||
|
||||
// Authenticate with admin user
|
||||
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
FilePlanComponent category = createCategory(FILE_PLAN_ALIAS.toString(), CATEGORY);
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
FilePlanComponentModel category = createCategory(FILE_PLAN_ALIAS, CATEGORY);
|
||||
|
||||
// Add child olders
|
||||
ArrayList<FilePlanComponent> children = new ArrayList<FilePlanComponent>();
|
||||
ArrayList<FilePlanComponentModel> children = new ArrayList<FilePlanComponentModel>();
|
||||
for (int i = 0; i < NUMBER_OF_FOLDERS; i++)
|
||||
{
|
||||
// Create a child
|
||||
FilePlanComponent child = createFolder(category.getId(),
|
||||
FilePlanComponentModel child = createFolder(category.getId(),
|
||||
getRandomAlphanumeric());
|
||||
assertNotNull(child.getId());
|
||||
children.add(child);
|
||||
}
|
||||
|
||||
// Authenticate with admin user
|
||||
RestWrapper restWrapper = filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// List children from API
|
||||
FilePlanComponentsCollection apiChildren = filePlanComponentAPI.listChildComponents(category.getId());
|
||||
FilePlanComponentsCollection apiChildren = getFilePlanComponentsAPI().listChildComponents(category.getId());
|
||||
|
||||
// Check status code
|
||||
restWrapper.assertStatusCodeIs(OK);
|
||||
assertStatusCodeIs(OK);
|
||||
|
||||
// Check listed children against created list
|
||||
apiChildren.getEntries().forEach(c ->
|
||||
{
|
||||
FilePlanComponent filePlanComponent = c.getFilePlanComponent();
|
||||
FilePlanComponentModel filePlanComponent = c.getFilePlanComponentModel();
|
||||
assertNotNull(filePlanComponent.getId());
|
||||
logger.info("Checking child " + filePlanComponent.getId());
|
||||
|
||||
try
|
||||
{
|
||||
// Find this child in created children list
|
||||
FilePlanComponent createdComponent = children.stream()
|
||||
FilePlanComponentModel createdComponent = children.stream()
|
||||
.filter(child -> child.getId().equals(filePlanComponent.getId()))
|
||||
.findFirst()
|
||||
.get();
|
||||
@@ -379,18 +376,18 @@ public class RecordFolderTests extends BaseRestTest
|
||||
String RELATIVE_PATH = LocalDateTime.now().getYear()+"/"+ LocalDateTime.now().getMonth()+"/"+ LocalDateTime.now().getDayOfMonth();
|
||||
|
||||
// Authenticate with admin user
|
||||
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
//The record folder to be created
|
||||
FilePlanComponent recordFolder = FilePlanComponent.builder()
|
||||
FilePlanComponentModel recordFolder = FilePlanComponentModel.builder()
|
||||
.name(FOLDER_NAME)
|
||||
.nodeType(RECORD_FOLDER_TYPE.toString())
|
||||
.nodeType(RECORD_FOLDER_TYPE)
|
||||
.relativePath(RELATIVE_PATH)
|
||||
.build();
|
||||
|
||||
// Create the record folder
|
||||
FilePlanComponent folder = filePlanComponentAPI.withParams("include="+ PATH).createFilePlanComponent(recordFolder,FILE_PLAN_ALIAS.toString());
|
||||
FilePlanComponentModel folder = getFilePlanComponentsAPI().createFilePlanComponent(recordFolder, FILE_PLAN_ALIAS, "include=" + PATH);
|
||||
//Check the API response code
|
||||
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(CREATED);
|
||||
assertStatusCodeIs(CREATED);
|
||||
|
||||
// Verify the returned properties for the file plan component - record folder
|
||||
assertFalse(folder.getIsCategory());
|
||||
@@ -400,12 +397,12 @@ public class RecordFolderTests extends BaseRestTest
|
||||
//Check the path return contains the RELATIVE_PATH
|
||||
assertTrue(folder.getPath().getName().contains(RELATIVE_PATH));
|
||||
//check the parent is a category
|
||||
assertTrue(filePlanComponentAPI.getFilePlanComponent(folder.getParentId()).getIsCategory());
|
||||
assertTrue(getFilePlanComponentsAPI().getFilePlanComponent(folder.getParentId()).getIsCategory());
|
||||
|
||||
//check the created folder from the server
|
||||
folder=filePlanComponentAPI.withParams("include=" + PATH).getFilePlanComponent(folder.getId());
|
||||
folder = getFilePlanComponentsAPI().getFilePlanComponent(folder.getId(), "include=" + PATH);
|
||||
//Check the API response code
|
||||
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(OK);
|
||||
assertStatusCodeIs(OK);
|
||||
// Verify the returned properties for the file plan component - record folder
|
||||
assertFalse(folder.getIsCategory());
|
||||
assertFalse(folder.getIsFile());
|
||||
@@ -417,16 +414,16 @@ public class RecordFolderTests extends BaseRestTest
|
||||
//New Relative Path only a part of containers need to be created before the record folder
|
||||
String NEW_RELATIVE_PATH = LocalDateTime.now().getYear() + "/" + LocalDateTime.now().getMonth() + "/" +( LocalDateTime.now().getDayOfMonth()+1);
|
||||
//The record folder to be created
|
||||
FilePlanComponent recordFolder2 = FilePlanComponent.builder()
|
||||
FilePlanComponentModel recordFolder2 = FilePlanComponentModel.builder()
|
||||
.name(FOLDER_NAME)
|
||||
.nodeType(RECORD_FOLDER_TYPE.toString())
|
||||
.nodeType(RECORD_FOLDER_TYPE)
|
||||
.relativePath(NEW_RELATIVE_PATH)
|
||||
.build();
|
||||
|
||||
// Create the record folder
|
||||
FilePlanComponent folder2 = filePlanComponentAPI.withParams("include=" + PATH).createFilePlanComponent(recordFolder2, FILE_PLAN_ALIAS.toString());
|
||||
FilePlanComponentModel folder2 = getFilePlanComponentsAPI().createFilePlanComponent(recordFolder2, FILE_PLAN_ALIAS, "include=" + PATH);
|
||||
//Check the API response code
|
||||
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(CREATED);
|
||||
assertStatusCodeIs(CREATED);
|
||||
|
||||
// Verify the returned properties for the file plan component - record folder
|
||||
assertFalse(folder2.getIsCategory());
|
||||
@@ -436,12 +433,12 @@ public class RecordFolderTests extends BaseRestTest
|
||||
assertTrue(folder2.getPath().getName().contains(NEW_RELATIVE_PATH));
|
||||
|
||||
//check the parent is a category
|
||||
assertTrue(filePlanComponentAPI.getFilePlanComponent(folder.getParentId()).getIsCategory());
|
||||
assertTrue(getFilePlanComponentsAPI().getFilePlanComponent(folder.getParentId()).getIsCategory());
|
||||
|
||||
// Check the folder created on the server
|
||||
folder2 = filePlanComponentAPI.withParams("include=" + PATH).getFilePlanComponent(folder2.getId());
|
||||
folder2 = getFilePlanComponentsAPI().getFilePlanComponent(folder2.getId(), "include=" + PATH);
|
||||
//Check the API response code
|
||||
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(OK);
|
||||
assertStatusCodeIs(OK);
|
||||
|
||||
// Verify the returned properties for the file plan component - record folder
|
||||
assertFalse(folder2.getIsCategory());
|
||||
@@ -454,12 +451,12 @@ public class RecordFolderTests extends BaseRestTest
|
||||
@AfterClass (alwaysRun = true)
|
||||
public void tearDown() throws Exception
|
||||
{
|
||||
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
filePlanComponentAPI.listChildComponents(FILE_PLAN_ALIAS.toString()).getEntries().forEach(filePlanComponentEntry ->
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
getFilePlanComponentsAPI().listChildComponents(FILE_PLAN_ALIAS).getEntries().forEach(filePlanComponentEntry ->
|
||||
{
|
||||
try
|
||||
{
|
||||
filePlanComponentAPI.deleteFilePlanComponent(filePlanComponentEntry.getFilePlanComponent().getId());
|
||||
getFilePlanComponentsAPI().deleteFilePlanComponent(filePlanComponentEntry.getFilePlanComponentModel().getId());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -467,7 +464,4 @@ public class RecordFolderTests extends BaseRestTest
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@@ -48,13 +48,10 @@ import static org.testng.Assert.assertTrue;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.alfresco.rest.core.RestWrapper;
|
||||
import org.alfresco.rest.rm.community.base.BaseRestTest;
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent;
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentModel;
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentProperties;
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType;
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentsCollection;
|
||||
import org.alfresco.rest.rm.community.requests.FilePlanComponentAPI;
|
||||
import org.alfresco.utility.data.DataUser;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.testng.annotations.DataProvider;
|
||||
@@ -68,9 +65,6 @@ import org.testng.annotations.Test;
|
||||
*/
|
||||
public class UnfiledRecordsFolderTests extends BaseRestTest
|
||||
{
|
||||
@Autowired
|
||||
private FilePlanComponentAPI filePlanComponentAPI;
|
||||
|
||||
@Autowired
|
||||
private DataUser dataUser;
|
||||
|
||||
@@ -100,27 +94,26 @@ public class UnfiledRecordsFolderTests extends BaseRestTest
|
||||
public void createRootUnfiledRecordsFolder() throws Exception
|
||||
{
|
||||
// Authenticate with admin user
|
||||
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
String folderName = "Folder " + getRandomAlphanumeric();
|
||||
String folderTitle = folderName + " Title";
|
||||
String folderDescription = folderName + " Description";
|
||||
|
||||
// Build unfiled records folder properties
|
||||
FilePlanComponent unfiledFolder = FilePlanComponent.builder()
|
||||
FilePlanComponentModel unfiledFolder = FilePlanComponentModel.builder()
|
||||
.name(folderName)
|
||||
.nodeType(UNFILED_RECORD_FOLDER_TYPE.toString())
|
||||
.nodeType(UNFILED_RECORD_FOLDER_TYPE)
|
||||
.properties(FilePlanComponentProperties.builder()
|
||||
.title(folderTitle)
|
||||
.description(folderDescription)
|
||||
.build())
|
||||
.build();
|
||||
|
||||
FilePlanComponent filePlanComponent = filePlanComponentAPI.createFilePlanComponent(unfiledFolder,
|
||||
UNFILED_RECORDS_CONTAINER_ALIAS.toString());
|
||||
FilePlanComponentModel filePlanComponent = getFilePlanComponentsAPI().createFilePlanComponent(unfiledFolder, UNFILED_RECORDS_CONTAINER_ALIAS);
|
||||
|
||||
// Verify the status code
|
||||
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(CREATED);
|
||||
assertStatusCodeIs(CREATED);
|
||||
|
||||
// Verify the returned file plan component
|
||||
assertFalse(filePlanComponent.getIsCategory());
|
||||
@@ -128,7 +121,7 @@ public class UnfiledRecordsFolderTests extends BaseRestTest
|
||||
assertFalse(filePlanComponent.getIsRecordFolder()); // it is not a _normal_ record folder!
|
||||
|
||||
assertEquals(filePlanComponent.getName(), folderName);
|
||||
assertEquals(filePlanComponent.getNodeType(), UNFILED_RECORD_FOLDER_TYPE.toString());
|
||||
assertEquals(filePlanComponent.getNodeType(), UNFILED_RECORD_FOLDER_TYPE);
|
||||
|
||||
assertEquals(filePlanComponent.getCreatedByUser().getId(), dataUser.getAdminUser().getUsername());
|
||||
|
||||
@@ -146,20 +139,20 @@ public class UnfiledRecordsFolderTests extends BaseRestTest
|
||||
dataProvider = "invalidRootTypes",
|
||||
description = "Only unfiled records folders can be created at unfiled records root level"
|
||||
)
|
||||
public void onlyRecordFoldersCanBeCreatedAtUnfiledRecordsRoot(FilePlanComponentType componentType)
|
||||
public void onlyRecordFoldersCanBeCreatedAtUnfiledRecordsRoot(String filePlanComponentType)
|
||||
{
|
||||
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
String folderName = "Folder " + getRandomAlphanumeric();
|
||||
String folderTitle = folderName + " Title";
|
||||
String folderDescription = folderName + " Description";
|
||||
|
||||
logger.info("creating " + componentType.toString());
|
||||
logger.info("creating " + filePlanComponentType);
|
||||
|
||||
// Build unfiled records folder properties
|
||||
FilePlanComponent unfiledFolder = FilePlanComponent.builder()
|
||||
FilePlanComponentModel unfiledFolder = FilePlanComponentModel.builder()
|
||||
.name(folderName)
|
||||
.nodeType(componentType.toString())
|
||||
.nodeType(filePlanComponentType)
|
||||
.properties(FilePlanComponentProperties.builder()
|
||||
.title(folderTitle)
|
||||
.description(folderDescription)
|
||||
@@ -168,15 +161,14 @@ public class UnfiledRecordsFolderTests extends BaseRestTest
|
||||
|
||||
try
|
||||
{
|
||||
filePlanComponentAPI.createFilePlanComponent(unfiledFolder,
|
||||
UNFILED_RECORDS_CONTAINER_ALIAS.toString());
|
||||
getFilePlanComponentsAPI().createFilePlanComponent(unfiledFolder, UNFILED_RECORDS_CONTAINER_ALIAS);
|
||||
}
|
||||
catch (Exception error)
|
||||
{
|
||||
}
|
||||
|
||||
// Verify the status code
|
||||
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(UNPROCESSABLE_ENTITY);
|
||||
assertStatusCodeIs(UNPROCESSABLE_ENTITY);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -189,7 +181,7 @@ public class UnfiledRecordsFolderTests extends BaseRestTest
|
||||
@Test(description = "Child unfiled records folder can be created in a parent unfiled records folder")
|
||||
public void childUnfiledRecordsFolderCanBeCreated() throws Exception
|
||||
{
|
||||
RestWrapper restWrapper = filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
String parentFolderName = "Parent Folder " + getRandomAlphanumeric();
|
||||
String childFolderName = "Child Folder " + getRandomAlphanumeric();
|
||||
@@ -197,13 +189,13 @@ public class UnfiledRecordsFolderTests extends BaseRestTest
|
||||
String childFolderDescription = childFolderName + " Description";
|
||||
|
||||
// No need for fine control, create it using utility function
|
||||
FilePlanComponent parentFolder = createUnfiledRecordsFolder(UNFILED_RECORDS_CONTAINER_ALIAS.toString(), parentFolderName);
|
||||
FilePlanComponentModel parentFolder = createUnfiledRecordsFolder(UNFILED_RECORDS_CONTAINER_ALIAS, parentFolderName);
|
||||
assertEquals(parentFolderName, parentFolder.getName());
|
||||
|
||||
// Build the unfiled records folder properties
|
||||
FilePlanComponent unfiledFolder = FilePlanComponent.builder()
|
||||
FilePlanComponentModel unfiledFolder = FilePlanComponentModel.builder()
|
||||
.name(childFolderName)
|
||||
.nodeType(UNFILED_RECORD_FOLDER_TYPE.toString())
|
||||
.nodeType(UNFILED_RECORD_FOLDER_TYPE)
|
||||
.properties(FilePlanComponentProperties.builder()
|
||||
.title(childFolderTitle)
|
||||
.description(childFolderDescription)
|
||||
@@ -211,11 +203,10 @@ public class UnfiledRecordsFolderTests extends BaseRestTest
|
||||
.build();
|
||||
|
||||
// Create it as a child of parentFolder
|
||||
FilePlanComponent childFolder = filePlanComponentAPI.createFilePlanComponent(unfiledFolder,
|
||||
parentFolder.getId());
|
||||
FilePlanComponentModel childFolder = getFilePlanComponentsAPI().createFilePlanComponent(unfiledFolder, parentFolder.getId());
|
||||
|
||||
// Verify the status code
|
||||
restWrapper.assertStatusCodeIs(CREATED);
|
||||
assertStatusCodeIs(CREATED);
|
||||
|
||||
// Verify the returned file plan component
|
||||
assertFalse(childFolder.getIsCategory());
|
||||
@@ -223,7 +214,7 @@ public class UnfiledRecordsFolderTests extends BaseRestTest
|
||||
assertFalse(childFolder.getIsRecordFolder()); // it is not a _normal_ record folder!
|
||||
|
||||
assertEquals(childFolder.getName(), childFolderName);
|
||||
assertEquals(childFolder.getNodeType(), UNFILED_RECORD_FOLDER_TYPE.toString());
|
||||
assertEquals(childFolder.getNodeType(), UNFILED_RECORD_FOLDER_TYPE);
|
||||
assertEquals(childFolder.getCreatedByUser().getId(), dataUser.getAdminUser().getUsername());
|
||||
|
||||
// Verify the returned file plan component properties
|
||||
@@ -236,11 +227,11 @@ public class UnfiledRecordsFolderTests extends BaseRestTest
|
||||
|
||||
// Does child's parent point to it?
|
||||
// Perform another call as our parentFolder had been executed before childFolder existed
|
||||
FilePlanComponentsCollection parentsChildren = filePlanComponentAPI.listChildComponents(parentFolder.getId());
|
||||
restWrapper.assertStatusCodeIs(OK);
|
||||
FilePlanComponentsCollection parentsChildren = getFilePlanComponentsAPI().listChildComponents(parentFolder.getId());
|
||||
assertStatusCodeIs(OK);
|
||||
List<String> childIds = parentsChildren.getEntries()
|
||||
.stream()
|
||||
.map(c -> c.getFilePlanComponent().getId())
|
||||
.map(c -> c.getFilePlanComponentModel().getId())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// Child folder is listed in parent
|
||||
@@ -260,16 +251,16 @@ public class UnfiledRecordsFolderTests extends BaseRestTest
|
||||
@Test(description = "Unfiled record folder")
|
||||
public void editUnfiledRecordsFolder() throws Exception
|
||||
{
|
||||
RestWrapper restWrapper = filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
String modified = "Modified ";
|
||||
String folderName = "Folder To Modify" + getRandomAlphanumeric();
|
||||
|
||||
// No need for fine control, create it using utility function
|
||||
FilePlanComponent folderToModify = createUnfiledRecordsFolder(UNFILED_RECORDS_CONTAINER_ALIAS.toString(), folderName);
|
||||
FilePlanComponentModel folderToModify = createUnfiledRecordsFolder(UNFILED_RECORDS_CONTAINER_ALIAS, folderName);
|
||||
assertEquals(folderName, folderToModify.getName());
|
||||
|
||||
// Build the properties which will be updated
|
||||
FilePlanComponent folderToUpdate = FilePlanComponent.builder()
|
||||
FilePlanComponentModel folderToUpdate = FilePlanComponentModel.builder()
|
||||
.name(modified + folderToModify.getName())
|
||||
.properties(FilePlanComponentProperties.builder().
|
||||
title(modified + folderToModify.getProperties().getTitle()).
|
||||
@@ -278,12 +269,12 @@ public class UnfiledRecordsFolderTests extends BaseRestTest
|
||||
.build();
|
||||
|
||||
// Update the unfiled records folder
|
||||
filePlanComponentAPI.updateFilePlanComponent(folderToUpdate, folderToModify.getId());
|
||||
getFilePlanComponentsAPI().updateFilePlanComponent(folderToUpdate, folderToModify.getId());
|
||||
// Verify the status code
|
||||
restWrapper.assertStatusCodeIs(OK);
|
||||
assertStatusCodeIs(OK);
|
||||
|
||||
// This is to ensure the change was actually applied, rather than simply trusting the object returned by PUT
|
||||
FilePlanComponent renamedFolder = filePlanComponentAPI.getFilePlanComponent(folderToModify.getId());
|
||||
FilePlanComponentModel renamedFolder = getFilePlanComponentsAPI().getFilePlanComponent(folderToModify.getId());
|
||||
|
||||
// Verify the returned file plan component
|
||||
assertEquals(modified + folderToModify.getName(), renamedFolder.getName());
|
||||
@@ -301,21 +292,21 @@ public class UnfiledRecordsFolderTests extends BaseRestTest
|
||||
@Test(description = "Delete unfiled record folder")
|
||||
public void deleteUnfiledRecordsFolder() throws Exception
|
||||
{
|
||||
RestWrapper restWrapper = filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
String folderName = "Folder To Delete" + getRandomAlphanumeric();
|
||||
|
||||
// Create folderToDelete
|
||||
FilePlanComponent folderToDelete = createUnfiledRecordsFolder(UNFILED_RECORDS_CONTAINER_ALIAS.toString(), folderName);
|
||||
FilePlanComponentModel folderToDelete = createUnfiledRecordsFolder(UNFILED_RECORDS_CONTAINER_ALIAS, folderName);
|
||||
assertEquals(folderName, folderToDelete.getName());
|
||||
|
||||
// Delete folderToDelete
|
||||
filePlanComponentAPI.deleteFilePlanComponent(folderToDelete.getId());
|
||||
getFilePlanComponentsAPI().deleteFilePlanComponent(folderToDelete.getId());
|
||||
|
||||
// Verify the status code
|
||||
restWrapper.assertStatusCodeIs(NO_CONTENT);
|
||||
assertStatusCodeIs(NO_CONTENT);
|
||||
|
||||
// Deleted component should no longer be retrievable
|
||||
filePlanComponentAPI.getFilePlanComponent(folderToDelete.getId());
|
||||
restWrapper.assertStatusCodeIs(NOT_FOUND);
|
||||
getFilePlanComponentsAPI().getFilePlanComponent(folderToDelete.getId());
|
||||
assertStatusCodeIs(NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
@@ -43,10 +43,8 @@ import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
||||
import org.alfresco.dataprep.UserService;
|
||||
import org.alfresco.rest.core.RestWrapper;
|
||||
import org.alfresco.rest.rm.community.base.BaseRestTest;
|
||||
import org.alfresco.rest.rm.community.model.site.RMSite;
|
||||
import org.alfresco.rest.rm.community.requests.RMSiteAPI;
|
||||
import org.alfresco.rest.rm.community.model.site.RMSiteModel;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.data.DataUser;
|
||||
import org.alfresco.utility.data.RandomData;
|
||||
@@ -67,9 +65,6 @@ public class RMSiteTests extends BaseRestTest
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@Autowired
|
||||
private RMSiteAPI rmSiteAPI;
|
||||
|
||||
@Autowired
|
||||
private DataUser dataUser;
|
||||
|
||||
@@ -85,24 +80,24 @@ public class RMSiteTests extends BaseRestTest
|
||||
public void createRMSiteAsAdminUser() throws Exception
|
||||
{
|
||||
// Authenticate with admin user
|
||||
rmSiteAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// Check if the RM site exists
|
||||
if (rmSiteAPI.existsRMSite())
|
||||
if (getRMSiteAPI().existsRMSite())
|
||||
{
|
||||
// Delete the RM site
|
||||
rmSiteAPI.deleteRMSite();
|
||||
getRMSiteAPI().deleteRMSite();
|
||||
}
|
||||
|
||||
// Create the RM site
|
||||
RMSite rmSite =RMSite.builder().compliance(STANDARD).build();
|
||||
rmSite.setTitle(RM_TITLE);
|
||||
rmSite.setDescription(RM_DESCRIPTION);
|
||||
RMSiteModel rmSiteModel = RMSiteModel.builder().compliance(STANDARD).build();
|
||||
rmSiteModel.setTitle(RM_TITLE);
|
||||
rmSiteModel.setDescription(RM_DESCRIPTION);
|
||||
|
||||
RMSite rmSiteResponse = rmSiteAPI.createRMSite(rmSite);
|
||||
RMSiteModel rmSiteResponse = getRMSiteAPI().createRMSite(rmSiteModel);
|
||||
|
||||
// Verify the status code
|
||||
rmSiteAPI.usingRestWrapper().assertStatusCodeIs(CREATED);
|
||||
assertStatusCodeIs(CREATED);
|
||||
|
||||
// Verify the returned file plan component
|
||||
assertEquals(rmSiteResponse.getId(), RM_ID);
|
||||
@@ -128,21 +123,21 @@ public class RMSiteTests extends BaseRestTest
|
||||
createRMSiteIfNotExists();
|
||||
|
||||
// Authenticate with admin user
|
||||
RestWrapper restWrapper = rmSiteAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// Construct new properties
|
||||
String newTitle = RM_TITLE + "createRMSiteWhenSiteExists";
|
||||
String newDescription = RM_DESCRIPTION + "createRMSiteWhenSiteExists";
|
||||
|
||||
// Create the RM site
|
||||
RMSite rmSite = RMSite.builder().compliance(STANDARD).build();
|
||||
rmSite.setTitle(newTitle);
|
||||
rmSite.setDescription(newDescription);
|
||||
RMSiteModel rmSiteModel = RMSiteModel.builder().compliance(STANDARD).build();
|
||||
rmSiteModel.setTitle(newTitle);
|
||||
rmSiteModel.setDescription(newDescription);
|
||||
|
||||
rmSiteAPI.createRMSite(rmSite);
|
||||
getRMSiteAPI().createRMSite(rmSiteModel);
|
||||
|
||||
// Verify the status code
|
||||
restWrapper.assertStatusCodeIs(CONFLICT);
|
||||
assertStatusCodeIs(CONFLICT);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -157,13 +152,13 @@ public class RMSiteTests extends BaseRestTest
|
||||
public void deleteRMSite() throws Exception
|
||||
{
|
||||
// Authenticate with admin user
|
||||
RestWrapper restWrapper = rmSiteAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// Delete the RM site
|
||||
rmSiteAPI.deleteRMSite();
|
||||
getRMSiteAPI().deleteRMSite();
|
||||
|
||||
// Verify the status code
|
||||
restWrapper.assertStatusCodeIs(NO_CONTENT);
|
||||
assertStatusCodeIs(NO_CONTENT);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -178,26 +173,26 @@ public class RMSiteTests extends BaseRestTest
|
||||
public void getRMSite() throws Exception
|
||||
{
|
||||
// Authenticate with admin user
|
||||
RestWrapper restWrapper = rmSiteAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// Check if RM site exists
|
||||
if (!rmSiteAPI.existsRMSite())
|
||||
if (!getRMSiteAPI().existsRMSite())
|
||||
{
|
||||
// Verify the status code when RM site doesn't exist
|
||||
restWrapper.assertStatusCodeIs(NOT_FOUND);
|
||||
assertStatusCodeIs(NOT_FOUND);
|
||||
createRMSiteIfNotExists();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Get the RM site
|
||||
RMSite rmSite = rmSiteAPI.getSite();
|
||||
RMSiteModel rmSiteModel = getRMSiteAPI().getSite();
|
||||
|
||||
// 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);
|
||||
assertStatusCodeIs(OK);
|
||||
assertEquals(rmSiteModel.getId(), RM_ID);
|
||||
assertEquals(rmSiteModel.getDescription(), RM_DESCRIPTION);
|
||||
assertEquals(rmSiteModel.getCompliance(), STANDARD);
|
||||
assertEquals(rmSiteModel.getVisibility(), PUBLIC);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,17 +209,17 @@ public class RMSiteTests extends BaseRestTest
|
||||
public void createRMSiteAsAnotherAdminUser() throws Exception
|
||||
{
|
||||
// Authenticate with admin user
|
||||
rmSiteAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// Check if the RM site exists
|
||||
if (rmSiteAPI.existsRMSite())
|
||||
if (getRMSiteAPI().existsRMSite())
|
||||
{
|
||||
// Delete the RM site
|
||||
rmSiteAPI.deleteRMSite();
|
||||
getRMSiteAPI().deleteRMSite();
|
||||
}
|
||||
|
||||
// Disconnect the current user from the API session
|
||||
rmSiteAPI.usingRestWrapper().disconnect();
|
||||
disconnect();
|
||||
|
||||
// Create user
|
||||
userService.create(dataUser.getAdminUser().getUsername(),
|
||||
@@ -239,24 +234,24 @@ public class RMSiteTests extends BaseRestTest
|
||||
UserModel userModel = new UserModel(ANOTHER_ADMIN,DEFAULT_PASSWORD);
|
||||
|
||||
// Authenticate as that new user
|
||||
rmSiteAPI.usingRestWrapper().authenticateUser(userModel);
|
||||
authenticateUser(userModel);
|
||||
|
||||
// Create the RM site
|
||||
RMSite rmSite = RMSite.builder().compliance(DOD5015).build();
|
||||
rmSite.setTitle(RM_TITLE);
|
||||
rmSite.setDescription(RM_DESCRIPTION);
|
||||
rmSite=rmSiteAPI.createRMSite(rmSite);
|
||||
RMSiteModel rmSiteModel = RMSiteModel.builder().compliance(DOD5015).build();
|
||||
rmSiteModel.setTitle(RM_TITLE);
|
||||
rmSiteModel.setDescription(RM_DESCRIPTION);
|
||||
rmSiteModel = getRMSiteAPI().createRMSite(rmSiteModel);
|
||||
|
||||
// Verify the status code
|
||||
rmSiteAPI.usingRestWrapper().assertStatusCodeIs(CREATED);
|
||||
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);
|
||||
assertEquals(rmSite.getRole(), UserRole.SiteManager.toString());
|
||||
assertEquals(rmSiteModel.getId(), RM_ID);
|
||||
assertEquals(rmSiteModel.getTitle(), RM_TITLE);
|
||||
assertEquals(rmSiteModel.getDescription(), RM_DESCRIPTION);
|
||||
assertEquals(rmSiteModel.getCompliance(), DOD5015);
|
||||
assertEquals(rmSiteModel.getVisibility(), PUBLIC);
|
||||
assertEquals(rmSiteModel.getRole(), UserRole.SiteManager.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -270,52 +265,52 @@ public class RMSiteTests extends BaseRestTest
|
||||
public void updateRMSiteDetails()throws Exception
|
||||
{
|
||||
String NEW_TITLE = RM_TITLE + RandomData.getRandomAlphanumeric();
|
||||
String NEW_DESCRIPTION = RM_DESCRIPTION+ RandomData.getRandomAlphanumeric();
|
||||
String NEW_DESCRIPTION = RM_DESCRIPTION + RandomData.getRandomAlphanumeric();
|
||||
|
||||
// Authenticate with admin user
|
||||
rmSiteAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// Create the site if it does not exist
|
||||
createRMSiteIfNotExists();
|
||||
|
||||
//Create RM site model
|
||||
RMSite rmSiteToUpdate = new RMSite();
|
||||
// Create RM site model
|
||||
RMSiteModel rmSiteToUpdate = RMSiteModel.builder().build();
|
||||
rmSiteToUpdate.setTitle(NEW_TITLE);
|
||||
rmSiteToUpdate.setDescription(NEW_DESCRIPTION);
|
||||
|
||||
// Disconnect the user from the API session
|
||||
rmSiteAPI.usingRestWrapper().disconnect();
|
||||
disconnect();
|
||||
|
||||
// Create a random user
|
||||
UserModel nonRMuser = dataUser.createRandomTestUser("testUser");
|
||||
|
||||
// Authenticate as that random user
|
||||
rmSiteAPI.usingRestWrapper().authenticateUser(nonRMuser);
|
||||
authenticateUser(nonRMuser);
|
||||
|
||||
// Create the RM site
|
||||
rmSiteAPI.updateRMSite(rmSiteToUpdate);
|
||||
getRMSiteAPI().updateRMSite(rmSiteToUpdate);
|
||||
|
||||
// Verify the status code
|
||||
rmSiteAPI.usingRestWrapper().assertStatusCodeIs(FORBIDDEN);
|
||||
assertStatusCodeIs(FORBIDDEN);
|
||||
|
||||
// Disconnect the user from the API session
|
||||
rmSiteAPI.usingRestWrapper().disconnect();
|
||||
disconnect();
|
||||
|
||||
// Authenticate with admin user
|
||||
rmSiteAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// Update the RM Site
|
||||
RMSite rmSite = rmSiteAPI.updateRMSite(rmSiteToUpdate);
|
||||
RMSiteModel rmSiteModel = getRMSiteAPI().updateRMSite(rmSiteToUpdate);
|
||||
|
||||
// Verify the response status code
|
||||
rmSiteAPI.usingRestWrapper().assertStatusCodeIs(OK);
|
||||
assertStatusCodeIs(OK);
|
||||
|
||||
// Verify the returned file plan component
|
||||
assertEquals(rmSite.getId(), RM_ID);
|
||||
assertEquals(rmSite.getTitle(), NEW_TITLE);
|
||||
assertEquals(rmSite.getDescription(), NEW_DESCRIPTION);
|
||||
assertNotNull(rmSite.getCompliance());
|
||||
assertEquals(rmSite.getVisibility(), PUBLIC);
|
||||
assertEquals(rmSiteModel.getId(), RM_ID);
|
||||
assertEquals(rmSiteModel.getTitle(), NEW_TITLE);
|
||||
assertEquals(rmSiteModel.getDescription(), NEW_DESCRIPTION);
|
||||
assertNotNull(rmSiteModel.getCompliance());
|
||||
assertEquals(rmSiteModel.getVisibility(), PUBLIC);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -327,18 +322,18 @@ public class RMSiteTests extends BaseRestTest
|
||||
public void updateRMSiteComplianceAsAdmin() throws Exception
|
||||
{
|
||||
// Authenticate with admin user
|
||||
rmSiteAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// Create the RM site if it does not exist
|
||||
createRMSiteIfNotExists();
|
||||
|
||||
// Build the RM site properties
|
||||
RMSite rmSiteToUpdate = RMSite.builder().compliance(DOD5015).build();
|
||||
RMSiteModel rmSiteToUpdate = RMSiteModel.builder().compliance(DOD5015).build();
|
||||
|
||||
// Update the RM site
|
||||
rmSiteAPI.updateRMSite(rmSiteToUpdate);
|
||||
getRMSiteAPI().updateRMSite(rmSiteToUpdate);
|
||||
|
||||
// Verify the response status code
|
||||
rmSiteAPI.usingRestWrapper().assertStatusCodeIs(BAD_REQUEST);
|
||||
assertStatusCodeIs(BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user