public void getMasterVersionInfo()

in ddm-rrm/src/it/java/com/epam/digital/data/platform/management/MasterVersionControllerIT.java [54:96]


  public void getMasterVersionInfo(String message, String status) {
    Timestamp timestamp = Timestamp.valueOf(LocalDateTime.of(2022, 8, 10, 13, 18));
    final var lastMergedChangeInfo = Map.of(
        "_number", 1,
        "owner", Map.of("username", context.getGerritProps().getUser()),
        "topic", "this is description for version candidate",
        "subject", "commit message",
        "submitted", "2022-08-02 16:15:12.786589626",
        "labels", Map.of(),
        "messages", List.of(Map.of("message", message, "date", timestamp.toString())),
        "change_id", "change_id"
    );

    final var om = new ObjectMapper();
    context.getGerritMockServer().addStubMapping(stubFor(
        WireMock.get(urlEqualTo(String.format("/a/changes/?q=project:%s+status:merged+owner:%s&n=10",
                context.getGerritProps().getRepository(), context.getGerritProps().getUser())))
            .willReturn(aResponse().withStatus(200)
                .withBody(om.writeValueAsString(List.of(lastMergedChangeInfo))))
    ));
    context.getGerritMockServer().addStubMapping(stubFor(
        WireMock.get(urlPathEqualTo("/a/changes/change_id"))
            .willReturn(aResponse().withStatus(200)
                .withBody(om.writeValueAsString(lastMergedChangeInfo)))
    ));

    mockMvc.perform(
        get("/versions/master")
            .accept(MediaType.APPLICATION_JSON_VALUE)
    ).andExpectAll(
        status().isOk(),
        content().contentType("application/json"),
        jsonPath("$.id", is("1")),
        jsonPath("$.author", is(context.getGerritProps().getUser())),
        jsonPath("$.description", is("this is description for version candidate")),
        jsonPath("$.name", is("commit message")),
        jsonPath("$.latestUpdate", is("2022-08-02T16:15:12.000Z")),
        jsonPath("$.status", is(status)),
        jsonPath("$.published", nullValue()),
        jsonPath("$.inspector", nullValue()),
        jsonPath("$.validations", nullValue())
    );
  }