org.camunda.bpm.engine.ProcessEngineException Java Examples
The following examples show how to use
org.camunda.bpm.engine.ProcessEngineException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JavaSerializationProhibitedTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test public void testStandaloneTaskTransientVariableSerializedObject() { Task task = taskService.newTask(); task.setName("gonzoTask"); taskService.saveTask(task); String taskId = task.getId(); try { thrown.expect(ProcessEngineException.class); thrown.expectMessage("Cannot set variable with name instrument. Java serialization format is prohibited"); taskService.setVariable(taskId, "instrument", Variables.serializedObjectValue("any value") .serializationDataFormat(Variables.SerializationDataFormats.JAVA) .setTransient(true) .create()); } finally { taskService.deleteTask(taskId, true); } }
Example #2
Source File: DelegateExpressionCaseExecutionListener.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public void notify(DelegateCaseExecution caseExecution) throws Exception { // Note: we can't cache the result of the expression, because the // caseExecution can change: eg. delegateExpression='${mySpringBeanFactory.randomSpringBean()}' Object delegate = expression.getValue(caseExecution); applyFieldDeclaration(fieldDeclarations, delegate); if (delegate instanceof CaseExecutionListener) { CaseExecutionListener listenerInstance = (CaseExecutionListener) delegate; Context .getProcessEngineConfiguration() .getDelegateInterceptor() .handleInvocation(new CaseExecutionListenerInvocation(listenerInstance, caseExecution)); } else { throw new ProcessEngineException("Delegate expression " + expression + " did not resolve to an implementation of " + CaseExecutionListener.class); } }
Example #3
Source File: ProcessInstanceRestServiceInteractionTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test public void testSuspendProcessInstanceByProcessDefinitionKeyWithException() { Map<String, Object> params = new HashMap<String, Object>(); params.put("suspended", true); params.put("processDefinitionKey", MockProvider.EXAMPLE_PROCESS_DEFINITION_KEY); String expectedException = "expectedException"; doThrow(new ProcessEngineException(expectedException)) .when(mockUpdateSuspensionStateBuilder) .suspend(); given() .contentType(ContentType.JSON) .body(params) .then() .expect() .statusCode(Status.INTERNAL_SERVER_ERROR.getStatusCode()) .body("type", is(ProcessEngineException.class.getSimpleName())) .body("message", is(expectedException)) .when() .put(PROCESS_INSTANCE_SUSPENDED_URL); }
Example #4
Source File: JPAEntityScanner.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public EntityMetaData scanClass(Class<?> clazz) { EntityMetaData metaData = new EntityMetaData(); metaData.setEntityClass(clazz); // Class should have @Entity annotation boolean isEntity = isEntityAnnotationPresent(clazz); metaData.setJPAEntity(isEntity); if(isEntity) { // Try to find a field annotated with @Id Field idField = getIdField(clazz); if(idField != null) { metaData.setIdField(idField); } else { // Try to find a method annotated with @Id Method idMethod = getIdMethod(clazz); if(idMethod != null) { metaData.setIdMethod(idMethod); } else { throw new ProcessEngineException("Cannot find field or method with annotation @Id on class '" + clazz.getName() + "', only single-valued primary keys are supported on JPA-enities"); } } } return metaData; }
Example #5
Source File: CaseInstanceRestServiceInteractionTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test public void testVariableModificationForNonExistingCaseInstance() { doThrow(new ProcessEngineException("expected exception")).when(caseExecutionCommandBuilderMock).execute(); String variableKey = "aKey"; int variableValue = 123; Map<String, Object> messageBodyJson = new HashMap<String, Object>(); Map<String, Object> modifications = VariablesBuilder.create().variable(variableKey, variableValue).getVariables(); messageBodyJson.put("modifications", modifications); given().pathParam("id", MockProvider.EXAMPLE_CASE_INSTANCE_ID).contentType(ContentType.JSON).body(messageBodyJson) .then().expect().statusCode(Status.INTERNAL_SERVER_ERROR.getStatusCode()).contentType(ContentType.JSON) .body("type", equalTo(RestException.class.getSimpleName())) .body("message", equalTo("Cannot modify variables for case execution " + MockProvider.EXAMPLE_CASE_INSTANCE_ID + ": expected exception")) .when().post(CASE_INSTANCE_VARIABLES_URL); }
Example #6
Source File: JobRestServiceInteractionTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test public void testSetJobDuedateNonExistentJob() { Date newDuedate = MockProvider.createMockDuedate(); String expectedMessage = "No job found with id '" + MockProvider.NON_EXISTING_JOB_ID + "'."; doThrow(new ProcessEngineException(expectedMessage)).when(mockManagementService).setJobDuedate(MockProvider.NON_EXISTING_JOB_ID, newDuedate, false); Map<String, Object> duedateVariableJson = new HashMap<String, Object>(); duedateVariableJson.put("duedate", newDuedate); given().pathParam("id", MockProvider.NON_EXISTING_JOB_ID).contentType(ContentType.JSON) .body(duedateVariableJson).then().expect() .statusCode(Status.INTERNAL_SERVER_ERROR.getStatusCode()) .body("type", equalTo(InvalidRequestException.class.getSimpleName())) .body("message", equalTo(expectedMessage)) .when().put(JOB_RESOURCE_SET_DUEDATE_URL); verify(mockManagementService).setJobDuedate(MockProvider.NON_EXISTING_JOB_ID, newDuedate, false); }
Example #7
Source File: UnhandledBpmnErrorTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test public void testThrownInJavaDelegate() { // expect thrown.expect(ProcessEngineException.class); thrown.expectMessage(containsString("no error handler")); // given BpmnModelInstance instance = Bpmn.createExecutableProcess("process") .startEvent() .serviceTask().camundaClass(ThrowBpmnErrorDelegate.class) .endEvent().done(); testRule.deploy(instance); // when runtimeService.startProcessInstanceByKey("process"); }
Example #8
Source File: MigrationProcessInstanceTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test public void testEmptyProcessInstanceQuery() { ProcessDefinition testProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS); MigrationPlan migrationPlan = runtimeService.createMigrationPlan(testProcessDefinition.getId(), testProcessDefinition.getId()) .mapEqualActivities() .build(); ProcessInstanceQuery emptyProcessInstanceQuery = runtimeService.createProcessInstanceQuery(); assertEquals(0, emptyProcessInstanceQuery.count()); try { runtimeService.newMigration(migrationPlan).processInstanceQuery(emptyProcessInstanceQuery).execute(); fail("Should not be able to migrate"); } catch (ProcessEngineException e) { assertThat(e.getMessage(), CoreMatchers.containsString("process instance ids is empty")); } }
Example #9
Source File: CaseExecutionRestServiceInteractionTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test public void testGetLocalVariableForNonExistingExecution() { when(caseServiceMock.getVariableLocalTyped(eq(MockProvider.EXAMPLE_CASE_EXECUTION_ID), eq(EXAMPLE_VARIABLE_KEY), eq(true))) .thenThrow(new ProcessEngineException("expected exception")); given() .pathParam("id", MockProvider.EXAMPLE_CASE_EXECUTION_ID) .pathParam("varId", EXAMPLE_VARIABLE_KEY) .then() .expect() .statusCode(Status.INTERNAL_SERVER_ERROR.getStatusCode()) .body("type", is(RestException.class.getSimpleName())) .body("message", is("Cannot get case execution variable " + EXAMPLE_VARIABLE_KEY + ": expected exception")) .when() .get(SINGLE_CASE_EXECUTION_LOCAL_VARIABLE_URL); }
Example #10
Source File: JobRestServiceInteractionTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test public void testSuspendedThrowsProcessEngineException() { JobSuspensionStateDto dto = new JobSuspensionStateDto(); dto.setSuspended(true); String expectedMessage = "expectedMessage"; doThrow(new ProcessEngineException(expectedMessage)) .when(mockSuspensionStateBuilder) .suspend(); given() .pathParam("id", MockProvider.NON_EXISTING_JOB_ID) .contentType(ContentType.JSON) .body(dto) .then() .expect() .statusCode(Status.INTERNAL_SERVER_ERROR.getStatusCode()) .body("type", is(ProcessEngineException.class.getSimpleName())) .body("message", is(expectedMessage)) .when() .put(SINGLE_JOB_SUSPENDED_URL); }
Example #11
Source File: ProcessInstanceModificationMultiInstanceTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Deployment(resources = SEQUENTIAL_MULTI_INSTANCE_TASK_PROCESS) public void testStartBeforeInnerActivitySequentialTasks() { // given ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("miSequentialUserTasks"); completeTasksInOrder("beforeTask"); // then creating a second inner instance is not possible ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId()); try { runtimeService .createProcessInstanceModification(processInstance.getId()) .startBeforeActivity("miTasks", tree.getActivityInstances("miTasks#multiInstanceBody")[0].getId()) .execute(); fail("expect exception"); } catch (ProcessEngineException e) { assertTextPresent(e.getMessage(), "Concurrent instantiation not possible for activities " + "in scope miTasks#multiInstanceBody"); } }
Example #12
Source File: CustomBpmnParse.java From wecube-platform with Apache License 2.0 | 6 votes |
protected Condition parseConditionExpression(Element conditionExprElement) { String expression = translateConditionExpressionElementText(conditionExprElement); String type = conditionExprElement.attributeNS(XSI_NS, TYPE); String language = conditionExprElement.attribute(PROPERTYNAME_LANGUAGE); String resource = conditionExprElement.attributeNS(CAMUNDA_BPMN_EXTENSIONS_NS, PROPERTYNAME_RESOURCE); if (type != null) { String value = type.contains(":") ? resolveName(type) : BpmnParser.BPMN20_NS + ":" + type; if (!value.equals(ATTRIBUTEVALUE_T_FORMAL_EXPRESSION)) { addError("Invalid type, only tFormalExpression is currently supported", conditionExprElement); } } Condition condition = null; if (language == null) { condition = new UelExpressionCondition(expressionManager.createExpression(expression)); } else { try { ExecutableScript script = ScriptUtil.getScript(language, expression, resource, expressionManager); condition = new ScriptCondition(script); } catch (ProcessEngineException e) { addError("Unable to process condition expression:" + e.getMessage(), conditionExprElement); } } return condition; }
Example #13
Source File: PersistenceExceptionTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test public void testPersistenceExceptionContainsRealCause() { Assume.assumeFalse(engineRule.getProcessEngineConfiguration().getDatabaseType().equals(DbSqlSessionFactory.MARIADB)); StringBuffer longString = new StringBuffer(); for (int i = 0; i < 100; i++) { longString.append("tensymbols"); } final BpmnModelInstance modelInstance = Bpmn.createExecutableProcess("process1").startEvent().userTask(longString.toString()).endEvent().done(); testRule.deploy(modelInstance); try { runtimeService.startProcessInstanceByKey("process1").getId(); fail("persistence exception is expected"); } catch (ProcessEngineException ex) { assertTrue(ex.getMessage().contains("insertHistoricTaskInstanceEvent")); } }
Example #14
Source File: RepositoryServiceTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public void testFindDeploymentResourcesNullDeploymentId() { try { repositoryService.getDeploymentResources(null); fail("ProcessEngineException expected"); } catch (ProcessEngineException e) { assertTextPresent("deploymentId is null", e.getMessage()); } }
Example #15
Source File: UserOperationLogQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public void testQueryByInvalidDeploymentId() { UserOperationLogQuery query = historyService .createUserOperationLogQuery() .deploymentId("invalid"); verifyQueryResults(query, 0); try { query.deploymentId(null); fail(); } catch (ProcessEngineException e) { // expected } }
Example #16
Source File: CommandLogger.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public ProcessEngineException historicProcessInstanceActive(HistoricProcessInstance historicProcessInstance) { return new ProcessEngineException(exceptionMessage( "040", "Historic process instance '{}' cannot be restarted. It is not completed or terminated.", historicProcessInstance.getId(), historicProcessInstance.getProcessDefinitionId() )); }
Example #17
Source File: TargetVariableScopeTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test @Deployment(resources = {"org/camunda/bpm/engine/test/api/variables/scope/doer.bpmn"}) public void testWithDelegateVariableMappingAndChildScope () { BpmnModelInstance instance = Bpmn.createExecutableProcess("process1") .startEvent() .parallelGateway() .subProcess("SubProcess_1") .embeddedSubProcess() .startEvent() .callActivity() .calledElement("Process_StuffDoer") .camundaVariableMappingClass("org.camunda.bpm.engine.test.api.variables.scope.SetVariableToChildMappingDelegate") .serviceTask() .camundaClass("org.camunda.bpm.engine.test.api.variables.scope.AssertVariableScopeDelegate") .endEvent() .subProcessDone() .moveToLastGateway() .subProcess("SubProcess_2") .embeddedSubProcess() .startEvent() .userTask("ut") .endEvent() .subProcessDone() .endEvent() .done(); instance = modify(instance) .activityBuilder("SubProcess_1") .multiInstance() .parallel() .camundaCollection("orderIds") .camundaElementVariable("orderId") .done(); ProcessDefinition processDefinition = testHelper.deployAndGetDefinition(instance); thrown.expect(ProcessEngineException.class); thrown.expectMessage(startsWith("org.camunda.bpm.engine.ProcessEngineException: ENGINE-20011 Scope with specified activity Id SubProcess_2 and execution")); VariableMap variables = Variables.createVariables().putValue("orderIds", Arrays.asList(new int[]{1, 2, 3})); engineRule.getRuntimeService().startProcessInstanceById(processDefinition.getId(),variables); }
Example #18
Source File: JobDefinitionQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Deployment(resources = {"org/camunda/bpm/engine/test/api/mgmt/JobDefinitionQueryTest.testBase.bpmn"}) public void testQueryByInvalidDefinitionKey() { JobDefinitionQuery query = managementService.createJobDefinitionQuery().processDefinitionKey("invalid"); verifyQueryResults(query, 0); try { managementService.createJobDefinitionQuery().processDefinitionKey(null); fail("A ProcessEngineExcpetion was expected."); } catch (ProcessEngineException e) {} }
Example #19
Source File: ProcessEngineConfigurationImpl.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
protected CommandInterceptor initInterceptorChain(List<CommandInterceptor> chain) { if (chain == null || chain.isEmpty()) { throw new ProcessEngineException("invalid command interceptor chain configuration: " + chain); } for (int i = 0; i < chain.size() - 1; i++) { chain.get(i).setNext(chain.get(i + 1)); } return chain.get(0); }
Example #20
Source File: RepositoryServiceTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" }) public void testGetResourceAsStreamUnexistingResourceInExistingDeployment() { // Get hold of the deployment id org.camunda.bpm.engine.repository.Deployment deployment = repositoryService.createDeploymentQuery().singleResult(); try { repositoryService.getResourceAsStream(deployment.getId(), "org/camunda/bpm/engine/test/api/unexistingProcess.bpmn.xml"); fail("ProcessEngineException expected"); } catch (ProcessEngineException ae) { assertTextPresent("no resource found with name", ae.getMessage()); } }
Example #21
Source File: TaskQueryOrTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test public void shouldThrowExceptionByWithCandidateUsersApplied() { thrown.expect(ProcessEngineException.class); thrown.expectMessage("Invalid query usage: cannot set withCandidateUsers() within 'or' query"); taskService.createTaskQuery() .or() .withCandidateUsers() .endOr(); }
Example #22
Source File: QueryMaxResultsLimitUtil.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public static void checkMaxResultsLimit(int resultsCount) { ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration(); if (processEngineConfiguration == null) { throw new ProcessEngineException("Command context unset."); } checkMaxResultsLimit(resultsCount, getMaxResultsLimit(processEngineConfiguration), isUserAuthenticated(processEngineConfiguration)); }
Example #23
Source File: UserQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public void testQueryByInvalidEmailLike() { UserQuery query = identityService.createUserQuery().userEmailLike("%invalid%"); verifyQueryResults(query, 0); try { identityService.createUserQuery().userEmailLike(null).singleResult(); fail(); } catch (ProcessEngineException e) { } }
Example #24
Source File: MultiTenancyProcessInstanceCmdsTenantCheckTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test public void modifyProcessInstanceWithNoAuthenticatedTenant() { engineRule.getIdentityService().setAuthentication("aUserId", null); thrown.expect(ProcessEngineException.class); thrown.expectMessage("Cannot update the process instance '" + processInstanceId +"' because it belongs to no authenticated tenant."); // when engineRule.getRuntimeService() .createProcessInstanceModification(processInstanceId) .cancelAllForActivity("task") .execute(); }
Example #25
Source File: ModificationExecutionAsyncTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test public void testNullProcessInstanceQueryAsync() { try { runtimeService.createModification("processDefinitionId").startAfterActivity("user1").processInstanceQuery(null).executeAsync(); fail("Should not succeed"); } catch (ProcessEngineException e) { assertThat(e.getMessage(), containsString("Process instance ids is empty")); } }
Example #26
Source File: TaskQueryImpl.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Override public TaskQuery withoutCandidateUsers() { if (isOrQueryActive) { throw new ProcessEngineException("Invalid query usage: cannot set withoutCandidateUsers() within 'or' query"); } this.withoutCandidateUsers = true; return this; }
Example #27
Source File: JobDefinitionQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Deployment(resources = {"org/camunda/bpm/engine/test/api/mgmt/JobDefinitionQueryTest.testBase.bpmn"}) public void testQueryByInvalidJobType() { JobDefinitionQuery query = managementService.createJobDefinitionQuery().jobType("invalid"); verifyQueryResults(query, 0); try { managementService.createJobDefinitionQuery().jobType(null); fail("A ProcessEngineExcpetion was expected."); } catch (ProcessEngineException e) {} }
Example #28
Source File: EnginePersistenceLogger.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public ProcessEngineException requiredAsyncContinuationException(String id) { return new ProcessEngineException(exceptionMessage( "033", "Asynchronous Continuation for activity with id '{}' requires a message job declaration", id )); }
Example #29
Source File: TaskRestServiceInteractionTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test public void testUnsuccessfulUnclaimTask() { doThrow(new ProcessEngineException("expected exception")).when(taskServiceMock).setAssignee(any(String.class), any(String.class)); given().pathParam("id", EXAMPLE_TASK_ID) .header("accept", MediaType.APPLICATION_JSON) .then().expect() .statusCode(Status.INTERNAL_SERVER_ERROR.getStatusCode()).contentType(ContentType.JSON) .body("type", equalTo(ProcessEngineException.class.getSimpleName())) .body("message", equalTo("expected exception")) .when().post(UNCLAIM_TASK_URL); }
Example #30
Source File: HistoricTaskInstanceQueryImpl.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public HistoricTaskInstanceQueryImpl orderByHistoricTaskInstanceDuration() { if (isOrQueryActive) { throw new ProcessEngineException("Invalid query usage: cannot set orderByHistoricTaskInstanceDuration() within 'or' query"); } orderBy(HistoricTaskInstanceQueryProperty.DURATION); return this; }