@Override public List<CleanableHistoricDecisionInstanceReportResultDto> getCleanableHistoricDecisionInstanceReport(UriInfo uriInfo, Integer firstResult, Integer maxResults) { CleanableHistoricDecisionInstanceReportDto queryDto = new CleanableHistoricDecisionInstanceReportDto(objectMapper, uriInfo.getQueryParameters()); CleanableHistoricDecisionInstanceReport query = queryDto.toQuery(processEngine); List<CleanableHistoricDecisionInstanceReportResult> reportResult; if (firstResult != null || maxResults != null) { reportResult = executePaginatedQuery(query, firstResult, maxResults); } else { reportResult = query.list(); } return CleanableHistoricDecisionInstanceReportResultDto.convert(reportResult); }
@Override public List<CleanableHistoricDecisionInstanceReportResultDto> getCleanableHistoricDecisionInstanceReport(UriInfo uriInfo, Integer firstResult, Integer maxResults) { CleanableHistoricDecisionInstanceReportDto queryDto = new CleanableHistoricDecisionInstanceReportDto(objectMapper, uriInfo.getQueryParameters()); CleanableHistoricDecisionInstanceReport query = queryDto.toQuery(processEngine); List<CleanableHistoricDecisionInstanceReportResult> reportResult; if (firstResult != null || maxResults != null) { reportResult = executePaginatedQuery(query, firstResult, maxResults); } else { reportResult = query.list(); } return CleanableHistoricDecisionInstanceReportResultDto.convert(reportResult); }
public void testHistoryCleanupReportWithoutAuthorization() { // given prepareDecisionInstances(DECISION_DEFINITION_KEY, -6, 5, 10); // when List<CleanableHistoricDecisionInstanceReportResult> reportResults = historyService.createCleanableHistoricDecisionInstanceReport().list(); // then assertEquals(0, reportResults.size()); }
public void testHistoryCleanupReportWithReadHistoryPermissionOnly() { // given prepareDecisionInstances(DECISION_DEFINITION_KEY, -6, 5, 10); createGrantAuthorization(DECISION_DEFINITION, DECISION_DEFINITION_KEY, userId, Permissions.READ_HISTORY); // when List<CleanableHistoricDecisionInstanceReportResult> reportResults = historyService.createCleanableHistoricDecisionInstanceReport().list(); // then assertEquals(0, reportResults.size()); }
public void testHistoryCleanupReportWithReadPermissionOnly() { // given prepareDecisionInstances(DECISION_DEFINITION_KEY, -6, 5, 10); createGrantAuthorization(DECISION_DEFINITION, DECISION_DEFINITION_KEY, userId, Permissions.READ); // when List<CleanableHistoricDecisionInstanceReportResult> reportResults = historyService.createCleanableHistoricDecisionInstanceReport().list(); // then assertEquals(0, reportResults.size()); }
@Test public void testGetReport() { given() .then().expect() .statusCode(Status.OK.getStatusCode()) .contentType(ContentType.JSON) .when().get(HISTORIC_REPORT_URL); InOrder inOrder = Mockito.inOrder(historicDecisionInstanceReport); inOrder.verify(historicDecisionInstanceReport).list(); verifyNoMoreInteractions(historicDecisionInstanceReport); }
@Test public void testReportWithPartiallyCleanableInstances() { // given prepareDecisionInstances(DECISION_DEFINITION_KEY, -6, 5, 5); prepareDecisionInstances(DECISION_DEFINITION_KEY, 0, 5, 5); // when List<CleanableHistoricDecisionInstanceReportResult> reportResults = historyService.createCleanableHistoricDecisionInstanceReport().list(); // then assertEquals(1, reportResults.size()); checkResultNumbers(reportResults.get(0), 5, 10); }
@Test public void testReportWithNullHistoryTTL() { // given prepareDecisionInstances(DECISION_DEFINITION_KEY, -6, null, 5); prepareDecisionInstances(DECISION_DEFINITION_KEY, 0, null, 5); // when List<CleanableHistoricDecisionInstanceReportResult> reportResults = historyService.createCleanableHistoricDecisionInstanceReport().list(); // then assertEquals(1, reportResults.size()); checkResultNumbers(reportResults.get(0), 0, 10); }
@Test public void testReportWithZeroHistoryTTL() { // given prepareDecisionInstances(DECISION_DEFINITION_KEY, -6, 0, 5); prepareDecisionInstances(DECISION_DEFINITION_KEY, 0, 0, 5); // when List<CleanableHistoricDecisionInstanceReportResult> reportResults = historyService.createCleanableHistoricDecisionInstanceReport().list(); // then assertEquals(1, reportResults.size()); checkResultNumbers(reportResults.get(0), 10, 10); }
@Test public void testMissingAuthorization() { String message = "not authorized"; when(historicDecisionInstanceReport.list()).thenThrow(new AuthorizationException(message)); given() .then().expect() .statusCode(Status.FORBIDDEN.getStatusCode()) .contentType(ContentType.JSON) .body("type", equalTo(AuthorizationException.class.getSimpleName())) .body("message", equalTo(message)) .when().get(HISTORIC_REPORT_URL); }
@Test public void testReportWithAuthenticatedTenants() { // given testRule.deployForTenant(TENANT_ONE, DMN_MODEL); prepareDecisionInstances(DECISION_DEFINITION_KEY, -6, 5, 10, TENANT_ONE); identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE)); // when List<CleanableHistoricDecisionInstanceReportResult> reportResults = historyService.createCleanableHistoricDecisionInstanceReport().list(); // then assertEquals(1, reportResults.size()); assertEquals(TENANT_ONE, reportResults.get(0).getTenantId()); }
@Test public void testOrderByFinishedDecisionInstanceAsc() { given() .queryParam("sortBy", "finished") .queryParam("sortOrder", "asc") .then().expect() .statusCode(Status.OK.getStatusCode()) .when() .get(HISTORIC_REPORT_URL); verify(historicDecisionInstanceReport).orderByFinished(); verify(historicDecisionInstanceReport).asc(); verify(historicDecisionInstanceReport).list(); verifyNoMoreInteractions(historicDecisionInstanceReport); }
public void testHistoryCleanupReportWithAuthorization() { // given prepareDecisionInstances(DECISION_DEFINITION_KEY, -6, 5, 10); createGrantAuthorization(DECISION_DEFINITION, DECISION_DEFINITION_KEY, userId, Permissions.READ, Permissions.READ_HISTORY); createGrantAuthorizationGroup(DECISION_DEFINITION, DECISION_DEFINITION_KEY, groupId, Permissions.READ, Permissions.READ_HISTORY); // when List<CleanableHistoricDecisionInstanceReportResult> reportResults = historyService.createCleanableHistoricDecisionInstanceReport().list(); // then assertEquals(1, reportResults.size()); assertEquals(10, reportResults.get(0).getCleanableDecisionInstanceCount()); assertEquals(10, reportResults.get(0).getFinishedDecisionInstanceCount()); }
@Test public void testQueryByTenantId() { given() .queryParam("tenantIdIn", EXAMPLE_TENANT_ID + "," + ANOTHER_EXAMPLE_TENANT_ID) .then() .expect() .statusCode(Status.OK.getStatusCode()) .contentType(ContentType.JSON) .when() .get(HISTORIC_REPORT_URL); verify(historicDecisionInstanceReport).tenantIdIn(EXAMPLE_TENANT_ID, ANOTHER_EXAMPLE_TENANT_ID); verify(historicDecisionInstanceReport).list(); verifyNoMoreInteractions(historicDecisionInstanceReport); }
@Test public void testQueryCompact() { given() .queryParam("compact", true) .then() .expect() .statusCode(Status.OK.getStatusCode()) .contentType(ContentType.JSON) .when() .get(HISTORIC_REPORT_URL); verify(historicDecisionInstanceReport).compact(); verify(historicDecisionInstanceReport).list(); verifyNoMoreInteractions(historicDecisionInstanceReport); }
@Test public void testReportNoAuthenticatedTenants() { // given testRule.deployForTenant(TENANT_ONE, DMN_MODEL); prepareDecisionInstances(DECISION_DEFINITION_KEY, -6, 5, 10, TENANT_ONE); identityService.setAuthentication("user", null, null); // when List<CleanableHistoricDecisionInstanceReportResult> reportResults = historyService.createCleanableHistoricDecisionInstanceReport().list(); // then assertEquals(0, reportResults.size()); }
@Test public void testReportWithoutTenantId() { // given testRule.deploy(DMN_MODEL); prepareDecisionInstances(DECISION_DEFINITION_KEY, -6, 5, 10, null); // when List<CleanableHistoricDecisionInstanceReportResult> reportResults = historyService.createCleanableHistoricDecisionInstanceReport().withoutTenantId().list(); // then assertEquals(1, reportResults.size()); assertEquals(null, reportResults.get(0).getTenantId()); }
@Test public void testReportWithAllCleanableInstances() { // given prepareDecisionInstances(DECISION_DEFINITION_KEY, -6, 5, 10); // when List<CleanableHistoricDecisionInstanceReportResult> reportResults = historyService.createCleanableHistoricDecisionInstanceReport().list(); long count = historyService.createCleanableHistoricDecisionInstanceReport().count(); // then assertEquals(1, reportResults.size()); assertEquals(1, count); checkResultNumbers(reportResults.get(0), 10, 10); }
@Test public void testReportCompact() { // given List<DecisionDefinition> decisionDefinitions = repositoryService.createDecisionDefinitionQuery().decisionDefinitionKey(DECISION_DEFINITION_KEY).list(); assertEquals(1, decisionDefinitions.size()); // assume List<CleanableHistoricDecisionInstanceReportResult> resultWithZeros = historyService.createCleanableHistoricDecisionInstanceReport().list(); assertEquals(1, resultWithZeros.size()); assertEquals(0, resultWithZeros.get(0).getFinishedDecisionInstanceCount()); // when long resultCountWithoutZeros = historyService.createCleanableHistoricDecisionInstanceReport().compact().count(); // then assertEquals(0, resultCountWithoutZeros); }
@Test public void testFullQuery() { given() .params(getCompleteQueryParameters()) .then() .expect() .statusCode(Status.OK.getStatusCode()) .contentType(ContentType.JSON) .when() .get(HISTORIC_REPORT_URL); verifyQueryParameterInvocations(); verify(historicDecisionInstanceReport).list(); }