@Override
  public Optional<PersistentQueryMetadata> getPersistentQuery(final QueryId queryId) {
    return Optional.ofNullable(persistentQueries.get(queryId));
  }
@Test
  public void shouldCallListenerOnError() {
    // Given:
    final QueryMetadata.Listener queryListener = givenCreateGetListener(registry, "foo");
    final QueryMetadata query = registry.getPersistentQuery(new QueryId("foo")).get();
    final QueryError error = new QueryError(123L, "error", Type.USER);

    // When:
    queryListener.onError(query, error);

    // Then:
    verify(listener1).onError(query, error);
    verify(listener2).onError(query, error);
  }