From 1c2fa9a703fd67a472bf789f366eafd435691bfe Mon Sep 17 00:00:00 2001 From: Bryan Orozco Date: Fri, 16 Feb 2024 12:10:01 -0800 Subject: [PATCH] feat: create ref from commit --- .../mms/core/services/BranchService.java | 2 +- .../branches/BranchesController.java | 4 - .../crud/services/DefaultBranchService.java | 113 +- .../mms/crud/services/NodeGetHelper.java | 1 + example/crud.postman_collection.json | 1577 +++++++++-------- 5 files changed, 922 insertions(+), 775 deletions(-) diff --git a/core/src/main/java/org/openmbee/mms/core/services/BranchService.java b/core/src/main/java/org/openmbee/mms/core/services/BranchService.java index 1adc2427c..bc61f413d 100644 --- a/core/src/main/java/org/openmbee/mms/core/services/BranchService.java +++ b/core/src/main/java/org/openmbee/mms/core/services/BranchService.java @@ -10,7 +10,7 @@ public interface BranchService { RefsResponse getBranch(String projectId, String id); RefJson createBranch(String projectId, RefJson branch); - RefJson createBranchfromCommit(String projectId, RefJson parentCommitId, NodeService nodeService); + RefJson createBranchfromCommit(String projectId, RefJson branch, NodeService nodeService); RefsResponse deleteBranch(String projectId, String id); } diff --git a/crud/src/main/java/org/openmbee/mms/crud/controllers/branches/BranchesController.java b/crud/src/main/java/org/openmbee/mms/crud/controllers/branches/BranchesController.java index 6db4b002d..598821731 100644 --- a/crud/src/main/java/org/openmbee/mms/crud/controllers/branches/BranchesController.java +++ b/crud/src/main/java/org/openmbee/mms/crud/controllers/branches/BranchesController.java @@ -9,7 +9,6 @@ import org.openmbee.mms.core.objects.RefsResponse; import org.openmbee.mms.core.objects.Rejection; import org.openmbee.mms.core.services.BranchService; -import org.openmbee.mms.core.services.NodeService; import org.openmbee.mms.crud.controllers.BaseController; import org.openmbee.mms.json.RefJson; import org.springframework.beans.factory.annotation.Autowired; @@ -18,7 +17,6 @@ import org.springframework.security.core.Authentication; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; -import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody; import java.util.ArrayList; import java.util.List; @@ -98,8 +96,6 @@ public RefsResponse createRefs( if (branch.getParentCommitId() == null || branch.getParentCommitId().isEmpty()) { res = branchService.createBranch(projectId, branch); } else { - //TODO implement branching from historical commit - res = branchService.createBranchfromCommit(projectId, branch, getNodeService(projectId)); } diff --git a/crud/src/main/java/org/openmbee/mms/crud/services/DefaultBranchService.java b/crud/src/main/java/org/openmbee/mms/crud/services/DefaultBranchService.java index 7abeac682..68b4230ee 100644 --- a/crud/src/main/java/org/openmbee/mms/crud/services/DefaultBranchService.java +++ b/crud/src/main/java/org/openmbee/mms/crud/services/DefaultBranchService.java @@ -18,6 +18,7 @@ import org.openmbee.mms.data.domains.scoped.Branch; import org.openmbee.mms.data.domains.scoped.Commit; import org.openmbee.mms.data.domains.scoped.Node; +import org.openmbee.mms.json.ElementJson; import org.openmbee.mms.json.RefJson; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -153,11 +154,24 @@ public RefJson createBranch(String projectId, RefJson branch) { Optional refOption = branchRepository.findByBranchId(b.getParentRefId()); if (refOption.isPresent()) { - Optional parentCommit = commitRepository.findLatestByRef(refOption.get()); - parentCommit.ifPresent(parent -> { - b.setParentCommit(parent.getId()); - branch.setParentCommitId(parent.getCommitId()); //commit id is same as its docId - }); + if(branch.getParentCommitId() != null){ + Optional commitRequestId = commitRepository.findByCommitId(branch.getParentCommitId()); + commitRequestId.ifPresentOrElse(commit -> { + Optional parentCommit = commitRepository.findByRefAndTimestamp(refOption.get(), commit.getTimestamp()); + parentCommit.ifPresent(parent -> { + b.setParentCommit(parent.getId()); + branch.setParentCommitId(parent.getCommitId()); + }); + }, + () -> { throw new BadRequestException(new RefsResponse().addMessage("parentCommitId not found " + now.toString())); + }); + } else { + Optional parentCommit = commitRepository.findLatestByRef(refOption.get()); + parentCommit.ifPresent(parent -> { + b.setParentCommit(parent.getId()); + branch.setParentCommitId(parent.getCommitId()); //commit id is same as its docId + }); + } } if (b.getParentCommit() == null) { @@ -182,51 +196,54 @@ public RefJson createBranch(String projectId, RefJson branch) { throw new InternalErrorException(e); } } - - public RefJson createBranchfromCommit(String projectId, RefJson branch, NodeService nodeService) { + public RefJson createBranchfromCommit(String projectId, RefJson parentCommitIdRef, NodeService nodeService) { Instant now = Instant.now(); + + if(parentCommitIdRef.getParentCommitId().isEmpty()){ + throw new BadRequestException(new RefsResponse().addMessage("parentCommitId not provided " + now.toString())); + } + ContextHolder.setContext(projectId); - // Check commit exists - // Create a new branch, from the branch that the commit was made under - // Get all elements in the commit and update the branch. - // Get all deleted elements and remove them from branch - // Return branch -// for (Node n: nodeRepository.findAll()) { -// System.out.println(n.getNodeId()); -// } - -// Optional parentCommit = commitRepository.findByCommitId(branch.getParentCommitId()); -// String parentCommitID = parentCommit.map(Commit::getCommitId).orElse("UNKNOWN"); // TODO: Need to remove UNKNOWN else -// -// String parentRef = parentCommit.map(Commit::getBranchId).orElse("UNKNOWN"); // TODO: Need to remove UNKNOWN else -// -// RefJson newBranch = this.createBranch(projectId, branch); - -// List nodes = nodeRepository.findAll(); // database table -// try { -// Collection result = nodeGetHelper.processGetJsonFromNodes(nodes, parentCommitID, nodeService) -// .getActiveElementMap().values(); // elastic search -// result.forEach(res ->{ -// System.out.println(res.getDocId()); -// }); -// } catch (Exception e) { -// logger.error("Error in commitChanges: ", e); -// throw new InternalErrorException("Error committing changes: " + e.getMessage()); -// } - - // database table needs to match elastic search docIDs -// -// nodeRepository.saveAll(nodes); -// for (Node n: nodeRepository.findAll()) { -// System.out.println(n.getNodeId()); -// } -// -// for (Node n: nodeRepository.findAll()) { -// nodes.add(n.getNodeId()); -// } - - RefJson b = new RefJson(); - return b; + Optional parentCommit = commitRepository.findByCommitId(parentCommitIdRef.getParentCommitId()); + + // Get Commit object + String parentCommitID = parentCommit.map(Commit::getCommitId).orElseThrow(() -> + new BadRequestException(new RefsResponse().addMessage("parentCommitId not found " + now.toString()))); + + // Get Commit parentRef, the branch will be created from this + String parentRef = parentCommit.map(Commit::getBranchId).orElseThrow(() -> + new BadRequestException(new RefsResponse().addMessage("Ref from parentCommitId not found" + now.toString()))); + + parentCommitIdRef.setParentRefId(parentRef); + ContextHolder.setContext(projectId, parentRef); + + RefJson branchFromCommit = this.createBranch(projectId, parentCommitIdRef); + + ContextHolder.setContext(projectId, branchFromCommit.getRefId()); + + // Get current nodes from database + List nodes = nodeRepository.findAll(); + // Get elements from index + Collection result = nodeGetHelper.processGetJsonFromNodes(nodes, parentCommitID, nodeService) + .getActiveElementMap().values(); + + Map nodeCommitData = new HashMap<>(); + for (ElementJson element : result) { + nodeCommitData.put(element.getId(), element); + } + + // Update database table to match index + for (Node node : nodes) { + if(nodeCommitData.containsKey(node.getNodeId())){ + node.setDocId(nodeCommitData.get(node.getNodeId()).getDocId()); + node.setDeleted(false); + } else { + node.setDeleted(true); + } + } + nodeRepository.updateAll(nodes); + + return branchFromCommit; } public RefsResponse deleteBranch(String projectId, String id) { diff --git a/crud/src/main/java/org/openmbee/mms/crud/services/NodeGetHelper.java b/crud/src/main/java/org/openmbee/mms/crud/services/NodeGetHelper.java index 61faa7226..96d97bd61 100644 --- a/crud/src/main/java/org/openmbee/mms/crud/services/NodeGetHelper.java +++ b/crud/src/main/java/org/openmbee/mms/crud/services/NodeGetHelper.java @@ -129,6 +129,7 @@ private NodeGetInfo processCommit(NodeGetInfo info, String commitId, NodeService rejectNotFound(info, nodeId); // element not found at commit time } } else if (info.getExistingNodeMap().get(nodeId).isDeleted()) { // latest element is before commit, but deleted + // TODO check if time of deletion is after the commit time rejectDeleted(info, nodeId, indexElement); } else { // latest element version is version at commit, not deleted info.getActiveElementMap().put(nodeId, indexElement); diff --git a/example/crud.postman_collection.json b/example/crud.postman_collection.json index 2bcb351bc..e6dde837e 100644 --- a/example/crud.postman_collection.json +++ b/example/crud.postman_collection.json @@ -1,8 +1,9 @@ { "info": { - "_postman_id": "83c02ec5-771f-4414-9675-5989af423702", + "_postman_id": "1da77eed-083d-4cb2-86fb-2ea37cf99434", "name": "crud", - "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", + "_exporter_id": "3693486" }, "item": [ { @@ -11,7 +12,6 @@ { "listen": "test", "script": { - "id": "e461c018-db96-4ae9-8552-ea794604e7c9", "exec": [ "", "pm.test(\"Status code is 200\", function () {", @@ -67,7 +67,6 @@ { "listen": "test", "script": { - "id": "523b4238-18ab-457b-8aad-af0c45cd7298", "exec": [ "pm.test(\"response has org a\", function () {", " var jsonData = pm.response.json();", @@ -109,7 +108,6 @@ { "listen": "test", "script": { - "id": "3eaaac55-3d76-45dc-8913-665359597d55", "exec": [ "pm.test(\"response has at least 1 org\", function () {", " var jsonData = pm.response.json();", @@ -154,7 +152,6 @@ { "listen": "test", "script": { - "id": "edaf2d75-3139-4dee-9c27-011d342127db", "exec": [ "pm.test(\"response has project aa\", function () {", " var jsonData = pm.response.json();", @@ -196,7 +193,6 @@ { "listen": "test", "script": { - "id": "0a2a87fa-9bbf-4543-9375-a7fef902f76c", "exec": [ "pm.test(\"Status code is 400\", function () {", " pm.response.to.have.status(400);", @@ -237,7 +233,6 @@ { "listen": "test", "script": { - "id": "8e0473f9-66d1-4f32-8ff0-265a6e359490", "exec": [ "pm.test(\"response has at least 1 project\", function () {", " var jsonData = pm.response.json();", @@ -282,7 +277,6 @@ { "listen": "test", "script": { - "id": "fa11f100-64f3-4a2c-bcb1-ed44e1f47253", "exec": [ "pm.test(\"response has project aa\", function () {", " var jsonData = pm.response.json();", @@ -324,7 +318,6 @@ { "listen": "test", "script": { - "id": "1733a3bc-a43d-49b6-863a-cf2b899368df", "exec": [ "pm.test(\"response has project aa with extra field\", function () {", " var jsonData = pm.response.json();", @@ -370,7 +363,6 @@ { "listen": "test", "script": { - "id": "5734965a-24fd-45ee-b6f9-3cafb777208a", "exec": [ "pm.test(\"response has elements\", function () {", " var jsonData = pm.response.json();", @@ -412,102 +404,101 @@ }, "response": [] }, - { - "name": "get all elements returns last commitId", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"response has 3 elements and correct commitId\", function () {", - " var jsonData = pm.response.json();", - " pm.expect(jsonData.elements.length).to.eql(3);", - " pm.expect(jsonData.commitId).to.eql(pm.environment.get(\"commitId1\"))", - "});", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [ - { - "key": "Content-Type", - "value": "application/json", - "type": "text", - "disabled": true - } - ], - "url": { - "raw": "{{host}}/projects/aa/refs/master/elements", - "host": [ - "{{host}}" - ], - "path": [ - "projects", - "aa", - "refs", - "master", - "elements" - ] - } - }, - "response": [] - }, - { - "name": "post elements with wrong lastCommitId results in 409", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"response code is 409\", function () {", - " pm.response.to.have.status(409);", - "});", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "value": "application/json", - "type": "text" - } - ], - "body": { - "mode": "raw", - "raw": "{ \"lastCommitId\": \"blah\",\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"x\",\n\t\t\t\"name\": \"x\"\n\t\t}, {\n\t\t\t\"id\": \"y\", \n\t\t\t\"name\": \"y\"\n\t\t}, {\n\t\t\t\"id\": \"z\",\n\t\t\t\"name\": \"z\"\n\t\t}\n\t]\n}" - }, - "url": { - "raw": "{{host}}/projects/aa/refs/master/elements", - "host": [ - "{{host}}" - ], - "path": [ - "projects", - "aa", - "refs", - "master", - "elements" - ] - } - }, - "response": [] - }, + { + "name": "get all elements returns last commitId", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"response has 3 elements and correct commitId\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.elements.length).to.eql(3);", + " pm.expect(jsonData.commitId).to.eql(pm.environment.get(\"commitId1\"))", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text", + "disabled": true + } + ], + "url": { + "raw": "{{host}}/projects/aa/refs/master/elements", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "aa", + "refs", + "master", + "elements" + ] + } + }, + "response": [] + }, + { + "name": "post elements with wrong lastCommitId results in 409", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"response code is 409\", function () {", + " pm.response.to.have.status(409);", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{ \"lastCommitId\": \"blah\",\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"x\",\n\t\t\t\"name\": \"x\"\n\t\t}, {\n\t\t\t\"id\": \"y\", \n\t\t\t\"name\": \"y\"\n\t\t}, {\n\t\t\t\"id\": \"z\",\n\t\t\t\"name\": \"z\"\n\t\t}\n\t]\n}" + }, + "url": { + "raw": "{{host}}/projects/aa/refs/master/elements", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "aa", + "refs", + "master", + "elements" + ] + } + }, + "response": [] + }, { "name": "update x", "event": [ { "listen": "test", "script": { - "id": "90d2953d-b3a9-49e6-a341-ab7d26ea5bd4", "exec": [ "pm.test(\"response has elements\", function () {", " var jsonData = pm.response.json();", @@ -555,7 +546,6 @@ { "listen": "test", "script": { - "id": "5108608d-d411-4eb9-ad4a-a385e2bc35e6", "exec": [ "pm.test(\"response has elements\", function () {", " var jsonData = pm.response.json();", @@ -603,7 +593,6 @@ { "listen": "test", "script": { - "id": "da640696-721b-4d24-bf14-be712a3c251d", "exec": [ "pm.test(\"response has elements\", function () {", " var jsonData = pm.response.json();", @@ -651,7 +640,6 @@ { "listen": "test", "script": { - "id": "7482648e-a716-47e3-a291-73881ee89515", "exec": [ "pm.test(\"response has 4 commits\", function () {", " var jsonData = pm.response.json();", @@ -697,7 +685,6 @@ { "listen": "test", "script": { - "id": "0807c98f-e9a9-4c50-9f26-57d40781b0a9", "exec": [ "pm.test(\"response has 3 commits\", function () {", " var jsonData = pm.response.json();", @@ -744,7 +731,6 @@ { "listen": "test", "script": { - "id": "e9a7cd38-9443-452f-ab4e-10a015563228", "exec": [ "pm.test(\"response has 2 commits\", function () {", " var jsonData = pm.response.json();", @@ -790,7 +776,6 @@ { "listen": "test", "script": { - "id": "42f760d7-9177-4112-9902-6920419f4815", "exec": [ "pm.test(\"response has 2 commits\", function () {", " var jsonData = pm.response.json();", @@ -835,7 +820,6 @@ { "listen": "test", "script": { - "id": "90832c91-7b3f-484b-99d5-2a22411a0782", "exec": [ "pm.test(\"first commit has 3 added\", function () {", " var jsonData = pm.response.json();", @@ -870,7 +854,6 @@ { "listen": "test", "script": { - "id": "405c0a55-b089-42c0-ae0f-bf62903e9114", "exec": [ "pm.test(\"elements have expected names\", function () {", " var jsonData = pm.response.json();", @@ -933,7 +916,6 @@ { "listen": "test", "script": { - "id": "4ff8a308-edb9-4035-be10-7ee850e81b1d", "exec": [ "pm.test(\"branch created with right parentRef and commit id\", function () {", " var jsonData = pm.response.json();", @@ -979,7 +961,6 @@ { "listen": "test", "script": { - "id": "4314629f-5f7b-4848-bfc1-4855b548c13f", "exec": [ "pm.test(\"branch refa has extraField\", function () {", " var jsonData = pm.response.json();", @@ -1028,7 +1009,6 @@ { "listen": "test", "script": { - "id": "058cd4ef-fbfb-40f6-b11a-51f0decb4ad7", "exec": [ "pm.test(\"Status code is 400\", function () {", " pm.response.to.have.status(400);", @@ -1071,7 +1051,6 @@ { "listen": "test", "script": { - "id": "579a59ee-097c-4006-84cd-03148c3cf0cb", "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", @@ -1114,7 +1093,6 @@ { "listen": "test", "script": { - "id": "48e8c19e-4aa8-4a96-9ae4-5e4a7d1e5a62", "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", @@ -1157,13 +1135,12 @@ { "listen": "test", "script": { - "id": "7cca3a7a-4b10-4051-addd-c902cb6f5400", "exec": [ "pm.test(\"elements in new ref have right _inRefIds\", function () {", " var jsonData = pm.response.json();", " jsonData.elements.forEach(function(e) {", " pm.expect(e._inRefIds).to.include('refa');", - " pm.expect(e._refId).to.equal('refa');", + " pm.expect(e._refId).to.equal('refa');", " })", "});" ], @@ -1190,51 +1167,50 @@ }, "response": [] }, - { - "name": "check response element _refId matches request", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"return element in new ref have right _refId\", function () {", - " var jsonData = pm.response.json();", - " jsonData.elements.forEach(function(e) {", - " pm.expect(e._refId).to.equal('refa');", - " })", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{host}}/projects/aa/refs/refa/elements/x", - "host": [ - "{{host}}" - ], - "path": [ - "projects", - "aa", - "refs", - "refa", - "elements", - "x" - ] - } - }, - "response": [] - }, + { + "name": "check response element _refId matches request", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"return element in new ref have right _refId\", function () {", + " var jsonData = pm.response.json();", + " jsonData.elements.forEach(function(e) {", + " pm.expect(e._refId).to.equal('refa');", + " })", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{host}}/projects/aa/refs/refa/elements/x", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "aa", + "refs", + "refa", + "elements", + "x" + ] + } + }, + "response": [] + }, { "name": "update x and y on refa", "event": [ { "listen": "test", "script": { - "id": "a2143942-d897-4a4f-a629-bfa46a7dc505", "exec": [ "pm.test(\"response has elements\", function () {", " var jsonData = pm.response.json();", @@ -1277,37 +1253,27 @@ "response": [] }, { - "name": "update z on refa and add element q", + "name": "get current elements at refa before updating them", "event": [ { "listen": "test", "script": { - "id": "1f6b9962-67de-44a8-a812-b25f42a8d077", "exec": [ - "pm.test(\"response has elements\", function () {", + "pm.test(\"return latest elements on refa\", function () {", " var jsonData = pm.response.json();", - " pm.expect(jsonData.elements.length).to.eql(2);", - "});", + " pm.expect(jsonData.commitId).to.eql(pm.environment.get(\"commitXYRef\"))", "", - "pm.environment.set(\"commitZQRef\", pm.response.json().elements[0]._commitId);" + " pm.environment.set(\"commitXYRefElements\", pm.response.json());", + "});", + "" ], "type": "text/javascript" } } ], "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "type": "text", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"z\",\n\t\t\t\"name\": \"updated5\"\n\t\t},\n\t\t{\n\t\t\t\"id\": \"q\",\n\t\t\t\"name\": \"q\"\n\t\t}\n\t]\n}" - }, + "method": "GET", + "header": [], "url": { "raw": "{{host}}/projects/aa/refs/refa/elements", "host": [ @@ -1325,19 +1291,18 @@ "response": [] }, { - "name": "update z on master and add element p", + "name": "update z on refa and add element q", "event": [ { "listen": "test", "script": { - "id": "0686db2c-2f1a-412d-928d-965b25a71470", "exec": [ "pm.test(\"response has elements\", function () {", " var jsonData = pm.response.json();", " pm.expect(jsonData.elements.length).to.eql(2);", "});", "", - "pm.environment.set(\"commitZP\", pm.response.json().elements[0]._commitId);" + "pm.environment.set(\"commitZQRef\", pm.response.json().elements[0]._commitId);" ], "type": "text/javascript" } @@ -1354,10 +1319,10 @@ ], "body": { "mode": "raw", - "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"z\",\n\t\t\t\"name\": \"updated6\"\n\t\t},\n\t\t{\n\t\t\t\"id\": \"p\",\n\t\t\t\"name\": \"p\"\n\t\t}\n\t]\n}" + "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"z\",\n\t\t\t\"name\": \"updated5\"\n\t\t},\n\t\t{\n\t\t\t\"id\": \"q\",\n\t\t\t\"name\": \"q\"\n\t\t}\n\t]\n}" }, "url": { - "raw": "{{host}}/projects/aa/refs/master/elements", + "raw": "{{host}}/projects/aa/refs/refa/elements", "host": [ "{{host}}" ], @@ -1365,7 +1330,7 @@ "projects", "aa", "refs", - "master", + "refa", "elements" ] } @@ -1373,120 +1338,107 @@ "response": [] }, { - "name": "check master commit history", + "name": "create branch from invalid parentCommitId", "event": [ { "listen": "test", "script": { - "id": "eb0d752b-95db-466a-a5c2-d9b48cc6c146", "exec": [ - "pm.test(\"response has 5 commits\", function () {", - " var jsonData = pm.response.json();", - " pm.expect(jsonData.commits.length).to.eql(5);", - "});", - "", - "pm.test(\"commit history is right\", function() {", - " var jsonData = pm.response.json();", - " pm.expect(jsonData.commits[0].id).to.eql(pm.environment.get(\"commitZP\"))", - " pm.expect(jsonData.commits[1].id).to.eql(pm.environment.get(\"commitId4\"))", - " pm.expect(jsonData.commits[2].id).to.eql(pm.environment.get(\"commitId3\"))", - " pm.expect(jsonData.commits[3].id).to.eql(pm.environment.get(\"commitId2\"))", - " pm.expect(jsonData.commits[4].id).to.eql(pm.environment.get(\"commitId1\"))", - "})", - "" + "pm.test(\"Status code is 400\", function () {", + " pm.response.to.have.status(400);", + "});" ], "type": "text/javascript" } } ], "request": { - "method": "GET", - "header": [], + "method": "POST", + "header": [ + { + "key": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"refs\": [\n {\n \"name\": \"branch_from_commit\",\n \"type\": \"Branch\",\n \"parentCommitId\": \"invalid\",\n \"id\": \"branch_from_commit\"\n }\n ]\n}" + }, "url": { - "raw": "{{host}}/projects/aa/refs/master/commits", + "raw": "{{host}}/projects/aa/refs", "host": [ "{{host}}" ], "path": [ "projects", "aa", - "refs", - "master", - "commits" + "refs" ] } }, "response": [] }, { - "name": "check refa commit history", + "name": "create branch from commit", "event": [ { "listen": "test", "script": { - "id": "03347469-fdcc-4bef-8a72-02763ee852dd", "exec": [ - "pm.test(\"response has 6 commits\", function () {", - " var jsonData = pm.response.json();", - " pm.expect(jsonData.commits.length).to.eql(6);", - "});", - "", - "pm.test(\"commit history is right\", function() {", + "pm.test(\"branch created from parentCommitId\", function () {", " var jsonData = pm.response.json();", - " pm.expect(jsonData.commits[0].id).to.eql(pm.environment.get(\"commitZQRef\"))", - " pm.expect(jsonData.commits[1].id).to.eql(pm.environment.get(\"commitXYRef\"))", - " pm.expect(jsonData.commits[2].id).to.eql(pm.environment.get(\"commitId4\"))", - " pm.expect(jsonData.commits[3].id).to.eql(pm.environment.get(\"commitId3\"))", - " pm.expect(jsonData.commits[4].id).to.eql(pm.environment.get(\"commitId2\"))", - " pm.expect(jsonData.commits[5].id).to.eql(pm.environment.get(\"commitId1\"))", - "})", - "" + " pm.expect(jsonData.refs[0].id).to.eql('branch_from_commit');", + " pm.expect(jsonData.refs[0].parentRefId).to.eql('refa');", + "});" ], "type": "text/javascript" } } ], "request": { - "method": "GET", - "header": [], + "method": "POST", + "header": [ + { + "key": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"refs\": [\n {\n \"name\": \"branch_from_commit\",\n \"type\": \"Branch\",\n \"parentCommitId\": \"{{commitXYRef}}\",\n \"id\": \"branch_from_commit\"\n }\n ]\n}" + }, "url": { - "raw": "{{host}}/projects/aa/refs/refa/commits", + "raw": "{{host}}/projects/aa/refs", "host": [ "{{host}}" ], "path": [ "projects", "aa", - "refs", - "refa", - "commits" + "refs" ] } }, "response": [] }, { - "name": "check x commit history on refa", + "name": "check elements from branch made from commit", "event": [ { "listen": "test", "script": { - "id": "8fe61517-a474-4ca7-91ea-aacfe01bb060", "exec": [ - "pm.test(\"response has 3 commits\", function () {", + "pm.test(\"Commit in ref match commit before updating refa\", function () {", " var jsonData = pm.response.json();", - " pm.expect(jsonData.commits.length).to.eql(4);", + " pm.expect(jsonData.commitId).to.eql(pm.environment.get('commitXYRef'));", "});", "", - "pm.test(\"commit history is right\", function() {", + "pm.test(\"Elements made in ref match what was created under commit\", function () {", " var jsonData = pm.response.json();", - " pm.expect(jsonData.commits[0].id).to.eql(pm.environment.get(\"commitXYRef\"))", - " pm.expect(jsonData.commits[1].id).to.eql(pm.environment.get(\"commitId3\"))", - " pm.expect(jsonData.commits[2].id).to.eql(pm.environment.get(\"commitId2\"))", - " pm.expect(jsonData.commits[3].id).to.eql(pm.environment.get(\"commitId1\"))", - "})", - "", - "" + " pm.expect(jsonData).to.equal(pm.environment.get('commitXYRefElements'));", + "});" ], "type": "text/javascript" } @@ -1496,7 +1448,7 @@ "method": "GET", "header": [], "url": { - "raw": "{{host}}/projects/aa/refs/refa/elements/x/commits", + "raw": "{{host}}/projects/aa/refs/{{branch_from_commit_ref}}/elements", "host": [ "{{host}}" ], @@ -1504,44 +1456,272 @@ "projects", "aa", "refs", - "refa", - "elements", - "x", - "commits" + "{{branch_from_commit_ref}}", + "elements" ] } }, "response": [] }, { - "name": "check y commit history on refa", + "name": "update z on master and add element p", "event": [ { "listen": "test", "script": { - "id": "cb0e814e-b415-4dfc-88b1-c70aedd0e1d2", "exec": [ - "pm.test(\"response has 3 commits\", function () {", + "pm.test(\"response has elements\", function () {", " var jsonData = pm.response.json();", - " pm.expect(jsonData.commits.length).to.eql(3);", + " pm.expect(jsonData.elements.length).to.eql(2);", "});", "", - "pm.test(\"commit history is right\", function() {", - " var jsonData = pm.response.json();", - " pm.expect(jsonData.commits[0].id).to.eql(pm.environment.get(\"commitXYRef\"))", - " pm.expect(jsonData.commits[1].id).to.eql(pm.environment.get(\"commitId3\"))", - " pm.expect(jsonData.commits[2].id).to.eql(pm.environment.get(\"commitId1\"))", - "})", - "", - "" + "pm.environment.set(\"commitZP\", pm.response.json().elements[0]._commitId);" ], "type": "text/javascript" } } ], "request": { - "method": "GET", - "header": [], + "method": "POST", + "header": [ + { + "key": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"z\",\n\t\t\t\"name\": \"updated6\"\n\t\t},\n\t\t{\n\t\t\t\"id\": \"p\",\n\t\t\t\"name\": \"p\"\n\t\t}\n\t]\n}" + }, + "url": { + "raw": "{{host}}/projects/aa/refs/master/elements", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "aa", + "refs", + "master", + "elements" + ] + } + }, + "response": [] + }, + { + "name": "get elements at commit", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"commit id matches before updating refa\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.commitId).to.eql(pm.environment.get(\"commitXYRef\"))", + "});", + "", + "pm.test(\"elements in refa match resutls before updating refa\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(pm.response.json()).to.equal(pm.environment.get('commitXYRefElements'));", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{host}}/projects/aa/refs/refa/elements?commitId={{commitXYRef}}", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "aa", + "refs", + "refa", + "elements" + ], + "query": [ + { + "key": "commitId", + "value": "{{commitXYRef}}" + } + ] + } + }, + "response": [] + }, + { + "name": "check master commit history", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"response has 5 commits\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.commits.length).to.eql(5);", + "});", + "", + "pm.test(\"commit history is right\", function() {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.commits[0].id).to.eql(pm.environment.get(\"commitZP\"))", + " pm.expect(jsonData.commits[1].id).to.eql(pm.environment.get(\"commitId4\"))", + " pm.expect(jsonData.commits[2].id).to.eql(pm.environment.get(\"commitId3\"))", + " pm.expect(jsonData.commits[3].id).to.eql(pm.environment.get(\"commitId2\"))", + " pm.expect(jsonData.commits[4].id).to.eql(pm.environment.get(\"commitId1\"))", + "})", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{host}}/projects/aa/refs/master/commits", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "aa", + "refs", + "master", + "commits" + ] + } + }, + "response": [] + }, + { + "name": "check refa commit history", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"response has 6 commits\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.commits.length).to.eql(6);", + "});", + "", + "pm.test(\"commit history is right\", function() {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.commits[0].id).to.eql(pm.environment.get(\"commitZQRef\"))", + " pm.expect(jsonData.commits[1].id).to.eql(pm.environment.get(\"commitXYRef\"))", + " pm.expect(jsonData.commits[2].id).to.eql(pm.environment.get(\"commitId4\"))", + " pm.expect(jsonData.commits[3].id).to.eql(pm.environment.get(\"commitId3\"))", + " pm.expect(jsonData.commits[4].id).to.eql(pm.environment.get(\"commitId2\"))", + " pm.expect(jsonData.commits[5].id).to.eql(pm.environment.get(\"commitId1\"))", + "})", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{host}}/projects/aa/refs/refa/commits", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "aa", + "refs", + "refa", + "commits" + ] + } + }, + "response": [] + }, + { + "name": "check x commit history on refa", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"response has 3 commits\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.commits.length).to.eql(4);", + "});", + "", + "pm.test(\"commit history is right\", function() {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.commits[0].id).to.eql(pm.environment.get(\"commitXYRef\"))", + " pm.expect(jsonData.commits[1].id).to.eql(pm.environment.get(\"commitId3\"))", + " pm.expect(jsonData.commits[2].id).to.eql(pm.environment.get(\"commitId2\"))", + " pm.expect(jsonData.commits[3].id).to.eql(pm.environment.get(\"commitId1\"))", + "})", + "", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{host}}/projects/aa/refs/refa/elements/x/commits", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "aa", + "refs", + "refa", + "elements", + "x", + "commits" + ] + } + }, + "response": [] + }, + { + "name": "check y commit history on refa", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"response has 3 commits\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.commits.length).to.eql(3);", + "});", + "", + "pm.test(\"commit history is right\", function() {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.commits[0].id).to.eql(pm.environment.get(\"commitXYRef\"))", + " pm.expect(jsonData.commits[1].id).to.eql(pm.environment.get(\"commitId3\"))", + " pm.expect(jsonData.commits[2].id).to.eql(pm.environment.get(\"commitId1\"))", + "})", + "", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], "url": { "raw": "{{host}}/projects/aa/refs/refa/elements/y/commits", "host": [ @@ -1566,7 +1746,6 @@ { "listen": "test", "script": { - "id": "3225e877-45f8-4b8b-81f0-037fab73a0d8", "exec": [ "pm.test(\"response has 3 commits\", function () {", " var jsonData = pm.response.json();", @@ -1612,7 +1791,6 @@ { "listen": "test", "script": { - "id": "2f0cb424-4943-4808-8504-decf5a5f13a0", "exec": [ "pm.test(\"has 4 results\", function () {", " var jsonData = pm.response.json();", @@ -1658,7 +1836,6 @@ { "listen": "test", "script": { - "id": "3dc49cda-109d-4301-b605-5c34bd2e6356", "exec": [ "pm.test(\"has 4 results\", function () {", " var jsonData = pm.response.json();", @@ -1707,7 +1884,6 @@ { "listen": "test", "script": { - "id": "89a56141-ec9b-429c-bfa3-36d0e43edfe4", "exec": [ "pm.test(\"has 3 results and 1 rejected\", function () {", " var jsonData = pm.response.json();", @@ -1754,7 +1930,6 @@ { "listen": "test", "script": { - "id": "6ac63f9d-1dec-4f8d-af53-31a821f98803", "exec": [ "pm.test(\"has 3 results and 2 rejected\", function () {", " var jsonData = pm.response.json();", @@ -1807,7 +1982,6 @@ { "listen": "test", "script": { - "id": "64884b31-07b9-45d6-80d9-aaaee57e6cf0", "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", @@ -1847,7 +2021,6 @@ { "listen": "test", "script": { - "id": "a5fb1b5b-390a-4238-a587-a8d5f8c2c08c", "exec": [ "pm.test(\"Status code is 410\", function () {", " pm.response.to.have.status(410);", @@ -1883,7 +2056,6 @@ { "listen": "test", "script": { - "id": "2891567e-05ac-41db-bbef-a408ae6fb4f4", "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", @@ -1933,7 +2105,6 @@ { "listen": "test", "script": { - "id": "6c242219-5862-44dd-9aa2-cf684c27b485", "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", @@ -1987,7 +2158,6 @@ { "listen": "test", "script": { - "id": "cc0bb3da-5473-48b8-b706-3f64bedfec62", "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", @@ -2032,7 +2202,6 @@ { "listen": "test", "script": { - "id": "ea871dc1-9d88-4481-9c1b-2090a25233e9", "exec": [ "pm.test(\"response has org a\", function () {", " var jsonData = pm.response.json();", @@ -2074,7 +2243,6 @@ { "listen": "test", "script": { - "id": "4120ad4c-9cb5-4b51-bf53-f608d68f0298", "exec": [ "pm.test(\"response has project cc\", function () {", " var jsonData = pm.response.json();", @@ -2116,7 +2284,6 @@ { "listen": "test", "script": { - "id": "cc901e7b-9269-4396-8acb-0606f11dc4db", "exec": [ "", "pm.test(\"Status code is 400, cannot make branch in empty project\", function () {", @@ -2160,7 +2327,6 @@ { "listen": "test", "script": { - "id": "b28e0221-9f3d-49d7-87de-280586509c47", "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", @@ -2205,7 +2371,6 @@ { "listen": "test", "script": { - "id": "66049694-521b-43cf-92ae-dc6c8cc8405a", "exec": [ "pm.test(\"branch created\", function () {", " var jsonData = pm.response.json();", @@ -2249,7 +2414,6 @@ { "listen": "test", "script": { - "id": "5043a523-c8be-4509-bc2f-ea8b040a2bf2", "exec": [ "pm.test(\"branch deleted\", function () {", " var jsonData = pm.response.json();", @@ -2288,7 +2452,6 @@ { "listen": "test", "script": { - "id": "83c40f4d-cbf7-4e16-8c6f-9931a78df22f", "exec": [ " ", "pm.test(\"Status code is 410\", function () {", @@ -2331,7 +2494,6 @@ { "listen": "test", "script": { - "id": "7b4f2fdb-68d9-4e0e-8980-774baa4f9413", "exec": [ "", "pm.test(\"Status code is 400\", function () {", @@ -2371,7 +2533,6 @@ { "listen": "test", "script": { - "id": "49b6fb54-9300-4433-983c-8d4ca6a84e35", "exec": [ "pm.test(\"project soft deleted\", function () {", " var jsonData = pm.response.json();", @@ -2408,7 +2569,6 @@ { "listen": "test", "script": { - "id": "cdac43db-2126-404b-af6a-91d4c5eac600", "exec": [ "pm.test(\"Status code is 410\", function () {", " pm.response.to.have.status(410);", @@ -2447,7 +2607,6 @@ { "listen": "test", "script": { - "id": "121ac082-4e34-4a42-9fdd-15bb6545898d", "exec": [ "pm.test(\"Status code is 400, org not empty\", function () {", " pm.response.to.have.status(400);", @@ -2483,7 +2642,6 @@ { "listen": "test", "script": { - "id": "b5729049-9a5a-4660-b97b-2658d7027f84", "exec": [ "pm.test(\"project hard deleted\", function () {", " var jsonData = pm.response.json();", @@ -2526,7 +2684,6 @@ { "listen": "test", "script": { - "id": "0a4fcb5e-c5b6-4ea5-b4ec-36babadffaff", "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", @@ -2562,7 +2719,6 @@ { "listen": "test", "script": { - "id": "ac5d3658-38e9-423f-b985-d903cceb0740", "exec": [ "pm.test(\"Status code is 404\", function () {", " pm.response.to.have.status(404);", @@ -2642,7 +2798,6 @@ { "listen": "test", "script": { - "id": "2ba7a873-1bdf-4e86-8329-7069064232a9", "exec": [ "pm.test(\"webhook created with returned id\", function () {", " var jsonData = pm.response.json();", @@ -2688,7 +2843,6 @@ { "listen": "test", "script": { - "id": "8410e98d-60b6-40bf-b17a-91c78b5f1dda", "exec": [ "pm.test(\"project aa has one webhook\", function () {", " var jsonData = pm.response.json();", @@ -2738,7 +2892,6 @@ { "listen": "test", "script": { - "id": "e0baf005-f27c-42d9-9763-6b194ecccd3f", "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", @@ -2784,7 +2937,6 @@ { "listen": "test", "script": { - "id": "009db0b6-7e14-42d8-89ae-33cdb7a20a6f", "exec": [ "pm.test(\"project aa has no webhooks\", function () {", " var jsonData = pm.response.json();", @@ -2833,7 +2985,6 @@ { "listen": "test", "script": { - "id": "5d411406-9444-4333-9b15-43c0ae716821", "exec": [ "pm.test(\"Status code is 400\", function () {\r", " pm.response.to.have.status(400);\r", @@ -2879,7 +3030,6 @@ { "listen": "test", "script": { - "id": "53ab3019-1cc1-4da3-aece-5c157766f627", "exec": [ "pm.test(\"response has org c\", function () {", " var jsonData = pm.response.json();", @@ -2923,7 +3073,6 @@ { "listen": "test", "script": { - "id": "8d61501e-4a5b-4a71-9f1d-ad00c75893bd", "exec": [ "pm.test(\"org id number is right\", function() {", " var jsonData = pm.response.json();", @@ -2962,7 +3111,6 @@ { "listen": "test", "script": { - "id": "39291cc7-7dbe-4eb9-ad83-857b839bfda8", "exec": [ "pm.test(\"response has project random\", function () {", " var jsonData = pm.response.json();", @@ -3000,98 +3148,97 @@ }, "response": [] }, - { - "name": "get org c projects", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"response has 1 project random\", function () {", - " var jsonData = pm.response.json();", - " pm.expect(jsonData.projects.length).to.eql(1);", - " pm.expect(jsonData.projects[0].name).to.eql('random');", - "});" - ], - "type": "text/javascript" - } - } - ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, - "request": { - "method": "GET", - "header": [ - { - "key": "Content-Type", - "type": "text", - "value": "application/json", - "disabled": true - } - ], - "body": { - "mode": "raw", - "raw": "" - }, - "url": { - "raw": "{{host}}/projects?orgId={{orgIdC}}", - "host": [ - "{{host}}" - ], - "path": [ - "projects" - ], - "query": [ - { - "key": "orgId", - "value": "{{orgIdC}}" - } - ] - } - }, - "response": [] - }, { - "name": "add element random to project random without id", + "name": "get org c projects", "event": [ { "listen": "test", "script": { - "id": "4c60e596-758d-4347-8a0c-ef9071a78421", "exec": [ - "pm.test(\"response has element random\", function () {", + "pm.test(\"response has 1 project random\", function () {", " var jsonData = pm.response.json();", - " pm.expect(jsonData.elements[0].name).to.eql('random');", - "});", - "", - "pm.environment.set(\"elementRandomId\", pm.response.json().elements[0].id);" + " pm.expect(jsonData.projects.length).to.eql(1);", + " pm.expect(jsonData.projects[0].name).to.eql('random');", + "});" ], "type": "text/javascript" } } ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, "request": { - "method": "POST", + "method": "GET", "header": [ { "key": "Content-Type", "type": "text", - "value": "application/json" + "value": "application/json", + "disabled": true } ], "body": { "mode": "raw", - "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"name\": \"random\"\n\t\t}\n\t]\n}" + "raw": "" }, "url": { - "raw": "{{host}}/projects/{{projectRandomId}}/refs/master/elements", + "raw": "{{host}}/projects?orgId={{orgIdC}}", "host": [ "{{host}}" ], "path": [ - "projects", - "{{projectRandomId}}", + "projects" + ], + "query": [ + { + "key": "orgId", + "value": "{{orgIdC}}" + } + ] + } + }, + "response": [] + }, + { + "name": "add element random to project random without id", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"response has element random\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.elements[0].name).to.eql('random');", + "});", + "", + "pm.environment.set(\"elementRandomId\", pm.response.json().elements[0].id);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"name\": \"random\"\n\t\t}\n\t]\n}" + }, + "url": { + "raw": "{{host}}/projects/{{projectRandomId}}/refs/master/elements", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "{{projectRandomId}}", "refs", "master", "elements" @@ -3106,7 +3253,6 @@ { "listen": "test", "script": { - "id": "fa70a5cd-4079-4216-b4f6-b4202c26cfc0", "exec": [ "pm.test(\"response has ref random\", function () {", " var jsonData = pm.response.json();", @@ -3152,7 +3298,6 @@ { "listen": "test", "script": { - "id": "e1a34e6f-ae27-4a4f-8294-a7c9f86d9512", "exec": [ "pm.test(\"element is there\", function() {", " var jsonData = pm.response.json();", @@ -3195,7 +3340,6 @@ { "listen": "test", "script": { - "id": "90859114-65cc-41c2-8b34-015f1464201a", "exec": [ "pm.test(\"Status code is 404\", function () {", " pm.response.to.have.status(404);", @@ -3236,7 +3380,6 @@ { "listen": "test", "script": { - "id": "c410396b-451f-4120-bbd6-69fa66effe42", "exec": [ "pm.test(\"Status code is 404\", function () {", " pm.response.to.have.status(404);", @@ -3277,7 +3420,6 @@ { "listen": "test", "script": { - "id": "bfbfce50-298d-4d87-b403-951ab3e2f574", "exec": [ "pm.test(\"Status code is 400\", function () {", " pm.response.to.have.status(400);", @@ -3320,7 +3462,6 @@ { "listen": "test", "script": { - "id": "c140808f-619f-4b5e-ab06-ae1124039678", "exec": [ "pm.test(\"Status code is 400\", function () {", " pm.response.to.have.status(400);", @@ -3363,7 +3504,6 @@ { "listen": "test", "script": { - "id": "563236de-9fa5-4902-aa08-b271cdee278e", "exec": [ "pm.test(\"Status code is 404\", function () {", " pm.response.to.have.status(404);", @@ -3408,7 +3548,6 @@ { "listen": "test", "script": { - "id": "9f8b1c3b-629e-4080-bd96-c7ea7a29faf0", "exec": [ "pm.test(\"Status code is 404\", function () {", " pm.response.to.have.status(404);", @@ -3453,7 +3592,6 @@ { "listen": "test", "script": { - "id": "f9e479b7-97e5-41f2-b801-7c1f7f4553ec", "exec": [ "pm.test(\"Status code is 404\", function () {", " pm.response.to.have.status(404);", @@ -3491,7 +3629,6 @@ { "listen": "test", "script": { - "id": "58d3d7d2-416b-4ac3-8933-7b54c2691fd4", "exec": [ "pm.test(\"Status code is 404\", function () {", " pm.response.to.have.status(404);", @@ -3531,7 +3668,6 @@ { "listen": "test", "script": { - "id": "5eacc2a2-caea-4256-aa97-bf6e50bd3b68", "exec": [ "pm.test(\"Status code is 404\", function () {", " pm.response.to.have.status(404);", @@ -3567,362 +3703,362 @@ }, "response": [] }, - { - "name": "get nonexistent commit", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 404\", function () {", - " pm.response.to.have.status(404);", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [ - { - "key": "Content-Type", - "type": "text", - "value": "application/json" - } - ], - "url": { - "raw": "{{host}}/projects/aa/commits/missing", - "host": [ - "{{host}}" - ], - "path": [ - "projects", - "aa", - "commits", - "missing" - ] - } - }, - "response": [] - }, - { - "name": "create branch with long id", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "type": "text", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\t\"refs\": [\n\t\t{\n\t\t\t\"name\": \"long\",\n \"id\": \"a123456789012345678901234567890123456789012345678901234567890\"\n\t\t}\n\t]\n}" - }, - "url": { - "raw": "{{host}}/projects/aa/refs", - "host": [ - "{{host}}" - ], - "path": [ - "projects", - "aa", - "refs" - ] - } - }, - "response": [] - }, - { - "name": "post to long branch", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "type": "text", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"name\": \"blah\",\n\t\t\t\"id\": \"blah\"\n\t\t}\n\t]\n}" - }, - "url": { - "raw": "{{host}}/projects/aa/refs/a123456789012345678901234567890123456789012345678901234567890/elements", - "host": [ - "{{host}}" - ], - "path": [ - "projects", - "aa", - "refs", - "a123456789012345678901234567890123456789012345678901234567890", - "elements" - ] - } - }, - "response": [] - }, - { - "name": "create project zz", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "type": "text", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\t\"projects\": [\n\t\t{\n\t\t\t\"id\": \"zz\", \n\t\t\t\"name\": \"zz\",\n\t\t\t\"orgId\": \"a\",\n\t\t\t\"schema\": \"default\"\n\t\t}\n\t]\n}" - }, - "url": { - "raw": "{{host}}/projects", - "host": [ - "{{host}}" - ], - "path": [ - "projects" - ] - } - }, - "response": [] - }, - { - "name": "add elements to project zz", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "type": "text", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"x\",\n\t\t\t\"name\": \"x\"\n\t\t}, {\n\t\t\t\"id\": \"y\", \n\t\t\t\"name\": \"y\"\n\t\t}, {\n\t\t\t\"id\": \"z\",\n\t\t\t\"name\": \"z\"\n\t\t}\n\t]\n}" - }, - "url": { - "raw": "{{host}}/projects/zz/refs/master/elements", - "host": [ - "{{host}}" - ], - "path": [ - "projects", - "zz", - "refs", - "master", - "elements" - ] - } - }, - "response": [] - }, - { - "name": "update and delete elements in same commit", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"response has elements\", function () {", - " var jsonData = pm.response.json();", - " pm.expect(jsonData.elements.length).to.eql(2);", - " pm.expect(jsonData.deleted.length).to.eql(1);", - "});", - "", - "pm.environment.set(\"hybridCommit\", pm.response.json().commitId);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "type": "text", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"x\",\n\t\t\t\"name\": \"xx\"\n\t\t}, {\n\t\t\t\"id\": \"y\", \n\t\t\t\"name\": \"yy\"\n\t\t}\n\t],\n \"deletes\": [{\"id\": \"z\"}]\n}" - }, - "url": { - "raw": "{{host}}/projects/zz/refs/master/elements", - "host": [ - "{{host}}" - ], - "path": [ - "projects", - "zz", - "refs", - "master", - "elements" - ] - } - }, - "response": [] - }, - { - "name": "get deleted element", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 410\", function () {", - " pm.response.to.have.status(410);", - "});" - ], - "type": "text/javascript" - } - } - ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, - "request": { - "method": "GET", - "header": [ - { - "key": "Content-Type", - "type": "text", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"x\",\n\t\t\t\"name\": \"xx\"\n\t\t}, {\n\t\t\t\"id\": \"y\", \n\t\t\t\"name\": \"yy\"\n\t\t}\n\t],\n \"deletes\": [{\"id\": \"z\"}]\n}" - }, - "url": { - "raw": "{{host}}/projects/zz/refs/master/elements/z", - "host": [ - "{{host}}" - ], - "path": [ - "projects", - "zz", - "refs", - "master", - "elements", - "z" - ] - } - }, - "response": [] - }, - { - "name": "get commit object", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"commit has right data\", function () {", - " var jsonData = pm.response.json();", - " pm.expect(jsonData.commits[0].updated.length).to.eql(2);", - " pm.expect(jsonData.commits[0].deleted.length).to.eql(1);", - "", - "});", - "", - "" - ], - "type": "text/javascript" - } - } - ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, - "request": { - "method": "GET", - "header": [ - { - "key": "Content-Type", - "type": "text", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"x\",\n\t\t\t\"name\": \"xx\"\n\t\t}, {\n\t\t\t\"id\": \"y\", \n\t\t\t\"name\": \"yy\"\n\t\t}\n\t],\n \"deletes\": [{\"id\": \"z\"}]\n}" - }, - "url": { - "raw": "{{host}}/projects/zz/commits/{{hybridCommit}}", - "host": [ - "{{host}}" - ], - "path": [ - "projects", - "zz", - "commits", - "{{hybridCommit}}" - ] - } - }, - "response": [] - } + { + "name": "get nonexistent commit", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 404\", function () {", + " pm.response.to.have.status(404);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "url": { + "raw": "{{host}}/projects/aa/commits/missing", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "aa", + "commits", + "missing" + ] + } + }, + "response": [] + }, + { + "name": "create branch with long id", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"refs\": [\n\t\t{\n\t\t\t\"name\": \"long\",\n \"id\": \"a123456789012345678901234567890123456789012345678901234567890\"\n\t\t}\n\t]\n}" + }, + "url": { + "raw": "{{host}}/projects/aa/refs", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "aa", + "refs" + ] + } + }, + "response": [] + }, + { + "name": "post to long branch", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"name\": \"blah\",\n\t\t\t\"id\": \"blah\"\n\t\t}\n\t]\n}" + }, + "url": { + "raw": "{{host}}/projects/aa/refs/a123456789012345678901234567890123456789012345678901234567890/elements", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "aa", + "refs", + "a123456789012345678901234567890123456789012345678901234567890", + "elements" + ] + } + }, + "response": [] + }, + { + "name": "create project zz", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"projects\": [\n\t\t{\n\t\t\t\"id\": \"zz\", \n\t\t\t\"name\": \"zz\",\n\t\t\t\"orgId\": \"a\",\n\t\t\t\"schema\": \"default\"\n\t\t}\n\t]\n}" + }, + "url": { + "raw": "{{host}}/projects", + "host": [ + "{{host}}" + ], + "path": [ + "projects" + ] + } + }, + "response": [] + }, + { + "name": "add elements to project zz", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"x\",\n\t\t\t\"name\": \"x\"\n\t\t}, {\n\t\t\t\"id\": \"y\", \n\t\t\t\"name\": \"y\"\n\t\t}, {\n\t\t\t\"id\": \"z\",\n\t\t\t\"name\": \"z\"\n\t\t}\n\t]\n}" + }, + "url": { + "raw": "{{host}}/projects/zz/refs/master/elements", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "zz", + "refs", + "master", + "elements" + ] + } + }, + "response": [] + }, + { + "name": "update and delete elements in same commit", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"response has elements\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.elements.length).to.eql(2);", + " pm.expect(jsonData.deleted.length).to.eql(1);", + "});", + "", + "pm.environment.set(\"hybridCommit\", pm.response.json().commitId);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"x\",\n\t\t\t\"name\": \"xx\"\n\t\t}, {\n\t\t\t\"id\": \"y\", \n\t\t\t\"name\": \"yy\"\n\t\t}\n\t],\n \"deletes\": [{\"id\": \"z\"}]\n}" + }, + "url": { + "raw": "{{host}}/projects/zz/refs/master/elements", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "zz", + "refs", + "master", + "elements" + ] + } + }, + "response": [] + }, + { + "name": "get deleted element", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 410\", function () {", + " pm.response.to.have.status(410);", + "});" + ], + "type": "text/javascript" + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"x\",\n\t\t\t\"name\": \"xx\"\n\t\t}, {\n\t\t\t\"id\": \"y\", \n\t\t\t\"name\": \"yy\"\n\t\t}\n\t],\n \"deletes\": [{\"id\": \"z\"}]\n}" + }, + "url": { + "raw": "{{host}}/projects/zz/refs/master/elements/z", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "zz", + "refs", + "master", + "elements", + "z" + ] + } + }, + "response": [] + }, + { + "name": "get commit object", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"commit has right data\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.commits[0].updated.length).to.eql(2);", + " pm.expect(jsonData.commits[0].deleted.length).to.eql(1);", + "", + "});", + "", + "" + ], + "type": "text/javascript" + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"x\",\n\t\t\t\"name\": \"xx\"\n\t\t}, {\n\t\t\t\"id\": \"y\", \n\t\t\t\"name\": \"yy\"\n\t\t}\n\t],\n \"deletes\": [{\"id\": \"z\"}]\n}" + }, + "url": { + "raw": "{{host}}/projects/zz/commits/{{hybridCommit}}", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "zz", + "commits", + "{{hybridCommit}}" + ] + } + }, + "response": [] + } ], "auth": { "type": "bearer", @@ -3938,7 +4074,6 @@ { "listen": "prerequest", "script": { - "id": "cd69ddc1-20da-4c86-919c-ad9bf455d71d", "type": "text/javascript", "exec": [ "" @@ -3948,13 +4083,11 @@ { "listen": "test", "script": { - "id": "480b7515-91c4-49b1-9bee-f5af24bb9524", "type": "text/javascript", "exec": [ "" ] } } - ], - "protocolProfileBehavior": {} + ] } \ No newline at end of file