in ddm-rrm/src/it/java/com/epam/digital/data/platform/management/CandidateVersionControllerIT.java [281:405]
void getVersionChanges() {
// add forms to "remote" repo
final var changedFormHead = context.getResourceContent(
"/versions/candidates/{versionCandidateId}/changes/GET/changed-form-head.json");
context.addFileToRemoteHeadRepo("/forms/changed-form.json", changedFormHead);
final var unchangedForm = context.getResourceContent(
"/versions/candidates/{versionCandidateId}/changes/GET/unchanged-form.json");
context.addFileToRemoteHeadRepo("/forms/unchanged-form.json", unchangedForm);
final var deletedForm = context.getResourceContent(
"/versions/candidates/{versionCandidateId}/changes/GET/deleted-form.json");
context.addFileToRemoteHeadRepo("/forms/deleted-form.json", deletedForm);
// add business-processes to "remote" repo
final var changedProcessHead = context.getResourceContent(
"/versions/candidates/{versionCandidateId}/changes/GET/changed-process-head.bpmn");
context.addFileToRemoteHeadRepo("/bpmn/changed-process.bpmn", changedProcessHead);
final var unchangedProcess = context.getResourceContent(
"/versions/candidates/{versionCandidateId}/changes/GET/unchanged-process.bpmn");
context.addFileToRemoteHeadRepo("/bpmn/unchanged-process.bpmn", unchangedProcess);
final var deletedProcess = context.getResourceContent(
"/versions/candidates/{versionCandidateId}/changes/GET/deleted-process.bpmn");
context.addFileToRemoteHeadRepo("/bpmn/deleted-process.bpmn", deletedProcess);
final var addedGroup = context.getResourceContent(
"/versions/candidates/{versionCandidateId}/changes/GET/bp-grouping.yml");
context.addFileToRemoteHeadRepo("/bp-grouping/bp-grouping.yml", addedGroup);
context.pullHeadRepo();
// create version candidate
final var versionCandidateId = context.createVersionCandidate();
// change forms in version candidate remote
final var addedForm = context.getResourceContent(
"/versions/candidates/{versionCandidateId}/changes/GET/added-form.json");
context.addFileToVersionCandidateRemote("/forms/added-form.json", addedForm);
final var changedFormVC = context.getResourceContent(
"/versions/candidates/{versionCandidateId}/changes/GET/changed-form-version-candidate.json");
context.addFileToVersionCandidateRemote("/forms/changed-form.json",
changedFormVC);
context.deleteFileFromVersionCandidateRemote("forms/deleted-form.json");
// change business-processes in version candidate remote
final var addedProcess = context.getResourceContent(
"/versions/candidates/{versionCandidateId}/changes/GET/added-process.bpmn");
context.addFileToVersionCandidateRemote("/bpmn/added-process.bpmn",
addedProcess);
final var changedProcessVC = context.getResourceContent(
"/versions/candidates/{versionCandidateId}/changes/GET/changed-process-version-candidate.bpmn");
context.addFileToVersionCandidateRemote("/bpmn/changed-process.bpmn",
changedProcessVC);
context.deleteFileFromVersionCandidateRemote("bpmn/deleted-process.bpmn");
final var changedGrouping = context.getResourceContent(
"/versions/candidates/{versionCandidateId}/changes/GET/changed-bp-grouping.yml");
context.addFileToVersionCandidateRemote("/bp-grouping/bp-grouping.yml",
changedGrouping);
//change data-model in version candidate remote
final var addedCreateSearchConditions = context.getResourceContent(
"/versions/candidates/{versionCandidateId}/changes/GET/added-createSearchConditions.xml");
context.addFileToVersionCandidateRemote("/data-model/createSearchConditions.xml",
addedCreateSearchConditions);
final var changedCreateTablesVC = context.getResourceContent(
"/versions/candidates/{versionCandidateId}/changes/GET/changed-createTables-version-candidate.xml");
context.addFileToVersionCandidateRemote("/data-model/createTables.xml",
changedCreateTablesVC);
// mock gerrit response about changed files
final var filesResponse = Map.of(
"bpmn/added-process.bpmn", Map.of("status", "A"),
"bpmn/changed-process.bpmn", Map.of("status", "R"),
"bpmn/deleted-process.bpmn", Map.of("status", "D"),
"forms/added-form.json", Map.of("status", "A"),
"forms/changed-form.json", Map.of("status", "R"),
"forms/deleted-form.json", Map.of("status", "D"),
"data-model/createTables.xml", Map.of("status", "R"),
"data-model/createSearchConditions.xml", Map.of("status", "A"),
"bp-grouping/bp-grouping.yml", Map.of("status", "A")
);
context.getGerritMockServer().addStubMapping(
stubFor(WireMock.get(urlPathEqualTo(String.format("/a/changes/%s/revisions/current/files",
context.getVersionCandidate().getChangeId()))
).willReturn(aResponse()
.withStatus(200)
.withBody(new ObjectMapper().writeValueAsString(filesResponse))))
);
// perform request
mockMvc.perform(get("/versions/candidates/{versionCandidateId}/changes", versionCandidateId)
.accept(MediaType.APPLICATION_JSON_VALUE)
).andExpectAll(
status().isOk(),
content().contentType("application/json"),
jsonPath("$.changedForms", hasSize(3)),
jsonPath("$.changedForms[0].name", is("added-form")),
jsonPath("$.changedForms[0].title", is("Added form")),
jsonPath("$.changedForms[0].status", is("NEW")),
jsonPath("$.changedForms[1].name", is("changed-form")),
jsonPath("$.changedForms[1].title", is("Changed form VC")),
jsonPath("$.changedForms[1].status", is("CHANGED")),
jsonPath("$.changedForms[2].name", is("deleted-form")),
jsonPath("$.changedForms[2].title", is("Deleted form")),
jsonPath("$.changedForms[2].status", is("DELETED")),
jsonPath("$.changedBusinessProcesses", hasSize(3)),
jsonPath("$.changedBusinessProcesses[0].name", is("added-process")),
jsonPath("$.changedBusinessProcesses[0].title", is("Added process")),
jsonPath("$.changedBusinessProcesses[0].status", is("NEW")),
jsonPath("$.changedBusinessProcesses[1].name", is("changed-process")),
jsonPath("$.changedBusinessProcesses[1].title", is("Changed process VC")),
jsonPath("$.changedBusinessProcesses[1].status", is("CHANGED")),
jsonPath("$.changedBusinessProcesses[2].name", is("deleted-process")),
jsonPath("$.changedBusinessProcesses[2].title", is("Deleted process")),
jsonPath("$.changedBusinessProcesses[2].status", is("DELETED")),
jsonPath("$.changedGroups[0].name", is("bp-grouping.yml")),
jsonPath("$.changedGroups[0].status", is("NEW")),
jsonPath("$.changedBusinessProcesses[2].status", is("DELETED")),
jsonPath("$.changedDataModelFiles", hasSize(2)),
jsonPath("$.changedDataModelFiles[0].name", is("createSearchConditions")),
jsonPath("$.changedDataModelFiles[0].fileType", is(nullValue())),
jsonPath("$.changedDataModelFiles[0].status", is("NEW")),
jsonPath("$.changedDataModelFiles[1].name", is("createTables")),
jsonPath("$.changedDataModelFiles[1].fileType", is("TABLES_FILE")),
jsonPath("$.changedDataModelFiles[1].status", is("CHANGED"))
);
}