@Override
  public Optional<QueryMetadata> getQuery(final QueryId queryId) {
    return Optional.ofNullable(allLiveQueries.get(queryId));
  }
@Test
  public void shouldGetQuery() {
    // Given:
    final TransientQueryMetadata q1 = givenCreateTransient(registry, "transient1");
    final PersistentQueryMetadata q2 = givenCreate(registry, "q1", "source",
        Optional.of("sink1"), CREATE_AS);
    final PersistentQueryMetadata q3 = givenCreate(registry, "q2", "source",
        Optional.empty(), CREATE_SOURCE);

    // When:
    final QueryMetadata queryMetadata1 = registry.getQuery(q1.getQueryId()).get();
    final QueryMetadata queryMetadata2 = registry.getQuery(q2.getQueryId()).get();
    final QueryMetadata queryMetadata3 = registry.getQuery(q3.getQueryId()).get();

    // Then:
    assertThat(queryMetadata1, is(q1));
    assertThat(queryMetadata2, is(q2));
    assertThat(queryMetadata3, is(q3));
  }