Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple way to unit test classes whose collaborators return promises #491

Closed
tomdcc opened this issue Nov 14, 2014 · 1 comment
Closed

Simple way to unit test classes whose collaborators return promises #491

tomdcc opened this issue Nov 14, 2014 · 1 comment
Assignees

Comments

@tomdcc
Copy link
Contributor

tomdcc commented Nov 14, 2014

Handlers calling collaborator classes who return promises need those promises to have been created using the same ExecController that the handler is run with. This is a bit of a pain when running with UnitTest.handle.

FWIW for my purposes it was enough to write a utility method to grab it from the stored threadlocal:

static <T> Promise<T> instaPromise(T val) {
    ExecController.current().get().control.promise { f -> f.success(val) }
}
@ldaley ldaley added this to the release-0.9.17 milestone May 30, 2015
@ldaley ldaley self-assigned this May 30, 2015
@ldaley
Copy link
Member

ldaley commented May 30, 2015

This was effectively solved by the new ExecController.execController() method which lazily binds to the exec controller.

So, you can now do ExecController.execController().promiseOf(val). I think we can sweeten this even more by some static methods on Promise, but that can be a separate thing.

@ldaley ldaley closed this as completed May 30, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants