本文整理汇总了Java中rx.singles.BlockingSingle类的典型用法代码示例。如果您正苦于以下问题:Java BlockingSingle类的具体用法?Java BlockingSingle怎么用?Java BlockingSingle使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BlockingSingle类属于rx.singles包,在下文中一共展示了BlockingSingle类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getNearbyItems_shouldReturnItemsFromApi
import rx.singles.BlockingSingle; //导入依赖的package包/类
@Test
public void getNearbyItems_shouldReturnItemsFromApi() {
List<Cache> caches = asList(mock(Cache.class), mock(Cache.class));
when(
okApiService.searchAndRetrieve(anyString(),
anyString(),
anyString(),
anyString(),
anyBoolean(),
anyString())
).thenReturn(Single.just(caches));
BlockingSingle<List<Cache>> result = okApiInteractor.getNearbyCaches(lat, lon, radius).toBlocking();
assertThat(result.value()).containsExactlyElementsIn(caches);
}
示例2: submitLog_shouldReturnResponseFromApi
import rx.singles.BlockingSingle; //导入依赖的package包/类
@Test
public void submitLog_shouldReturnResponseFromApi() {
SubmitLogResponse response = mock(SubmitLogResponse.class);
when(
okApiService.submitLog(anyString(), anyString(), anyString())
).thenReturn(Single.just(response));
BlockingSingle<SubmitLogResponse> result = okApiInteractor.submitLog("", "", "").toBlocking();
assertThat(result.value()).isSameAs(response);
}
示例3: blockingSingle
import rx.singles.BlockingSingle; //导入依赖的package包/类
public void blockingSingle() throws Exception {
final String message = "Hello World";
String actualMessage = echoService.echo(message)
.subscribeOn(Schedulers.computation())
.toBlocking()
.value();
Assert.assertEquals(message, actualMessage);
TestHelper.awaitForSpanDataFlush();
PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
verifier.printCache();
// Skip rx java internal traces as they differ between versions and it's too much work to split the tests.
// Instead, we can verify them indirectly by checking if user methods have been traced.
verifier.ignoreServiceType("RX_JAVA_INTERNAL");
Method toBlockingMethod = Single.class.getDeclaredMethod("toBlocking");
verifier.verifyTrace(event("RX_JAVA", toBlockingMethod));
Method valueMethod = BlockingSingle.class.getDeclaredMethod("value");
verifier.verifyTrace(event("RX_JAVA", valueMethod));
Method subscribe = Single.class.getDeclaredMethod("subscribe", SingleSubscriber.class);
verifier.verifyTrace(event("RX_JAVA", subscribe));
// event - RX_JAVA_INTERNAL some form of Worker.schedule(Action0)
verifier.verifyTrace(event(ServiceType.ASYNC.getName(), "Asynchronous Invocation"));
// event - RX_JAVA_INTERNAL some form of Action0 implementation's call() inside OperatorSubscribeOn that gets scheduled
Method subscribeMethod2 = Single.class.getDeclaredMethod("subscribe", SingleSubscriber.class);
verifier.verifyTrace(event("RX_JAVA", subscribeMethod2));
Method echoMethod = EchoRepository.class.getDeclaredMethod("echo", String.class);
verifier.verifyTrace(event(ServiceType.INTERNAL_METHOD.getName(), echoMethod));
}
示例4: toBlocking
import rx.singles.BlockingSingle; //导入依赖的package包/类
@Experimental
public final BlockingSingle<T> toBlocking() {
return BlockingSingle.from(this);
}