in ddm-rrm/src/it/java/com/epam/digital/data/platform/management/context/TestExecutionContext.java [461:497]
private void stubGerritGetChangeById(String id) {
final var gerritDateFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSSSSS");
String message = "Build Started ... MASTER-Code-review ...";
Timestamp timestamp = Timestamp.valueOf(LocalDateTime.of(2022, 8, 10, 13, 18));
final var response = Map.ofEntries(
Map.entry("id", versionCandidate.getId()),
Map.entry("change_id", versionCandidate.getChangeId()),
Map.entry("_number", versionCandidate.getNumber()),
Map.entry("subject", versionCandidate.getSubject()),
Map.entry("topic", versionCandidate.getTopic()),
Map.entry("created", versionCandidate.getCreated().format(gerritDateFormat)),
Map.entry("updated", versionCandidate.getUpdated().format(gerritDateFormat)),
Map.entry("owner", Map.of("username", gerritProps.getUser())),
Map.entry("current_revision", versionCandidate.getCurrentRevision()),
Map.entry("revisions", Map.of(versionCandidate.getCurrentRevision(),
Map.of("ref", versionCandidate.getRef()))),
Map.entry("labels", Map.of("Verified", new LabelInfo())),
Map.entry("messages", List.of(Map.of("message", message, "date", timestamp.toString())))
);
gerritMockServer.addStubMapping(stubFor(get(urlPathEqualTo(String.format("/a/changes/%s", id))
).willReturn(aResponse()
.withStatus(200)
.withBody(new ObjectMapper().writeValueAsString(response))))
);
gerritMockServer.addStubMapping(
stubFor(get(urlPathEqualTo(String.format("/a/changes/%s/revisions/current/mergeable", id))
).willReturn(aResponse()
.withStatus(200)
.withBody(String.format("{\"mergeable\":%s}", versionCandidate.isMergeable()))))
);
gerritMockServer.addStubMapping(
stubFor(get(urlPathEqualTo(String.format("/a/changes/%s/revisions/current/files", id))
).willReturn(aResponse()
.withStatus(200)
.withBody("{}")))
);
}