use of com.pushtorefresh.storio3.Interceptor.Chain in project storio by pushtorefresh.
the class ChainImplTest method proceed_shouldThrowIfCalledMultipleTimes.
@Test
public void proceed_shouldThrowIfCalledMultipleTimes() {
final List<Interceptor> interceptors = Arrays.asList(mock(Interceptor.class), mock(Interceptor.class));
try {
final Chain chain = new ChainImpl(interceptors.listIterator());
final PreparedOperation operation = mock(PreparedOperation.class);
chain.proceed(operation);
chain.proceed(operation);
failBecauseExceptionWasNotThrown(IllegalStateException.class);
} catch (IllegalStateException e) {
assertThat(e).hasMessage("nextInterceptor " + interceptors.get(0) + " must call proceed() exactly once");
}
}
use of com.pushtorefresh.storio3.Interceptor.Chain in project storio by pushtorefresh.
the class ChainImplTest method buildChain_placesRealInterceptorAfterRegistered.
@Test
public void buildChain_placesRealInterceptorAfterRegistered() {
Interceptor registered1 = spy(new IntermediateInterceptor());
Interceptor registered2 = spy(new IntermediateInterceptor());
final List<Interceptor> interceptors = Arrays.asList(registered1, registered2);
Interceptor real = mock(Interceptor.class);
final Chain chain = ChainImpl.buildChain(interceptors, real);
InOrder inOrder = Mockito.inOrder(registered1, registered2, real);
PreparedOperation operation = mock(PreparedOperation.class);
chain.proceed(operation);
inOrder.verify(registered1).intercept(eq(operation), any(Chain.class));
inOrder.verify(registered2).intercept(eq(operation), any(Chain.class));
inOrder.verify(real).intercept(eq(operation), any(Chain.class));
}
use of com.pushtorefresh.storio3.Interceptor.Chain in project storio by pushtorefresh.
the class ChainImplTest method buildChain_shouldThrowIfRegisteredInterceptorNull.
@Test
public void buildChain_shouldThrowIfRegisteredInterceptorNull() {
try {
final List<Interceptor> interceptors = Arrays.asList(null, mock(Interceptor.class));
final Chain chain = ChainImpl.buildChain(interceptors, mock(Interceptor.class));
chain.proceed(mock(PreparedOperation.class));
failBecauseExceptionWasNotThrown(IllegalArgumentException.class);
} catch (IllegalArgumentException e) {
assertThat(e).hasMessage("Interceptor should not be null");
}
}
Aggregations