mercredi 27 mai 2015

Unit testing Amazon SWF child workflows

I have a parent workflow (BWorkflow) calling a child workflow (AWorkflow) and I'm trying to test out the call.

The parent code looks something like this:

private final AWorkflowClientFactory aWorkflowClientFactory =
        new AWorkflowClientFactoryImpl();

...
new TryCatch() {
    @Override
    protected void doTry() throws Throwable {
        Promise<Void> workflowFinished = aWorkflowClient.aWorkflow(x);
        ...
    }
...

I want to mock out the aWorkflowClient.aWorkflow(x) call, however when I am hooking up the unit test I don't appear to have the option to inject the client factory, the unit test code looks like this:

@Rule
public WorkflowTest workflowTest = new WorkflowTest();
@Mock
private Activities mockActivities;

private BWorkflowClientFactory workflowFactory
        = new BWorkflowClientFactoryImpl();

@Before
public void setUp() throws Exception {
    // set up mocks
    initMocks(this);

    workflowTest.addActivitiesImplementation(mockActivities);
    workflowTest.addWorkflowImplementationType(BWorkflowImpl.class);
    workflowTest.addWorkflowImplementationType(AWorkflowImpl.class);

I don't appear to be able to pass anything into the workflow implementation classes, is there another way I can mock the child workflow out?

Aucun commentaire:

Enregistrer un commentaire