Skip to content

Commit

Permalink
Tests added
Browse files Browse the repository at this point in the history
  • Loading branch information
rsinukov committed Apr 16, 2017
1 parent 19a45a5 commit 200fd46
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import org.junit.Test;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

Expand All @@ -26,4 +27,19 @@ public void proceed_shouldThrowIfIteratorEmpty() {
assertThat(e).hasMessage("proceed was called on empty iterator");
}
}

@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");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -307,58 +307,61 @@ public void shouldThrowExceptionIfNoTypeMappingWasFoundWithoutAffectingDbAsCompl
}
}

@Test
public void shouldReturnObjectInGetData() {
final DeleteStub deleteStub = DeleteStub.newStubForOneObjectWithoutTypeMapping();
public static class OtherTests {

final PreparedDeleteObject<TestItem> 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<TestItem> 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<TestItem> operation = deleteStub.storIOSQLite
.delete()
.object(deleteStub.itemsRequestedForDelete.get(0))
.withDeleteResolver(deleteStub.deleteResolver)
.prepare();
final PreparedDeleteObject<TestItem> 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<TestItem> operation = deleteStub.storIOSQLite
.delete()
.object(deleteStub.itemsRequestedForDelete.get(0))
.withDeleteResolver(deleteStub.deleteResolver)
.prepare();
final PreparedDeleteObject<TestItem> 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<TestItem> operation = deleteStub.storIOSQLite
.delete()
.object(deleteStub.itemsRequestedForDelete.get(0))
.withDeleteResolver(deleteStub.deleteResolver)
.prepare();
final PreparedDeleteObject<TestItem> operation = deleteStub.storIOSQLite
.delete()
.object(deleteStub.itemsRequestedForDelete.get(0))
.withDeleteResolver(deleteStub.deleteResolver)
.prepare();

schedulerChecker.checkAsCompletable(operation);
schedulerChecker.checkAsCompletable(operation);
}
}
}

0 comments on commit 200fd46

Please sign in to comment.