Skip to content

Commit

Permalink
Netflix#733: added tests for async generic method
Browse files Browse the repository at this point in the history
  • Loading branch information
dmgcodevil committed Mar 28, 2015
1 parent 533661c commit bf9da0e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
*
* A method annotated with {@link HystrixCollapser} annotation can return any
* value with compatible type, it does not affect the result of collapser execution,
* collapser method can even return {@code null} or another stab.
* collapser method can even return {@code null} or another stub.
* Pay attention that if a collapser method returns parametrized Future then generic type must be equal to generic type of List,
* for instance:
* <pre>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,15 @@ public void should_work_with_parameterized_method() throws Exception {
assertTrue(getCommand().getExecutionEvents().contains(HystrixEventType.SUCCESS));
}

@Test
public void should_work_with_parameterized_asyncMethod() throws Exception {
assertEquals(Integer.valueOf(1), userService.echoAsync(1).get());

assertEquals(1, HystrixRequestLog.getCurrentRequest().getAllExecutedCommands().size());
assertTrue(getCommand().getExecutionEvents().contains(HystrixEventType.SUCCESS));
}


private void assertGetUserSnycCommandExecuted(User u1) {
assertEquals("name: 1", u1.getName());
assertEquals(1, HystrixRequestLog.getCurrentRequest().getAllExecutedCommands().size());
Expand Down Expand Up @@ -138,6 +147,16 @@ public <T> T echo(T value) {
return value;
}

@HystrixCommand
public <T> Future<T> echoAsync(final T value) {
return new AsyncResult<T>() {
@Override
public T invoke() {
return value;
}
};
}

}

public static class AdvancedUserService extends UserService {
Expand Down

0 comments on commit bf9da0e

Please sign in to comment.