use of com.netflix.hystrix.contrib.javanica.test.common.domain.User in project Hystrix by Netflix.
the class BasicObservableTest method testGetUserWithRxCommandFallback.
@Test
public void testGetUserWithRxCommandFallback() {
final User exUser = new User("def", "def");
// blocking
Observable<User> userObservable = userService.getUserRxCommandFallback(" ", "");
assertEquals(exUser, userObservable.toBlocking().single());
assertEquals(2, HystrixRequestLog.getCurrentRequest().getAllExecutedCommands().size());
com.netflix.hystrix.HystrixInvokableInfo getUserRxCommandFallback = getHystrixCommandByKey("getUserRxCommandFallback");
com.netflix.hystrix.HystrixInvokableInfo rxCommandFallback = getHystrixCommandByKey("rxCommandFallback");
// confirm that command has failed
assertTrue(getUserRxCommandFallback.getExecutionEvents().contains(HystrixEventType.FAILURE));
assertTrue(getUserRxCommandFallback.getExecutionEvents().contains(HystrixEventType.FALLBACK_SUCCESS));
// and that fallback command was successful
assertTrue(rxCommandFallback.getExecutionEvents().contains(HystrixEventType.SUCCESS));
}
use of com.netflix.hystrix.contrib.javanica.test.common.domain.User in project Hystrix by Netflix.
the class BasicCollapserTest method testGetUserByIdWithFallbackWithThrowableParam.
@Test
public void testGetUserByIdWithFallbackWithThrowableParam() throws ExecutionException, InterruptedException {
Future<User> f1 = userService.getUserByIdWithFallbackWithThrowableParam("1");
Future<User> f2 = userService.getUserByIdWithFallbackWithThrowableParam("2");
Future<User> f3 = userService.getUserByIdWithFallbackWithThrowableParam("3");
Future<User> f4 = userService.getUserByIdWithFallbackWithThrowableParam("4");
Future<User> f5 = userService.getUserByIdWithFallbackWithThrowableParam("5");
assertEquals("name: 1", f1.get().getName());
assertEquals("name: 2", f2.get().getName());
assertEquals("name: 3", f3.get().getName());
assertEquals("name: 4", f4.get().getName());
assertEquals("name: 5", f5.get().getName());
// 4 commands should be executed
assertEquals(4, HystrixRequestLog.getCurrentRequest().getAllExecutedCommands().size());
HystrixInvokableInfo<?> batchCommand = getHystrixCommandByKey("getUserByIdsThrowsException");
com.netflix.hystrix.HystrixInvokableInfo fallback1 = getHystrixCommandByKey("getUserByIdsFallbackWithThrowableParam1");
com.netflix.hystrix.HystrixInvokableInfo fallback2 = getHystrixCommandByKey("getUserByIdsFallbackWithThrowableParam2");
com.netflix.hystrix.HystrixInvokableInfo fallback3 = getHystrixCommandByKey("getUserByIdsFallbackWithThrowableParam3");
// confirm that command has failed
assertTrue(batchCommand.getExecutionEvents().contains(HystrixEventType.FAILURE));
assertTrue(fallback1.getExecutionEvents().contains(HystrixEventType.FAILURE));
assertTrue(fallback2.getExecutionEvents().contains(HystrixEventType.FAILURE));
assertTrue(fallback2.getExecutionEvents().contains(HystrixEventType.FALLBACK_SUCCESS));
// and that last fallback3 was successful
assertTrue(fallback3.getExecutionEvents().contains(HystrixEventType.SUCCESS));
}
use of com.netflix.hystrix.contrib.javanica.test.common.domain.User in project Hystrix by Netflix.
the class BasicCollapserTest method testGetUserByIdWithFallback.
@Test
public void testGetUserByIdWithFallback() throws ExecutionException, InterruptedException {
Future<User> f1 = userService.getUserByIdWithFallback("1");
Future<User> f2 = userService.getUserByIdWithFallback("2");
Future<User> f3 = userService.getUserByIdWithFallback("3");
Future<User> f4 = userService.getUserByIdWithFallback("4");
Future<User> f5 = userService.getUserByIdWithFallback("5");
assertEquals("name: 1", f1.get().getName());
assertEquals("name: 2", f2.get().getName());
assertEquals("name: 3", f3.get().getName());
assertEquals("name: 4", f4.get().getName());
assertEquals("name: 5", f5.get().getName());
// two command should be executed: "getUserByIdWithFallback" and "getUserByIdsWithFallback"
assertEquals(2, HystrixRequestLog.getCurrentRequest().getAllExecutedCommands().size());
HystrixInvokableInfo<?> getUserByIdsWithFallback = getHystrixCommandByKey("getUserByIdsWithFallback");
com.netflix.hystrix.HystrixInvokableInfo getUserByIdsFallback = getHystrixCommandByKey("getUserByIdsFallback");
// confirm that command has failed
assertTrue(getUserByIdsWithFallback.getExecutionEvents().contains(HystrixEventType.FAILURE));
assertTrue(getUserByIdsWithFallback.getExecutionEvents().contains(HystrixEventType.FALLBACK_SUCCESS));
// and that fallback was successful
assertTrue(getUserByIdsFallback.getExecutionEvents().contains(HystrixEventType.SUCCESS));
}
use of com.netflix.hystrix.contrib.javanica.test.common.domain.User in project Hystrix by Netflix.
the class BasicCommandTest method shouldWorkWithInheritedMethod.
@Test
public void shouldWorkWithInheritedMethod() {
User u1 = advancedUserService.getUserSync("1", "name: ");
assertGetUserSnycCommandExecuted(u1);
}
use of com.netflix.hystrix.contrib.javanica.test.common.domain.User in project Hystrix by Netflix.
the class BasicCommandTest method testGetUserSync.
@Test
public void testGetUserSync() {
User u1 = userService.getUserSync("1", "name: ");
assertGetUserSnycCommandExecuted(u1);
}
Aggregations