diff --git a/storio-sqlite/src/test/java/com/pushtorefresh/storio/sqlite/impl/ChainImplTest.java b/storio-sqlite/src/test/java/com/pushtorefresh/storio/sqlite/impl/ChainImplTest.java index 2b012c66a..1d3a2e31f 100644 --- a/storio-sqlite/src/test/java/com/pushtorefresh/storio/sqlite/impl/ChainImplTest.java +++ b/storio-sqlite/src/test/java/com/pushtorefresh/storio/sqlite/impl/ChainImplTest.java @@ -6,6 +6,7 @@ import org.junit.Test; +import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -26,4 +27,19 @@ public void proceed_shouldThrowIfIteratorEmpty() { assertThat(e).hasMessage("proceed was called on empty iterator"); } } + + @Test + public void proceed_shouldThrowIfCalledMultipleTimes() { + final List 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"); + } + } } \ No newline at end of file diff --git a/storio-sqlite/src/test/java/com/pushtorefresh/storio/sqlite/operations/delete/PreparedDeleteObjectTest.java b/storio-sqlite/src/test/java/com/pushtorefresh/storio/sqlite/operations/delete/PreparedDeleteObjectTest.java index aa8b9c086..5f01a1cfb 100644 --- a/storio-sqlite/src/test/java/com/pushtorefresh/storio/sqlite/operations/delete/PreparedDeleteObjectTest.java +++ b/storio-sqlite/src/test/java/com/pushtorefresh/storio/sqlite/operations/delete/PreparedDeleteObjectTest.java @@ -307,58 +307,61 @@ public void shouldThrowExceptionIfNoTypeMappingWasFoundWithoutAffectingDbAsCompl } } - @Test - public void shouldReturnObjectInGetData() { - final DeleteStub deleteStub = DeleteStub.newStubForOneObjectWithoutTypeMapping(); + public static class OtherTests { - final PreparedDeleteObject operation = deleteStub.storIOSQLite - .delete() - .object(deleteStub.itemsRequestedForDelete.get(0)) - .withDeleteResolver(deleteStub.deleteResolver) - .prepare(); + @Test + public void shouldReturnObjectInGetData() { + final DeleteStub deleteStub = DeleteStub.newStubForOneObjectWithoutTypeMapping(); - assertThat(operation.getData()).isEqualTo(deleteStub.itemsRequestedForDelete.get(0)); - } + final PreparedDeleteObject operation = deleteStub.storIOSQLite + .delete() + .object(deleteStub.itemsRequestedForDelete.get(0)) + .withDeleteResolver(deleteStub.deleteResolver) + .prepare(); + + assertThat(operation.getData()).isEqualTo(deleteStub.itemsRequestedForDelete.get(0)); + } - @Test - public void deleteObjectObservableExecutesOnSpecifiedScheduler() { - final DeleteStub deleteStub = DeleteStub.newStubForOneObjectWithoutTypeMapping(); - final SchedulerChecker schedulerChecker = SchedulerChecker.create(deleteStub.storIOSQLite); + @Test + public void deleteObjectObservableExecutesOnSpecifiedScheduler() { + final DeleteStub deleteStub = DeleteStub.newStubForOneObjectWithoutTypeMapping(); + final SchedulerChecker schedulerChecker = SchedulerChecker.create(deleteStub.storIOSQLite); - final PreparedDeleteObject operation = deleteStub.storIOSQLite - .delete() - .object(deleteStub.itemsRequestedForDelete.get(0)) - .withDeleteResolver(deleteStub.deleteResolver) - .prepare(); + final PreparedDeleteObject operation = deleteStub.storIOSQLite + .delete() + .object(deleteStub.itemsRequestedForDelete.get(0)) + .withDeleteResolver(deleteStub.deleteResolver) + .prepare(); - schedulerChecker.checkAsObservable(operation); - } + schedulerChecker.checkAsObservable(operation); + } - @Test - public void deleteObjectSingleExecutesOnSpecifiedScheduler() { - final DeleteStub deleteStub = DeleteStub.newStubForOneObjectWithoutTypeMapping(); - final SchedulerChecker schedulerChecker = SchedulerChecker.create(deleteStub.storIOSQLite); + @Test + public void deleteObjectSingleExecutesOnSpecifiedScheduler() { + final DeleteStub deleteStub = DeleteStub.newStubForOneObjectWithoutTypeMapping(); + final SchedulerChecker schedulerChecker = SchedulerChecker.create(deleteStub.storIOSQLite); - final PreparedDeleteObject operation = deleteStub.storIOSQLite - .delete() - .object(deleteStub.itemsRequestedForDelete.get(0)) - .withDeleteResolver(deleteStub.deleteResolver) - .prepare(); + final PreparedDeleteObject operation = deleteStub.storIOSQLite + .delete() + .object(deleteStub.itemsRequestedForDelete.get(0)) + .withDeleteResolver(deleteStub.deleteResolver) + .prepare(); - schedulerChecker.checkAsSingle(operation); - } + schedulerChecker.checkAsSingle(operation); + } - @Test - public void deleteObjectCompletableExecutesOnSpecifiedScheduler() { - final DeleteStub deleteStub = DeleteStub.newStubForOneObjectWithoutTypeMapping(); - final SchedulerChecker schedulerChecker = SchedulerChecker.create(deleteStub.storIOSQLite); + @Test + public void deleteObjectCompletableExecutesOnSpecifiedScheduler() { + final DeleteStub deleteStub = DeleteStub.newStubForOneObjectWithoutTypeMapping(); + final SchedulerChecker schedulerChecker = SchedulerChecker.create(deleteStub.storIOSQLite); - final PreparedDeleteObject operation = deleteStub.storIOSQLite - .delete() - .object(deleteStub.itemsRequestedForDelete.get(0)) - .withDeleteResolver(deleteStub.deleteResolver) - .prepare(); + final PreparedDeleteObject operation = deleteStub.storIOSQLite + .delete() + .object(deleteStub.itemsRequestedForDelete.get(0)) + .withDeleteResolver(deleteStub.deleteResolver) + .prepare(); - schedulerChecker.checkAsCompletable(operation); + schedulerChecker.checkAsCompletable(operation); + } } }