return null;
}
}).once();
final Props intermediateReturnProps = new Props();
intermediateReturnProps.put("some","value1--");
intermediateReturnProps.put("other", "value2--");
EasyMock.expect(dependeeFlow.getReturnProps()).andReturn(intermediateReturnProps).times(2);
final Capture<FlowCallback> dependerCallback = new Capture<FlowCallback>();
final Capture<Props> intermediatePropsCap = new Capture<Props>();
dependerFlow.execute(EasyMock.capture(intermediatePropsCap), EasyMock.capture(dependerCallback));
EasyMock.expectLastCall().andAnswer(new IAnswer<Object>()
{
@Override
public Object answer() throws Throwable
{
Assert.assertTrue("Dependee must run before depender", dependeeRan.get());
Assert.assertEquals(Status.RUNNING, flow.getStatus());
dependerCallback.getValue().completed(Status.SUCCEEDED);
return null;
}
}).once();
EasyMock.expect(dependerFlow.getExceptions()).andReturn(emptyExceptions).times(1);
EasyMock.reset(props);
EasyMock.expect(props.equalsProps(props)).andReturn(true).once();
EasyMock.replay(dependerFlow, dependeeFlow, props);
Assert.assertEquals(Status.READY, flow.getStatus());
AtomicBoolean callbackRan = new AtomicBoolean(false);
flow.execute(
props,
new OneCallFlowCallback(callbackRan) {
@Override
protected void theCallback(Status status)
{
Assert.assertEquals(Status.SUCCEEDED, status);
}
});
Assert.assertTrue("Internal flow executes never ran.", dependeeRan.get());
Assert.assertTrue("Callback didn't run.", callbackRan.get());
Assert.assertEquals(Status.SUCCEEDED, flow.getStatus());
Assert.assertEquals(emptyExceptions, flow.getExceptions());
Assert.assertEquals(props, flow.getParentProps());
final Props intProps = intermediatePropsCap.getValue().local();
Assert.assertTrue(intProps != null);
Assert.assertEquals(2, intProps.size());
Assert.assertEquals("value1--", intProps.get("some"));
Assert.assertEquals("value2--", intProps.get("other"));
callbackRan = new AtomicBoolean(false);
flow.execute(
props,
new OneCallFlowCallback(callbackRan) {
@Override
protected void theCallback(Status status)
{
Assert.assertEquals(Status.SUCCEEDED, status);
}
});
Assert.assertTrue("Callback didn't run.", callbackRan.get());
Assert.assertEquals(Status.SUCCEEDED, flow.getStatus());
Assert.assertEquals(emptyExceptions, flow.getExceptions());
EasyMock.verify(props, dependerFlow);
EasyMock.reset(props, dependerFlow);
final Props someProps = new Props();
someProps.put("some", "yay");
someProps.put("something", "you");
EasyMock.expect(dependerFlow.getReturnProps()).andReturn(someProps).times(1);
EasyMock.expect(props.equalsProps(props)).andReturn(false).once();
EasyMock.replay(props, dependerFlow);
final Props retProps = flow.getReturnProps();
final Props expectedProps = new Props();
expectedProps.put("some", "yay");
expectedProps.put("something", "you");
expectedProps.put("other", "value2--");
Assert.assertTrue(
String.format("Return props should be the combination of all sub-flow return props[%s]. Was[%s]", expectedProps, retProps),
retProps.equalsProps(expectedProps)
);