in ddm-rrm/src/it/java/com/epam/digital/data/platform/management/CandidateVersionControllerIT.java [451:493]
void createNewVersion() {
final var versionCandidateId = context.createVersionCandidate(
TestVersionCandidate.builder()
.subject("request-name")
.topic("request description")
.mergeable(true)
.created(LocalDateTime.of(2022, 10, 28, 15, 34))
.updated(LocalDateTime.of(2022, 10, 28, 15, 34))
.build()
);
context.getGerritMockServer().addStubMapping(
stubFor(WireMock.post("/a/changes/")
.withRequestBody(matchingJsonPath("$.subject", equalTo("request-name")))
.withRequestBody(matchingJsonPath("$.topic", equalTo("request description")))
.willReturn(aResponse().withStatus(200)
.withBody(String.format("{\"_number\":%s}", versionCandidateId))))
);
final var request = CreateVersionRequest.builder()
.name("request-name")
.description("request description")
.build();
mockMvc.perform(
post("/versions/candidates")
.contentType(MediaType.APPLICATION_JSON_VALUE)
.content(new ObjectMapper().writeValueAsString(request))
.accept(MediaType.APPLICATION_JSON_VALUE)
).andExpectAll(
status().isCreated(),
content().contentType("application/json"),
jsonPath("$.id", is(versionCandidateId)),
jsonPath("$.name", is("request-name")),
jsonPath("$.description", is("request description")),
jsonPath("$.hasConflicts", is(false)),
jsonPath("$.creationDate", is("2022-10-28T15:34:00.000Z")),
jsonPath("$.latestUpdate", is("2022-10-28T15:34:00.000Z")),
jsonPath("$.author", is(context.getGerritProps().getUser())),
jsonPath("$.validations[0].result", is("PENDING"))
);
Assertions.assertThat(context.getRepo(versionCandidateId)).exists();
}