@Test public void canGetCompleteListOfChannelsForAUser() { List<Channel> expectedList = buildExpectedChannelsList(); PersistedChannelService persistedChannelService = buildPersistedChannelService(); Observable<Channels> channelsObservable = persistedChannelService.getChannelsFor(user); TestObserver<Channels> channelsTestObserver = new TestObserver<>(); channelsObservable.subscribe(channelsTestObserver); channelsTestObserver.assertValues(new Channels(expectedList)); }
@Override public Observable<Channels> getChannelsFor(User user) { return Observable.combineLatest(publicChannels(), privateChannelsFor(user), mergeChannels()); }
PersistedChannelService implements ChannelService { @Override public Observable<Channels> getChannelsFor(User user) { return Observable.combineLatest(publicChannels(), privateChannelsFor(user), mergeChannels()); } }
PersistedChannelService implements ChannelService { @Override public Observable<Channels> getChannelsFor(User user) { return Observable.combineLatest(publicChannels(), privateChannelsFor(user), mergeChannels()); } PersistedChannelService(ChannelsDatabase channelsDatabase, UserDatabase userDatabase); }
PersistedChannelService implements ChannelService { @Override public Observable<Channels> getChannelsFor(User user) { return Observable.combineLatest(publicChannels(), privateChannelsFor(user), mergeChannels()); } PersistedChannelService(ChannelsDatabase channelsDatabase, UserDatabase userDatabase); @Override Observable<Channels> getChannelsFor(User user); @Override Observable<DatabaseResult<Channel>> createPublicChannel(Channel newChannel); @Override Observable<DatabaseResult<Channel>> createPrivateChannel(final Channel newChannel, User owner); @Override Observable<DatabaseResult<User>> addOwnerToPrivateChannel(final Channel channel, final User newOwner); @Override Observable<DatabaseResult<User>> removeOwnerFromPrivateChannel(final Channel channel, final User removedOwner); @Override Observable<DatabaseResult<Users>> getOwnersOfChannel(Channel channel); }
PersistedChannelService implements ChannelService { @Override public Observable<Channels> getChannelsFor(User user) { return Observable.combineLatest(publicChannels(), privateChannelsFor(user), mergeChannels()); } PersistedChannelService(ChannelsDatabase channelsDatabase, UserDatabase userDatabase); @Override Observable<Channels> getChannelsFor(User user); @Override Observable<DatabaseResult<Channel>> createPublicChannel(Channel newChannel); @Override Observable<DatabaseResult<Channel>> createPrivateChannel(final Channel newChannel, User owner); @Override Observable<DatabaseResult<User>> addOwnerToPrivateChannel(final Channel channel, final User newOwner); @Override Observable<DatabaseResult<User>> removeOwnerFromPrivateChannel(final Channel channel, final User removedOwner); @Override Observable<DatabaseResult<Users>> getOwnersOfChannel(Channel channel);  }