void getGroupedProcessDefinitions()

in src/it/java/com/epam/digital/data/platform/usrprcssmgt/ProcessDefinitionManagementIT.java [268:304]


  void getGroupedProcessDefinitions() {
    mockBpmsRequest(StubRequest.builder()
        .method(HttpMethod.POST)
        .path(urlPathEqualTo("/api/extended/process-definition"))
        .requestBody(equalToJson("{\"active\":true,\"latestVersion\":true,"
            + "\"suspended\":false,\"sortBy\":\"name\",\"sortOrder\":\"asc\","
            + "\"processDefinitionId\":null,\"processDefinitionIdIn\":null}"))
        .status(200)
        .responseBody(
            "[ { \"id\": \"123\", \"key\": \"first-process-group\", \"name\":\"name1\" }, "
                + "{ \"id\": \"345\", \"key\": \"without-group-1\", \"name\":\"name2\" }, "
                + "{ \"id\": \"234\", \"key\": \"third-process-group\", \"name\":\"name3\" }, "
                + "{ \"id\": \"567\", \"key\": \"without-group-2\", \"name\":\"name4\" }, "
                + "{ \"id\": \"456\", \"key\": \"second-process-group\",  \"name\":\"name5\" }] ")
        .responseHeaders(Map.of("Content-Type", List.of("application/json")))
        .build());

    var request = get("/api/grouped-process-definition?active=true&suspended=false")
        .accept(MediaType.APPLICATION_JSON_VALUE);
    var result = performForObjectAsOfficer(request, GroupedProcessDefinitionResponse.class);

    assertThat(result).isNotNull();
    assertThat(result.getGroups()).hasSize(1);
    assertThat(result.getUngrouped()).hasSize(3);
    assertThat(result.getGroups().get(0))
        .hasFieldOrPropertyWithValue("name", "Test group name");
    assertThat(result.getGroups().get(0).getProcessDefinitions().get(0).getKey())
        .hasToString("first-process-group");
    assertThat(result.getGroups().get(0).getProcessDefinitions().get(1).getKey())
        .hasToString("third-process-group");
    assertThat(result.getUngrouped().get(0))
        .hasFieldOrPropertyWithValue("name", "name5");
    assertThat(result.getUngrouped().get(1))
        .hasFieldOrPropertyWithValue("name", "name2");
    assertThat(result.getUngrouped().get(2))
        .hasFieldOrPropertyWithValue("name", "name4");
  }