@Test public void storeImpression_noErrors_storesAppendedCampaigns() { when(storageClient.read(any(CampaignImpressionsParser.class))) .thenReturn( Maybe.just( CampaignImpressionList.newBuilder() .addAlreadySeenCampaigns(campaignImpression) .build())); ArgumentCaptor<CampaignImpressionList> campaignImpressionListArgumentCaptor = ArgumentCaptor.forClass(CampaignImpressionList.class); impressionStorageClient.storeImpression(campaignImpression).subscribe(); verify(storageClient).write(campaignImpressionListArgumentCaptor.capture()); assertThat(campaignImpressionListArgumentCaptor.getValue().getAlreadySeenCampaignsList()) .containsExactly(campaignImpression, campaignImpression); }
public Completable storeImpression(CampaignImpression impression) { return getAllImpressions() .defaultIfEmpty(EMPTY_IMPRESSIONS) .flatMapCompletable( storedImpressions -> { CampaignImpressionList appendedImpressions = appendImpression(storedImpressions, impression); return storageClient .write(appendedImpressions) .doOnComplete(() -> initInMemCache(appendedImpressions)); }); }
ImpressionStorageClient { public Completable storeImpression(CampaignImpression impression) { return getAllImpressions() .defaultIfEmpty(EMPTY_IMPRESSIONS) .flatMapCompletable( storedImpressions -> { CampaignImpressionList appendedImpressions = appendImpression(storedImpressions, impression); return storageClient .write(appendedImpressions) .doOnComplete(() -> initInMemCache(appendedImpressions)); }); } }
ImpressionStorageClient { public Completable storeImpression(CampaignImpression impression) { return getAllImpressions() .defaultIfEmpty(EMPTY_IMPRESSIONS) .flatMapCompletable( storedImpressions -> { CampaignImpressionList appendedImpressions = appendImpression(storedImpressions, impression); return storageClient .write(appendedImpressions) .doOnComplete(() -> initInMemCache(appendedImpressions)); }); } @Inject  ImpressionStorageClient(@ImpressionStore ProtoStorageClient storageClient); }
ImpressionStorageClient { public Completable storeImpression(CampaignImpression impression) { return getAllImpressions() .defaultIfEmpty(EMPTY_IMPRESSIONS) .flatMapCompletable( storedImpressions -> { CampaignImpressionList appendedImpressions = appendImpression(storedImpressions, impression); return storageClient .write(appendedImpressions) .doOnComplete(() -> initInMemCache(appendedImpressions)); }); } @Inject  ImpressionStorageClient(@ImpressionStore ProtoStorageClient storageClient); Completable storeImpression(CampaignImpression impression); Maybe<CampaignImpressionList> getAllImpressions(); Single<Boolean> isImpressed(CampaignProto.ThickContent content); Completable clearImpressions(FetchEligibleCampaignsResponse response); }
ImpressionStorageClient { public Completable storeImpression(CampaignImpression impression) { return getAllImpressions() .defaultIfEmpty(EMPTY_IMPRESSIONS) .flatMapCompletable( storedImpressions -> { CampaignImpressionList appendedImpressions = appendImpression(storedImpressions, impression); return storageClient .write(appendedImpressions) .doOnComplete(() -> initInMemCache(appendedImpressions)); }); } @Inject  ImpressionStorageClient(@ImpressionStore ProtoStorageClient storageClient); Completable storeImpression(CampaignImpression impression); Maybe<CampaignImpressionList> getAllImpressions(); Single<Boolean> isImpressed(CampaignProto.ThickContent content); Completable clearImpressions(FetchEligibleCampaignsResponse response);  }