-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #348 from sawano/1.3.x
1.3.x Allow for @HystrixCommand to be used on parameterized return type
- Loading branch information
Showing
3 changed files
with
111 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
...avanica/src/test/java/com/netflix/hystrix/contrib/javanica/command/ExecutionTypeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package com.netflix.hystrix.contrib.javanica.command; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.Parameterized; | ||
import rx.Observable; | ||
import rx.internal.operators.OperatorMulticast; | ||
|
||
import java.util.List; | ||
import java.util.concurrent.Future; | ||
import java.util.concurrent.RunnableFuture; | ||
|
||
import static com.netflix.hystrix.contrib.javanica.command.ExecutionType.ASYNCHRONOUS; | ||
import static com.netflix.hystrix.contrib.javanica.command.ExecutionType.OBSERVABLE; | ||
import static com.netflix.hystrix.contrib.javanica.command.ExecutionType.SYNCHRONOUS; | ||
import static java.util.Arrays.asList; | ||
import static org.junit.Assert.assertEquals; | ||
|
||
@RunWith(Parameterized.class) | ||
public class ExecutionTypeTest { | ||
|
||
@Parameterized.Parameters | ||
public static List<Object[]> data() { | ||
return asList(new Object[][]{ | ||
{returnType(Integer.class), shouldHaveExecutionType(SYNCHRONOUS)}, | ||
{returnType(List.class), shouldHaveExecutionType(SYNCHRONOUS)}, | ||
{returnType(Object.class), shouldHaveExecutionType(SYNCHRONOUS)}, | ||
{returnType(Class.class), shouldHaveExecutionType(SYNCHRONOUS)}, | ||
{returnType(Future.class), shouldHaveExecutionType(ASYNCHRONOUS)}, | ||
{returnType(AsyncResult.class), shouldHaveExecutionType(ASYNCHRONOUS)}, | ||
{returnType(RunnableFuture.class), shouldHaveExecutionType(ASYNCHRONOUS)}, | ||
{returnType(Observable.class), shouldHaveExecutionType(OBSERVABLE)}, | ||
{returnType(OperatorMulticast.class), shouldHaveExecutionType(OBSERVABLE)}, | ||
}); | ||
} | ||
|
||
@Test | ||
public void should_return_correct_execution_type() throws Exception { | ||
assertEquals("Unexpected execution type for method return type: " + methodReturnType, expectedType, ExecutionType.getExecutionType(methodReturnType)); | ||
|
||
} | ||
|
||
private static ExecutionType shouldHaveExecutionType(final ExecutionType type) { | ||
return type; | ||
} | ||
|
||
private static Class<?> returnType(final Class<?> aClass) { | ||
return aClass; | ||
} | ||
|
||
private final Class<?> methodReturnType; | ||
private final ExecutionType expectedType; | ||
|
||
public ExecutionTypeTest(final Class<?> methodReturnType, final ExecutionType expectedType) { | ||
this.methodReturnType = methodReturnType; | ||
this.expectedType = expectedType; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters