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

127611 jkaabimofrad: Merged API-STRIKES-BACK (5.2.0) to HEAD (5.2)
      127447 jvonka: Node Associations - creating/listing primary child assoc type other than cm:contains
      - follow-on fix + test based on review back (create children below content)
      - also -ve test for model integrity excet
      - RA-1092


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@127718 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2016-06-03 15:18:53 +00:00
parent 6fccac5a48
commit f99ba16ec7
2 changed files with 41 additions and 5 deletions

View File

@@ -1823,9 +1823,11 @@ public class NodeApiTest extends AbstractBaseApiTest
obj.setName("c1");
obj.setNodeType(TYPE_CM_CONTENT);
// assoc type => cm:contains
response = post(getNodeChildrenUrl(fId), user1, toJsonAsStringNonNull(obj), 201);
Node nodeResp = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Node.class);
String c1Id = nodeResp.getId();
assertEquals(fId, nodeResp.getParentId());
obj = new Node();
obj.setName("c2");
@@ -1834,9 +1836,11 @@ public class NodeApiTest extends AbstractBaseApiTest
assoc.setAssocType(ASSOC_TYPE_CM_PREFERENCE_IMAGE);
obj.setAssociation(assoc);
// assoc type => cm:preferenceImage
response = post(getNodeChildrenUrl(fId), user1, toJsonAsStringNonNull(obj), 201);
nodeResp = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Node.class);
String c2Id = nodeResp.getId();
assertEquals(fId, nodeResp.getParentId());
response = getAll(getNodeChildrenUrl(fId), user1, null, null, 200);
nodes = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Node.class);
@@ -1859,6 +1863,43 @@ public class NodeApiTest extends AbstractBaseApiTest
assertEquals(1, nodes.size());
assertEquals(c2Id, nodes.get(0).getId());
assertTrue(nodes.get(0).getAssociation().getIsPrimary());
//
// test that we can also create children below content
//
obj = new Node();
obj.setName("c3");
obj.setNodeType(TYPE_CM_CONTENT);
nodeUpdate.setAspectNames(Collections.singletonList(ASPECT_CM_PREFERENCES));
// assoc type => cm:contains
response = post(getNodeChildrenUrl(fId), user1, toJsonAsStringNonNull(obj), 201);
nodeResp = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Node.class);
String c3Id = nodeResp.getId();
obj = new Node();
obj.setName("c4");
obj.setNodeType(TYPE_CM_CONTENT);
assoc = new Association();
assoc.setAssocType(ASSOC_TYPE_CM_PREFERENCE_IMAGE);
obj.setAssociation(assoc);
// assoc type => cm:preferenceImage
response = post(getNodeChildrenUrl(c3Id), user1, toJsonAsStringNonNull(obj), 201);
nodeResp = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Node.class);
assertEquals(c3Id, nodeResp.getParentId());
// -ve test
obj = new Node();
obj.setName("c5");
obj.setNodeType(TYPE_CM_CONTENT);
assoc = new Association();
assoc.setAssocType(ASSOC_TYPE_CM_CONTAINS);
obj.setAssociation(assoc);
// assoc type => cm:contains (requires parent to be a folder !)
post(getNodeChildrenUrl(c3Id), user1, toJsonAsStringNonNull(obj), 422);
}
finally
{