@Test public void canGetOwnersOfSpecificChannel() { Users expectedUsersList = buildExpectedUsers(); PersistedChannelService persistedChannelService = buildPersistedChannelService(); Observable<DatabaseResult<Users>> channelsObservable = persistedChannelService.getOwnersOfChannel(privateChannel); TestObserver<DatabaseResult<Users>> usersTestObserver = new TestObserver<>(); channelsObservable.subscribe(usersTestObserver); usersTestObserver.assertValues(new DatabaseResult<>(expectedUsersList)); }
@Override public Observable<DatabaseResult<Users>> getOwnersOfChannel(Channel channel) { return channelsDatabase.observeOwnerIdsFor(channel) .flatMap(getUsersFromIds()) .onErrorReturn(DatabaseResult.<Users>errorAsDatabaseResult()); }
PersistedChannelService implements ChannelService { @Override public Observable<DatabaseResult<Users>> getOwnersOfChannel(Channel channel) { return channelsDatabase.observeOwnerIdsFor(channel) .flatMap(getUsersFromIds()) .onErrorReturn(DatabaseResult.<Users>errorAsDatabaseResult()); } }
PersistedChannelService implements ChannelService { @Override public Observable<DatabaseResult<Users>> getOwnersOfChannel(Channel channel) { return channelsDatabase.observeOwnerIdsFor(channel) .flatMap(getUsersFromIds()) .onErrorReturn(DatabaseResult.<Users>errorAsDatabaseResult()); } PersistedChannelService(ChannelsDatabase channelsDatabase, UserDatabase userDatabase); }
PersistedChannelService implements ChannelService { @Override public Observable<DatabaseResult<Users>> getOwnersOfChannel(Channel channel) { return channelsDatabase.observeOwnerIdsFor(channel) .flatMap(getUsersFromIds()) .onErrorReturn(DatabaseResult.<Users>errorAsDatabaseResult()); } 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<DatabaseResult<Users>> getOwnersOfChannel(Channel channel) { return channelsDatabase.observeOwnerIdsFor(channel) .flatMap(getUsersFromIds()) .onErrorReturn(DatabaseResult.<Users>errorAsDatabaseResult()); } 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);  }