Netflix / glisten

Ease of use Groovy library for building JVM applications with Amazon Simple Workflow (SWF)
Apache License 2.0
67 stars 31 forks source link

void activity methods never complete in unit tests #28

Open robfletcher opened 10 years ago

robfletcher commented 10 years ago

If I have an activity method declared as void there seems to be no way to make its promise complete in a unit test.

For example if I have a test like:

when: workflow.start()
then: 1 * activities.step1()
then: 1 * activities.step2()

That is testing:

void start() {
  waitFor(activities.step1()) {
    activities.step2()
  }
}

Then activities.step2() is never called in the unit test. If I simply change the method definition to return any type – say boolean – and make the mock expectation return something using >> true then both activity methods do get executed.

Maybe I'm misunderstanding how this is supposed to work.

claymccoy commented 10 years ago

That is exactly right. Currently, if you want to wait on an activity, it needs to return something. Flow, handles this by generating method signatures that return Promise. Glisten doesn't generate alternate signatures. We could fix this with some AST transformations, but providing return types has worked so far.

robfletcher commented 10 years ago

ok, I was hoping it would pick up Promise<Void> but it's not a big deal for me to return something.