public static HistoricJobLog createMockHistoricJobLog(String tenantId) { HistoricJobLog mock = mock(HistoricJobLog.class); when(mock.getId()).thenReturn(EXAMPLE_HISTORIC_JOB_LOG_ID); when(mock.getTimestamp()).thenReturn(DateTimeUtil.parseDate(EXAMPLE_HISTORIC_JOB_LOG_TIMESTAMP)); when(mock.getRemovalTime()).thenReturn(DateTimeUtil.parseDate(EXAMPLE_HISTORIC_JOB_LOG_REMOVAL_TIME)); when(mock.getJobId()).thenReturn(EXAMPLE_HISTORIC_JOB_LOG_JOB_ID); when(mock.getJobDueDate()).thenReturn(DateTimeUtil.parseDate(EXAMPLE_HISTORIC_JOB_LOG_JOB_DUE_DATE)); when(mock.getJobRetries()).thenReturn(EXAMPLE_HISTORIC_JOB_LOG_JOB_RETRIES); when(mock.getJobPriority()).thenReturn(EXAMPLE_HISTORIC_JOB_LOG_JOB_PRIORITY); when(mock.getJobExceptionMessage()).thenReturn(EXAMPLE_HISTORIC_JOB_LOG_JOB_EXCEPTION_MSG); when(mock.getJobDefinitionId()).thenReturn(EXAMPLE_HISTORIC_JOB_LOG_JOB_DEF_ID); when(mock.getJobDefinitionType()).thenReturn(EXAMPLE_HISTORIC_JOB_LOG_JOB_DEF_TYPE); when(mock.getJobDefinitionConfiguration()).thenReturn(EXAMPLE_HISTORIC_JOB_LOG_JOB_DEF_CONFIG); when(mock.getActivityId()).thenReturn(EXAMPLE_HISTORIC_JOB_LOG_ACTIVITY_ID); when(mock.getExecutionId()).thenReturn(EXAMPLE_HISTORIC_JOB_LOG_EXECUTION_ID); when(mock.getProcessInstanceId()).thenReturn(EXAMPLE_HISTORIC_JOB_LOG_PROC_INST_ID); when(mock.getProcessDefinitionId()).thenReturn(EXAMPLE_HISTORIC_JOB_LOG_PROC_DEF_ID); when(mock.getProcessDefinitionKey()).thenReturn(EXAMPLE_HISTORIC_JOB_LOG_PROC_DEF_KEY); when(mock.getDeploymentId()).thenReturn(EXAMPLE_HISTORIC_JOB_LOG_DEPLOYMENT_ID); when(mock.getTenantId()).thenReturn(tenantId); when(mock.getRootProcessInstanceId()).thenReturn(EXAMPLE_HISTORIC_JOB_LOG_ROOT_PROC_INST_ID); when(mock.isCreationLog()).thenReturn(EXAMPLE_HISTORIC_JOB_LOG_IS_CREATION_LOG); when(mock.isFailureLog()).thenReturn(EXAMPLE_HISTORIC_JOB_LOG_IS_FAILURE_LOG); when(mock.isSuccessLog()).thenReturn(EXAMPLE_HISTORIC_JOB_LOG_IS_SUCCESS_LOG); when(mock.isDeletionLog()).thenReturn(EXAMPLE_HISTORIC_JOB_LOG_IS_DELETION_LOG); return mock; }
public Void execute(CommandContext commandContext) { List<HistoricJobLog> jobLogs = processEngine.getHistoryService().createHistoricJobLogQuery().list(); for (HistoricJobLog jobLog : jobLogs) { commandContext.getHistoricJobLogManager().deleteHistoricJobLogById(jobLog.getId()); } return null; } });
@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 execute(CommandContext commandContext) { List<HistoricJobLog> historicJobLogs = processEngineConfiguration .getHistoryService() .createHistoricJobLogQuery() .list(); for (HistoricJobLog historicJobLog : historicJobLogs) { commandContext .getHistoricJobLogManager() .deleteHistoricJobLogById(historicJobLog.getId()); } return null; } });
public Void execute(CommandContext commandContext) { List<HistoricJobLog> historicJobLogs = processEngineConfiguration .getHistoryService() .createHistoricJobLogQuery() .list(); for (HistoricJobLog historicJobLog : historicJobLogs) { commandContext .getHistoricJobLogManager() .deleteHistoricJobLogById(historicJobLog.getId()); } return null; } });
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()); }
@Deployment(resources = {"org/camunda/bpm/engine/test/history/HistoricJobLogTest.testAsyncContinuation.bpmn20.xml"}) public void testQueryByLogId() { runtimeService.startProcessInstanceByKey("process"); String logId = historyService.createHistoricJobLogQuery().singleResult().getId(); HistoricJobLogQuery query = historyService.createHistoricJobLogQuery().logId(logId); verifyQueryResults(query, 1); }
public Void execute(CommandContext commandContext) { List<Job> jobs = commandContext.getDbEntityManager().createJobQuery().list(); for (Job job : jobs) { commandContext.getJobManager().deleteJob((JobEntity) job, false); } for (HistoricJobLog jobLog : commandContext.getDbEntityManager().createHistoricJobLogQuery().list()) { commandContext.getHistoricJobLogManager().deleteHistoricJobLogById(jobLog.getId()); } return null; }
@Test public void failToGetHistoricJobLogExceptionStacktraceNoAuthenticatedTenants() { testRule.deployForTenant(TENANT_ONE, FAILING_BPMN_PROCESS); String processInstanceId = startProcessInstance(null); String historicJobLogId = historyService.createHistoricJobLogQuery() .processInstanceId(processInstanceId).singleResult().getId(); identityService.setAuthentication("user", null, null); thrown.expect(ProcessEngineException.class); thrown.expectMessage("Cannot get the historic job log"); historyService.getHistoricJobLogExceptionStacktrace(historicJobLogId); }
public void testGetHistoricStandaloneJobLogExceptionStacktrace() { // given disableAuthorization(); repositoryService.suspendProcessDefinitionByKey(TIMER_BOUNDARY_PROCESS_KEY, true, new Date()); enableAuthorization(); String jobLogId = historyService.createHistoricJobLogQuery().singleResult().getId(); // when String stacktrace = historyService.getHistoricJobLogExceptionStacktrace(jobLogId); // then assertNull(stacktrace); deleteDeployment(deploymentId); disableAuthorization(); String jobId = managementService.createJobQuery().singleResult().getId(); managementService.deleteJob(jobId); enableAuthorization(); }
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); } }
@Deployment public void testThrowExceptionWithoutMessage() { // given runtimeService.startProcessInstanceByKey("process").getId(); String jobId = managementService.createJobQuery().singleResult().getId(); // when try { managementService.executeJob(jobId); fail(); } catch (Exception e) { // expected } // then HistoricJobLog failedHistoricJobLog = historyService .createHistoricJobLogQuery() .failureLog() .singleResult(); String failedHistoricJobLogId = failedHistoricJobLog.getId(); assertNull(failedHistoricJobLog.getJobExceptionMessage()); String stacktrace = historyService.getHistoricJobLogExceptionStacktrace(failedHistoricJobLogId); assertNotNull(stacktrace); assertTextPresent(ThrowExceptionWithoutMessageDelegate.class.getName(), stacktrace); }
public static HistoricJobLogDto fromHistoricJobLog(HistoricJobLog historicJobLog) { HistoricJobLogDto result = new HistoricJobLogDto(); result.id = historicJobLog.getId(); result.timestamp = historicJobLog.getTimestamp(); result.removalTime = historicJobLog.getRemovalTime(); result.jobId = historicJobLog.getJobId(); result.jobDueDate = historicJobLog.getJobDueDate(); result.jobRetries = historicJobLog.getJobRetries(); result.jobPriority = historicJobLog.getJobPriority(); result.jobExceptionMessage = historicJobLog.getJobExceptionMessage(); result.jobDefinitionId = historicJobLog.getJobDefinitionId(); result.jobDefinitionType = historicJobLog.getJobDefinitionType(); result.jobDefinitionConfiguration = historicJobLog.getJobDefinitionConfiguration(); result.activityId = historicJobLog.getActivityId(); result.executionId = historicJobLog.getExecutionId(); result.processInstanceId = historicJobLog.getProcessInstanceId(); result.processDefinitionId = historicJobLog.getProcessDefinitionId(); result.processDefinitionKey = historicJobLog.getProcessDefinitionKey(); result.deploymentId = historicJobLog.getDeploymentId(); result.tenantId = historicJobLog.getTenantId(); result.rootProcessInstanceId = historicJobLog.getRootProcessInstanceId(); result.creationLog = historicJobLog.isCreationLog(); result.failureLog = historicJobLog.isFailureLog(); result.successLog = historicJobLog.isSuccessLog(); result.deletionLog = historicJobLog.isDeletionLog(); return result; }
public static HistoricJobLogDto fromHistoricJobLog(HistoricJobLog historicJobLog) { HistoricJobLogDto result = new HistoricJobLogDto(); result.id = historicJobLog.getId(); result.timestamp = historicJobLog.getTimestamp(); result.removalTime = historicJobLog.getRemovalTime(); result.jobId = historicJobLog.getJobId(); result.jobDueDate = historicJobLog.getJobDueDate(); result.jobRetries = historicJobLog.getJobRetries(); result.jobPriority = historicJobLog.getJobPriority(); result.jobExceptionMessage = historicJobLog.getJobExceptionMessage(); result.jobDefinitionId = historicJobLog.getJobDefinitionId(); result.jobDefinitionType = historicJobLog.getJobDefinitionType(); result.jobDefinitionConfiguration = historicJobLog.getJobDefinitionConfiguration(); result.activityId = historicJobLog.getActivityId(); result.executionId = historicJobLog.getExecutionId(); result.processInstanceId = historicJobLog.getProcessInstanceId(); result.processDefinitionId = historicJobLog.getProcessDefinitionId(); result.processDefinitionKey = historicJobLog.getProcessDefinitionKey(); result.deploymentId = historicJobLog.getDeploymentId(); result.tenantId = historicJobLog.getTenantId(); result.rootProcessInstanceId = historicJobLog.getRootProcessInstanceId(); result.creationLog = historicJobLog.isCreationLog(); result.failureLog = historicJobLog.isFailureLog(); result.successLog = historicJobLog.isSuccessLog(); result.deletionLog = historicJobLog.isDeletionLog(); return result; }
@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 execute(CommandContext commandContext) { List<Job> jobs = processEngineConfiguration .getManagementService() .createJobQuery() .list(); for (Job job : jobs) { new DeleteJobCmd(job.getId()).execute(commandContext); commandContext.getHistoricJobLogManager().deleteHistoricJobLogByJobId(job.getId()); } List<HistoricIncident> historicIncidents = processEngineConfiguration .getHistoryService() .createHistoricIncidentQuery() .list(); for (HistoricIncident historicIncident : historicIncidents) { commandContext .getDbEntityManager() .delete((DbEntity) historicIncident); } List<HistoricJobLog> historicJobLogs = processEngineConfiguration .getHistoryService() .createHistoricJobLogQuery() .list(); for (HistoricJobLog historicJobLog : historicJobLogs) { commandContext .getHistoricJobLogManager() .deleteHistoricJobLogById(historicJobLog.getId()); } return null; } });
@Deployment(resources = {"org/camunda/bpm/engine/test/history/HistoricJobLogTest.testAsyncContinuation.bpmn20.xml"}) public void testQueryByLogId() { runtimeService.startProcessInstanceByKey("process"); String logId = historyService.createHistoricJobLogQuery().singleResult().getId(); HistoricJobLogQuery query = historyService.createHistoricJobLogQuery().logId(logId); verifyQueryResults(query, 1); }