当前位置: 首页>>代码示例>>Java>>正文


Java BlockingSingle类代码示例

本文整理汇总了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);
}
 
开发者ID:Plastix,项目名称:Forage,代码行数:16,代码来源:OkApiInteractorTest.java

示例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);
}
 
开发者ID:Plastix,项目名称:Forage,代码行数:12,代码来源:OkApiInteractorTest.java

示例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));
}
 
开发者ID:naver,项目名称:pinpoint,代码行数:32,代码来源:SingleTestRunner.java

示例4: toBlocking

import rx.singles.BlockingSingle; //导入依赖的package包/类
@Experimental
public final BlockingSingle<T> toBlocking() {
    return BlockingSingle.from(this);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:5,代码来源:Single.java


注:本文中的rx.singles.BlockingSingle类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。