@Deployment(resources = {"org/camunda/bpm/engine/test/history/HistoricJobLogTest.testAsyncContinuation.bpmn20.xml"}) public void testDeletedJob() { // given runtimeService.startProcessInstanceByKey("process"); String jobId = managementService.createJobQuery().singleResult().getId(); HistoricJobLogQuery query = historyService.createHistoricJobLogQuery().jobId(jobId); HistoricJobLogQuery createdQuery = historyService.createHistoricJobLogQuery().jobId(jobId).creationLog(); HistoricJobLogQuery deletedQuery = historyService.createHistoricJobLogQuery().jobId(jobId).deletionLog(); // there exists one historic job log entry assertEquals(1, query.count()); assertEquals(1, createdQuery.count()); assertEquals(0, deletedQuery.count()); // when managementService.deleteJob(jobId); // then assertEquals(2, query.count()); assertEquals(1, createdQuery.count()); assertEquals(1, deletedQuery.count()); HistoricJobLog createdJobLogEntry = createdQuery.singleResult(); assertEquals(3, createdJobLogEntry.getJobRetries()); HistoricJobLog deletedJobLogEntry = deletedQuery.singleResult(); assertEquals(3, deletedJobLogEntry.getJobRetries()); }
@Override protected void applyFilters(HistoricJobLogQuery query) { if (id != null) { query.logId(id); query.jobId(jobId); query.jobExceptionMessage(jobExceptionMessage); query.jobDefinitionId(jobDefinitionId); query.jobDefinitionType(jobDefinitionType); query.jobDefinitionConfiguration(jobDefinitionConfiguration); query.activityIdIn(activityIds); query.executionIdIn(executionIds); query.processInstanceId(processInstanceId); query.processDefinitionId(processDefinitionId); query.processDefinitionKey(processDefinitionKey); query.deploymentId(deploymentId); query.creationLog(); query.failureLog();
@Override public void execute(PerfTestRunContext context) { long failedJobs = processEngine.getHistoryService().createHistoricJobLogQuery().failureLog().count(); long createdJobs = processEngine.getHistoryService().createHistoricJobLogQuery().creationLog().count(); long successfulJobs = processEngine.getHistoryService().createHistoricJobLogQuery().successLog().count(); System.out.println("Number of created jobs: " + createdJobs); System.out.println("Number of failed jobs: " + failedJobs); System.out.println("Number of successful jobs: " + successfulJobs); }
protected void verifyBooleanParameterQueryInvocations() { verify(mockedQuery).creationLog(); verify(mockedQuery).failureLog(); verify(mockedQuery).successLog(); verify(mockedQuery).deletionLog(); verify(mockedQuery).list(); }
HistoricJobLogQuery query = historyService.createHistoricJobLogQuery().jobId(jobId); HistoricJobLogQuery createdQuery = historyService.createHistoricJobLogQuery().jobId(jobId).creationLog(); HistoricJobLogQuery failedQuery = historyService.createHistoricJobLogQuery().jobId(jobId).failureLog().orderByJobRetries().desc(); assertEquals(1, query.count()); assertEquals(1, createdQuery.count()); assertEquals(0, failedQuery.count()); assertEquals(4, query.count()); assertEquals(1, createdQuery.count()); assertEquals(3, failedQuery.count()); HistoricJobLog createdJobLogEntry = createdQuery.singleResult(); assertEquals(3, createdJobLogEntry.getJobRetries()); HistoricJobLog failedJobLogEntry = failedQuery.list().get(0); assertEquals(3, failedJobLogEntry.getJobRetries()); failedJobLogEntry = failedQuery.list().get(1); assertEquals(2, failedJobLogEntry.getJobRetries()); failedJobLogEntry = failedQuery.list().get(2); assertEquals(1, failedJobLogEntry.getJobRetries()); assertEquals(5, query.count()); assertEquals(1, createdQuery.count()); assertEquals(4, failedQuery.count()); createdJobLogEntry = createdQuery.singleResult();
protected void verifyStringParameterQueryInvocations() { Map<String, String> stringQueryParameters = getCompleteStringQueryParameters(); verify(mockedQuery).logId(stringQueryParameters.get("logId")); verify(mockedQuery).jobId(stringQueryParameters.get("jobId")); verify(mockedQuery).jobExceptionMessage(stringQueryParameters.get("jobExceptionMessage")); verify(mockedQuery).jobDefinitionId(stringQueryParameters.get("jobDefinitionId")); verify(mockedQuery).jobDefinitionType(stringQueryParameters.get("jobDefinitionType")); verify(mockedQuery).jobDefinitionConfiguration(stringQueryParameters.get("jobDefinitionConfiguration")); verify(mockedQuery).processInstanceId(stringQueryParameters.get("processInstanceId")); verify(mockedQuery).processDefinitionId(stringQueryParameters.get("processDefinitionId")); verify(mockedQuery).processDefinitionKey(stringQueryParameters.get("processDefinitionKey")); verify(mockedQuery).deploymentId(stringQueryParameters.get("deploymentId")); verify(mockedQuery).list(); }
public List<HistoricJobLog> getHistoricMonitorJobLog(Batch batch) { return getHistoryService() .createHistoricJobLogQuery() .jobDefinitionId(batch.getMonitorJobDefinitionId()) .orderPartiallyByOccurrence() .asc() .list(); }
@Test public void testCleanupHistoricJobLog() { initBatchOperationHistoryTimeToLive(DEFAULT_TTL_DAYS); int daysInThePast = -11; // given prepareHistoricBatches(1, daysInThePast); HistoricBatch batch = historyService.createHistoricBatchQuery().singleResult(); String batchId = batch.getId(); // when runHistoryCleanup(); // then assertEquals(0, historyService.createHistoricBatchQuery().count()); assertEquals(0, historyService.createHistoricJobLogQuery().jobDefinitionConfiguration(batchId).count()); }
.jobId(jobId) .creationLog() .singleResult(); assertNotNull(historicJob); .jobId(jobId) .failureLog() .singleResult(); assertNotNull(historicJob); .jobId(jobId) .successLog() .singleResult(); assertNotNull(historicJob);
@Deployment(resources = {"org/camunda/bpm/engine/test/history/HistoricJobLogTest.testAsyncContinuation.bpmn20.xml"}) public void testExceptionStacktrace() { // given runtimeService.startProcessInstanceByKey("process"); String jobId = managementService.createJobQuery().singleResult().getId(); // when try { managementService.executeJob(jobId); fail(); } catch (Exception e) { // expected } // then String failedHistoricJobLogId = historyService .createHistoricJobLogQuery() .failureLog() .singleResult() .getId(); String stacktrace = historyService.getHistoricJobLogExceptionStacktrace(failedHistoricJobLogId); assertNotNull(stacktrace); assertTextPresent(FailingDelegate.EXCEPTION_MESSAGE, stacktrace); }
public void testQueryAuthenticatedTenant() { identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE)); HistoricJobLogQuery query = historyService.createHistoricJobLogQuery(); assertThat(query.count(), is(2L)); assertThat(query.tenantIdIn(TENANT_ONE).count(), is(2L)); assertThat(query.tenantIdIn(TENANT_TWO).count(), is(0L)); assertThat(query.tenantIdIn(TENANT_ONE, TENANT_TWO).count(), is(2L)); }
@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 testListParametersAsPost() { String anActId = "anActId"; String anotherActId = "anotherActId"; String anExecutionId = "anExecutionId"; String anotherExecutionId = "anotherExecutionId"; Map<String, List<String>> json = new HashMap<String, List<String>>(); json.put("activityIdIn", Arrays.asList(anActId, anotherActId)); json.put("executionIdIn", Arrays.asList(anExecutionId, anotherExecutionId)); given() .contentType(POST_JSON_CONTENT_TYPE) .body(json) .then() .expect() .statusCode(Status.OK.getStatusCode()) .when() .post(HISTORIC_JOB_LOG_RESOURCE_URL); verify(mockedQuery).activityIdIn(anActId, anotherActId); verify(mockedQuery).executionIdIn(anExecutionId, anotherExecutionId); verify(mockedQuery).list(); }
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); }
@Deployment(resources = {"org/camunda/bpm/engine/test/history/HistoricJobLogTest.testAsyncContinuationWithLongId.bpmn20.xml"}) public void testSuccessfulHistoricJobLogEntryStoredForLongActivityId() { runtimeService.startProcessInstanceByKey("process", Variables.createVariables().putValue("fail", false)); Job job = managementService .createJobQuery() .singleResult(); managementService.executeJob(job.getId()); HistoricJobLog historicJob = historyService .createHistoricJobLogQuery() .successLog() .singleResult(); assertNotNull(historicJob); assertEquals("serviceTaskIdIsReallyLongAndItShouldBeMoreThan64CharsSoItWill" + "BlowAnyActivityIdColumnWhereSizeIs64OrLessSoWeAlignItTo255LikeEverywhereElse", historicJob.getActivityId()); }
protected void verifyQueryResults(HistoricJobLogQuery query, int countExpected) { assertEquals(countExpected, query.list().size()); assertEquals(countExpected, query.count()); if (countExpected == 1) { assertNotNull(query.singleResult()); } else if (countExpected > 1){ verifySingleResultFails(query); } else if (countExpected == 0) { assertNull(query.singleResult()); } }
public CountResultDto queryHistoricJobLogsCount(HistoricJobLogQueryDto queryDto) { queryDto.setObjectMapper(objectMapper); HistoricJobLogQuery query = queryDto.toQuery(processEngine); long count = query.count(); CountResultDto result = new CountResultDto(); result.setCount(count); return result; }
.deletionLog() .singleResult(); assertNotNull(historicJob);
protected HistoricJobLogQuery setUpMockHistoricJobLogQuery(List<HistoricJobLog> mockedHistoricJogLogs) { HistoricJobLogQuery mockedhistoricJobLogQuery = mock(HistoricJobLogQuery.class); when(mockedhistoricJobLogQuery.list()).thenReturn(mockedHistoricJogLogs); when(mockedhistoricJobLogQuery.count()).thenReturn((long) mockedHistoricJogLogs.size()); when(processEngine.getHistoryService().createHistoricJobLogQuery()).thenReturn(mockedhistoricJobLogQuery); return mockedhistoricJobLogQuery; }
protected List<ByteArrayEntity> findByteArrays() { List<HistoricJobLog> jobLogs = historyService.createHistoricJobLogQuery() .failureLog() .list(); List<ByteArrayEntity> byteArrays = new ArrayList<>(); for (HistoricJobLog jobLog: jobLogs) { byteArrays.add(findByteArrayById(((HistoricJobLogEventEntity) jobLog).getExceptionByteArrayId())); } return byteArrays; }