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)
127609 jkaabimofrad: Merged API-STRIKES-BACK (5.2.0) to HEAD (5.2) 127435 jvonka: Node Associations - creating/listing primary child assoc type other than cm:contains - follow-on to add api sanity tests RA-1092 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@127716 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -55,6 +55,7 @@ import org.alfresco.rest.api.tests.client.PublicApiClient.ExpectedPaging;
|
||||
import org.alfresco.rest.api.tests.client.PublicApiClient.Paging;
|
||||
import org.alfresco.rest.api.tests.client.PublicApiHttpClient.BinaryPayload;
|
||||
import org.alfresco.rest.api.tests.client.RequestContext;
|
||||
import org.alfresco.rest.api.tests.client.data.Association;
|
||||
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;
|
||||
@@ -1789,6 +1790,86 @@ public class NodeApiTest extends AbstractBaseApiTest
|
||||
post(getNodeChildrenUrl(myNodeId), user1, RestApiUtil.toJsonAsStringNonNull(n), 409);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests creation and listing of children using assoc type other than "cm:contains".
|
||||
*
|
||||
* <p>POST:</p>
|
||||
* {@literal <host>:<port>/alfresco/api/-default-/public/alfresco/versions/1/nodes/<nodeId>/children}
|
||||
*
|
||||
* <p>GET:</p>
|
||||
* {@literal <host>:<port>/alfresco/api/-default-/public/alfresco/versions/1/nodes/<nodeId>/children}
|
||||
*/
|
||||
@Test
|
||||
public void testChildrenAssocType() throws Exception
|
||||
{
|
||||
String myNodeId = getMyNodeId(user1);
|
||||
|
||||
String fId = null;
|
||||
|
||||
try
|
||||
{
|
||||
fId = createFolder(user1, myNodeId, "testChildrenAssocType folder").getId();
|
||||
|
||||
Node nodeUpdate = new Node();
|
||||
nodeUpdate.setAspectNames(Collections.singletonList(ASPECT_CM_PREFERENCES));
|
||||
|
||||
put(URL_NODES, user1, fId, toJsonAsStringNonNull(nodeUpdate), null, 200);
|
||||
|
||||
HttpResponse response = getAll(getNodeChildrenUrl(fId), user1, null, null, 200);
|
||||
List<Node> nodes = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Node.class);
|
||||
assertEquals(0, nodes.size());
|
||||
|
||||
Node obj = new Node();
|
||||
obj.setName("c1");
|
||||
obj.setNodeType(TYPE_CM_CONTENT);
|
||||
|
||||
response = post(getNodeChildrenUrl(fId), user1, toJsonAsStringNonNull(obj), 201);
|
||||
Node nodeResp = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Node.class);
|
||||
String c1Id = nodeResp.getId();
|
||||
|
||||
obj = new Node();
|
||||
obj.setName("c2");
|
||||
obj.setNodeType(TYPE_CM_CONTENT);
|
||||
Association assoc = new Association();
|
||||
assoc.setAssocType(ASSOC_TYPE_CM_PREFERENCE_IMAGE);
|
||||
obj.setAssociation(assoc);
|
||||
|
||||
response = post(getNodeChildrenUrl(fId), user1, toJsonAsStringNonNull(obj), 201);
|
||||
nodeResp = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Node.class);
|
||||
String c2Id = nodeResp.getId();
|
||||
|
||||
response = getAll(getNodeChildrenUrl(fId), user1, null, null, 200);
|
||||
nodes = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Node.class);
|
||||
assertEquals(2, nodes.size());
|
||||
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("where", "(assocType='"+ASSOC_TYPE_CM_CONTAINS+"')");
|
||||
params.put("include", "association");
|
||||
response = getAll(getNodeChildrenUrl(fId), user1, null, params, 200);
|
||||
nodes = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Node.class);
|
||||
assertEquals(1, nodes.size());
|
||||
assertEquals(c1Id, nodes.get(0).getId());
|
||||
assertTrue(nodes.get(0).getAssociation().getIsPrimary());
|
||||
|
||||
params = new HashMap<>();
|
||||
params.put("where", "(assocType='"+ASSOC_TYPE_CM_PREFERENCE_IMAGE+"')");
|
||||
params.put("include", "association");
|
||||
response = getAll(getNodeChildrenUrl(fId), user1, null, params, 200);
|
||||
nodes = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Node.class);
|
||||
assertEquals(1, nodes.size());
|
||||
assertEquals(c2Id, nodes.get(0).getId());
|
||||
assertTrue(nodes.get(0).getAssociation().getIsPrimary());
|
||||
}
|
||||
finally
|
||||
{
|
||||
// some cleanup
|
||||
if (fId != null)
|
||||
{
|
||||
delete(URL_NODES, user1, fId, 204);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO test custom types with properties (sub-type of cm:cmobject)
|
||||
|
||||
@Test
|
||||
|
Reference in New Issue
Block a user