From bf9da0e1b954468e059ccca11971a52c0e7ce480 Mon Sep 17 00:00:00 2001 From: dmgcodevil Date: Sat, 28 Mar 2015 09:23:35 +0300 Subject: [PATCH] #733: added tests for async generic method --- .../javanica/annotation/HystrixCollapser.java | 2 +- .../test/spring/command/CommandTest.java | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/hystrix-contrib/hystrix-javanica/src/main/java/com/netflix/hystrix/contrib/javanica/annotation/HystrixCollapser.java b/hystrix-contrib/hystrix-javanica/src/main/java/com/netflix/hystrix/contrib/javanica/annotation/HystrixCollapser.java index 3e8b952db..21b4da2a7 100644 --- a/hystrix-contrib/hystrix-javanica/src/main/java/com/netflix/hystrix/contrib/javanica/annotation/HystrixCollapser.java +++ b/hystrix-contrib/hystrix-javanica/src/main/java/com/netflix/hystrix/contrib/javanica/annotation/HystrixCollapser.java @@ -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: *
diff --git a/hystrix-contrib/hystrix-javanica/src/test/java/com/netflix/hystrix/contrib/javanica/test/spring/command/CommandTest.java b/hystrix-contrib/hystrix-javanica/src/test/java/com/netflix/hystrix/contrib/javanica/test/spring/command/CommandTest.java
index 2497cb0a2..750e95040 100644
--- a/hystrix-contrib/hystrix-javanica/src/test/java/com/netflix/hystrix/contrib/javanica/test/spring/command/CommandTest.java
+++ b/hystrix-contrib/hystrix-javanica/src/test/java/com/netflix/hystrix/contrib/javanica/test/spring/command/CommandTest.java
@@ -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());
@@ -138,6 +147,16 @@ public  T echo(T value) {
             return value;
         }
 
+        @HystrixCommand
+        public  Future echoAsync(final T value) {
+            return new AsyncResult() {
+                @Override
+                public T invoke() {
+                    return value;
+                }
+            };
+        }
+
     }
 
     public static class AdvancedUserService extends UserService {