use of com.karumi.rosie.doubles.FakeCallbackScheduler in project Rosie by Karumi.
the class UseCaseHandlerTest method onSuccessCallbackShouldBeCalledWithSuccessArgsAndDowncastingResponse.
@Test
public void onSuccessCallbackShouldBeCalledWithSuccessArgsAndDowncastingResponse() {
FakeTaskScheduler taskScheduler = new FakeTaskScheduler();
AnyUseCase anyUseCase = new AnyUseCase();
AnyOnSuccessWithDowncast onSuccessCallback = new AnyOnSuccessWithDowncast();
ErrorHandler errorHandler = new ErrorHandler(new FakeCallbackScheduler());
UseCaseHandler useCaseHandler = new UseCaseHandler(taskScheduler, errorHandler);
UseCaseCall useCaseCall = new UseCaseCall(anyUseCase, useCaseHandler);
useCaseCall.useCaseName("downcastResponse").onSuccess(onSuccessCallback).execute();
assertNotNull(onSuccessCallback.getValue());
}
use of com.karumi.rosie.doubles.FakeCallbackScheduler in project Rosie by Karumi.
the class UseCaseHandlerTest method completeCallbackShouldNotBeExecutedWhenNotMatchArgs.
@Test
public void completeCallbackShouldNotBeExecutedWhenNotMatchArgs() {
FakeTaskScheduler taskScheduler = new FakeTaskScheduler();
AnyUseCase anyUseCase = new AnyUseCase();
EmptyOnSuccess onSuccessCallback = new EmptyOnSuccess();
ErrorHandler errorHandler = new ErrorHandler(new FakeCallbackScheduler());
UseCaseHandler useCaseHandler = new UseCaseHandler(taskScheduler, errorHandler);
UseCaseCall useCaseCall = new UseCaseCall(anyUseCase, useCaseHandler);
useCaseCall.useCaseName("anyExecution").onSuccess(onSuccessCallback).execute();
assertFalse(onSuccessCallback.isSuccess());
}
use of com.karumi.rosie.doubles.FakeCallbackScheduler in project Rosie by Karumi.
the class UseCaseHandlerTest method testExecuteNoAmbigous.
@Test
public void testExecuteNoAmbigous() throws Exception {
TaskScheduler taskScheduler = mock(TaskScheduler.class);
AmbiguousUseCase ambigousUseCase = new AmbiguousUseCase();
ErrorHandler errorHandler = new ErrorHandler(new FakeCallbackScheduler());
UseCaseHandler useCaseHandler = new UseCaseHandler(taskScheduler, errorHandler);
UseCaseCall useCaseCall = new UseCaseCall(ambigousUseCase, useCaseHandler);
useCaseCall.args(ANY_PARAM1, ANY_PARAM2).useCaseName("method1").execute();
verify(taskScheduler, only()).execute(any(UseCaseWrapper.class));
}
Aggregations