本文整理匯總了Java中io.reactivex.subscribers.TestSubscriber.assertErrorMessage方法的典型用法代碼示例。如果您正苦於以下問題:Java TestSubscriber.assertErrorMessage方法的具體用法?Java TestSubscriber.assertErrorMessage怎麽用?Java TestSubscriber.assertErrorMessage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類io.reactivex.subscribers.TestSubscriber
的用法示例。
在下文中一共展示了TestSubscriber.assertErrorMessage方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testGetOneWithError
import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testGetOneWithError(){
testStore.shouldThrowError(true);
models.clear();
List<TestModel> list = new ArrayList<>();
list.add(new TestModel(10));
list.add(new TestModel(20));
list.add(new TestModel(30));
memoryStore.insertOrUpdate(list);
TestSubscriber<Optional<TestModel>> observer = new TestSubscriber<>();
disposables.add(testStore.getOne()
.subscribeOn(Schedulers.io())
.subscribeWith(observer));
observer.awaitTerminalEvent(2, SECONDS);
observer.assertError(Throwable.class);
observer.assertErrorMessage("getOne.error");
testStore.shouldThrowError(false);
Assert.assertEquals(3, models.size());
}
示例2: testInsertListWithError
import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testInsertListWithError(){
models.clear();
testStore.shouldThrowError(true); // enable error
List<TestModel> list = new ArrayList<>();
list.add(new TestModel(1));
list.add(new TestModel(2));
list.add(new TestModel(3));
TestSubscriber<Optional<List<TestModel>>> observer = new TestSubscriber<>();
disposables.add(testStore.insert(list)
.subscribeOn(Schedulers.io())
.subscribeWith(observer));
observer.awaitTerminalEvent(2, SECONDS);
observer.assertError(Throwable.class);
observer.assertErrorMessage("insert.error");
testStore.shouldThrowError(false); // disable error
Assert.assertEquals(0, models.size()); // should have been cleared
}
示例3: testInsertWithError
import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testInsertWithError(){
models.clear();
testStore.shouldThrowError(true); // enable error
TestModel model = new TestModel(99);
TestSubscriber<Optional<TestModel>> observer = new TestSubscriber<>();
disposables.add(testStore.insert(model)
.subscribeOn(Schedulers.io())
.subscribeWith(observer));
observer.awaitTerminalEvent(2, SECONDS);
observer.assertError(Throwable.class);
observer.assertErrorMessage("insertSingle.error");
testStore.shouldThrowError(false); // disable error
Assert.assertEquals(0, models.size());
}
示例4: testDeleteAllWithError
import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testDeleteAllWithError(){
testStore.shouldThrowError(true);
models.clear();
List<TestModel> list = new ArrayList<>();
list.add(new TestModel(1));
list.add(new TestModel(2));
list.add(new TestModel(3));
memoryStore.insertOrUpdate(list);
TestSubscriber<Integer> observer = new TestSubscriber<>();
disposables.add(testStore.deleteAll()
.subscribeOn(Schedulers.io())
.subscribeWith(observer));
observer.awaitTerminalEvent(5, SECONDS);
observer.assertError(Throwable.class);
observer.assertErrorMessage("deleteAll.error");
testStore.shouldThrowError(false); // disable error
Assert.assertEquals(3, models.size());
}
示例5: testInsertOrUpdateForInsertWithError
import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testInsertOrUpdateForInsertWithError(){
models.clear();
testStore.shouldThrowError(true);
final TestModel model = new TestModel(99);
model.setAvailable(true);
TestSubscriber<Optional<TestModel>> observer = new TestSubscriber<>();
disposables.add(testStore.insertOrUpdate(model)
.subscribeOn(Schedulers.io())
.subscribeWith(observer));
observer.awaitTerminalEvent(4, SECONDS);
observer.assertError(Throwable.class);
observer.assertErrorMessage("insertOrUpdateSingle.error");
testStore.shouldThrowError(false);
Assert.assertEquals(0, models.size());
}
示例6: testGetAllWithError
import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testGetAllWithError(){
models.clear();
testStore.shouldThrowError(true); // enable error
List<TestModel> list = new ArrayList<>();
list.add(new TestModel(1));
list.add(new TestModel(2));
list.add(new TestModel(3));
memoryStore.insertOrUpdate(list);
TestSubscriber<Optional<List<TestModel>>> observer = new TestSubscriber<>();
disposables.add(testStore.getAll(null, null)
.subscribeOn(Schedulers.io())
.subscribeWith(observer));
observer.awaitTerminalEvent(2, SECONDS);
observer.assertError(Throwable.class);
observer.assertErrorMessage("getAll.error");
testStore.shouldThrowError(false); // disable error
Assert.assertEquals(models.size(), 3);
int sum = 0;
for(TestModel tm : models){
sum += tm.getId();
}
Assert.assertEquals(6, sum);
}
示例7: testDeleteSingleWithError
import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testDeleteSingleWithError(){
models.clear();
testStore.shouldThrowError(true);
List<TestModel> list = new ArrayList<>();
list.add(new TestModel(1));
list.add(new TestModel(2));
list.add(new TestModel(3));
memoryStore.insertOrUpdate(list);
TestModel model = new TestModel(2);
TestSubscriber<Integer> observer = new TestSubscriber<>();
disposables.add(testStore.delete(model)
.subscribeOn(Schedulers.io())
.subscribeWith(observer));
observer.awaitTerminalEvent(2, SECONDS);
observer.assertError(Throwable.class);
observer.assertErrorMessage("deleteSingle.error");
int sum = 0;
for(TestModel tm : models){
sum += tm.getId();
}
testStore.shouldThrowError(false); // disable error
Assert.assertEquals(3, models.size());
Assert.assertEquals(6, sum);
}
示例8: testInsertOrUpdateForUpdateWithError
import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testInsertOrUpdateForUpdateWithError(){
models.clear();
final TestModel model = new TestModel(99);
model.setAvailable(true); // should be rollback to this version
models.add(model);
testStore.shouldThrowError(true);
final TestModel otherModelReferenceWithSameId = new TestModel(99);
otherModelReferenceWithSameId.setAvailable(false);
TestSubscriber<Optional<TestModel>> observer = new TestSubscriber<>();
disposables.add(testStore.insertOrUpdate(otherModelReferenceWithSameId)
.subscribeOn(Schedulers.io())
.subscribeWith(observer));
observer.awaitTerminalEvent(5, SECONDS);
observer.assertError(Throwable.class);
observer.assertErrorMessage("insertOrUpdateSingle.error");
testStore.shouldThrowError(false);
final TestModel output = models.get(0);
Assert.assertEquals(1, models.size());
Assert.assertNotNull(output);
Assert.assertTrue(output.isAvailable()); // rollback to first version
}
示例9: testInsertOrUpdateManyWithError
import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testInsertOrUpdateManyWithError(){
models.clear();
testStore.shouldThrowError(true);
List<TestModel> list = new ArrayList<>();
list.add(new TestModel(10));
list.add(new TestModel(20));
list.add(new TestModel(30));
memoryStore.insertOrUpdate(list);
List<TestModel> listToInsertOrUpdate = new ArrayList<>();
final TestModel first = new TestModel(20);
first.setAvailable(true);
final TestModel second = new TestModel(99);
second.setAvailable(true);
listToInsertOrUpdate.add(first);
listToInsertOrUpdate.add(second);
TestSubscriber<Optional<List<TestModel>>> observer = new TestSubscriber<>();
disposables.add(testStore.insertOrUpdate(listToInsertOrUpdate)
.subscribeOn(Schedulers.io())
.subscribeWith(observer));
observer.awaitTerminalEvent(5, SECONDS);
observer.assertError(Throwable.class);
observer.assertErrorMessage("insertOrUpdate.error");
testStore.shouldThrowError(false);
for(TestModel tm : MemoryDao.models){
Assert.assertFalse(tm.isAvailable());
}
Assert.assertEquals(3, MemoryDao.models.size());
}
示例10: testUpdateListWithError
import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testUpdateListWithError(){
models.clear();
testStore.shouldThrowError(true); // enable error
List<TestModel> list = new ArrayList<>();
list.add(new TestModel(1));
list.add(new TestModel(2));
list.add(new TestModel(3));
memoryStore.insertOrUpdate(list);
List<TestModel> updateList = new ArrayList<>();
TestModel testModel = new TestModel(1);
testModel.setAvailable(true);
updateList.add(testModel);
testModel = new TestModel(3);
testModel.setAvailable(true);
updateList.add(testModel);
TestSubscriber<Optional<List<TestModel>>> observer = new TestSubscriber<>();
disposables.add(testStore.update(updateList)
.subscribeOn(Schedulers.io())
.subscribeWith(observer));
observer.awaitTerminalEvent(4, SECONDS);
observer.assertError(Throwable.class);
observer.assertErrorMessage("update.error");
testStore.shouldThrowError(false); // disable error
Assert.assertEquals(3, models.size()); // should have been cleared
for(TestModel tm : models){
Assert.assertFalse(tm.isAvailable());
}
}
示例11: testUpdateWithError
import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testUpdateWithError(){
models.clear();
testStore.shouldThrowError(true); // enable error
List<TestModel> list = new ArrayList<>();
list.add(new TestModel(1));
list.add(new TestModel(2));
list.add(new TestModel(3));
memoryStore.insertOrUpdate(list);
TestModel testModel = new TestModel(1);
testModel.setAvailable(true);
TestSubscriber<Optional<TestModel>> observer = new TestSubscriber<>();
disposables.add(testStore.update(testModel)
.subscribeOn(Schedulers.io())
.subscribeWith(observer));
observer.awaitTerminalEvent(4, SECONDS);
observer.assertError(Throwable.class);
observer.assertErrorMessage("updateSingle.error");
testStore.shouldThrowError(false); // disable error
Assert.assertEquals(3, models.size()); // should have been cleared
for(TestModel tm : models){
Assert.assertFalse(tm.isAvailable());
}
}