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());
}
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());
}
Aggregations