diff --git a/e2e-test/java/org/alfresco/rest/nodes/NodesParentChildrenTests.java b/e2e-test/java/org/alfresco/rest/nodes/NodesParentChildrenTests.java index 74f107adf..097f652e3 100644 --- a/e2e-test/java/org/alfresco/rest/nodes/NodesParentChildrenTests.java +++ b/e2e-test/java/org/alfresco/rest/nodes/NodesParentChildrenTests.java @@ -8,7 +8,7 @@ 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.RestNodeAssociationModelCollection; import org.alfresco.rest.model.builder.NodesBuilder; import org.alfresco.utility.Utility; import org.alfresco.utility.model.ContentModel; @@ -136,7 +136,7 @@ public class NodesParentChildrenTests extends RestTest 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() + RestNodeAssociationModelCollection secondaryChildren = restClient.withParams("where=(assocType='cm:contains')").withCoreAPI() .usingNode(nodesBuilder.getNode("F1").toContentModel()).getSecondaryChildren(); restClient.assertStatusCodeIs(HttpStatus.OK); secondaryChildren.assertThat().entriesListCountIs(2); @@ -186,7 +186,7 @@ public class NodesParentChildrenTests extends RestTest 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(); + RestNodeAssociationModelCollection parents = restClient.withCoreAPI().usingNode(nodesBuilder.getNode("f1").toContentModel()).getParents(); restClient.assertStatusCodeIs(HttpStatus.OK); parents.assertThat().entriesListCountIs(2); diff --git a/e2e-test/java/org/alfresco/rest/nodes/NodesTargetSourcesTests.java b/e2e-test/java/org/alfresco/rest/nodes/NodesTargetSourcesTests.java new file mode 100644 index 000000000..47290fd09 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/nodes/NodesTargetSourcesTests.java @@ -0,0 +1,74 @@ +package org.alfresco.rest.nodes; + +import static org.alfresco.utility.report.log.Step.STEP; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestNodeAssocTargetModel; +import org.alfresco.rest.model.RestNodeAssociationModelCollection; +import org.alfresco.rest.model.builder.NodesBuilder; +import org.alfresco.utility.model.ContentModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class NodesTargetSourcesTests extends RestTest +{ + + private UserModel adminUserModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + } + + /** + * Sanity check for the following api endpoints + * POST /nodes/{nodeId}/targets + * GET /nodes/{nodeId}/targets + * DELETE /nodes/{nodeId}/targets/{targetId} + */ + + @TestRail(section = { TestGroup.REST_API, + TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Check /targets (create, list, delete) api calls") + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY }) + public void checkTargetsNodeApi() 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").folder("F3").file("f1").file("f2").file("f3"); + + STEP("2. Create target associations model objects"); + RestNodeAssocTargetModel assocDocTarget1 = new RestNodeAssocTargetModel(nodesBuilder.getNode("f2").toContentModel().getNodeRef(), "cm:references"); + RestNodeAssocTargetModel assocDocTarget2 = new RestNodeAssocTargetModel(nodesBuilder.getNode("f3").toContentModel().getNodeRef(), "cm:references"); + + STEP("3. Create target associations using POST /nodes/{nodeId}/targets"); + restClient.authenticateUser(adminUserModel); + restClient.withCoreAPI().usingResource(nodesBuilder.getNode("f1").toContentModel()).createTargetForNode(assocDocTarget1); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withCoreAPI().usingResource(nodesBuilder.getNode("f1").toContentModel()).createTargetForNode(assocDocTarget2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + STEP("4. Check using GET /nodes/{nodeId}/targets targets associations were created"); + RestNodeAssociationModelCollection tagets = restClient.withParams("where=(assocType='cm:references')").withCoreAPI() + .usingResource(nodesBuilder.getNode("f1").toContentModel()).getNodeTargets(); + restClient.assertStatusCodeIs(HttpStatus.OK); + tagets.assertThat().entriesListCountIs(2); + + STEP("5. Check using DELETE /nodes/{nodeId}/targets/{targetId} that a target can be deleted"); + restClient.authenticateUser(adminUserModel); + restClient.withCoreAPI().usingResource(nodesBuilder.getNode("f1").toContentModel()).deleteTarget(assocDocTarget1); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + STEP("6. Check using GET /nodes/{nodeId}/targets that target association was deleted"); + RestNodeAssociationModelCollection targetsRes = restClient.withParams("where=(assocType='cm:references')").withCoreAPI() + .usingResource(nodesBuilder.getNode("f1").toContentModel()).getNodeTargets(); + restClient.assertStatusCodeIs(HttpStatus.OK); + targetsRes.assertThat().entriesListCountIs(1); + } + +}