Search in sources :

Example 1 with Execution

use of org.kie.kogito.trusty.storage.api.model.Execution in project kogito-apps by kiegroup.

the class ExecutionsApiV1IT method givenARequestWhenExecutionEndpointIsCalledThenTheExecutionHeaderIsReturned.

@Test
void givenARequestWhenExecutionEndpointIsCalledThenTheExecutionHeaderIsReturned() throws ParseException {
    Execution execution = new Decision("test1", "http://localhost:8081/model/service", "http://localhost:8081", OffsetDateTime.parse("2020-01-01T00:00:00Z", DateTimeFormatter.ISO_OFFSET_DATE_TIME).toInstant().toEpochMilli(), true, "name", "model", "namespace", Collections.emptyList(), Collections.emptyList());
    Mockito.when(executionService.getExecutionHeaders(any(OffsetDateTime.class), any(OffsetDateTime.class), any(Integer.class), any(Integer.class), any(String.class))).thenReturn(new MatchedExecutionHeaders(List.of(execution), 1));
    ExecutionsResponse response = given().contentType(ContentType.JSON).when().get("/executions?from=2000-01" + "-01T00:00:00Z&to=2021" + "-01-01T00:00:00Z").as(ExecutionsResponse.class);
    Assertions.assertEquals(1, response.getHeaders().size());
}
Also used : Execution(org.kie.kogito.trusty.storage.api.model.Execution) MatchedExecutionHeaders(org.kie.kogito.trusty.service.common.models.MatchedExecutionHeaders) OffsetDateTime(java.time.OffsetDateTime) ExecutionsResponse(org.kie.kogito.trusty.service.common.responses.ExecutionsResponse) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Decision(org.kie.kogito.trusty.storage.api.model.decision.Decision) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 2 with Execution

use of org.kie.kogito.trusty.storage.api.model.Execution in project kogito-apps by kiegroup.

the class ExecutionsApiV1IT method givenMoreResultsThanQueryLimitThenPaginationIsCorrect.

@Test
void givenMoreResultsThanQueryLimitThenPaginationIsCorrect() throws ParseException {
    List<Execution> executions = generateExecutions(15);
    mockGetExecutionHeaders(executions, 0, 10);
    mockGetExecutionHeaders(executions, 5, 10);
    mockGetExecutionHeaders(executions, 10, 10);
    ExecutionsResponse response = given().contentType(ContentType.JSON).when().get("/executions?from=2000-01-01T00:00:00Z&to=2021-01-01T00:00:00Z&limit=10").as(ExecutionsResponse.class);
    Assertions.assertEquals(10, response.getHeaders().size());
    Assertions.assertEquals(15, response.getTotal());
    Assertions.assertEquals(0, response.getOffset());
    Assertions.assertEquals(10, response.getLimit());
    response = given().contentType(ContentType.JSON).when().get("/executions?from=2000-01-01T00:00:00Z&to=2021-01-01T00:00:00Z&limit=10&offset=5").as(ExecutionsResponse.class);
    Assertions.assertEquals(10, response.getHeaders().size());
    Assertions.assertEquals(15, response.getTotal());
    Assertions.assertEquals(5, response.getOffset());
    Assertions.assertEquals(10, response.getLimit());
    response = given().contentType(ContentType.JSON).when().get("/executions?from=2000-01-01T00:00:00Z&to=2021-01-01T00:00:00Z&limit=10&offset=10").as(ExecutionsResponse.class);
    Assertions.assertEquals(5, response.getHeaders().size());
    Assertions.assertEquals(15, response.getTotal());
    Assertions.assertEquals(10, response.getOffset());
    Assertions.assertEquals(10, response.getLimit());
}
Also used : Execution(org.kie.kogito.trusty.storage.api.model.Execution) ExecutionsResponse(org.kie.kogito.trusty.service.common.responses.ExecutionsResponse) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Aggregations

QuarkusTest (io.quarkus.test.junit.QuarkusTest)2 Test (org.junit.jupiter.api.Test)2 ExecutionsResponse (org.kie.kogito.trusty.service.common.responses.ExecutionsResponse)2 Execution (org.kie.kogito.trusty.storage.api.model.Execution)2 OffsetDateTime (java.time.OffsetDateTime)1 MatchedExecutionHeaders (org.kie.kogito.trusty.service.common.models.MatchedExecutionHeaders)1 Decision (org.kie.kogito.trusty.storage.api.model.decision.Decision)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1