View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.module.jbpm;
8   
9   import org.mule.api.MuleMessage;
10  import org.mule.api.client.MuleClient;
11  import org.mule.module.bpm.BPMS;
12  import org.mule.module.bpm.Process;
13  import org.mule.tck.junit4.FunctionalTestCase;
14  
15  import java.util.HashMap;
16  import java.util.Map;
17  
18  import org.junit.Test;
19  
20  import static org.junit.Assert.assertEquals;
21  import static org.junit.Assert.assertFalse;
22  import static org.junit.Assert.assertNotNull;
23  import static org.junit.Assert.assertTrue;
24  
25  /**
26   * Tests jBPM component with a simple process.
27   */
28  public class SimpleJbpmComponentTestCase extends FunctionalTestCase
29  {
30  
31      @Override
32      protected String getConfigResources()
33      {
34          return "jbpm-component-functional-test.xml";
35      }
36  
37      @Test
38      public void testSimpleProcess() throws Exception 
39      {
40          MuleClient client = muleContext.getClient();
41          BPMS bpms = muleContext.getRegistry().lookupObject(BPMS.class);
42          assertNotNull(bpms);
43  
44          // Create a new process.
45          MuleMessage response = client.send("vm://simple", "data", null);
46          Object process = response.getPayload();
47  
48          String processId = (String)bpms.getId(process);
49          // The process should be started and in a wait state.
50          assertFalse(processId == null);
51          assertEquals("dummyState", bpms.getState(process));
52  
53          // Advance the process one step.
54          Map props = new HashMap();
55          props.put(Process.PROPERTY_PROCESS_ID, processId);
56          response = client.send("vm://simple", null, props);
57          process = response.getPayload();
58  
59          // The process should have ended.
60          assertTrue(bpms.hasEnded(process));
61      }
62  
63  }