use of com.karumi.rosie.domain.usecase.error.ErrorHandler in project Rosie by Karumi.
the class UseCaseHandlerTest method completeCallbackShouldBeCalledWithSuccessArgs.
@Test
public void completeCallbackShouldBeCalledWithSuccessArgs() {
FakeTaskScheduler taskScheduler = new FakeTaskScheduler();
AnyUseCase anyUseCase = new AnyUseCase();
AnyOnSuccess onSuccessCallback = new AnyOnSuccess();
ErrorHandler errorHandler = new ErrorHandler(new FakeCallbackScheduler());
UseCaseHandler useCaseHandler = new UseCaseHandler(taskScheduler, errorHandler);
UseCaseCall useCaseCall = new UseCaseCall(anyUseCase, useCaseHandler);
useCaseCall.useCaseName("anyExecution").onSuccess(onSuccessCallback).execute();
assertEquals(ANY_RETURN_VALUE, onSuccessCallback.getValue());
}
use of com.karumi.rosie.domain.usecase.error.ErrorHandler in project Rosie by Karumi.
the class UseCaseHandlerTest method testExecuteWithArgs.
@Test
public void testExecuteWithArgs() throws Exception {
TaskScheduler taskScheduler = mock(TaskScheduler.class);
AnyUseCase anyUseCase = new AnyUseCase();
ErrorHandler errorHandler = new ErrorHandler(new FakeCallbackScheduler());
UseCaseHandler useCaseHandler = new UseCaseHandler(taskScheduler, errorHandler);
String anyArg1 = ANY_PARAM1;
int anyArg2 = ANY_PARAM2;
UseCaseCall useCaseCall = new UseCaseCall(anyUseCase, useCaseHandler);
useCaseCall.args(anyArg1, anyArg2).execute();
verify(taskScheduler, only()).execute(any(UseCaseWrapper.class));
}
use of com.karumi.rosie.domain.usecase.error.ErrorHandler in project Rosie by Karumi.
the class UseCaseHandlerTest method shouldSupportNullUseCaseParams.
@Test
public void shouldSupportNullUseCaseParams() {
FakeTaskScheduler taskScheduler = new FakeTaskScheduler();
AnyUseCase useCase = new AnyUseCase();
ErrorHandler errorHandler = mock(ErrorHandler.class);
UseCaseHandler useCaseHandler = new UseCaseHandler(taskScheduler, errorHandler);
AnyOnSuccess onSuccessCallback = new AnyOnSuccess();
UseCaseCall useCaseCall = new UseCaseCall(useCase, useCaseHandler);
useCaseCall.args(null, ANY_INT_PARAM).onSuccess(onSuccessCallback).execute();
assertEquals(ANY_INT_PARAM, onSuccessCallback.getValue());
}
use of com.karumi.rosie.domain.usecase.error.ErrorHandler in project Rosie by Karumi.
the class UseCaseHandlerTest method shouldCallErrorHandlerWhenUseCaseInvokeAnError.
@Test
public void shouldCallErrorHandlerWhenUseCaseInvokeAnError() {
FakeTaskScheduler taskScheduler = new FakeTaskScheduler();
ErrorUseCase errorUseCase = new ErrorUseCase();
ErrorHandler errorHandler = mock(ErrorHandler.class);
UseCaseHandler useCaseHandler = new UseCaseHandler(taskScheduler, errorHandler);
UseCaseCall useCaseCall = new UseCaseCall(errorUseCase, useCaseHandler);
useCaseCall.useCaseName("customError").execute();
verify(errorHandler).notifyError(any(Error.class), eq((OnErrorCallback) null));
}
use of com.karumi.rosie.domain.usecase.error.ErrorHandler in project Rosie by Karumi.
the class UseCaseHandlerTest method onSuccessCallbackShouldBeCalledWithSuccessArgs.
@Test
public void onSuccessCallbackShouldBeCalledWithSuccessArgs() {
FakeTaskScheduler taskScheduler = new FakeTaskScheduler();
EmptyResponseUseCase anyUseCase = new EmptyResponseUseCase();
EmptyOnSuccess onSuccessCallback = new EmptyOnSuccess();
ErrorHandler errorHandler = new ErrorHandler(new FakeCallbackScheduler());
UseCaseHandler useCaseHandler = new UseCaseHandler(taskScheduler, errorHandler);
UseCaseCall useCaseCall = new UseCaseCall(anyUseCase, useCaseHandler);
useCaseCall.onSuccess(onSuccessCallback).execute();
assertTrue(onSuccessCallback.isSuccess());
}
Aggregations