protected List<HistoricJobLog> executePaginatedQuery(HistoricJobLogQuery query, Integer firstResult, Integer maxResults) { if (firstResult == null) { firstResult = 0; } if (maxResults == null) { maxResults = Integer.MAX_VALUE; } return query.listPage(firstResult, maxResults); }
protected List<HistoricJobLog> executePaginatedQuery(HistoricJobLogQuery query, Integer firstResult, Integer maxResults) { if (firstResult == null) { firstResult = 0; } if (maxResults == null) { maxResults = Integer.MAX_VALUE; } return query.listPage(firstResult, maxResults); }
protected List<HistoricJobLog> executePaginatedQuery(HistoricJobLogQuery query, Integer firstResult, Integer maxResults) { if (firstResult == null) { firstResult = 0; } if (maxResults == null) { maxResults = Integer.MAX_VALUE; } return query.listPage(firstResult, maxResults); }
@Test public void testMissingFirstResultParameter() { int maxResults = 10; given() .queryParam("maxResults", maxResults) .then() .expect() .statusCode(Status.OK.getStatusCode()) .when() .get(HISTORIC_JOB_LOG_RESOURCE_URL); verify(mockedQuery).listPage(0, maxResults); }
@Test public void testMissingMaxResultsParameter() { int firstResult = 10; given() .queryParam("firstResult", firstResult) .then() .expect() .statusCode(Status.OK.getStatusCode()) .when() .get(HISTORIC_JOB_LOG_RESOURCE_URL); verify(mockedQuery).listPage(firstResult, Integer.MAX_VALUE); }
@Test public void getHistoricJobLogExceptionStacktraceWithAuthenticatedTenant() { testRule.deployForTenant(TENANT_ONE, FAILING_BPMN_PROCESS); String processInstanceId = startProcessInstance(null); testRule.executeAvailableJobs(); HistoricJobLog log = historyService.createHistoricJobLogQuery() .processInstanceId(processInstanceId).failureLog().listPage(0, 1).get(0); identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE)); String historicJobLogExceptionStacktrace = historyService.getHistoricJobLogExceptionStacktrace(log.getId()); assertThat(historicJobLogExceptionStacktrace, notNullValue()); }
@Test public void testSuccessfulPagination() { int firstResult = 0; int maxResults = 10; given() .queryParam("firstResult", firstResult) .queryParam("maxResults", maxResults) .then() .expect() .statusCode(Status.OK.getStatusCode()) .when() .get(HISTORIC_JOB_LOG_RESOURCE_URL); verify(mockedQuery).listPage(firstResult, maxResults); }
@Test public void getHistoricJobLogExceptionStacktraceWithDisabledTenantCheck() { testRule.deployForTenant(TENANT_ONE, FAILING_BPMN_PROCESS); String processInstanceId = startProcessInstance(TENANT_ONE); testRule.executeAvailableJobs(); HistoricJobLog log = historyService.createHistoricJobLogQuery() .processInstanceId(processInstanceId).failureLog().listPage(0, 1).get(0); identityService.setAuthentication("user", null, null); processEngineConfiguration.setTenantCheckEnabled(false); String historicJobLogExceptionStacktrace = historyService.getHistoricJobLogExceptionStacktrace(log.getId()); assertThat(historicJobLogExceptionStacktrace, notNullValue()); }
public void testGetHistoricJobLogExceptionStacktraceWithReadHistoryPermissionOnProcessDefinition() { // given startProcessAndExecuteJob(ONE_INCIDENT_PROCESS_KEY); disableAuthorization(); String jobLogId = historyService.createHistoricJobLogQuery().failureLog().listPage(0, 1).get(0).getId(); enableAuthorization(); createGrantAuthorization(PROCESS_DEFINITION, ONE_INCIDENT_PROCESS_KEY, userId, READ_HISTORY); // when String stacktrace = historyService.getHistoricJobLogExceptionStacktrace(jobLogId); // then assertNotNull(stacktrace); }
public void testGetHistoricJobLogExceptionStacktraceWithReadHistoryPermissionOnAnyProcessDefinition() { // given startProcessAndExecuteJob(ONE_INCIDENT_PROCESS_KEY); disableAuthorization(); String jobLogId = historyService.createHistoricJobLogQuery().failureLog().listPage(0, 1).get(0).getId(); enableAuthorization(); createGrantAuthorization(PROCESS_DEFINITION, ANY, userId, READ_HISTORY); // when String stacktrace = historyService.getHistoricJobLogExceptionStacktrace(jobLogId); // then assertNotNull(stacktrace); }
public void testGetHistoricJobLogExceptionStacktraceWithoutAuthorization() { // given startProcessAndExecuteJob(ONE_INCIDENT_PROCESS_KEY); disableAuthorization(); String jobLogId = historyService.createHistoricJobLogQuery().failureLog().listPage(0, 1).get(0).getId(); enableAuthorization(); try { // when historyService.getHistoricJobLogExceptionStacktrace(jobLogId); fail("Exception expected: It should not be possible to get the historic job log exception stacktrace"); } catch (AuthorizationException e) { // then String message = e.getMessage(); assertTextPresent(userId, message); assertTextPresent(READ_HISTORY.getName(), message); assertTextPresent(ONE_INCIDENT_PROCESS_KEY, message); assertTextPresent(PROCESS_DEFINITION.resourceName(), message); } }
@Test public void getHistoricJobLogExceptionStacktraceWithAuthenticatedTenant() { testRule.deployForTenant(TENANT_ONE, FAILING_BPMN_PROCESS); String processInstanceId = startProcessInstance(null); testRule.executeAvailableJobs(); HistoricJobLog log = historyService.createHistoricJobLogQuery() .processInstanceId(processInstanceId).failureLog().listPage(0, 1).get(0); identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE)); String historicJobLogExceptionStacktrace = historyService.getHistoricJobLogExceptionStacktrace(log.getId()); assertThat(historicJobLogExceptionStacktrace, notNullValue()); }
public void testGetHistoricJobLogExceptionStacktraceWithReadHistoryPermissionOnProcessDefinition() { // given startProcessAndExecuteJob(ONE_INCIDENT_PROCESS_KEY); disableAuthorization(); String jobLogId = historyService.createHistoricJobLogQuery().failureLog().listPage(0, 1).get(0).getId(); enableAuthorization(); createGrantAuthorization(PROCESS_DEFINITION, ONE_INCIDENT_PROCESS_KEY, userId, READ_HISTORY); // when String stacktrace = historyService.getHistoricJobLogExceptionStacktrace(jobLogId); // then assertNotNull(stacktrace); }
public void testGetHistoricJobLogExceptionStacktraceWithReadHistoryPermissionOnAnyProcessDefinition() { // given startProcessAndExecuteJob(ONE_INCIDENT_PROCESS_KEY); disableAuthorization(); String jobLogId = historyService.createHistoricJobLogQuery().failureLog().listPage(0, 1).get(0).getId(); enableAuthorization(); createGrantAuthorization(PROCESS_DEFINITION, ANY, userId, READ_HISTORY); // when String stacktrace = historyService.getHistoricJobLogExceptionStacktrace(jobLogId); // then assertNotNull(stacktrace); }
@Test public void getHistoricJobLogExceptionStacktraceWithDisabledTenantCheck() { testRule.deployForTenant(TENANT_ONE, FAILING_BPMN_PROCESS); String processInstanceId = startProcessInstance(TENANT_ONE); testRule.executeAvailableJobs(); HistoricJobLog log = historyService.createHistoricJobLogQuery() .processInstanceId(processInstanceId).failureLog().listPage(0, 1).get(0); identityService.setAuthentication("user", null, null); processEngineConfiguration.setTenantCheckEnabled(false); String historicJobLogExceptionStacktrace = historyService.getHistoricJobLogExceptionStacktrace(log.getId()); assertThat(historicJobLogExceptionStacktrace, notNullValue()); }
public void testGetHistoricJobLogExceptionStacktraceWithoutAuthorization() { // given startProcessAndExecuteJob(ONE_INCIDENT_PROCESS_KEY); disableAuthorization(); String jobLogId = historyService.createHistoricJobLogQuery().failureLog().listPage(0, 1).get(0).getId(); enableAuthorization(); try { // when historyService.getHistoricJobLogExceptionStacktrace(jobLogId); fail("Exception expected: It should not be possible to get the historic job log exception stacktrace"); } catch (AuthorizationException e) { // then String message = e.getMessage(); assertTextPresent(userId, message); assertTextPresent(READ_HISTORY.getName(), message); assertTextPresent(ONE_INCIDENT_PROCESS_KEY, message); assertTextPresent(PROCESS_DEFINITION.resourceName(), message); } }