Search in sources :

Example 11 with Deployment

use of org.activiti.engine.test.Deployment in project Activiti by Activiti.

the class EmptyProcessTest method testRunProcessWithHeader.

@Deployment(resources = { "process/empty.bpmn20.xml" })
public void testRunProcessWithHeader() throws Exception {
    CamelContext ctx = applicationContext.getBean(CamelContext.class);
    ProducerTemplate tpl = camelContext.createProducerTemplate();
    String body = "body text";
    Exchange exchange = ctx.getEndpoint("direct:startEmptyWithHeader").createExchange();
    exchange.getIn().setBody(body);
    tpl.send("direct:startEmptyWithHeader", exchange);
    String instanceId = (String) exchange.getProperty("PROCESS_ID_PROPERTY");
    assertProcessEnded(instanceId);
    HistoricVariableInstance var = processEngine.getHistoryService().createHistoricVariableInstanceQuery().variableName("camelBody").singleResult();
    assertNotNull(var);
    assertEquals(body, var.getValue());
    var = processEngine.getHistoryService().createHistoricVariableInstanceQuery().variableName("MyVar").singleResult();
    assertNotNull(var);
    assertEquals("Foo", var.getValue());
}
Also used : CamelContext(org.apache.camel.CamelContext) Exchange(org.apache.camel.Exchange) ProducerTemplate(org.apache.camel.ProducerTemplate) HistoricVariableInstance(org.activiti.engine.history.HistoricVariableInstance) Deployment(org.activiti.engine.test.Deployment)

Example 12 with Deployment

use of org.activiti.engine.test.Deployment in project Activiti by Activiti.

the class EmptyProcessTest method testObjectAsVariable.

@Deployment(resources = { "process/empty.bpmn20.xml" })
public void testObjectAsVariable() throws Exception {
    CamelContext ctx = applicationContext.getBean(CamelContext.class);
    ProducerTemplate tpl = ctx.createProducerTemplate();
    Object expectedObj = new Long(99);
    Exchange exchange = ctx.getEndpoint("direct:startEmpty").createExchange();
    exchange.getIn().setBody(expectedObj);
    tpl.send("direct:startEmpty", exchange);
    String instanceId = (String) exchange.getProperty("PROCESS_ID_PROPERTY");
    assertProcessEnded(instanceId);
    HistoricVariableInstance var = processEngine.getHistoryService().createHistoricVariableInstanceQuery().variableName("camelBody").singleResult();
    assertNotNull(var);
    assertEquals(expectedObj, var.getValue());
}
Also used : CamelContext(org.apache.camel.CamelContext) Exchange(org.apache.camel.Exchange) ProducerTemplate(org.apache.camel.ProducerTemplate) HistoricVariableInstance(org.activiti.engine.history.HistoricVariableInstance) Deployment(org.activiti.engine.test.Deployment)

Example 13 with Deployment

use of org.activiti.engine.test.Deployment in project Activiti by Activiti.

the class ErrorHandlingTest method testCamelRouteWorksAsIntended.

/**
	 * Process instance should be removed after completion. Works as intended, 
	 * if no exception interrupts the Camel route. 
	 * 
	 * @throws Exception
	 */
@Deployment(resources = { "process/errorHandling.bpmn20.xml" })
public void testCamelRouteWorksAsIntended() throws Exception {
    Map<String, Object> variables = new HashMap<String, Object>();
    variables.put("routing", Routing.DEFAULT);
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("ErrorHandling", variables);
    Job job = managementService.createJobQuery().processInstanceId(processInstance.getId()).singleResult();
    assertNotNull(job);
    managementService.executeJob(job.getId());
    Thread.sleep(WAIT);
    assertEquals("Process instance not completed", 0, runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.getId()).count());
}
Also used : HashMap(java.util.HashMap) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) Job(org.activiti.engine.runtime.Job) Deployment(org.activiti.engine.test.Deployment)

Example 14 with Deployment

use of org.activiti.engine.test.Deployment in project Activiti by Activiti.

the class ErrorHandlingTest method testRollbackOnException.

/**
	 * Expected behavior, with  default error handling in Camel: 
	 * Roll-back to previous wait state. Fails with Activiti 5.12.
	 * 
	 * @throws Exception
	 */
@Deployment(resources = { "process/errorHandling.bpmn20.xml" })
public void testRollbackOnException() throws Exception {
    Map<String, Object> variables = new HashMap<String, Object>();
    variables.put("routing", Routing.PROVOKE_ERROR);
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("ErrorHandling", variables);
    assertEquals("No roll-back to previous wait state", 1, runtimeService.createExecutionQuery().processInstanceId(processInstance.getId()).activityId(PREVIOUS_WAIT_STATE).count());
    assertEquals("Process instance advanced to next wait state", 0, runtimeService.createExecutionQuery().processInstanceId(processInstance.getId()).activityId(NEXT_WAIT_STATE).count());
}
Also used : HashMap(java.util.HashMap) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) Deployment(org.activiti.engine.test.Deployment)

Example 15 with Deployment

use of org.activiti.engine.test.Deployment in project Activiti by Activiti.

the class ErrorMapExceptionTest method testCamelParentMap.

@Deployment(resources = { "process/mapExceptionParentMap.bpmn20.xml" })
public void testCamelParentMap() throws Exception {
    camelContext.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from("activiti:mapExceptionParentProcess:exceptionRoute").throwException(new MapExceptionChild("test exception"));
        }
    });
    FlagJavaDelegate.reset();
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("mapExceptionParentProcess");
    assertTrue(FlagJavaDelegate.isFlagSet());
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) Deployment(org.activiti.engine.test.Deployment)

Aggregations

Deployment (org.activiti.engine.test.Deployment)1020 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)709 Task (org.activiti.engine.task.Task)469 HashMap (java.util.HashMap)267 HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)180 Execution (org.activiti.engine.runtime.Execution)106 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)87 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)84 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)83 Date (java.util.Date)82 Job (org.activiti.engine.runtime.Job)76 JsonNode (com.fasterxml.jackson.databind.JsonNode)66 Calendar (java.util.Calendar)54 StringEntity (org.apache.http.entity.StringEntity)50 HttpGet (org.apache.http.client.methods.HttpGet)49 ActivitiException (org.activiti.engine.ActivitiException)46 DelegateTask (org.activiti.engine.delegate.DelegateTask)40 ArrayList (java.util.ArrayList)39 HistoricActivityInstance (org.activiti.engine.history.HistoricActivityInstance)30 TaskQuery (org.activiti.engine.task.TaskQuery)29