Merged 5.2.N (5.2.2) to HEAD (5.2)

134045 cturlica: REPO-1684: We should not return properties that are empty
      - Empty (zero length) string values are considered to be null values, and will be represented the same as null values (i.e. by non-existence of the property).


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@137334 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Andrei Rebegea
2017-06-14 16:56:13 +00:00
parent 7b013ec1c5
commit a3fcd7a5b3
4 changed files with 63 additions and 0 deletions

View File

@@ -3544,6 +3544,49 @@ public class NodeApiTest extends AbstractSingleNetworkSiteTest
assertEquals("The quick brown fox jumps over the lazy dog", textContent);
}
@Test
public void testGetNodeWithEmptyProperties() throws Exception
{
setRequestContext(user1);
String myNodeId = getMyNodeId();
// create folder f1
Folder folderResp = createFolder(myNodeId, "fld1_" + RUNID);
String f1Id = folderResp.getId();
String nodeName = "f1 link";
String nodeType = "app:folderlink";
String propertyName = "cm:destination";
Map<String, Object> props = new HashMap<>();
props.put(propertyName, "");
Node nodeResp = createNode(f1Id, nodeName, nodeType, props);
String nodeId = nodeResp.getId();
Node n1 = new Node();
n1.setName(nodeName);
n1.setNodeType(nodeType);
n1.setIsFolder(true);
// note: parent of the link (not where it is pointing)
n1.setParentId(f1Id);
n1.setAspectNames(Collections.singletonList("cm:auditable"));
// Empty (zero length) string values are considered to be
// null values, and will be represented the same as null
// values (i.e. by non-existence of the property).
n1.setProperties(null);
// Check create response.
n1.expected(nodeResp);
HttpResponse httpResponse = getSingle(NodesEntityResource.class, nodeId, null, 200);
nodeResp = RestApiUtil.parseRestApiEntry(httpResponse.getJsonResponse(), Node.class);
// Check get response.
n1.expected(nodeResp);
}
/**
* Tests optional lookup of Allowable Operations (eg. when getting node info, listing node children, ...)
*

View File

@@ -77,6 +77,7 @@ public class TestPeople extends EnterpriseTestApi
private static final QName PROP_TELEHASH = QName.createQName("test.people.api", "telehash");
private static final QName ASPECT_LUNCHABLE = QName.createQName("test.people.api", "lunchable");
private static final QName PROP_LUNCH = QName.createQName("test.people.api", "lunch");
private static final QName PROP_LUNCH_COMMENTS = QName.createQName("test.people.api", "lunchcomments");
private People people;
private Iterator<TestNetwork> accountsIt;
private TestNetwork account1;
@@ -577,6 +578,7 @@ public class TestPeople extends EnterpriseTestApi
Map<QName, Serializable> nodeProps = new HashMap<>();
// The papi:lunchable aspect should be auto-added for the papi:lunch property
nodeProps.put(PROP_LUNCH, "Falafel wrap");
nodeProps.put(PROP_LUNCH_COMMENTS, "");
// These properties should not be present when a person is retrieved
// since they are present as top-level fields.
@@ -629,6 +631,11 @@ public class TestPeople extends EnterpriseTestApi
assertEquals("Doc", person.getFirstName());
assertEquals("Falafel wrap", person.getProperties().get("papi:lunch"));
assertTrue(person.getAspectNames().contains("papi:lunchable"));
// Empty (zero length) string values are considered to be
// null values, and will be represented the same as null
// values (i.e. by non-existence of the property).
assertNull(person.getProperties().get("papi:lunchcomments"));
// Check that no properties are present that should have been filtered by namespace.
for (String key : person.getProperties().keySet())