Search in sources :

Example 1 with Deployment

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

the class BusinessProcessBeanTest method testResolveTaskBean.

@Test
@Deployment(resources = "org/activiti/cdi/test/api/BusinessProcessBeanTest.test.bpmn20.xml")
public void testResolveTaskBean() {
    BusinessProcess businessProcess = getBeanInstance(BusinessProcess.class);
    assertNull(getBeanInstance(Task.class));
    assertNull(getBeanInstance("taskId"));
    businessProcess.startProcessByKey("businessProcessBeanTest");
    String taskId = taskService.createTaskQuery().singleResult().getId();
    businessProcess.startTask(taskId);
    // assert that now we can resolve the Task-bean
    assertEquals(taskId, getBeanInstance(Task.class).getId());
    assertEquals(taskId, getBeanInstance("taskId"));
    taskService.complete(taskService.createTaskQuery().singleResult().getId());
}
Also used : Task(org.activiti.engine.task.Task) BusinessProcess(org.activiti.cdi.BusinessProcess) Test(org.junit.Test) Deployment(org.activiti.engine.test.Deployment)

Example 2 with Deployment

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

the class BusinessProcessBeanTest method testProcessWithoutWaitState.

@Test
@Deployment
public void testProcessWithoutWaitState() {
    BusinessProcess businessProcess = getBeanInstance(BusinessProcess.class);
    // start the process
    businessProcess.startProcessByKey("businessProcessBeanTest").getId();
    // assert that the process is ended:
    assertNull(processEngine.getRuntimeService().createProcessInstanceQuery().singleResult());
}
Also used : BusinessProcess(org.activiti.cdi.BusinessProcess) Test(org.junit.Test) Deployment(org.activiti.engine.test.Deployment)

Example 3 with Deployment

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

the class InitiatorCamelCallTest method testInitiatorCamelCall.

@Deployment
public void testInitiatorCamelCall() throws Exception {
    CamelContext ctx = applicationContext.getBean(CamelContext.class);
    ProducerTemplate tpl = ctx.createProducerTemplate();
    String body = "body text";
    Exchange exchange = ctx.getEndpoint("direct:startWithInitiatorHeader").createExchange();
    exchange.getIn().setBody(body);
    tpl.send("direct:startWithInitiatorHeader", exchange);
    String instanceId = (String) exchange.getProperty("PROCESS_ID_PROPERTY");
    String initiator = (String) runtimeService.getVariable(instanceId, "initiator");
    assertEquals("kermit", initiator);
    Object camelInitiatorHeader = runtimeService.getVariable(instanceId, "CamelProcessInitiatorHeader");
    assertNull(camelInitiatorHeader);
}
Also used : CamelContext(org.apache.camel.CamelContext) Exchange(org.apache.camel.Exchange) ProducerTemplate(org.apache.camel.ProducerTemplate) Deployment(org.activiti.engine.test.Deployment)

Example 4 with Deployment

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

the class MultiInstanceTest method testRunProcess.

@Deployment(resources = { "process/multiinstanceReceive.bpmn20.xml" })
public void testRunProcess() throws Exception {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("miProcessExample");
    List<Job> jobList = managementService.createJobQuery().list();
    assertEquals(5, jobList.size());
    assertEquals(5, runtimeService.createExecutionQuery().processInstanceId(processInstance.getId()).activityId("serviceTask1").count());
    waitForJobExecutorToProcessAllJobs(3000, 500);
    int counter = 0;
    long processInstanceCount = 1;
    while (processInstanceCount == 1 && counter < 20) {
        Thread.sleep(500);
        processInstanceCount = runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.getId()).count();
        counter++;
    }
    assertEquals(0, runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.getId()).count());
}
Also used : ProcessInstance(org.activiti.engine.runtime.ProcessInstance) Job(org.activiti.engine.runtime.Job) Deployment(org.activiti.engine.test.Deployment)

Example 5 with Deployment

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

the class CamelExceptionTest method testHappyPathAsynchronous.

// check happy path in asynchronous camel call
@Deployment(resources = { "org/activiti/camel/exception/bpmnExceptionInRouteAsynchronous.bpmn20.xml" })
public void testHappyPathAsynchronous() {
    // Signal ThrowBpmnExceptionBean to throw no exception
    ThrowBpmnExceptionBean.setExceptionType(ThrowBpmnExceptionBean.ExceptionType.NO_EXCEPTION);
    runtimeService.startProcessInstanceByKey("exceptionInRouteSynchron");
    Job job = managementService.createJobQuery().singleResult();
    managementService.executeJob(job.getId());
    assertFalse(JobTestHelper.areJobsAvailable(managementService));
    assertFalse(ExceptionServiceMock.isCalled());
    assertTrue(NoExceptionServiceMock.isCalled());
}
Also used : Job(org.activiti.engine.runtime.Job) Deployment(org.activiti.engine.test.Deployment)

Aggregations

Deployment (org.activiti.engine.test.Deployment)1178 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)846 Task (org.activiti.engine.task.Task)549 HashMap (java.util.HashMap)277 HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)218 Execution (org.activiti.engine.runtime.Execution)151 Date (java.util.Date)94 Job (org.activiti.engine.runtime.Job)91 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)87 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)87 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)85 JsonNode (com.fasterxml.jackson.databind.JsonNode)66 Calendar (java.util.Calendar)63 DelegateTask (org.activiti.engine.delegate.DelegateTask)52 StringEntity (org.apache.http.entity.StringEntity)50 ArrayList (java.util.ArrayList)49 HttpGet (org.apache.http.client.methods.HttpGet)49 HistoricActivityInstance (org.activiti.engine.history.HistoricActivityInstance)41 HistoricTaskInstance (org.activiti.engine.history.HistoricTaskInstance)34 ActivitiException (org.activiti.engine.ActivitiException)31