mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged HEAD (5.2) to 5.2.N (5.2.1)
126401 jkaabimofrad: Merged FILE-FOLDER-API (5.2.0) to HEAD (5.2) 121206 jvonka: FileFolder API - NodeApiTest - minor updates around 'expected' checks - pre-work (eg. before implementing "move" and also hiding "sys" namespace aspects/props, etc) RA-638, RA-683 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@126746 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -28,14 +28,14 @@ public class ContentInfo
|
||||
{
|
||||
private String mimeType;
|
||||
private String mimeTypeName;
|
||||
private long sizeInBytes;
|
||||
private Long sizeInBytes;
|
||||
private String encoding;
|
||||
|
||||
public ContentInfo()
|
||||
{
|
||||
}
|
||||
|
||||
public ContentInfo( String mimeType, String mimeTypeName, long sizeInBytes, String encoding)
|
||||
public ContentInfo(String mimeType, String mimeTypeName, Long sizeInBytes, String encoding)
|
||||
{
|
||||
this.mimeType = mimeType;
|
||||
this.mimeTypeName = mimeTypeName;
|
||||
@@ -55,7 +55,7 @@ public class ContentInfo
|
||||
return mimeTypeName;
|
||||
}
|
||||
|
||||
public long getSizeInBytes() {
|
||||
public Long getSizeInBytes() {
|
||||
return sizeInBytes;
|
||||
}
|
||||
|
||||
|
@@ -511,99 +511,90 @@ public class NodeApiTest extends AbstractBaseApiTest
|
||||
public void testGetNodeInfo() throws Exception
|
||||
{
|
||||
AuthenticationUtil.setFullyAuthenticatedUser(user1);
|
||||
HttpResponse response = getSingle(NodesEntityResource.class, user1, Nodes.PATH_MY, null, 200);
|
||||
|
||||
HttpResponse response = getSingle(NodesEntityResource.class, user1, Nodes.PATH_ROOT, null, 200);
|
||||
Node node = jacksonUtil.parseEntry(response.getJsonResponse(), Node.class);
|
||||
NodeRef companyHomeNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, node.getId());
|
||||
|
||||
response = getSingle(NodesEntityResource.class, user1, Nodes.PATH_MY, null, 200);
|
||||
node = jacksonUtil.parseEntry(response.getJsonResponse(), Node.class);
|
||||
String myFilesNodeId = node.getId();
|
||||
assertNotNull(myFilesNodeId);
|
||||
assertEquals(user1, node.getName());
|
||||
assertTrue(node.getIsFolder());
|
||||
|
||||
NodeRef myHomeNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, myFilesNodeId);
|
||||
NodeRef userHomesNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, node.getParentId());
|
||||
|
||||
// /Company Home/User Homes/user<timestamp>/folder<timestamp>_A
|
||||
String folderA = "folder" + System.currentTimeMillis() + "_A";
|
||||
NodeRef folderA_Ref = repoService.createFolder(new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, myFilesNodeId), folderA);
|
||||
NodeRef folderA_Ref = repoService.createFolder(myHomeNodeRef, folderA);
|
||||
|
||||
// /Company Home/User Homes/user<timestamp>/folder<timestamp>_A/folder<timestamp>_B
|
||||
String folderB = "folder" + System.currentTimeMillis() + "_B";
|
||||
NodeRef folderB_Ref = repoService.createFolder(folderA_Ref, folderB);
|
||||
|
||||
// /Company Home/User Homes/user<timestamp>/folder<timestamp>_A/folder<timestamp>_B/content<timestamp>
|
||||
String content = "content" + System.currentTimeMillis();
|
||||
NodeRef contentNodeRef = repoService.createDocument(folderB_Ref, content, "The quick brown fox jumps over the lazy dog.");
|
||||
String contentName = "content" + System.currentTimeMillis();
|
||||
NodeRef contentNodeRef = repoService.createDocument(folderB_Ref, contentName, "The quick brown fox jumps over the lazy dog.");
|
||||
|
||||
// Add property
|
||||
repoService.nodeService.setProperty(contentNodeRef, ContentModel.PROP_TITLE, "test title");
|
||||
String title = "test title";
|
||||
repoService.nodeService.setProperty(contentNodeRef, ContentModel.PROP_TITLE, title);
|
||||
|
||||
// get node info
|
||||
response = getSingle(NodesEntityResource.class, user1, contentNodeRef.getId(), null, 200);
|
||||
Document document = jacksonUtil.parseEntry(response.getJsonResponse(), Document.class);
|
||||
// Check all the default info the node API should return
|
||||
assertEquals(content, document.getName());
|
||||
assertNotNull(document.getId());
|
||||
assertNotNull(document.getCreatedAt());
|
||||
assertNotNull(document.getCreatedByUser());
|
||||
UserInfo createdByUser = document.getCreatedByUser();
|
||||
assertEquals(user1, createdByUser.getId());
|
||||
assertEquals(user1 + " " + user1, createdByUser.getDisplayName());
|
||||
assertNotNull(document.getModifiedAt());
|
||||
assertNotNull(document.getModifiedByUser());
|
||||
UserInfo modifiedByUser = document.getModifiedByUser();
|
||||
assertEquals(user1, modifiedByUser.getId());
|
||||
assertEquals(user1 + " " + user1, modifiedByUser.getDisplayName());
|
||||
assertFalse(document.getIsFolder());
|
||||
assertNull(document.getIsLink());
|
||||
assertEquals("cm:content", document.getNodeType());
|
||||
assertNotNull(document.getParentId());
|
||||
assertNotNull(document.getProperties());
|
||||
assertTrue(document.getProperties().containsKey("cm:title"));
|
||||
assertNotNull(document.getAspectNames());
|
||||
assertTrue(document.getAspectNames().contains("cm:titled"));
|
||||
ContentInfo contentInfo = document.getContent();
|
||||
assertNotNull(contentInfo);
|
||||
assertNotNull(contentInfo.getEncoding());
|
||||
assertTrue(contentInfo.getSizeInBytes() > 0);
|
||||
assertNotNull(contentInfo.getMimeType());
|
||||
assertNotNull(contentInfo.getMimeTypeName());
|
||||
// Path is not part of the default info
|
||||
assertNull(document.getPath());
|
||||
Document documentResp = jacksonUtil.parseEntry(response.getJsonResponse(), Document.class);
|
||||
|
||||
// Expected result ...
|
||||
UserInfo expectedUser = new UserInfo(user1, user1+" "+user1);
|
||||
|
||||
Document d1 = new Document();
|
||||
d1.setId(documentResp.getId());
|
||||
d1.setParentId(folderB_Ref.getId());
|
||||
d1.setName(contentName);
|
||||
d1.setNodeType("cm:content");
|
||||
ContentInfo ci = new ContentInfo();
|
||||
|
||||
// TODO fix me !!
|
||||
//ci.setMimeType("text/plain");
|
||||
//ci.setMimeTypeName("Plain Text");
|
||||
ci.setMimeType("application/octet-stream");
|
||||
ci.setMimeTypeName("Binary File (Octet Stream)");
|
||||
|
||||
ci.setSizeInBytes(44L);
|
||||
ci.setEncoding("UTF-8");
|
||||
d1.setContent(ci);
|
||||
d1.setCreatedByUser(expectedUser);
|
||||
d1.setModifiedByUser(expectedUser);
|
||||
|
||||
Map<String,Object> props = new HashMap<>();
|
||||
props.put("cm:title",title);
|
||||
|
||||
d1.setProperties(props);
|
||||
d1.setAspectNames(Arrays.asList("cm:auditable","cm:titled"));
|
||||
|
||||
// Note: Path is not part of the default info
|
||||
d1.expected(documentResp);
|
||||
|
||||
// get node info + path
|
||||
//...nodes/nodeId?select=path
|
||||
Map<String, String> params = Collections.singletonMap("select", "path");
|
||||
response = getSingle(NodesEntityResource.class, user1, contentNodeRef.getId(), params, 200);
|
||||
document = jacksonUtil.parseEntry(response.getJsonResponse(), Document.class);
|
||||
// default info
|
||||
assertEquals(content, document.getName());
|
||||
assertNotNull(document.getId());
|
||||
assertNotNull(document.getCreatedAt());
|
||||
assertNotNull(document.getCreatedByUser());
|
||||
assertNotNull(document.getModifiedAt());
|
||||
assertNotNull(document.getModifiedByUser());
|
||||
assertFalse(document.getIsFolder());
|
||||
assertNull(document.getIsLink());
|
||||
assertEquals("cm:content", document.getNodeType());
|
||||
assertNotNull(document.getParentId());
|
||||
assertNotNull(document.getProperties());
|
||||
assertNotNull(document.getAspectNames());
|
||||
assertNotNull(document.getContent());
|
||||
// Path info
|
||||
PathInfo pathInfo = document.getPath();
|
||||
assertNotNull(pathInfo);
|
||||
assertTrue(pathInfo.getIsComplete());
|
||||
assertNotNull(pathInfo.getName());
|
||||
// the pathInfo should only include the parents (not the requested node)
|
||||
assertFalse(pathInfo.getName().endsWith(content));
|
||||
assertTrue(pathInfo.getName().startsWith("/Company Home"));
|
||||
List<ElementInfo> pathElements = pathInfo.getElements();
|
||||
assertEquals(5, pathElements.size());
|
||||
assertEquals("Company Home", pathElements.get(0).getName());
|
||||
assertNotNull(pathElements.get(0).getId());
|
||||
assertEquals("User Homes", pathElements.get(1).getName());
|
||||
assertNotNull(pathElements.get(1).getId());
|
||||
assertEquals(user1, pathElements.get(2).getName());
|
||||
assertNotNull(pathElements.get(2).getId());
|
||||
assertEquals(folderA, pathElements.get(3).getName());
|
||||
assertNotNull(pathElements.get(3).getId());
|
||||
assertEquals(folderB, pathElements.get(4).getName());
|
||||
assertNotNull(pathElements.get(4).getId());
|
||||
documentResp = jacksonUtil.parseEntry(response.getJsonResponse(), Document.class);
|
||||
|
||||
// Expected path ...
|
||||
// note: the pathInfo should only include the parents (not the requested node)
|
||||
List<ElementInfo> elements = new ArrayList<>(5);
|
||||
elements.add(new ElementInfo(companyHomeNodeRef, "Company Home"));
|
||||
elements.add(new ElementInfo(userHomesNodeRef, "User Homes"));
|
||||
elements.add(new ElementInfo(myHomeNodeRef, user1));
|
||||
elements.add(new ElementInfo(folderA_Ref, folderA));
|
||||
elements.add(new ElementInfo(folderB_Ref, folderB));
|
||||
PathInfo expectedPath = new PathInfo("/Company Home/User Homes/"+user1+"/"+folderA+"/"+folderB, true, elements);
|
||||
d1.setPath(expectedPath);
|
||||
|
||||
d1.expected(documentResp);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -212,7 +212,14 @@ public class Node
|
||||
assertNotNull(other.createdAt);
|
||||
}
|
||||
|
||||
if (createdByUser != null)
|
||||
{
|
||||
createdByUser.expected(other.getCreatedByUser());
|
||||
}
|
||||
else
|
||||
{
|
||||
assertNotNull(other.createdByUser);
|
||||
}
|
||||
|
||||
if (modifiedAt != null)
|
||||
{
|
||||
@@ -223,12 +230,19 @@ public class Node
|
||||
assertNotNull(other.modifiedAt);
|
||||
}
|
||||
|
||||
if (modifiedByUser != null)
|
||||
{
|
||||
modifiedByUser.expected(other.getModifiedByUser());
|
||||
}
|
||||
else
|
||||
{
|
||||
assertNotNull(other.modifiedByUser);
|
||||
}
|
||||
|
||||
if (aspectNames != null)
|
||||
{
|
||||
assertNotNull(other.getAspectNames());
|
||||
assertEquals(aspectNames.size(), other.getAspectNames().size());
|
||||
assertEquals("Expected: "+aspectNames+", actual: "+other.getAspectNames(), aspectNames.size(), other.getAspectNames().size());
|
||||
for (String aspectName : aspectNames)
|
||||
{
|
||||
assertTrue(other.getAspectNames().contains(aspectName));
|
||||
@@ -254,6 +268,7 @@ public class Node
|
||||
assertNull(other.getProperties());
|
||||
}
|
||||
|
||||
AssertUtil.assertEquals("isFolder", isFolder, other.getIsFolder());
|
||||
AssertUtil.assertEquals("isLink", isLink, other.getIsLink());
|
||||
|
||||
if (path != null) {
|
||||
|
@@ -1,12 +1,32 @@
|
||||
|
||||
/*
|
||||
* Copyright (C) 2005-2016 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.rest.api.tests.client.data;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import junit.framework.TestCase;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
/**
|
||||
* Representation of a path info (initially for client tests for File Folder API)
|
||||
@@ -23,6 +43,13 @@ public class PathInfo
|
||||
{
|
||||
}
|
||||
|
||||
public PathInfo(String name, Boolean isComplete, List<ElementInfo> elements)
|
||||
{
|
||||
this.name = name;
|
||||
this.isComplete = isComplete;
|
||||
this.elements = elements;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
@@ -47,6 +74,12 @@ public class PathInfo
|
||||
{
|
||||
}
|
||||
|
||||
public ElementInfo(NodeRef id, String name)
|
||||
{
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
@@ -56,6 +89,15 @@ public class PathInfo
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public void expected(Object o)
|
||||
{
|
||||
assertTrue(o instanceof ElementInfo);
|
||||
|
||||
ElementInfo other = (ElementInfo) o;
|
||||
assertEquals(id, other.getName());
|
||||
assertEquals(name, other.getName());
|
||||
}
|
||||
}
|
||||
|
||||
public void expected(Object o)
|
||||
@@ -64,7 +106,17 @@ public class PathInfo
|
||||
|
||||
PathInfo other = (PathInfo) o;
|
||||
|
||||
// TODO
|
||||
Assert.fail("TODO test optional path elements !");
|
||||
assertEquals(getIsComplete(), other.getIsComplete());
|
||||
assertEquals(getName(), other.getName());
|
||||
|
||||
int idx = 0;
|
||||
for (ElementInfo element : elements)
|
||||
{
|
||||
ElementInfo otherElement = other.getElements().get(idx);
|
||||
|
||||
assertEquals("Expected: "+element.getId()+", actual: "+otherElement.getId(), element.getId(), otherElement.getId());
|
||||
assertEquals("Expected: "+element.getName()+", actual: "+otherElement.getName(), element.getName(), otherElement.getName());
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user