diff --git a/source/java/org/alfresco/rest/api/model/Document.java b/source/java/org/alfresco/rest/api/model/Document.java index cb51889dee..d348f43261 100644 --- a/source/java/org/alfresco/rest/api/model/Document.java +++ b/source/java/org/alfresco/rest/api/model/Document.java @@ -43,7 +43,6 @@ import org.alfresco.service.namespace.QName; * @author janv * */ -@JsonInclude(JsonInclude.Include.NON_NULL) public class Document extends Node { public Document() { @@ -66,6 +65,18 @@ public class Document extends Node this.isFolder = false; } + @Override + public ContentInfo getContent() + { + return contentInfo; + } + + @Override + public void setContent(ContentInfo contentInfoIn) + { + contentInfo = contentInfoIn; + } + @Override public String toString() { diff --git a/source/java/org/alfresco/rest/api/model/Folder.java b/source/java/org/alfresco/rest/api/model/Folder.java index d2ca07d43a..54005048dd 100644 --- a/source/java/org/alfresco/rest/api/model/Folder.java +++ b/source/java/org/alfresco/rest/api/model/Folder.java @@ -40,7 +40,6 @@ import org.alfresco.service.namespace.QName; * @author steveglover * @author janv */ -@JsonInclude(JsonInclude.Include.NON_NULL) public class Folder extends Node { public Folder() @@ -60,6 +59,11 @@ public class Folder extends Node return null; } + @Override + public void setContent(ContentInfo contentInfo) + { + } + @Override public String toString() { diff --git a/source/java/org/alfresco/rest/api/model/Node.java b/source/java/org/alfresco/rest/api/model/Node.java index cb36057614..14145e3c91 100644 --- a/source/java/org/alfresco/rest/api/model/Node.java +++ b/source/java/org/alfresco/rest/api/model/Node.java @@ -31,12 +31,12 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import com.fasterxml.jackson.annotation.JsonInclude; import org.alfresco.model.ContentModel; import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.rest.framework.resource.UniqueId; +import org.alfresco.rest.framework.resource.content.*; import org.alfresco.service.ServiceRegistry; import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.cmr.security.NoSuchPersonException; import org.alfresco.service.cmr.security.PersonService; import org.alfresco.service.namespace.QName; @@ -50,7 +50,6 @@ import org.apache.chemistry.opencmis.commons.data.PropertyData; * @author Gethin James * @author janv */ -@JsonInclude(JsonInclude.Include.NON_NULL) public class Node implements Comparable { protected NodeRef nodeRef; @@ -144,34 +143,15 @@ public class Node implements Comparable return userInfo; } - private String getNodeRefAsString(NodeRef nRef) { - return (nRef != null ? nRef.getId() : null); - } - - private NodeRef getStringAsNodeRef(String nRefString) { - if (nRefString == null) - { - return null; - } - - if( ! NodeRef.isNodeRef(nRefString)) - { - return new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, nRefString); - } - else - { - return new NodeRef(nRefString); - } - } - - public String getId() + @UniqueId + public NodeRef getNodeRef() { - return getNodeRefAsString(this.nodeRef); + return nodeRef; } - public void setId(String id) + public void setNodeRef(NodeRef nodeRef) { - this.nodeRef = getStringAsNodeRef(id); + this.nodeRef = nodeRef; } public Date getCreatedAt() @@ -243,14 +223,14 @@ public class Node implements Comparable this.aspectNames = aspectNames; } - public String getParentId() + public NodeRef getParentId() { - return getNodeRefAsString(parentNodeRef); + return parentNodeRef; } - public void setParentId(String parentId) + public void setParentId(NodeRef parentNodeRef) { - this.parentNodeRef = getStringAsNodeRef(parentId); + this.parentNodeRef = parentNodeRef; } public Boolean getIsFolder() @@ -286,13 +266,13 @@ public class Node implements Comparable } Node node = (Node)other; - return EqualsHelper.nullSafeEquals(getId(), node.getId()); + return EqualsHelper.nullSafeEquals(getNodeRef(), node.getNodeRef()); } @Override public int compareTo(Node node) { - return getId().toString().compareTo(node.getId().toString()); + return getNodeRef().toString().compareTo(node.getNodeRef().toString()); } @Override @@ -304,18 +284,18 @@ public class Node implements Comparable + modifiedByUser + ", pathInfo =" + pathInfo +"]"; } + // here to allow POST /nodes/{id}/children when creating empty file with specified content.mimeType protected ContentInfo contentInfo; - public ContentInfo getContent() - { - return contentInfo; - } - public void setContent(ContentInfo contentInfo) { this.contentInfo = contentInfo; } + public ContentInfo getContent() + { + return this.contentInfo; + } // TODO for backwards compat' - set explicitly when needed (ie. favourites) (note: we could choose to have separate old Node/NodeImpl etc) @@ -333,12 +313,11 @@ public class Node implements Comparable } /** - * @deprecated note: used when creating (via POST) favourite target + * @deprecated */ public void setGuid(NodeRef guid) { this.guid = guid; - setId(guid.toString()); } /** diff --git a/source/test-java/org/alfresco/rest/api/tests/NodeApiTest.java b/source/test-java/org/alfresco/rest/api/tests/NodeApiTest.java index d0327ae41a..cb1096ab03 100644 --- a/source/test-java/org/alfresco/rest/api/tests/NodeApiTest.java +++ b/source/test-java/org/alfresco/rest/api/tests/NodeApiTest.java @@ -34,13 +34,13 @@ import org.alfresco.repo.model.Repository; import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; import org.alfresco.rest.api.Nodes; -import org.alfresco.rest.api.model.ContentInfo; -import org.alfresco.rest.api.model.Document; -import org.alfresco.rest.api.model.Folder; -import org.alfresco.rest.api.model.Node; -import org.alfresco.rest.api.model.PathInfo; -import org.alfresco.rest.api.model.PathInfo.ElementInfo; -import org.alfresco.rest.api.model.UserInfo; +import org.alfresco.rest.api.tests.client.data.ContentInfo; +import org.alfresco.rest.api.tests.client.data.Document; +import org.alfresco.rest.api.tests.client.data.Folder; +import org.alfresco.rest.api.tests.client.data.Node; +import org.alfresco.rest.api.tests.client.data.PathInfo; +import org.alfresco.rest.api.tests.client.data.PathInfo.ElementInfo; +import org.alfresco.rest.api.tests.client.data.UserInfo; import org.alfresco.rest.api.nodes.NodesEntityResource; import org.alfresco.rest.api.tests.RepoService.TestNetwork; import org.alfresco.rest.api.tests.RepoService.TestPerson; @@ -92,6 +92,7 @@ import java.util.UUID; * * * @author Jamal Kaabi-Mofrad + * @author janv */ public class NodeApiTest extends AbstractBaseApiTest { diff --git a/source/test-java/org/alfresco/rest/api/tests/RepoService.java b/source/test-java/org/alfresco/rest/api/tests/RepoService.java index f7f25e912d..7ae1d51644 100644 --- a/source/test-java/org/alfresco/rest/api/tests/RepoService.java +++ b/source/test-java/org/alfresco/rest/api/tests/RepoService.java @@ -83,9 +83,9 @@ import org.alfresco.rest.api.impl.node.ratings.RatingScheme; import org.alfresco.rest.api.tests.client.data.Activity; import org.alfresco.rest.api.tests.client.data.Comment; import org.alfresco.rest.api.tests.client.data.Company; -import org.alfresco.rest.api.tests.client.data.Document; +import org.alfresco.rest.api.tests.client.data.FavouriteDocument; +import org.alfresco.rest.api.tests.client.data.FavouriteFolder; import org.alfresco.rest.api.tests.client.data.FavouriteSite; -import org.alfresco.rest.api.tests.client.data.Folder; import org.alfresco.rest.api.tests.client.data.MemberOfSite; import org.alfresco.rest.api.tests.client.data.NetworkImpl; import org.alfresco.rest.api.tests.client.data.NodeRating; @@ -924,20 +924,20 @@ public class RepoService return wrapProperties; } - public Document getDocument(String networkId, final NodeRef nodeRef) + public FavouriteDocument getDocument(String networkId, final NodeRef nodeRef) { - return TenantUtil.runAsSystemTenant(new TenantRunAsWork() + return TenantUtil.runAsSystemTenant(new TenantRunAsWork() { @Override - public Document doWork() throws Exception + public FavouriteDocument doWork() throws Exception { - Document document = null; + FavouriteDocument document = null; QName type = nodeService.getType(nodeRef); if(dictionaryService.isSubClass(type, ContentModel.TYPE_CONTENT)) { Properties properties = getProperties(nodeRef); - document = Document.getDocument(nodeRef.getId(), nodeRef.getId(), properties); + document = FavouriteDocument.getDocument(nodeRef.getId(), nodeRef.getId(), properties); } else { @@ -949,20 +949,20 @@ public class RepoService }, networkId); } - public Folder getFolder(String networkId, final NodeRef nodeRef) + public FavouriteFolder getFolder(String networkId, final NodeRef nodeRef) { - return TenantUtil.runAsSystemTenant(new TenantRunAsWork() + return TenantUtil.runAsSystemTenant(new TenantRunAsWork() { @Override - public Folder doWork() throws Exception + public FavouriteFolder doWork() throws Exception { - Folder folder = null; + FavouriteFolder folder = null; QName type = nodeService.getType(nodeRef); if(dictionaryService.isSubClass(type, ContentModel.TYPE_FOLDER)) { Properties properties = getProperties(nodeRef); - folder = Folder.getFolder(nodeRef.getId(), nodeRef.getId(), properties); + folder = FavouriteFolder.getFolder(nodeRef.getId(), nodeRef.getId(), properties); } else { diff --git a/source/test-java/org/alfresco/rest/api/tests/TestFavourites.java b/source/test-java/org/alfresco/rest/api/tests/TestFavourites.java index 12e30743e1..d3a0c545b9 100644 --- a/source/test-java/org/alfresco/rest/api/tests/TestFavourites.java +++ b/source/test-java/org/alfresco/rest/api/tests/TestFavourites.java @@ -58,11 +58,11 @@ import org.alfresco.rest.api.tests.client.PublicApiClient.SiteMembershipRequests import org.alfresco.rest.api.tests.client.PublicApiException; import org.alfresco.rest.api.tests.client.RequestContext; import org.alfresco.rest.api.tests.client.data.Comment; -import org.alfresco.rest.api.tests.client.data.Document; import org.alfresco.rest.api.tests.client.data.Favourite; +import org.alfresco.rest.api.tests.client.data.FavouriteDocument; +import org.alfresco.rest.api.tests.client.data.FavouriteFolder; import org.alfresco.rest.api.tests.client.data.FavouritesTarget; import org.alfresco.rest.api.tests.client.data.FileFavouriteTarget; -import org.alfresco.rest.api.tests.client.data.Folder; import org.alfresco.rest.api.tests.client.data.FolderFavouriteTarget; import org.alfresco.rest.api.tests.client.data.InvalidFavouriteTarget; import org.alfresco.rest.api.tests.client.data.JSONAble; @@ -497,7 +497,7 @@ public class TestFavourites extends EnterpriseTestApi private Favourite makeFolderFavourite(String targetGuid) throws ParseException { - Folder folder = new Folder(targetGuid); + FavouriteFolder folder = new FavouriteFolder(targetGuid); FolderFavouriteTarget target = new FolderFavouriteTarget(folder); Date creationData = new Date(); Favourite favourite = new Favourite(creationData, null, target); @@ -506,7 +506,7 @@ public class TestFavourites extends EnterpriseTestApi private Favourite makeFileFavourite(String targetGuid) throws ParseException { - Document document = new Document(targetGuid); + FavouriteDocument document = new FavouriteDocument(targetGuid); FileFavouriteTarget target = new FileFavouriteTarget(document); Date creationData = new Date(); Favourite favourite = new Favourite(creationData, null, target); @@ -609,7 +609,7 @@ public class TestFavourites extends EnterpriseTestApi publicApiClient.setRequestContext(new RequestContext(network1.getId(), person10Id)); String siteGuid = person1PublicSites.get(0).getGuid(); - Document document = new Document(siteGuid); + FavouriteDocument document = new FavouriteDocument(siteGuid); Favourite favourite = makeFileFavourite(document.getGuid()); Favourite ret = favouritesProxy.createFavourite(person10Id, favourite); favourite.expected(ret); @@ -626,7 +626,7 @@ public class TestFavourites extends EnterpriseTestApi publicApiClient.setRequestContext(new RequestContext(network1.getId(), person10Id)); String siteGuid = person1PublicSites.get(0).getGuid(); - Folder folder = new Folder(siteGuid); + FavouriteFolder folder = new FavouriteFolder(siteGuid); Favourite favourite = makeFolderFavourite(folder.getGuid()); Favourite ret = favouritesProxy.createFavourite(person10Id, favourite); favourite.expected(ret); @@ -643,7 +643,7 @@ public class TestFavourites extends EnterpriseTestApi { publicApiClient.setRequestContext(new RequestContext(network1.getId(), person10Id)); - Folder folder = new Folder(person1PublicDocs.get(0).getId()); + FavouriteFolder folder = new FavouriteFolder(person1PublicDocs.get(0).getId()); Favourite favourite = makeFolderFavourite(folder.getGuid()); Favourite ret = favouritesProxy.createFavourite(person10Id, favourite); favourite.expected(ret); @@ -660,7 +660,7 @@ public class TestFavourites extends EnterpriseTestApi { publicApiClient.setRequestContext(new RequestContext(network1.getId(), person10Id)); - Document document = new Document(person1PublicFolders.get(0).getId()); + FavouriteDocument document = new FavouriteDocument(person1PublicFolders.get(0).getId()); Favourite favourite = makeFileFavourite(document.getGuid()); Favourite ret = favouritesProxy.createFavourite(person10Id, favourite); favourite.expected(ret); @@ -680,8 +680,8 @@ public class TestFavourites extends EnterpriseTestApi try { publicApiClient.setRequestContext(new RequestContext(network1.getId(), person10Id)); - - Document document = new Document(person1PublicDocs.get(0).getId()); + + FavouriteDocument document = new FavouriteDocument(person1PublicDocs.get(0).getId()); Favourite favourite = makeFileFavourite(document.getGuid()); favouritesProxy.createFavourite(person11Id, favourite); @@ -776,8 +776,8 @@ public class TestFavourites extends EnterpriseTestApi try { publicApiClient.setRequestContext(new RequestContext(network1.getId(), person10Id)); - - Document document = new Document(GUID.generate()); + + FavouriteDocument document = new FavouriteDocument(GUID.generate()); Favourite favourite = makeFileFavourite(document.getGuid()); favouritesProxy.createFavourite(person10Id, favourite); @@ -796,8 +796,8 @@ public class TestFavourites extends EnterpriseTestApi try { publicApiClient.setRequestContext(new RequestContext(network1.getId(), person10Id)); - - Folder folder = new Folder(GUID.generate()); + + FavouriteFolder folder = new FavouriteFolder(GUID.generate()); Favourite favourite = makeFolderFavourite(folder.getGuid()); favouritesProxy.createFavourite(person10Id, favourite); @@ -851,7 +851,7 @@ public class TestFavourites extends EnterpriseTestApi assertEquals(HttpStatus.SC_NOT_FOUND, e.getHttpResponse().getStatusCode()); } - Document document = new Document(person1PublicDocs.get(0).getId()); + FavouriteDocument document = new FavouriteDocument(person1PublicDocs.get(0).getId()); try { @@ -884,9 +884,9 @@ public class TestFavourites extends EnterpriseTestApi { assertEquals(HttpStatus.SC_NOT_FOUND, e.getHttpResponse().getStatusCode()); } - - Folder folder = new Folder(person1PublicFolders.get(0).getId()); + FavouriteFolder folder = new FavouriteFolder(person1PublicFolders.get(0).getId()); + try { publicApiClient.setRequestContext(new RequestContext(network1.getId(), person10Id)); @@ -954,11 +954,11 @@ public class TestFavourites extends EnterpriseTestApi log("cloud-2467"); Favourite siteFavourite1 = makeSiteFavourite(person1PublicSites.get(0)); - - Document document = repoService.getDocument(network1.getId(), person1PublicDocs.get(0)); + + FavouriteDocument document = repoService.getDocument(network1.getId(), person1PublicDocs.get(0)); Favourite fileFavourite1 = makeFileFavourite(document.getGuid()); - - Folder folder = repoService.getFolder(network1.getId(), person1PublicFolders.get(0)); + + FavouriteFolder folder = repoService.getFolder(network1.getId(), person1PublicFolders.get(0)); Favourite folderFavourite1 = makeFolderFavourite(folder.getGuid()); Favourite siteFavourite2 = makeSiteFavourite(person1PublicSites.get(1)); @@ -1087,7 +1087,7 @@ public class TestFavourites extends EnterpriseTestApi { publicApiClient.setRequestContext(new RequestContext(network1.getId(), person21Id)); - Document document1 = new Document(person1PrivateDocs.get(0).getId()); + FavouriteDocument document1 = new FavouriteDocument(person1PrivateDocs.get(0).getId()); Favourite favourite = makeFileFavourite(document1.getGuid()); try { @@ -1119,7 +1119,7 @@ public class TestFavourites extends EnterpriseTestApi { publicApiClient.setRequestContext(new RequestContext(network1.getId(), person21Id)); - Folder folder1 = new Folder(person1PrivateFolders.get(0).getId()); + FavouriteFolder folder1 = new FavouriteFolder(person1PrivateFolders.get(0).getId()); Favourite favourite = makeFolderFavourite(folder1.getGuid()); try { diff --git a/source/test-java/org/alfresco/rest/api/tests/client/data/ContentInfo.java b/source/test-java/org/alfresco/rest/api/tests/client/data/ContentInfo.java new file mode 100644 index 0000000000..930746dc94 --- /dev/null +++ b/source/test-java/org/alfresco/rest/api/tests/client/data/ContentInfo.java @@ -0,0 +1,39 @@ +package org.alfresco.rest.api.tests.client.data; + +/** + * Representation of content info (initially for client tests for File Folder API) + * + * @author janv + * + */ +public class ContentInfo +{ + private String mimeType; + private String mimeTypeName; + private long sizeInBytes; + private String encoding; + + public ContentInfo() + { + } + + public String getMimeType() { + return mimeType; + } + + public void setMimeType(String mimeType) { + this.mimeType = mimeType; + } + + public String getMimeTypeName() { + return mimeTypeName; + } + + public long getSizeInBytes() { + return sizeInBytes; + } + + public String getEncoding() { + return encoding; + } +} diff --git a/source/test-java/org/alfresco/rest/api/tests/client/data/Document.java b/source/test-java/org/alfresco/rest/api/tests/client/data/Document.java index 1905696fce..09da05a212 100644 --- a/source/test-java/org/alfresco/rest/api/tests/client/data/Document.java +++ b/source/test-java/org/alfresco/rest/api/tests/client/data/Document.java @@ -25,161 +25,27 @@ */ package org.alfresco.rest.api.tests.client.data; -import static org.junit.Assert.assertTrue; - -import java.math.BigInteger; -import java.text.ParseException; -import java.util.Date; -import java.util.GregorianCalendar; -import java.util.Map; - -import org.alfresco.model.ContentModel; -import org.alfresco.rest.api.tests.PublicApiDateFormat; -import org.apache.chemistry.opencmis.commons.PropertyIds; -import org.apache.chemistry.opencmis.commons.data.Properties; -import org.apache.chemistry.opencmis.commons.data.PropertyData; -import org.json.simple.JSONObject; - /** - * Representation of a document node. - * - * @author steveglover + * Representation of a document node (initially for client tests for File Folder API) * + * @author janv + * */ -public class Document extends Node implements ExpectedComparison, JSONAble +public class Document extends Node { - private static final long serialVersionUID = -5890002728061039516L; + private ContentInfo content; - private String mimeType; - private BigInteger sizeInBytes; - private String versionLabel; + public Document() { + super(); + } - /** - * For POSTs - * @param guid String - */ - public Document(String guid) - { - super(guid); - } + public ContentInfo getContent() + { + return content; + } - public Document(String id, String guid) - { - super(id, guid); - } - -// public Document(String id, String guid, Map properties) -// { -// super(id, guid, properties); -// } - - public static Document getDocument(String id, String guid, Properties props) - { - Document document = new Document(id, guid); - - Map> properties = props.getProperties(); - document.setName((String)properties.get(PropertyIds.NAME).getFirstValue()); - document.setTitle((String)properties.get(ContentModel.PROP_TITLE.toString()).getFirstValue()); - document.setCreatedBy((String)properties.get(PropertyIds.CREATED_BY).getFirstValue()); - document.setModifiedBy((String)properties.get(PropertyIds.LAST_MODIFIED_BY).getFirstValue()); - GregorianCalendar modifiedAt = (GregorianCalendar)properties.get(PropertyIds.LAST_MODIFICATION_DATE).getFirstValue(); - document.setModifiedAt(modifiedAt.getTime()); - GregorianCalendar createdAt = (GregorianCalendar)properties.get(PropertyIds.CREATION_DATE).getFirstValue(); - document.setCreatedAt(createdAt.getTime()); - //document.setDescription((String)props.get(PropertyIds.DE).getFirstValue()); - document.setMimeType((String)properties.get(PropertyIds.CONTENT_STREAM_MIME_TYPE).getFirstValue()); - document.setSizeInBytes((BigInteger)properties.get(PropertyIds.CONTENT_STREAM_LENGTH).getFirstValue()); - document.setVersionLabel((String)properties.get(PropertyIds.VERSION_LABEL).getFirstValue()); - return document; - } - - public String getMimeType() - { - return mimeType; - } - - public BigInteger getSizeInBytes() - { - return sizeInBytes; - } - - public String getVersionLabel() - { - return versionLabel; - } - - public void setMimeType(String mimeType) - { - this.mimeType = mimeType; - } - - public void setSizeInBytes(BigInteger sizeInBytes) - { - this.sizeInBytes = sizeInBytes; - } - - public void setVersionLabel(String versionLabel) - { - this.versionLabel = versionLabel; - } - - public JSONObject toJSON() - { - JSONObject json = super.toJSON(); - return json; - } - - @Override - public void expected(Object o) - { - super.expected(o); - - assertTrue(o instanceof Document); - - Document other = (Document)o; - - AssertUtil.assertEquals("mimeType", mimeType, other.getMimeType()); - AssertUtil.assertEquals("sizeInBytes", sizeInBytes, other.getSizeInBytes()); - AssertUtil.assertEquals("versionLabel", versionLabel, other.getVersionLabel()); - } - - public static Document parseDocument(JSONObject jsonObject) throws ParseException - { - String id = (String)jsonObject.get("id"); - String guid = (String)jsonObject.get("guid"); - String name = (String)jsonObject.get("name"); - String title = (String)jsonObject.get("title"); - String description = (String)jsonObject.get("description"); - Date createdAt = PublicApiDateFormat.getDateFormat().parse((String)jsonObject.get("createdAt")); - Date modifiedAt = PublicApiDateFormat.getDateFormat().parse((String)jsonObject.get("modifiedAt")); - String createdBy = (String)jsonObject.get("createdBy"); - String modifiedBy = (String)jsonObject.get("modifiedBy"); - String mimeType = (String)jsonObject.get("mimeType"); - Long sizeInBytes = (Long)jsonObject.get("sizeInBytes"); - String versionLabel = (String)jsonObject.get("versionLabel"); - - Document document = new Document(id, guid); - document.setName(name); - document.setTitle(title); - document.setCreatedBy(createdBy); - document.setModifiedBy(modifiedBy); - document.setModifiedAt(modifiedAt); - document.setCreatedAt(createdAt); - document.setDescription(description); - document.setMimeType(mimeType); - document.setSizeInBytes(BigInteger.valueOf(sizeInBytes)); - document.setVersionLabel(versionLabel); - return document; - } - - @Override - public String toString() - { - return "Document [mimeType=" + mimeType + ", sizeInBytes=" - + sizeInBytes + ", versionLabel=" + versionLabel + ", nodeId=" - + nodeId + ", guid=" + guid + ", name=" + name + ", title=" - + title + ", description=" + description + ", createdAt=" - + createdAt + ", modifiedAt=" + modifiedAt + ", createdBy=" - + createdBy + ", modifiedBy=" + modifiedBy + "]"; - } + public void setContent(ContentInfo content) + { + this.content = content; + } } diff --git a/source/test-java/org/alfresco/rest/api/tests/client/data/Favourite.java b/source/test-java/org/alfresco/rest/api/tests/client/data/Favourite.java index fe6881a754..cf3291b084 100644 --- a/source/test-java/org/alfresco/rest/api/tests/client/data/Favourite.java +++ b/source/test-java/org/alfresco/rest/api/tests/client/data/Favourite.java @@ -165,14 +165,14 @@ public class Favourite implements Serializable, ExpectedComparison, Comparable properties) +// { +// super(id, guid, properties); +// } + + public static FavouriteDocument getDocument(String id, String guid, Properties props) + { + FavouriteDocument document = new FavouriteDocument(id, guid); + + Map> properties = props.getProperties(); + document.setName((String)properties.get(PropertyIds.NAME).getFirstValue()); + document.setTitle((String)properties.get(ContentModel.PROP_TITLE.toString()).getFirstValue()); + document.setCreatedBy((String)properties.get(PropertyIds.CREATED_BY).getFirstValue()); + document.setModifiedBy((String)properties.get(PropertyIds.LAST_MODIFIED_BY).getFirstValue()); + GregorianCalendar modifiedAt = (GregorianCalendar)properties.get(PropertyIds.LAST_MODIFICATION_DATE).getFirstValue(); + document.setModifiedAt(modifiedAt.getTime()); + GregorianCalendar createdAt = (GregorianCalendar)properties.get(PropertyIds.CREATION_DATE).getFirstValue(); + document.setCreatedAt(createdAt.getTime()); + //document.setDescription((String)props.get(PropertyIds.DE).getFirstValue()); + document.setMimeType((String)properties.get(PropertyIds.CONTENT_STREAM_MIME_TYPE).getFirstValue()); + document.setSizeInBytes((BigInteger)properties.get(PropertyIds.CONTENT_STREAM_LENGTH).getFirstValue()); + document.setVersionLabel((String)properties.get(PropertyIds.VERSION_LABEL).getFirstValue()); + return document; + } + + public String getMimeType() + { + return mimeType; + } + + public BigInteger getSizeInBytes() + { + return sizeInBytes; + } + + public String getVersionLabel() + { + return versionLabel; + } + + public void setMimeType(String mimeType) + { + this.mimeType = mimeType; + } + + public void setSizeInBytes(BigInteger sizeInBytes) + { + this.sizeInBytes = sizeInBytes; + } + + public void setVersionLabel(String versionLabel) + { + this.versionLabel = versionLabel; + } + + public JSONObject toJSON() + { + JSONObject json = super.toJSON(); + return json; + } + + @Override + public void expected(Object o) + { + super.expected(o); + + assertTrue(o instanceof FavouriteDocument); + + FavouriteDocument other = (FavouriteDocument)o; + + AssertUtil.assertEquals("mimeType", mimeType, other.getMimeType()); + AssertUtil.assertEquals("sizeInBytes", sizeInBytes, other.getSizeInBytes()); + AssertUtil.assertEquals("versionLabel", versionLabel, other.getVersionLabel()); + } + + public static FavouriteDocument parseDocument(JSONObject jsonObject) throws ParseException + { + String id = (String)jsonObject.get("id"); + String guid = (String)jsonObject.get("guid"); + String name = (String)jsonObject.get("name"); + String title = (String)jsonObject.get("title"); + String description = (String)jsonObject.get("description"); + Date createdAt = PublicApiDateFormat.getDateFormat().parse((String)jsonObject.get("createdAt")); + Date modifiedAt = PublicApiDateFormat.getDateFormat().parse((String)jsonObject.get("modifiedAt")); + String createdBy = (String)jsonObject.get("createdBy"); + String modifiedBy = (String)jsonObject.get("modifiedBy"); + String mimeType = (String)jsonObject.get("mimeType"); + Long sizeInBytes = (Long)jsonObject.get("sizeInBytes"); + String versionLabel = (String)jsonObject.get("versionLabel"); + + FavouriteDocument document = new FavouriteDocument(id, guid); + document.setName(name); + document.setTitle(title); + document.setCreatedBy(createdBy); + document.setModifiedBy(modifiedBy); + document.setModifiedAt(modifiedAt); + document.setCreatedAt(createdAt); + document.setDescription(description); + document.setMimeType(mimeType); + document.setSizeInBytes(BigInteger.valueOf(sizeInBytes)); + document.setVersionLabel(versionLabel); + return document; + } + + @Override + public String toString() + { + return "FavouriteDocument [mimeType=" + mimeType + ", sizeInBytes=" + + sizeInBytes + ", versionLabel=" + versionLabel + ", nodeId=" + + nodeId + ", guid=" + guid + ", name=" + name + ", title=" + + title + ", description=" + description + ", createdAt=" + + createdAt + ", modifiedAt=" + modifiedAt + ", createdBy=" + + createdBy + ", modifiedBy=" + modifiedBy + "]"; + } +} diff --git a/source/test-java/org/alfresco/rest/api/tests/client/data/FavouriteFolder.java b/source/test-java/org/alfresco/rest/api/tests/client/data/FavouriteFolder.java new file mode 100644 index 0000000000..bf4534ca86 --- /dev/null +++ b/source/test-java/org/alfresco/rest/api/tests/client/data/FavouriteFolder.java @@ -0,0 +1,105 @@ +package org.alfresco.rest.api.tests.client.data; + +import java.text.ParseException; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.Map; + +import org.alfresco.model.ContentModel; +import org.alfresco.rest.api.tests.PublicApiDateFormat; +import org.apache.chemistry.opencmis.commons.PropertyIds; +import org.apache.chemistry.opencmis.commons.data.Properties; +import org.apache.chemistry.opencmis.commons.data.PropertyData; +import org.json.simple.JSONObject; + +/** + * Representation of a folder node (as returned by Favourites API) + * + * @author steveglover + * + */ +public class FavouriteFolder extends FavouriteNode implements ExpectedComparison, JSONAble +{ + private static final long serialVersionUID = 5020819866533183524L; + + /** + * For POSTs + * @param guid String + */ + public FavouriteFolder(String guid) + { + super(guid); + } + + public FavouriteFolder(String id, String guid) + { + super(id, guid); + } + +// public Folder(String id, String guid, Map properties) +// { +// super(id, guid, properties); +// } + + public static FavouriteFolder getFolder(String id, String guid, Properties props) + { + FavouriteFolder folder = new FavouriteFolder(id, guid); + + Map> properties = props.getProperties(); + folder.setName((String)properties.get(PropertyIds.NAME).getFirstValue()); + folder.setTitle((String)properties.get(ContentModel.PROP_TITLE.toString()).getFirstValue()); + folder.setCreatedBy((String)properties.get(PropertyIds.CREATED_BY).getFirstValue()); + folder.setModifiedBy((String)properties.get(PropertyIds.LAST_MODIFIED_BY).getFirstValue()); + GregorianCalendar modifiedAt = (GregorianCalendar)properties.get(PropertyIds.LAST_MODIFICATION_DATE).getFirstValue(); + folder.setModifiedAt(modifiedAt.getTime()); + GregorianCalendar createdAt = (GregorianCalendar)properties.get(PropertyIds.CREATION_DATE).getFirstValue(); + folder.setCreatedAt(createdAt.getTime()); + //document.setDescription((String)props.get(PropertyIds.DE).getFirstValue()); + return folder; + } + + public JSONObject toJSON() + { + JSONObject json = super.toJSON(); + return json; + } + + public static FavouriteFolder parseFolder(JSONObject jsonObject) throws ParseException + { + String id = (String)jsonObject.get("id"); + String guid = (String)jsonObject.get("guid"); + String name = (String)jsonObject.get("name"); + String title = (String)jsonObject.get("title"); + String description = (String)jsonObject.get("description"); + Date createdAt = PublicApiDateFormat.getDateFormat().parse((String)jsonObject.get("createdAt")); + Date modifiedAt = PublicApiDateFormat.getDateFormat().parse((String)jsonObject.get("modifiedAt")); + String createdBy = (String)jsonObject.get("createdBy"); + String modifiedBy = (String)jsonObject.get("modifiedBy"); + + FavouriteFolder folder = new FavouriteFolder(id, guid); + folder.setName(name); + folder.setTitle(title); + folder.setCreatedBy(createdBy); + folder.setModifiedBy(modifiedBy); + folder.setModifiedAt(modifiedAt); + folder.setCreatedAt(createdAt); + folder.setDescription(description); + return folder; + } + + @Override + public void expected(Object o) + { + super.expected(o); + } + + @Override + public String toString() + { + return "Folder [nodeId=" + nodeId + ", guid=" + guid + ", name=" + name + + ", title=" + title + ", description=" + description + + ", createdAt=" + createdAt + ", modifiedAt=" + modifiedAt + + ", createdBy=" + createdBy + ", modifiedBy=" + modifiedBy + + "]"; + } +} diff --git a/source/test-java/org/alfresco/rest/api/tests/client/data/FavouriteNode.java b/source/test-java/org/alfresco/rest/api/tests/client/data/FavouriteNode.java new file mode 100644 index 0000000000..bdd1565af3 --- /dev/null +++ b/source/test-java/org/alfresco/rest/api/tests/client/data/FavouriteNode.java @@ -0,0 +1,217 @@ +package org.alfresco.rest.api.tests.client.data; + +import static org.junit.Assert.assertTrue; + +import java.io.Serializable; +import java.util.Date; + +import org.json.simple.JSONObject; + +/** + * Alfresco API - Favourite node representation. + * + * @author steveglover + * + */ +public class FavouriteNode implements Serializable, ExpectedComparison +{ + private static final long serialVersionUID = -6881545732441221372L; + + protected String nodeId; + protected String guid; + protected String name; + protected String title; + protected String description; + protected Date createdAt; + protected Date modifiedAt; + protected String createdBy; + protected String modifiedBy; + + public FavouriteNode() + { + } + + /** + * For POSTs + * + * @param guid String + */ + public FavouriteNode(String guid) + { + this.guid = guid; + } + + public FavouriteNode(String id, String guid) + { + this.nodeId = id; + this.guid = guid; + } + + public void setGuid(String guid) + { + this.guid = guid; + } + + public String getGuid() + { + return guid; + } + + public String getRawNodeId() + { + return nodeId; + } + + public String getNodeId() + { + return nodeId; + } + + public boolean isFolder() + { + return false; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public String getTitle() + { + return title; + } + + public void setTitle(String title) + { + this.title = title; + } + + public String getDescription() + { + return description; + } + + public void setDescription(String description) + { + this.description = description; + } + + public Date getCreatedAt() + { + return createdAt; + } + + public void setCreatedAt(Date createdAt) + { + this.createdAt = createdAt; + } + + public Date getModifiedAt() + { + return modifiedAt; + } + + public void setModifiedAt(Date modifiedAt) + { + this.modifiedAt = modifiedAt; + } + + public String getCreatedBy() + { + return createdBy; + } + + public void setCreatedBy(String createdBy) + { + this.createdBy = createdBy; + } + + public String getModifiedBy() + { + return modifiedBy; + } + + public void setModifiedBy(String modifiedBy) + { + this.modifiedBy = modifiedBy; + } + + public void setNodeId(String nodeId) + { + this.nodeId = nodeId; + } + + @Override + public int hashCode() + { + final int prime = 31; + int result = 1; + result = prime * result + ((nodeId == null) ? 0 : nodeId.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) + { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + FavouriteNode other = (FavouriteNode) obj; + if (nodeId == null) + { + if (other.nodeId != null) + return false; + } else if (!nodeId.equals(other.nodeId)) + return false; + return true; + } + + @SuppressWarnings("unchecked") + public JSONObject toJSON() + { + JSONObject json = new JSONObject(); + json.put("guid", getGuid()); + json.put("id", getNodeId()); + return json; + } + + @Override + public void expected(Object o) + { + assertTrue(o instanceof FavouriteNode); + + FavouriteNode other = (FavouriteNode) o; + + AssertUtil.assertEquals("id", nodeId, other.getNodeId()); + AssertUtil.assertEquals("guid", guid, other.getGuid()); + AssertUtil.assertEquals("name", name, other.getName()); + AssertUtil.assertEquals("title", title, other.getTitle()); + AssertUtil.assertEquals("description", description, other.getDescription()); + AssertUtil.assertEquals("createdAt", createdAt, other.getCreatedAt()); + if(modifiedAt != null) + { + assertTrue(modifiedAt.before(other.getModifiedAt()) || modifiedAt.equals(other.getModifiedAt())); + } + AssertUtil.assertEquals("createdBy", createdBy, other.getCreatedBy()); + AssertUtil.assertEquals("modifiedBy", modifiedBy, other.getModifiedBy()); + } + + @Override + public String toString() + { + return "Node [nodeId=" + nodeId + ", guid=" + guid + ", name=" + name + + ", title=" + title + ", description=" + description + + ", createdAt=" + createdAt + ", modifiedAt=" + modifiedAt + + ", createdBy=" + createdBy + ", modifiedBy=" + modifiedBy + + "]"; + } +} diff --git a/source/test-java/org/alfresco/rest/api/tests/client/data/FileFavouriteTarget.java b/source/test-java/org/alfresco/rest/api/tests/client/data/FileFavouriteTarget.java index e1c664803e..3ce2748859 100644 --- a/source/test-java/org/alfresco/rest/api/tests/client/data/FileFavouriteTarget.java +++ b/source/test-java/org/alfresco/rest/api/tests/client/data/FileFavouriteTarget.java @@ -31,15 +31,15 @@ import org.json.simple.JSONObject; public class FileFavouriteTarget implements FavouritesTarget { - private Document document; + private FavouriteDocument document; - public FileFavouriteTarget(Document document) + public FileFavouriteTarget(FavouriteDocument document) { super(); this.document = document; } - public Document getDocument() + public FavouriteDocument getDocument() { return document; } diff --git a/source/test-java/org/alfresco/rest/api/tests/client/data/Folder.java b/source/test-java/org/alfresco/rest/api/tests/client/data/Folder.java index 897a86a16f..c4001e54c8 100644 --- a/source/test-java/org/alfresco/rest/api/tests/client/data/Folder.java +++ b/source/test-java/org/alfresco/rest/api/tests/client/data/Folder.java @@ -25,106 +25,15 @@ */ package org.alfresco.rest.api.tests.client.data; -import java.text.ParseException; -import java.util.Date; -import java.util.GregorianCalendar; -import java.util.Map; - -import org.alfresco.model.ContentModel; -import org.alfresco.rest.api.tests.PublicApiDateFormat; -import org.apache.chemistry.opencmis.commons.PropertyIds; -import org.apache.chemistry.opencmis.commons.data.Properties; -import org.apache.chemistry.opencmis.commons.data.PropertyData; -import org.json.simple.JSONObject; - /** - * Representation of a folder node. - * - * @author steveglover + * Representation of a folder node (initially for client tests for File Folder API) * + * @author janv */ -public class Folder extends Node implements ExpectedComparison, JSONAble +public class Folder extends Node { - private static final long serialVersionUID = 5020819866533183524L; - - /** - * For POSTs - * @param guid String - */ - public Folder(String guid) - { - super(guid); - } - - public Folder(String id, String guid) - { - super(id, guid); - } - -// public Folder(String id, String guid, Map properties) -// { -// super(id, guid, properties); -// } - - public static Folder getFolder(String id, String guid, Properties props) - { - Folder folder = new Folder(id, guid); - - Map> properties = props.getProperties(); - folder.setName((String)properties.get(PropertyIds.NAME).getFirstValue()); - folder.setTitle((String)properties.get(ContentModel.PROP_TITLE.toString()).getFirstValue()); - folder.setCreatedBy((String)properties.get(PropertyIds.CREATED_BY).getFirstValue()); - folder.setModifiedBy((String)properties.get(PropertyIds.LAST_MODIFIED_BY).getFirstValue()); - GregorianCalendar modifiedAt = (GregorianCalendar)properties.get(PropertyIds.LAST_MODIFICATION_DATE).getFirstValue(); - folder.setModifiedAt(modifiedAt.getTime()); - GregorianCalendar createdAt = (GregorianCalendar)properties.get(PropertyIds.CREATION_DATE).getFirstValue(); - folder.setCreatedAt(createdAt.getTime()); - //document.setDescription((String)props.get(PropertyIds.DE).getFirstValue()); - return folder; - } - - public JSONObject toJSON() - { - JSONObject json = super.toJSON(); - return json; - } - - public static Folder parseFolder(JSONObject jsonObject) throws ParseException - { - String id = (String)jsonObject.get("id"); - String guid = (String)jsonObject.get("guid"); - String name = (String)jsonObject.get("name"); - String title = (String)jsonObject.get("title"); - String description = (String)jsonObject.get("description"); - Date createdAt = PublicApiDateFormat.getDateFormat().parse((String)jsonObject.get("createdAt")); - Date modifiedAt = PublicApiDateFormat.getDateFormat().parse((String)jsonObject.get("modifiedAt")); - String createdBy = (String)jsonObject.get("createdBy"); - String modifiedBy = (String)jsonObject.get("modifiedBy"); - - Folder folder = new Folder(id, guid); - folder.setName(name); - folder.setTitle(title); - folder.setCreatedBy(createdBy); - folder.setModifiedBy(modifiedBy); - folder.setModifiedAt(modifiedAt); - folder.setCreatedAt(createdAt); - folder.setDescription(description); - return folder; - } - - @Override - public void expected(Object o) - { - super.expected(o); - } - - @Override - public String toString() - { - return "Folder [nodeId=" + nodeId + ", guid=" + guid + ", name=" + name - + ", title=" + title + ", description=" + description - + ", createdAt=" + createdAt + ", modifiedAt=" + modifiedAt - + ", createdBy=" + createdBy + ", modifiedBy=" + modifiedBy - + "]"; - } + public Folder() + { + super(); + } } diff --git a/source/test-java/org/alfresco/rest/api/tests/client/data/FolderFavouriteTarget.java b/source/test-java/org/alfresco/rest/api/tests/client/data/FolderFavouriteTarget.java index 3d24fa21df..594cd8e11b 100644 --- a/source/test-java/org/alfresco/rest/api/tests/client/data/FolderFavouriteTarget.java +++ b/source/test-java/org/alfresco/rest/api/tests/client/data/FolderFavouriteTarget.java @@ -31,15 +31,15 @@ import org.json.simple.JSONObject; public class FolderFavouriteTarget implements FavouritesTarget { - private Folder folder; + private FavouriteFolder folder; - public FolderFavouriteTarget(Folder folder) + public FolderFavouriteTarget(FavouriteFolder folder) { super(); this.folder = folder; } - public Folder getFolder() + public FavouriteFolder getFolder() { return folder; } diff --git a/source/test-java/org/alfresco/rest/api/tests/client/data/Node.java b/source/test-java/org/alfresco/rest/api/tests/client/data/Node.java index f5a673e71e..1fdf133e99 100644 --- a/source/test-java/org/alfresco/rest/api/tests/client/data/Node.java +++ b/source/test-java/org/alfresco/rest/api/tests/client/data/Node.java @@ -25,218 +25,142 @@ */ package org.alfresco.rest.api.tests.client.data; -import static org.junit.Assert.assertTrue; - -import java.io.Serializable; import java.util.Date; - -import org.json.simple.JSONObject; +import java.util.List; +import java.util.Map; /** - * Alfresco API (non-CMIS) node representation. - * - * @author steveglover + * Representation of a node (for client tests for File Folder API) * + * @author janv */ -public class Node implements Serializable, ExpectedComparison +public class Node { - private static final long serialVersionUID = -6881545732441221372L; + protected String id; + protected String name; - protected String nodeId; - protected String guid; - protected String name; - protected String title; - protected String description; - protected Date createdAt; - protected Date modifiedAt; - protected String createdBy; - protected String modifiedBy; + protected Date createdAt; + protected Date modifiedAt; + protected UserInfo createdByUser; + protected UserInfo modifiedByUser; - public Node() - { - } + protected Boolean isFolder; + protected Boolean isLink; - /** - * For POSTs - * - * @param guid String - */ - public Node(String guid) - { - this.guid = guid; - } + protected String parentId; + protected PathInfo path; + protected String nodeType; - public Node(String id, String guid) - { - this.nodeId = id; - this.guid = guid; - } + protected List aspectNames; - public void setGuid(String guid) - { - this.guid = guid; - } + protected Map properties; - public String getGuid() - { - return guid; - } + public Node() + { + } - public String getRawNodeId() - { - return nodeId; - } + public String getId() + { + return id; + } - public String getNodeId() - { - return nodeId; - } + public String getName() + { + return name; + } - public boolean isFolder() - { - return false; - } - - public String getName() - { - return name; - } + public void setName(String name) + { + this.name = name; + } - public void setName(String name) - { - this.name = name; - } + public Date getCreatedAt() + { + return createdAt; + } - public String getTitle() - { - return title; - } + public Date getModifiedAt() + { + return modifiedAt; + } - public void setTitle(String title) - { - this.title = title; - } + public UserInfo getCreatedByUser() + { + return createdByUser; + } - public String getDescription() - { - return description; - } + public UserInfo getModifiedByUser() + { + return modifiedByUser; + } - public void setDescription(String description) - { - this.description = description; - } + public Boolean getIsFolder() + { + return isFolder; + } - public Date getCreatedAt() - { - return createdAt; - } + public void setIsFolder(Boolean folder) + { + isFolder = folder; + } - public void setCreatedAt(Date createdAt) - { - this.createdAt = createdAt; - } + public Boolean getIsLink() + { + return isLink; + } - public Date getModifiedAt() - { - return modifiedAt; - } + public void setIsLink(Boolean link) + { + isLink = link; + } - public void setModifiedAt(Date modifiedAt) - { - this.modifiedAt = modifiedAt; - } + public String getParentId() + { + return parentId; + } - public String getCreatedBy() - { - return createdBy; - } + public void setParentId(String parentId) + { + this.parentId = parentId; + } - public void setCreatedBy(String createdBy) - { - this.createdBy = createdBy; - } + public PathInfo getPath() + { + return path; + } - public String getModifiedBy() - { - return modifiedBy; - } + public void setPath(PathInfo path) + { + this.path = path; + } - public void setModifiedBy(String modifiedBy) - { - this.modifiedBy = modifiedBy; - } + public String getNodeType() + { + return nodeType; + } - public void setNodeId(String nodeId) - { - this.nodeId = nodeId; - } + public void setNodeType(String nodeType) + { + this.nodeType = nodeType; + } - @Override - public int hashCode() - { - final int prime = 31; - int result = 1; - result = prime * result + ((nodeId == null) ? 0 : nodeId.hashCode()); - return result; - } + public List getAspectNames() + { + return aspectNames; + } - @Override - public boolean equals(Object obj) - { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Node other = (Node) obj; - if (nodeId == null) - { - if (other.nodeId != null) - return false; - } else if (!nodeId.equals(other.nodeId)) - return false; - return true; - } + public void setAspectNames(List aspectNames) + { + this.aspectNames = aspectNames; + } - @SuppressWarnings("unchecked") - public JSONObject toJSON() - { - JSONObject json = new JSONObject(); - json.put("guid", getGuid()); - json.put("id", getNodeId()); - return json; - } + public Map getProperties() + { + return properties; + } - @Override - public void expected(Object o) - { - assertTrue(o instanceof Node); - - Node other = (Node) o; - - AssertUtil.assertEquals("id", nodeId, other.getNodeId()); - AssertUtil.assertEquals("guid", guid, other.getGuid()); - AssertUtil.assertEquals("name", name, other.getName()); - AssertUtil.assertEquals("title", title, other.getTitle()); - AssertUtil.assertEquals("description", description, other.getDescription()); - AssertUtil.assertEquals("createdAt", createdAt, other.getCreatedAt()); - if(modifiedAt != null) - { - assertTrue(modifiedAt.before(other.getModifiedAt()) || modifiedAt.equals(other.getModifiedAt())); - } - AssertUtil.assertEquals("createdBy", createdBy, other.getCreatedBy()); - AssertUtil.assertEquals("modifiedBy", modifiedBy, other.getModifiedBy()); - } - - @Override - public String toString() - { - return "Node [nodeId=" + nodeId + ", guid=" + guid + ", name=" + name - + ", title=" + title + ", description=" + description - + ", createdAt=" + createdAt + ", modifiedAt=" + modifiedAt - + ", createdBy=" + createdBy + ", modifiedBy=" + modifiedBy - + "]"; - } -} + public void setProperties(Map properties) + { + this.properties = properties; + } +} \ No newline at end of file diff --git a/source/test-java/org/alfresco/rest/api/tests/client/data/PathInfo.java b/source/test-java/org/alfresco/rest/api/tests/client/data/PathInfo.java new file mode 100644 index 0000000000..c62a6f6b4a --- /dev/null +++ b/source/test-java/org/alfresco/rest/api/tests/client/data/PathInfo.java @@ -0,0 +1,57 @@ + +package org.alfresco.rest.api.tests.client.data; + +import org.alfresco.service.cmr.repository.NodeRef; + +import java.util.List; + +/** + * Representation of a path info (initially for client tests for File Folder API) + * + * @author janv + */ +public class PathInfo +{ + private String name; + private Boolean isComplete; + private List elements; + + public PathInfo() + { + } + + public String getName() + { + return name; + } + + public Boolean getIsComplete() + { + return isComplete; + } + + public List getElements() + { + return elements; + } + + public static class ElementInfo + { + private NodeRef id; + private String name; + + public ElementInfo() + { + } + + public String getName() + { + return name; + } + + public NodeRef getId() + { + return id; + } + } +} diff --git a/source/test-java/org/alfresco/rest/api/tests/client/data/UserInfo.java b/source/test-java/org/alfresco/rest/api/tests/client/data/UserInfo.java new file mode 100644 index 0000000000..240e854b9c --- /dev/null +++ b/source/test-java/org/alfresco/rest/api/tests/client/data/UserInfo.java @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2005-2015 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * 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 . + */ + +package org.alfresco.rest.api.tests.client.data; + +/** + * Representation of a user info (initially for client tests for File Folder API) + * + * @author janv + */ +public class UserInfo +{ + private String userName; + private String displayName; + + public UserInfo() + { + } + + public String getDisplayName() + { + return displayName; + } + + public String getUserName() + { + return userName; + } +} diff --git a/source/test-java/org/alfresco/rest/workflow/api/tests/ProcessWorkflowApiTest.java b/source/test-java/org/alfresco/rest/workflow/api/tests/ProcessWorkflowApiTest.java index 92b9c5e06d..91e65d0b6a 100644 --- a/source/test-java/org/alfresco/rest/workflow/api/tests/ProcessWorkflowApiTest.java +++ b/source/test-java/org/alfresco/rest/workflow/api/tests/ProcessWorkflowApiTest.java @@ -56,6 +56,7 @@ import org.alfresco.rest.api.tests.client.PublicApiClient.ListResponse; import org.alfresco.rest.api.tests.client.PublicApiException; import org.alfresco.rest.api.tests.client.RequestContext; import org.alfresco.rest.api.tests.client.data.Document; +import org.alfresco.rest.api.tests.client.data.FavouriteDocument; import org.alfresco.rest.api.tests.client.data.MemberOfSite; import org.alfresco.rest.api.tests.client.data.SiteRole; import org.alfresco.rest.workflow.api.model.ProcessInfo; @@ -385,7 +386,7 @@ public class ProcessWorkflowApiTest extends EnterpriseWorkflowTestApi final ActivitiScriptNode packageScriptNode = (ActivitiScriptNode) variables.get("bpm_package"); assertNotNull(packageScriptNode); - final Map documentMap = new HashMap(); + final Map documentMap = new HashMap<>(); TenantUtil.runAsUserTenant(new TenantRunAsWork() { @@ -395,7 +396,7 @@ public class ProcessWorkflowApiTest extends EnterpriseWorkflowTestApi List documentList = nodeService.getChildAssocs(packageScriptNode.getNodeRef()); for (ChildAssociationRef childAssociationRef : documentList) { - Document doc = getTestFixture().getRepoService().getDocument(requestContext.getNetworkId(), childAssociationRef.getChildRef()); + FavouriteDocument doc = getTestFixture().getRepoService().getDocument(requestContext.getNetworkId(), childAssociationRef.getChildRef()); documentMap.put(doc.getName(), doc); } @@ -415,7 +416,7 @@ public class ProcessWorkflowApiTest extends EnterpriseWorkflowTestApi assertEquals(2, documentMap.size()); assertTrue(documentMap.containsKey("Test Doc1")); - Document doc = documentMap.get("Test Doc1"); + FavouriteDocument doc = documentMap.get("Test Doc1"); assertEquals("Test Doc1", doc.getName()); assertEquals("Test Doc1 Title", doc.getTitle());