mirror of
https://github.com/Alfresco/SearchServices.git
synced 2026-09-16 18:12:56 +00:00
Merge branch 'feature/REPO-2299Implement_TAS_tests_for_'Nodes'_RestApi_Part_1' into 'master'
Feature/repo 2299 implement tas tests for 'nodes' rest api part 1 See merge request !25
This commit is contained in:
@@ -1,94 +0,0 @@
|
||||
package org.alfresco.rest.nodes;
|
||||
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.model.RestNodeBodyModel;
|
||||
import org.alfresco.rest.model.RestNodeModel;
|
||||
import org.alfresco.rest.model.RestNodeModelsCollection;
|
||||
import org.alfresco.rest.model.builder.NodesBuilder;
|
||||
import org.alfresco.utility.Utility;
|
||||
import org.alfresco.utility.model.ContentModel;
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
import org.alfresco.utility.testrail.ExecutionType;
|
||||
import org.alfresco.utility.testrail.annotation.TestRail;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* Handles tests related to api-explorer/#!/nodes/children
|
||||
*/
|
||||
public class NodesChildrenTests extends RestTest
|
||||
{
|
||||
@TestRail(section = { TestGroup.REST_API,TestGroup.NODES }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify new folder node is created as children on -my- posting as JSON content type")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY})
|
||||
public void createNewFolderNodeViaJason() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(dataContent.getAdminUser());
|
||||
|
||||
RestNodeBodyModel node = new RestNodeBodyModel();
|
||||
node.setName("My Folder");
|
||||
node.setNodeType("cm:folder");
|
||||
|
||||
RestNodeModel newNode = restClient.withParams("autoRename=true").withCoreAPI().usingNode(ContentModel.my()).createNode(node);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
|
||||
newNode.assertThat().field("aspectNames").contains("cm:auditable")
|
||||
.assertThat().field("isFolder").is(true)
|
||||
.assertThat().field("isFile").is(false)
|
||||
.assertThat().field("name").contains(node.getName());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,TestGroup.NODES }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify new folder node is created as children on -my- posting as MultiPart content type")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY})
|
||||
public void createNewFolderNodeWithMultiPartForms() throws Exception
|
||||
{
|
||||
//configuring multipart form
|
||||
restClient.authenticateUser(dataContent.getAdminUser())
|
||||
.configureRequestSpec()
|
||||
.addMultiPart("filedata", Utility.getResourceTestDataFile("restapi-resource"))
|
||||
.addFormParam("renditions", "doclib")
|
||||
.addFormParam("autoRename", true);
|
||||
|
||||
RestNodeModel newNode = restClient.withCoreAPI().usingNode(ContentModel.my()).createNode();
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
newNode.assertThat().field("aspectNames").contains("cm:auditable")
|
||||
.assertThat().field("isFolder").is(false)
|
||||
.assertThat().field("isFile").is(true)
|
||||
.assertThat().field("name").contains("restapi-resource");
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,TestGroup.NODES }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify list children when listing with relativePath and pagination")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY})
|
||||
public void checkRelativePathAndPaginationOnCreateChildrenNode() throws Exception
|
||||
{
|
||||
/*
|
||||
* Given we have a folder hierarchy folder1/folder2/folder3 and folder3 containing 3 files file1, file2, and file3
|
||||
*/
|
||||
NodesBuilder nodesBuilder = restClient.authenticateUser(dataUser.getAdminUser())
|
||||
.withCoreAPI().usingNode(ContentModel.my())
|
||||
.defineNodes();
|
||||
nodesBuilder
|
||||
.folder("F1")
|
||||
.folder("F2")
|
||||
.folder("F3")
|
||||
.file("f1")
|
||||
.file("f2")
|
||||
.file("f3");
|
||||
|
||||
RestNodeModelsCollection returnedFiles = restClient.withParams("maxItems=2",
|
||||
"skipCount=1",
|
||||
String.format("relativePath=%s/%s", nodesBuilder.getNode("F2").getName(), nodesBuilder.getNode("F3").getName()))
|
||||
.withCoreAPI().usingNode(nodesBuilder.getNode("F1").toContentModel()).listChildren();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
/*
|
||||
* Then I receive file2 and file3
|
||||
*/
|
||||
returnedFiles.assertThat().entriesListCountIs(2);
|
||||
returnedFiles.getEntries().get(0).onModel().assertThat().field("id").is(nodesBuilder.getNode("f2").getId());
|
||||
returnedFiles.getEntries().get(1).onModel().assertThat().field("id").is(nodesBuilder.getNode("f3").getId());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,10 +1,18 @@
|
||||
package org.alfresco.rest.nodes;
|
||||
|
||||
import static org.alfresco.utility.report.log.Step.STEP;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertNotSame;
|
||||
import static org.testng.Assert.assertSame;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil.DocumentType;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.core.JsonBodyGenerator;
|
||||
import org.alfresco.rest.model.RestNodeModel;
|
||||
import org.alfresco.rest.model.body.RestNodeLockBodyModel;
|
||||
import org.alfresco.utility.Utility;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.FileType;
|
||||
@@ -15,6 +23,7 @@ import org.alfresco.utility.model.UserModel;
|
||||
import org.alfresco.utility.report.Bug;
|
||||
import org.alfresco.utility.testrail.ExecutionType;
|
||||
import org.alfresco.utility.testrail.annotation.TestRail;
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
@@ -35,7 +44,7 @@ public class NodesContentTests extends RestTest
|
||||
user1 = dataUser.createRandomTestUser();
|
||||
user2 = dataUser.createRandomTestUser();
|
||||
site1 = dataSite.usingUser(user1).createPublicRandomSite();
|
||||
site2 = dataSite.usingUser(user2).createPublicRandomSite();
|
||||
site2 = dataSite.usingUser(user2).createPublicRandomSite();
|
||||
file1 = dataContent.usingUser(user1).usingSite(site1).createContent(DocumentType.TEXT_PLAIN);
|
||||
}
|
||||
|
||||
@@ -91,7 +100,62 @@ public class NodesContentTests extends RestTest
|
||||
STEP("4. Retrieve the nodes and verify that the content type is the expected one (GET nodes/{nodeId}).");
|
||||
restClient.withCoreAPI().usingNode(utf8File).getNodeContent().assertThat().contentType(utf8Type);
|
||||
restClient.withCoreAPI().usingNode(iso8859File).getNodeContent().assertThat().contentType(iso8859Type);
|
||||
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE })
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Verify updating a node content.")
|
||||
public void testUpdateNodeContent() throws Exception
|
||||
{
|
||||
STEP("1. Retrieve the node in order to get data to compare after update GET /nodes/{nodeId}?include=path.");
|
||||
RestNodeModel initialNode = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=path").getNode();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
STEP("2. Update the node content (different from the initial one) PUT /nodes/{nodeId}/content?majorVersion=true&name=newfile.txt.");
|
||||
File avatarFile = Utility.getResourceTestDataFile("my-file.tif");
|
||||
RestNodeModel updatedBodyNode = restClient.withCoreAPI().usingNode(file1).usingParams("majorVersion=true&name=newfile.txt").updateNodeContent(avatarFile);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
STEP("3. Compare contentSize, modifiedAt, name and version, they should be different.");
|
||||
assertNotSame(initialNode.getContent().getSizeInBytes(), updatedBodyNode.getContent().getSizeInBytes());
|
||||
assertNotSame(initialNode.getModifiedAt(), updatedBodyNode.getModifiedAt());
|
||||
assertNotSame(initialNode.getName(), updatedBodyNode.getName());
|
||||
|
||||
String initialNodeVersion = new JSONObject(initialNode.toJson()).getJSONObject("properties").getString("cm:versionLabel");
|
||||
String updatedBodyNodeVersion = new JSONObject(updatedBodyNode.toJson()).getJSONObject("properties").getString("cm:versionLabel");
|
||||
assertTrue(updatedBodyNodeVersion.charAt(0) > initialNodeVersion.charAt(0));
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE })
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Test copy a node.")
|
||||
public void testCopyNode() throws Exception
|
||||
{
|
||||
STEP("1. Create a lock and lock the node POST /nodes/{nodeId}/lock?include=path,isLocked.");
|
||||
RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel();
|
||||
lockBodyModel.setLifetime("EPHEMERAL");
|
||||
lockBodyModel.setTimeToExpire(20);
|
||||
lockBodyModel.setType("FULL");
|
||||
RestNodeModel initialNode = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=path,isLocked").lockNode(lockBodyModel);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
STEP("2. With another user(that has access to the file), copy the node to another path POST /nodes/{nodeId}/copy?include=path,isLocked.");
|
||||
String postBody = JsonBodyGenerator.keyValueJson("targetParentId", site2.getGuid());
|
||||
RestNodeModel copiedNode = restClient.authenticateUser(user2).withCoreAPI().usingNode(file1).usingParams("include=path,isLocked")
|
||||
.copyNode(postBody);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
|
||||
STEP("3. ParentId, createdAt, path and lock are different, but the nodes have the same contentSize.");
|
||||
assertNotSame(copiedNode.getParentId(), initialNode.getParentId());
|
||||
assertNotSame(copiedNode.getCreatedAt(), initialNode.getCreatedAt());
|
||||
assertNotSame(copiedNode.getPath(), initialNode.getPath());
|
||||
assertTrue(initialNode.getIsLocked());
|
||||
assertSame(copiedNode.getContent().getSizeInBytes(), initialNode.getContent().getSizeInBytes());
|
||||
assertFalse(copiedNode.getIsLocked());
|
||||
|
||||
STEP("4. Unlock the node (this node may be used in the next tests).");
|
||||
initialNode = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").unlockNode();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
assertFalse(initialNode.getIsLocked());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,205 @@
|
||||
package org.alfresco.rest.nodes;
|
||||
|
||||
import static org.alfresco.utility.report.log.Step.STEP;
|
||||
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.model.RestNodeBodyModel;
|
||||
import org.alfresco.rest.model.RestNodeChildAssocModelCollection;
|
||||
import org.alfresco.rest.model.RestNodeChildAssociationModel;
|
||||
import org.alfresco.rest.model.RestNodeModel;
|
||||
import org.alfresco.rest.model.RestNodeModelsCollection;
|
||||
import org.alfresco.rest.model.RestNodeParentChildModelCollection;
|
||||
import org.alfresco.rest.model.builder.NodesBuilder;
|
||||
import org.alfresco.utility.Utility;
|
||||
import org.alfresco.utility.model.ContentModel;
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
import org.alfresco.utility.testrail.ExecutionType;
|
||||
import org.alfresco.utility.testrail.annotation.TestRail;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* Handles tests related to
|
||||
* api-explorer/#!/nodes/children
|
||||
* api-explorer/#!/nodes/secondary-children
|
||||
* api-explorer/#!/nodes/parents
|
||||
*/
|
||||
public class NodesParentChildrenTests extends RestTest
|
||||
{
|
||||
@TestRail(section = { TestGroup.REST_API,TestGroup.NODES }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify new folder node is created as children on -my- posting as JSON content type")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY})
|
||||
public void createNewFolderNodeViaJason() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(dataContent.getAdminUser());
|
||||
|
||||
RestNodeBodyModel node = new RestNodeBodyModel();
|
||||
node.setName("My Folder");
|
||||
node.setNodeType("cm:folder");
|
||||
|
||||
RestNodeModel newNode = restClient.withParams("autoRename=true").withCoreAPI().usingNode(ContentModel.my()).createNode(node);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
|
||||
newNode.assertThat().field("aspectNames").contains("cm:auditable")
|
||||
.assertThat().field("isFolder").is(true)
|
||||
.assertThat().field("isFile").is(false)
|
||||
.assertThat().field("name").contains(node.getName());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,TestGroup.NODES }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify new folder node is created as children on -my- posting as MultiPart content type")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY})
|
||||
public void createNewFolderNodeWithMultiPartForms() throws Exception
|
||||
{
|
||||
//configuring multipart form
|
||||
restClient.authenticateUser(dataContent.getAdminUser())
|
||||
.configureRequestSpec()
|
||||
.addMultiPart("filedata", Utility.getResourceTestDataFile("restapi-resource"))
|
||||
.addFormParam("renditions", "doclib")
|
||||
.addFormParam("autoRename", true);
|
||||
|
||||
RestNodeModel newNode = restClient.withCoreAPI().usingNode(ContentModel.my()).createNode();
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
newNode.assertThat().field("aspectNames").contains("cm:auditable")
|
||||
.assertThat().field("isFolder").is(false)
|
||||
.assertThat().field("isFile").is(true)
|
||||
.assertThat().field("name").contains("restapi-resource");
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,TestGroup.NODES }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify list children when listing with relativePath and pagination")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY})
|
||||
public void checkRelativePathAndPaginationOnCreateChildrenNode() throws Exception
|
||||
{
|
||||
/*
|
||||
* Given we have a folder hierarchy folder1/folder2/folder3 and folder3 containing 3 files file1, file2, and file3
|
||||
*/
|
||||
NodesBuilder nodesBuilder = restClient.authenticateUser(dataUser.getAdminUser())
|
||||
.withCoreAPI().usingNode(ContentModel.my())
|
||||
.defineNodes();
|
||||
nodesBuilder
|
||||
.folder("F1")
|
||||
.folder("F2")
|
||||
.folder("F3")
|
||||
.file("f1")
|
||||
.file("f2")
|
||||
.file("f3");
|
||||
|
||||
RestNodeModelsCollection returnedFiles = restClient.withParams("maxItems=2",
|
||||
"skipCount=1",
|
||||
String.format("relativePath=%s/%s", nodesBuilder.getNode("F2").getName(), nodesBuilder.getNode("F3").getName()))
|
||||
.withCoreAPI().usingNode(nodesBuilder.getNode("F1").toContentModel()).listChildren();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
/*
|
||||
* Then I receive file2 and file3
|
||||
*/
|
||||
returnedFiles.assertThat().entriesListCountIs(2);
|
||||
returnedFiles.getEntries().get(0).onModel().assertThat().field("id").is(nodesBuilder.getNode("f2").getId());
|
||||
returnedFiles.getEntries().get(1).onModel().assertThat().field("id").is(nodesBuilder.getNode("f3").getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanity check for the following api endpoints
|
||||
* POST /nodes/{nodeId}/secondary-children
|
||||
* GET /nodes/{nodeId}/secondary-children
|
||||
* DELETE /nodes/{nodeId}/secondary-children/{childId}
|
||||
*/
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Check /secondary-children (create, list, delete) api calls")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY })
|
||||
public void checkSecondaryChildrenApi() throws Exception
|
||||
{
|
||||
STEP("1. Create a folder hierarchy folder1/folder2, with folder2 containing 3 files: f1, f2, and f3");
|
||||
NodesBuilder nodesBuilder = restClient.authenticateUser(dataUser.getAdminUser())
|
||||
.withCoreAPI().usingNode(ContentModel.my())
|
||||
.defineNodes();
|
||||
nodesBuilder
|
||||
.folder("F1")
|
||||
.folder("F2")
|
||||
.file("f1")
|
||||
.file("f2")
|
||||
.file("f3");
|
||||
|
||||
STEP("2. Create secondary child associations model objects");
|
||||
RestNodeChildAssociationModel childAssoc1 = new RestNodeChildAssociationModel(nodesBuilder.getNode("f1").getId(), "cm:contains");
|
||||
RestNodeChildAssociationModel childAssoc2 = new RestNodeChildAssociationModel(nodesBuilder.getNode("f2").getId(), "cm:contains");
|
||||
RestNodeChildAssociationModel childAssoc3 = new RestNodeChildAssociationModel(nodesBuilder.getNode("f3").getId(), "cm:preferenceImage");
|
||||
String secondaryChildrenBody = "[" + childAssoc1.toJson() + "," + childAssoc2.toJson() + "," + childAssoc3.toJson() + "]";
|
||||
|
||||
STEP("3. Create secondary child associations using POST /nodes/{nodeId}/secondary-children");
|
||||
RestNodeChildAssocModelCollection secondaryChildAssoc = restClient.withCoreAPI().usingNode(nodesBuilder.getNode("F1").toContentModel())
|
||||
.createSecondaryChildren(secondaryChildrenBody);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
secondaryChildAssoc.getEntryByIndex(0).assertThat().field("childId").is(childAssoc1.getChildId());
|
||||
secondaryChildAssoc.getEntryByIndex(1).assertThat().field("childId").is(childAssoc2.getChildId());
|
||||
secondaryChildAssoc.getEntryByIndex(2).assertThat().field("childId").is(childAssoc3.getChildId());
|
||||
|
||||
STEP("4. Check using GET /nodes/{nodeId}/secondary-children that the secondary 'cm:contains' child associations were created");
|
||||
RestNodeParentChildModelCollection secondaryChildren = restClient.withParams("where=(assocType='cm:contains')").withCoreAPI()
|
||||
.usingNode(nodesBuilder.getNode("F1").toContentModel()).getSecondaryChildren();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
secondaryChildren.assertThat().entriesListCountIs(2);
|
||||
|
||||
STEP("5. Check using DELETE /nodes/{nodeId}/secondary-children/{childId} that a secondary child can be deleted");
|
||||
restClient.withCoreAPI().usingNode(nodesBuilder.getNode("F1").toContentModel()).deleteSecondaryChild(secondaryChildren.getEntryByIndex(0));
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
|
||||
STEP("6. Check using GET /nodes/{nodeId}/secondary-children that a secondary child association was deleted");
|
||||
secondaryChildren = restClient.withCoreAPI().usingNode(nodesBuilder.getNode("F1").toContentModel())
|
||||
.getSecondaryChildren();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
secondaryChildren.assertThat().entriesListCountIs(2);
|
||||
secondaryChildren.getEntryByIndex(0).assertThat()
|
||||
.field("id").is(secondaryChildAssoc.getEntryByIndex(1).getChildId()).and()
|
||||
.field("parentId").is(nodesBuilder.getNode("F2").getId())
|
||||
.getAssociation().assertThat()
|
||||
.field("isPrimary").is(false).and()
|
||||
.field("assocType").is("cm:contains");
|
||||
secondaryChildren.getEntryByIndex(1).assertThat()
|
||||
.field("id").is(secondaryChildAssoc.getEntryByIndex(2).getChildId())
|
||||
.getAssociation().assertThat()
|
||||
.field("assocType").is("cm:preferenceImage");
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanity check for the following api endpoint
|
||||
* GET /nodes/{nodeId}/parents
|
||||
*/
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Check that GET /parents retrieves primary and secondary parents for a node")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY })
|
||||
public void checkGetNodeParents() throws Exception
|
||||
{
|
||||
STEP("1. Create a folder hierarchy folder1/folder2, with folder2 containing file f1");
|
||||
NodesBuilder nodesBuilder = restClient.authenticateUser(dataUser.getAdminUser())
|
||||
.withCoreAPI().usingNode(ContentModel.my())
|
||||
.defineNodes();
|
||||
nodesBuilder
|
||||
.folder("F1")
|
||||
.folder("F2")
|
||||
.file("f1");
|
||||
|
||||
STEP("2. Create secondary child associations using POST /nodes/{nodeId}/secondary-children");
|
||||
RestNodeChildAssociationModel childAssoc = new RestNodeChildAssociationModel(nodesBuilder.getNode("f1").getId(), "cm:contains");
|
||||
restClient.withCoreAPI().usingNode(nodesBuilder.getNode("F1").toContentModel()).createSecondaryChildren(childAssoc.toJson());
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
|
||||
STEP("3. Get all parents for file 'f1' - both primary and secondary");
|
||||
RestNodeParentChildModelCollection parents = restClient.withCoreAPI().usingNode(nodesBuilder.getNode("f1").toContentModel()).getParents();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
parents.assertThat().entriesListCountIs(2);
|
||||
|
||||
STEP("4. Check using GET /nodes/{nodeId}/parents that the parent (not primary) for f1 is found");
|
||||
parents = restClient.withParams("where=(isPrimary=false)").withCoreAPI().usingNode(nodesBuilder.getNode("f1").toContentModel()).getParents();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
parents.assertThat().entriesListCountIs(1);
|
||||
parents.getEntryByIndex(0).assertThat()
|
||||
.field("isFolder").is("true").and()
|
||||
.field("isFile").is(false).and()
|
||||
.field("name").is(nodesBuilder.getNode("F1").getName())
|
||||
.getAssociation().assertThat()
|
||||
.field("isPrimary").is(false).and()
|
||||
.field("assocType").is("cm:contains");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user