• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java AssertableSubscriber类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中rx.observers.AssertableSubscriber的典型用法代码示例。如果您正苦于以下问题:Java AssertableSubscriber类的具体用法?Java AssertableSubscriber怎么用?Java AssertableSubscriber使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



AssertableSubscriber类属于rx.observers包,在下文中一共展示了AssertableSubscriber类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: addItem_ShouldNotBeSkipped_When_AddRequestFailedOnceAlready

import rx.observers.AssertableSubscriber; //导入依赖的package包/类
@Test
public void addItem_ShouldNotBeSkipped_When_AddRequestFailedOnceAlready() {
    ItemId itemId = mock(ItemId.class);
    Throwable throwable = new RuntimeException();
    when(api.addItem(itemId))
            .thenReturn(Single.error(throwable))
            .thenReturn(Single.just(ApiResponse.createSuccessfulResponse()));

    Response.Cause cause = mock(Response.Cause.class);
    when(apiErrorConverter.convertApiError(new ExceptionApiError(throwable))).thenReturn(cause);

    itemRepository.addItem(itemId).test();
    AssertableSubscriber<Response> subscriber = itemRepository.addItem(itemId).test();

    RxJavaSchedulerUtils.advanceOneSecond();
    verify(api, times(2)).addItem(itemId);
    subscriber.assertResult(Response.createSuccessfulResponse())
            .assertCompleted();
    assertTrue(itemRepository.hasItem(itemId));
}
 
开发者ID:NikitaKozlov,项目名称:Switchman,代码行数:21,代码来源:ItemRepositoryTest_Part4_ApiCallsOptimisation.java


示例2: removeItem_ShouldNotBeSkipped_When_RemoveRequestFailedOnceAlready

import rx.observers.AssertableSubscriber; //导入依赖的package包/类
@Test
public void removeItem_ShouldNotBeSkipped_When_RemoveRequestFailedOnceAlready() {
    ItemId itemId = addNewItemSuccessfully();
    Throwable throwable = new RuntimeException();
    when(api.removeItem(itemId))
            .thenReturn(Single.error(throwable))
            .thenReturn(Single.just(ApiResponse.createSuccessfulResponse()));

    Response.Cause cause = mock(Response.Cause.class);
    when(apiErrorConverter.convertApiError(new ExceptionApiError(throwable))).thenReturn(cause);

    itemRepository.removeItem(itemId).test();
    AssertableSubscriber<Response> subscriber = itemRepository.removeItem(itemId).test();

    RxJavaSchedulerUtils.advanceOneSecond();
    verify(api, times(2)).removeItem(itemId);
    subscriber.assertResult(Response.createSuccessfulResponse())
            .assertCompleted();
    assertFalse(itemRepository.hasItem(itemId));
}
 
开发者ID:NikitaKozlov,项目名称:Switchman,代码行数:21,代码来源:ItemRepositoryTest_Part4_ApiCallsOptimisation.java


示例3: twoAdditions_ShouldBeExecutedInParallel_When_ItemIdsAreDifferent

import rx.observers.AssertableSubscriber; //导入依赖的package包/类
@Test
public void twoAdditions_ShouldBeExecutedInParallel_When_ItemIdsAreDifferent() {
    ItemId itemId1 = mock(ItemId.class);
    ItemId itemId2 = mock(ItemId.class);

    when(api.addItem(itemId1)).thenReturn(RxJavaUtils.createNeverCompletedSingle());
    when(api.addItem(itemId2)).thenReturn(RxJavaUtils.createNeverCompletedSingle());

    AssertableSubscriber<Response> subscriber1 = itemRepository.addItem(itemId1).test();
    AssertableSubscriber<Response> subscriber2 = itemRepository.addItem(itemId2).test();

    RxJavaSchedulerUtils.advanceOneSecond();
    subscriber1.assertNotCompleted();
    subscriber2.assertNotCompleted();

    verify(api).addItem(itemId1);
    verify(api).addItem(itemId2);
}
 
开发者ID:NikitaKozlov,项目名称:Switchman,代码行数:19,代码来源:ItemRepositoryTest_Part4_ApiCallsOptimisation.java


示例4: ARA_ReturnsSkippedResponsesForRemoveAndSecondAdd

import rx.observers.AssertableSubscriber; //导入依赖的package包/类
@Test
public void ARA_ReturnsSkippedResponsesForRemoveAndSecondAdd() {
    ItemId itemId = mock(ItemId.class);

    when(api.addItem(itemId)).thenReturn(Single.just(ApiResponse.createSuccessfulResponse()));
    when(api.removeItem(itemId)).thenReturn(Single.just(ApiResponse.createSuccessfulResponse()));

    AssertableSubscriber<Response> firstAddSubscriber = itemRepository.addItem(itemId).test();
    AssertableSubscriber<Response> removeSubscriber = itemRepository.removeItem(itemId).test();
    AssertableSubscriber<Response> secondAddSubscriber = itemRepository.addItem(itemId).test();
    RxJavaSchedulerUtils.advanceOneSecond();

    assertTrue(firstAddSubscriber.getOnNextEvents().get(0).isSuccessful());
    assertTrue(removeSubscriber.getOnNextEvents().get(0).isSkipped());
    assertTrue(secondAddSubscriber.getOnNextEvents().get(0).isSkipped());
}
 
开发者ID:NikitaKozlov,项目名称:Switchman,代码行数:17,代码来源:ItemRepositoryTest_Part4_ApiCallsOptimisation.java


示例5: ARAR_ReturnsSkippedResponsesForFirstRemoveAndSecondAdd

import rx.observers.AssertableSubscriber; //导入依赖的package包/类
@Test
public void ARAR_ReturnsSkippedResponsesForFirstRemoveAndSecondAdd() {
    ItemId itemId = mock(ItemId.class);

    when(api.addItem(itemId)).thenReturn(Single.just(ApiResponse.createSuccessfulResponse()));
    when(api.removeItem(itemId)).thenReturn(Single.just(ApiResponse.createSuccessfulResponse()));

    AssertableSubscriber<Response> firstAddSubscriber = itemRepository.addItem(itemId).test();
    AssertableSubscriber<Response> firstRemoveSubscriber = itemRepository.removeItem(itemId).test();
    AssertableSubscriber<Response> secondAddSubscriber = itemRepository.addItem(itemId).test();
    AssertableSubscriber<Response> secondRemoveSubscriber = itemRepository.removeItem(itemId).test();
    RxJavaSchedulerUtils.advanceOneSecond();

    assertTrue(firstAddSubscriber.getOnNextEvents().get(0).isSuccessful());
    assertTrue(firstRemoveSubscriber.getOnNextEvents().get(0).isSkipped());
    assertTrue(secondAddSubscriber.getOnNextEvents().get(0).isSkipped());
    assertTrue(secondRemoveSubscriber.getOnNextEvents().get(0).isSuccessful());
}
 
开发者ID:NikitaKozlov,项目名称:Switchman,代码行数:19,代码来源:ItemRepositoryTest_Part4_ApiCallsOptimisation.java


示例6: removeItem_CallsApiAndReturnFailed_When_ApiReturnFailed

import rx.observers.AssertableSubscriber; //导入依赖的package包/类
@Test
public void removeItem_CallsApiAndReturnFailed_When_ApiReturnFailed() {
    ItemId itemId = addNewItemSuccessfully();

    ApiResponse.ApiError apiError = mock(ApiResponse.ApiError.class);

    when(api.removeItem(any())).thenReturn(Single.just(ApiResponse.createFailedResponse(HttpStatus.BAD_REQUEST.value(), apiError)));

    Response.Cause cause = mock(Response.Cause.class);
    when(apiErrorConverter.convertApiError(apiError)).thenReturn(cause);

    AssertableSubscriber<Response> subscriber = itemRepository.removeItem(itemId).test();
    RxJavaSchedulerUtils.advanceOneSecond();
    subscriber.assertResult(Response.createFailedResponse(cause))
            .assertCompleted();
    assertTrue(itemRepository.hasItem(itemId));
}
 
开发者ID:NikitaKozlov,项目名称:Switchman,代码行数:18,代码来源:ItemRepositoryTest_Part2_AddingAndRemoving.java


示例7: removeItem_CallsApiAndReturnSuccess_When_ApiReturnNotFound

import rx.observers.AssertableSubscriber; //导入依赖的package包/类
@Test
public void removeItem_CallsApiAndReturnSuccess_When_ApiReturnNotFound() {
    ItemId itemId = addNewItemSuccessfully();

    ApiResponse.ApiError apiError = mock(ApiResponse.ApiError.class);

    when(api.removeItem(any())).thenReturn(Single.just(ApiResponse.createFailedResponse(HttpStatus.NOT_FOUND.value(), apiError)));

    Response.Cause cause = mock(Response.Cause.class);
    when(apiErrorConverter.convertApiError(apiError)).thenReturn(cause);

    AssertableSubscriber<Response> subscriber = itemRepository.removeItem(itemId).test();
    RxJavaSchedulerUtils.advanceOneSecond();
    subscriber.assertResult(Response.createSuccessfulResponse())
            .assertCompleted();
    assertFalse(itemRepository.hasItem(itemId));
}
 
开发者ID:NikitaKozlov,项目名称:Switchman,代码行数:18,代码来源:ItemRepositoryTest_Part2_AddingAndRemoving.java


示例8: ARAR_ResultIn01010Counter

import rx.observers.AssertableSubscriber; //导入依赖的package包/类
@Test
public void ARAR_ResultIn01010Counter() {
    ItemId itemId = mock(ItemId.class);

    when(api.addItem(itemId)).thenReturn(Single.just(ApiResponse.createSuccessfulResponse()));
    when(api.removeItem(itemId)).thenReturn(Single.just(ApiResponse.createSuccessfulResponse()));

    AssertableSubscriber<Integer> counterTestSubscriber = itemRepository.getCounter().test();

    itemRepository.addItem(itemId).test();
    itemRepository.removeItem(itemId).test();
    itemRepository.addItem(itemId).test();
    itemRepository.removeItem(itemId).test();
    RxJavaSchedulerUtils.advanceOneSecond();

    counterTestSubscriber.assertReceivedOnNext(Arrays.asList(0, 1, 0, 1, 0));
}
 
开发者ID:NikitaKozlov,项目名称:Switchman,代码行数:18,代码来源:ItemRepositoryTest_Part3_CounterChanges.java


示例9: AR_ResultIn0101Counter_When_LastRemovalFails

import rx.observers.AssertableSubscriber; //导入依赖的package包/类
@Test
public void AR_ResultIn0101Counter_When_LastRemovalFails() {
    ItemId itemId = mock(ItemId.class);

    when(api.addItem(itemId)).thenReturn(Single.just(ApiResponse.createSuccessfulResponse()));
    when(api.removeItem(itemId)).thenReturn(Single.just(
            ApiResponse.createFailedResponse(HttpStatus.BAD_REQUEST.value(), mock(ApiResponse.ApiError.class))));

    AssertableSubscriber<Integer> counterTestSubscriber = itemRepository.getCounter().test();

    itemRepository.addItem(itemId).test();
    itemRepository.removeItem(itemId).test();
    RxJavaSchedulerUtils.advanceOneSecond();

    counterTestSubscriber.assertReceivedOnNext(Arrays.asList(0, 1, 0, 1));
}
 
开发者ID:NikitaKozlov,项目名称:Switchman,代码行数:17,代码来源:ItemRepositoryTest_Part3_CounterChanges.java


示例10: shouldCreateExecutableFromEndpointMethodWithRxJavaCompletableReturnType

import rx.observers.AssertableSubscriber; //导入依赖的package包/类
@Test
public void shouldCreateExecutableFromEndpointMethodWithRxJavaCompletableReturnType() throws Exception {
	EndpointCallExecutable<Completable, Void> executable = factory
			.create(new SimpleEndpointMethod(SomeType.class.getMethod("completable")));

	Completable completable = executable.execute(endpointCallMock, null);

	assertNotNull(completable);

	AssertableSubscriber<Void> subscriber = completable.subscribeOn(scheduler).test();

	subscriber.assertCompleted()
		.assertNoErrors()
		.assertNoValues();

	verify(endpointCallMock).execute();
}
 
开发者ID:ljtfreitas,项目名称:java-restify,代码行数:18,代码来源:RxJavaCompletableEndpointCallExecutableFactoryTest.java


示例11: addItem_CallsApiAndReturnSuccess_When_ApiReturnSuccess

import rx.observers.AssertableSubscriber; //导入依赖的package包/类
@Test
public void addItem_CallsApiAndReturnSuccess_When_ApiReturnSuccess() {
    ItemId itemId = mock(ItemId.class);
    when(api.addItem(itemId)).thenReturn(Single.just(ApiResponse.createSuccessfulResponse()));

    AssertableSubscriber<Response> subscriber = itemRepository.addItem(itemId).test();
    RxJavaSchedulerUtils.advanceOneSecond();

    subscriber.assertResult(Response.createSuccessfulResponse())
            .assertCompleted();
    assertTrue(itemRepository.hasItem(itemId));
}
 
开发者ID:NikitaKozlov,项目名称:Switchman,代码行数:13,代码来源:ItemRepositoryTest_Part2_AddingAndRemoving.java


示例12: addItem_CallsApiAndReturnFailed_When_ApiReturnBadRequest

import rx.observers.AssertableSubscriber; //导入依赖的package包/类
@Test
public void addItem_CallsApiAndReturnFailed_When_ApiReturnBadRequest() {
    ItemId itemId = mock(ItemId.class);
    ApiResponse.ApiError apiError = mock(ApiResponse.ApiError.class);
    when(api.addItem(any())).thenReturn(Single.just(ApiResponse.createFailedResponse(HttpStatus.BAD_REQUEST.value(), apiError)));
    Response.Cause cause = mock(Response.Cause.class);
    when(apiErrorConverter.convertApiError(apiError)).thenReturn(cause);

    AssertableSubscriber<Response> subscriber = itemRepository.addItem(itemId).test();
    RxJavaSchedulerUtils.advanceOneSecond();

    subscriber.assertResult(Response.createFailedResponse(cause))
            .assertCompleted();
    assertFalse(itemRepository.hasItem(itemId));
}
 
开发者ID:NikitaKozlov,项目名称:Switchman,代码行数:16,代码来源:ItemRepositoryTest_Part2_AddingAndRemoving.java


示例13: addItem_CallsApiAndReturnSuccess_When_ApiReturnConflict

import rx.observers.AssertableSubscriber; //导入依赖的package包/类
@Test
public void addItem_CallsApiAndReturnSuccess_When_ApiReturnConflict() {
    ItemId itemId = mock(ItemId.class);
    ApiResponse.ApiError apiError = mock(ApiResponse.ApiError.class);
    when(api.addItem(any())).thenReturn(Single.just(ApiResponse.createFailedResponse(HttpStatus.CONFLICT.value(), apiError)));
    Response.Cause cause = mock(Response.Cause.class);
    when(apiErrorConverter.convertApiError(apiError)).thenReturn(cause);

    AssertableSubscriber<Response> subscriber = itemRepository.addItem(itemId).test();
    RxJavaSchedulerUtils.advanceOneSecond();

    subscriber.assertResult(Response.createSuccessfulResponse())
            .assertCompleted();
    assertTrue(itemRepository.hasItem(itemId));
}
 
开发者ID:NikitaKozlov,项目名称:Switchman,代码行数:16,代码来源:ItemRepositoryTest_Part2_AddingAndRemoving.java


示例14: addItem_CallsApiAndReturnFailed_When_ApiThrowsException

import rx.observers.AssertableSubscriber; //导入依赖的package包/类
@Test
public void addItem_CallsApiAndReturnFailed_When_ApiThrowsException() {
    ItemId itemId = mock(ItemId.class);
    Throwable throwable = new RuntimeException();
    when(api.addItem(itemId)).thenReturn(Single.error(throwable));
    Response.Cause cause = mock(Response.Cause.class);
    when(apiErrorConverter.convertApiError(new ExceptionApiError(throwable))).thenReturn(cause);

    AssertableSubscriber<Response> subscriber = itemRepository.addItem(itemId).test();
    RxJavaSchedulerUtils.advanceOneSecond();

    subscriber.assertResult(Response.createFailedResponse(cause))
            .assertCompleted();
    assertFalse(itemRepository.hasItem(itemId));
}
 
开发者ID:NikitaKozlov,项目名称:Switchman,代码行数:16,代码来源:ItemRepositoryTest_Part2_AddingAndRemoving.java


示例15: removeItem_CallsApiAndReturnSuccess_When_ApiReturnSuccess

import rx.observers.AssertableSubscriber; //导入依赖的package包/类
@Test
public void removeItem_CallsApiAndReturnSuccess_When_ApiReturnSuccess() {
    ItemId itemId = addNewItemSuccessfully();
    when(api.removeItem(itemId)).thenReturn(Single.just(ApiResponse.createSuccessfulResponse()));

    AssertableSubscriber<Response> subscriber = itemRepository.removeItem(itemId).test();
    RxJavaSchedulerUtils.advanceOneSecond();

    subscriber.assertReceivedOnNext(Collections.singletonList(Response.createSuccessfulResponse()))
            .assertCompleted();
    assertFalse(itemRepository.hasItem(itemId));
}
 
开发者ID:NikitaKozlov,项目名称:Switchman,代码行数:13,代码来源:ItemRepositoryTest_Part2_AddingAndRemoving.java


示例16: removeItem_CallsApiAndReturnFailed_When_ApiThrows

import rx.observers.AssertableSubscriber; //导入依赖的package包/类
@Test
public void removeItem_CallsApiAndReturnFailed_When_ApiThrows() {
    ItemId itemId = addNewItemSuccessfully();
    Throwable throwable = new RuntimeException();
    when(api.removeItem(itemId)).thenReturn(Single.error(throwable));
    Response.Cause cause = mock(Response.Cause.class);
    when(apiErrorConverter.convertApiError(new ExceptionApiError(throwable))).thenReturn(cause);

    AssertableSubscriber<Response> subscriber = itemRepository.removeItem(itemId).test();
    RxJavaSchedulerUtils.advanceOneSecond();

    subscriber.assertResult(Response.createFailedResponse(cause))
            .assertCompleted();
    assertTrue(itemRepository.hasItem(itemId));
}
 
开发者ID:NikitaKozlov,项目名称:Switchman,代码行数:16,代码来源:ItemRepositoryTest_Part2_AddingAndRemoving.java


示例17: AR_ResultIn010Counter

import rx.observers.AssertableSubscriber; //导入依赖的package包/类
@Test
public void AR_ResultIn010Counter() {
    ItemId itemId = mock(ItemId.class);

    when(api.addItem(itemId)).thenReturn(Single.just(ApiResponse.createSuccessfulResponse()));
    when(api.removeItem(itemId)).thenReturn(Single.just(ApiResponse.createSuccessfulResponse()));

    AssertableSubscriber<Integer> counterTestSubscriber = itemRepository.getCounter().test();

    itemRepository.addItem(itemId).test();
    itemRepository.removeItem(itemId).test();
    RxJavaSchedulerUtils.advanceOneSecond();

    counterTestSubscriber.assertReceivedOnNext(Arrays.asList(0, 1, 0));
}
 
开发者ID:NikitaKozlov,项目名称:Switchman,代码行数:16,代码来源:ItemRepositoryTest_Part3_CounterChanges.java


示例18: AR_ResultIn0101Counter_When_LastRemovalThrows

import rx.observers.AssertableSubscriber; //导入依赖的package包/类
@Test
public void AR_ResultIn0101Counter_When_LastRemovalThrows() {
    ItemId itemId = mock(ItemId.class);

    when(api.addItem(itemId)).thenReturn(Single.just(ApiResponse.createSuccessfulResponse()));
    when(api.removeItem(itemId)).thenReturn(Single.error(new RuntimeException()));

    AssertableSubscriber<Integer> counterTestSubscriber = itemRepository.getCounter().test();

    itemRepository.addItem(itemId).test();
    itemRepository.removeItem(itemId).test();
    RxJavaSchedulerUtils.advanceOneSecond();

    counterTestSubscriber.assertReceivedOnNext(Arrays.asList(0, 1, 0, 1));
}
 
开发者ID:NikitaKozlov,项目名称:Switchman,代码行数:16,代码来源:ItemRepositoryTest_Part3_CounterChanges.java


示例19: Add_ResultIn010Counter_When_AdditionFails

import rx.observers.AssertableSubscriber; //导入依赖的package包/类
@Test
public void Add_ResultIn010Counter_When_AdditionFails() {
    ItemId itemId = mock(ItemId.class);

    when(api.addItem(itemId)).thenReturn(Single.just(ApiResponse.createFailedResponse(
                    HttpStatus.BAD_REQUEST.value(), mock(ApiResponse.ApiError.class))));

    AssertableSubscriber<Integer> counterTestSubscriber = itemRepository.getCounter().test();

    itemRepository.addItem(itemId).test();
    RxJavaSchedulerUtils.advanceOneSecond();

    counterTestSubscriber.assertReceivedOnNext(Arrays.asList(0, 1, 0));
}
 
开发者ID:NikitaKozlov,项目名称:Switchman,代码行数:15,代码来源:ItemRepositoryTest_Part3_CounterChanges.java


示例20: insertIntoV1TriggersV1Query

import rx.observers.AssertableSubscriber; //导入依赖的package包/类
@Test public void insertIntoV1TriggersV1Query() {
  AssertableSubscriber<com.squareup.sqlbrite.SqlBrite.Query> subscriber =
      db1.createQuery(TABLE_EMPLOYEE, SELECT_EMPLOYEES).test();
  subscriber.assertValueCount(1);

  db1.insert(TABLE_EMPLOYEE, employee("Foo", "Bar"));
  subscriber.assertValueCount(2);
}
 
开发者ID:jiechic,项目名称:sqlbrite-sqlcipher,代码行数:9,代码来源:BriteDatabaseBridgeTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ConstantNode类代码示例发布时间:2022-05-22
下一篇:
Java ISO9075类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap