Petals-SE-Flowable 1.5.0+

compared with
Key
This line was removed.
This word was removed. This word was added.
This line was added.

Changes (15)

View Page History
import static org.ow2.petals.flowable.junit.Assert.assertWsdlCompliance;
import javax.xml.namespace.QName;
import org.junit.jupiter.api.Test;

public class ValidateTest {
import static org.ow2.petals.flowable.junit.Assert.assertXslTransformation;
import ...
import org.junit.jupiter.api.Test;

public class XslTest {
h2. Unit-testing your process definition

Flowable provides a JUnit framework to write unit tests about business processes. You can find several articles on this subject on Internet, for example [here|http://docs.alfresco.com/activiti/topics/apiUnitTesting.html]. [here|https://www.flowable.com/open-source/docs/bpmn/ch04-API#unit-testing].
We don't discuss how to use the Flowable JUnit framework but how to integrate it into a service unit project.

We provided a JUnit framework inherited from the Flowable one that add several utility methods to simplify checks about our process. These methods are available as member methods of {{PetalsFlowableRule}}:
We provided a JUnit framework inherited from the Flowable one that add several utility methods to simplify interactions with your process. These methods are available as static methods of classes of package {{org.ow2.petals.flowable.utils.test}}:
* awaiting methods ({{wait...}}) as '{{waitEndOfProcessInstance}}' to wait the end of a process instance, from class {{org.ow2.petals.flowable.utils.test.Await}},
* assertion methods ({{assert...}}) as '{{assertProcessInstanceFinished}}' to check that your process instance is ended, from class {{org.ow2.petals.flowable.utils.test.Assert}},
See the class {{PetalsFlowableRule}} to get the list of methods.
* assertion methods ({{signal...}}) as '{{signalIntermediateCatchMessageEvent}}' to send an event to an intermediate event message catcher, from class {{org.ow2.petals.flowable.utils.test.Signal}}.

First, you must embedd an Flowable engine for your test, adding an dependency on it with scope {{test}} into your POM file. Don't forget to add also the JDBC driver, H2 for example, and the Petals JUnit Flowable framework:
<groupId>org.ow2.petals</groupId>
<artifactId>petals-se-flowable-junit</artifactId>
<version>1.05.0</version>
<scope>test</scope>
</dependency>
So, with this, you will be able to test the deployment of your process definition and check process instance creations using the Petals Flowable JUnit framework:
{code:java}
@PetalsFlowableTest
public class ProcessDeploymentTest {

@Rule
public final PetalsFlowableRule flowableRule = new PetalsFlowableRule();

@Test
@Deployment(resources = {"jbi/vacationRequest.bpmn20.xml"})
public void theProcessIsDeployableAndInstanciable(final ProcessEngine processEngine) {
final ProcessDefinition processDefinition = this.flowableRule.getRepositoryService() processEngine.getRepositoryService()
.createProcessDefinitionQuery().processDefinitionKey("vacationRequest").singleResult();
assertNotNull(processDefinition);
variables.put("startDate", new Date());
variables.put("vacationMotivation", "Vacations");
final ProcessInstance processInstance = this.flowableRule.getRuntimeService().startProcessInstanceByKey("vacationRequest", processEngine.getRuntimeService().startProcessInstanceByKey("vacationRequest", variables);
assertNotNull(processInstance);
}