@Override
  public Set<QueryId> getQueriesWithSink(final SourceName sourceName) {
    final ImmutableSet.Builder<QueryId> queries = ImmutableSet.builder();

    if (createAsQueries.containsKey(sourceName)) {
      queries.add(createAsQueries.get(sourceName));
    }

    queries.addAll(getInsertQueries(sourceName, FILTER_QUERIES_WITH_SINK));
    return queries.build();
  }
@Test
  public void shouldGetQueriesWithSink() {
    // Given:
    givenCreate(registry, "q1", "source", Optional.of("sink1"), CREATE_AS);
    givenCreate(registry, "q2", "source", Optional.of("sink1"), INSERT);
    givenCreate(registry, "q3", "source", Optional.of("sink2"), INSERT);
    givenCreate(registry, "q4", "source", Optional.empty(), CREATE_SOURCE);

    // When:
    final Set<QueryId> queries = registry.getQueriesWithSink(SourceName.of("sink1"));

    // Then:
    assertThat(queries, contains(new QueryId("q1"), new QueryId("q2")));
  }