InMemoryQueryRepository extends AbstractScheduledService implements QueryRepository { @Override public Set<StreamsQuery> list() throws QueryRepositoryException, IllegalStateException { lock.lock(); try { checkState(); updateCache(); return queriesCache.values() .stream() .collect(Collectors.toSet()); } finally { lock.unlock(); } } InMemoryQueryRepository(final QueryChangeLog changeLog, final Scheduler scheduler); @Override StreamsQuery add(final String query, final boolean isActive, final boolean isInsert); @Override Optional<StreamsQuery> get(final UUID queryId); @Override void updateIsActive(final UUID queryId, final boolean isActive); @Override void delete(final UUID queryId); @Override Set<StreamsQuery> list(); @Override Set<StreamsQuery> subscribe(final QueryChangeLogListener listener); @Override void unsubscribe(final QueryChangeLogListener listener);  }
@Test(expected = RuntimeException.class) public void changeLogThrowsExceptions() throws Exception { final QueryChangeLog changeLog = mock(QueryChangeLog.class); when(changeLog.readFromStart()).thenThrow(new QueryChangeLogException("Mocked exception.")); final QueryRepository queries = new InMemoryQueryRepository( changeLog, SCHEDULE ); queries.list(); }