I have implement a Simple JavaDelegate as a Task of my BPMN-Process:
public class CleanupVariables implements JavaDelegate {
@Override
public void execute(DelegateExecution execution) throws Exception {
String printJobId = execution.getVariable("VIP-Variable").toString();
// remove all variables
execution.removeVariables();
// set variable
execution.setVariable("VIP-Variable", printJobId);
}
}
Now I want to write a Unit-Test.
@Test
public void testRemove() throws Exception {
// Arrange
CleanupVariables cleanupVariables = new CleanupVariables();
testdelegate.setVariable("VIP-Variable", "12345");
testdelegate.setVariable("foo", "bar");
// Act
cleanupVariables.execute(????); // FIXME what to insert here?
// Assert
Assertions.assertThat(testdelegate.getVariables().size()).isEqualTo(1);
Assertions.assertThat(testdelegate.getVariable("VIP-Variable")).isEqualTo("12345");
}
I could not figure out how to insert some implementation of DelegateExecution in my act-step.
Is there any dummy-impl to use right here? How to test this as simple as possible?
I will not start a processinstance for testing this code. Google didn't come up with some usefull stuff.