use of org.camunda.bpm.engine.ProcessEngineException in project camunda-bpm-platform by camunda.
the class CdiProcessEngineTestCase method waitForJobExecutorToProcessAllJobs.
// ////////////////////// copied from AbstractActivitiTestcase
public void waitForJobExecutorToProcessAllJobs(long maxMillisToWait, long intervalMillis) {
JobExecutor jobExecutor = processEngineConfiguration.getJobExecutor();
jobExecutor.start();
try {
Timer timer = new Timer();
InteruptTask task = new InteruptTask(Thread.currentThread());
timer.schedule(task, maxMillisToWait);
boolean areJobsAvailable = true;
try {
while (areJobsAvailable && !task.isTimeLimitExceeded()) {
Thread.sleep(intervalMillis);
areJobsAvailable = areJobsAvailable();
}
} catch (InterruptedException e) {
} finally {
timer.cancel();
}
if (areJobsAvailable) {
throw new ProcessEngineException("time limit of " + maxMillisToWait + " was exceeded");
}
} finally {
jobExecutor.shutdown();
}
}
use of org.camunda.bpm.engine.ProcessEngineException in project camunda-bpm-platform by camunda.
the class HistoricDecisionInstanceDto method fromHistoricDecisionInstance.
public static HistoricDecisionInstanceDto fromHistoricDecisionInstance(HistoricDecisionInstance historicDecisionInstance) {
HistoricDecisionInstanceDto dto = new HistoricDecisionInstanceDto();
dto.id = historicDecisionInstance.getId();
dto.decisionDefinitionId = historicDecisionInstance.getDecisionDefinitionId();
dto.decisionDefinitionKey = historicDecisionInstance.getDecisionDefinitionKey();
dto.decisionDefinitionName = historicDecisionInstance.getDecisionDefinitionName();
dto.evaluationTime = historicDecisionInstance.getEvaluationTime();
dto.processDefinitionId = historicDecisionInstance.getProcessDefinitionId();
dto.processDefinitionKey = historicDecisionInstance.getProcessDefinitionKey();
dto.processInstanceId = historicDecisionInstance.getProcessInstanceId();
dto.caseDefinitionId = historicDecisionInstance.getCaseDefinitionId();
dto.caseDefinitionKey = historicDecisionInstance.getCaseDefinitionKey();
dto.caseInstanceId = historicDecisionInstance.getCaseInstanceId();
dto.activityId = historicDecisionInstance.getActivityId();
dto.activityInstanceId = historicDecisionInstance.getActivityInstanceId();
dto.userId = historicDecisionInstance.getUserId();
dto.collectResultValue = historicDecisionInstance.getCollectResultValue();
dto.rootDecisionInstanceId = historicDecisionInstance.getRootDecisionInstanceId();
dto.decisionRequirementsDefinitionId = historicDecisionInstance.getDecisionRequirementsDefinitionId();
dto.decisionRequirementsDefinitionKey = historicDecisionInstance.getDecisionRequirementsDefinitionKey();
dto.tenantId = historicDecisionInstance.getTenantId();
try {
List<HistoricDecisionInputInstanceDto> inputs = new ArrayList<HistoricDecisionInputInstanceDto>();
for (HistoricDecisionInputInstance input : historicDecisionInstance.getInputs()) {
HistoricDecisionInputInstanceDto inputDto = HistoricDecisionInputInstanceDto.fromHistoricDecisionInputInstance(input);
inputs.add(inputDto);
}
dto.inputs = inputs;
} catch (ProcessEngineException e) {
// no inputs fetched
}
try {
List<HistoricDecisionOutputInstanceDto> outputs = new ArrayList<HistoricDecisionOutputInstanceDto>();
for (HistoricDecisionOutputInstance output : historicDecisionInstance.getOutputs()) {
HistoricDecisionOutputInstanceDto outputDto = HistoricDecisionOutputInstanceDto.fromHistoricDecisionOutputInstance(output);
outputs.add(outputDto);
}
dto.outputs = outputs;
} catch (ProcessEngineException e) {
// no outputs fetched
}
return dto;
}
use of org.camunda.bpm.engine.ProcessEngineException in project camunda-bpm-platform by camunda.
the class TaskRestServiceInteractionTest method testGetNonExistingForm.
@Test
public void testGetNonExistingForm() {
when(formServiceMock.getTaskFormData(anyString())).thenThrow(new ProcessEngineException("Expected exception: task does not exist."));
given().pathParam("id", NON_EXISTING_ID).header("accept", MediaType.APPLICATION_JSON).then().expect().statusCode(Status.BAD_REQUEST.getStatusCode()).contentType(ContentType.JSON).body("type", equalTo(RestException.class.getSimpleName())).body("message", equalTo("Cannot get form for task " + NON_EXISTING_ID)).when().get(TASK_FORM_URL);
}
use of org.camunda.bpm.engine.ProcessEngineException in project camunda-bpm-platform by camunda.
the class TaskRestServiceInteractionTest method testUnsuccessfulCompleteTask.
@Test
public void testUnsuccessfulCompleteTask() {
doThrow(new ProcessEngineException("expected exception")).when(taskServiceMock).complete(any(String.class), Matchers.<Map<String, Object>>any());
given().pathParam("id", EXAMPLE_TASK_ID).header("accept", MediaType.APPLICATION_JSON).contentType(POST_JSON_CONTENT_TYPE).body(EMPTY_JSON_OBJECT).then().expect().statusCode(Status.INTERNAL_SERVER_ERROR.getStatusCode()).contentType(ContentType.JSON).body("type", equalTo(RestException.class.getSimpleName())).body("message", equalTo("Cannot complete task " + EXAMPLE_TASK_ID + ": expected exception")).when().post(COMPLETE_TASK_URL);
}
use of org.camunda.bpm.engine.ProcessEngineException in project camunda-bpm-platform by camunda.
the class TaskVariableLocalRestResourceInteractionTest method testPutLocalVariableForNonExistingTaskId.
@Test
public void testPutLocalVariableForNonExistingTaskId() {
String variableKey = "aVariableKey";
String variableValue = "aVariableValue";
Map<String, Object> variableJson = VariablesBuilder.getVariableValueMap(variableValue);
doThrow(new ProcessEngineException("Cannot find task with id " + NON_EXISTING_ID)).when(taskServiceMock).setVariableLocal(eq(NON_EXISTING_ID), eq(variableKey), any());
given().pathParam("id", NON_EXISTING_ID).pathParam("varId", variableKey).contentType(ContentType.JSON).body(variableJson).header("accept", MediaType.APPLICATION_JSON).then().expect().statusCode(Status.INTERNAL_SERVER_ERROR.getStatusCode()).body("type", is(RestException.class.getSimpleName())).body("message", is("Cannot put task variable " + variableKey + ": Cannot find task with id " + NON_EXISTING_ID)).when().put(SINGLE_TASK_PUT_SINGLE_VARIABLE_URL);
}
Aggregations