StreamCacheService extends AbstractIdleService { public Collection<Stream> getByName(String name) { return nameToStream.get(name); } @Inject  StreamCacheService(EventBus eventBus,
                              StreamService streamService,
                              @Named("daemonScheduler") ScheduledExecutorService executorService); @Subscribe void handleStreamUpdate(StreamsChangedEvent event); @VisibleForTesting void updateStreams(Collection<String> ids); Collection<Stream> getByName(String name); @Nullable Stream getById(String id);  }
@Test public void getByName() throws Exception { final StreamCacheService streamCacheService = new StreamCacheService(new EventBus(), mock(StreamService.class), Executors.newSingleThreadScheduledExecutor()); final Collection<Stream> streams = streamCacheService.getByName("nonexisting"); assertThat(streams).isNotNull().isEmpty(); }