  @Test
  public void getResourceReferencesReturnsExpectedReferencesForValidV3ResourceMessages() {

    String clusterServiceName = "clusterWithServiceName0";
    io.envoyproxy.envoy.config.cluster.v3.Cluster clusterWithServiceName = io.envoyproxy.envoy.config.cluster.v3.Cluster
        .newBuilder()
        .setName(V3_CLUSTER_NAME)
        .setEdsClusterConfig(
            io.envoyproxy.envoy.config.cluster.v3.Cluster.EdsClusterConfig.newBuilder()
                .setServiceName(clusterServiceName))
        .setType(io.envoyproxy.envoy.config.cluster.v3.Cluster.DiscoveryType.EDS)
        .build();

    Map<Collection<Message>, Set<String>> cases = ImmutableMap.<Collection<Message>, Set<String>>builder()
        .put(ImmutableList.of(V3_CLUSTER), ImmutableSet.of(V3_CLUSTER_NAME))
        .put(ImmutableList.of(clusterWithServiceName), ImmutableSet.of(clusterServiceName))
        .put(ImmutableList.of(V3_ENDPOINT), ImmutableSet.of())
        .put(ImmutableList.of(V3_LISTENER), ImmutableSet.of(V3_ROUTE_NAME))
        .put(ImmutableList.of(V3_ROUTE), ImmutableSet.of())
        .put(ImmutableList.of(V3_CLUSTER, V3_ENDPOINT, V3_LISTENER, V3_ROUTE),
            ImmutableSet.of(V3_CLUSTER_NAME, V3_ROUTE_NAME))
        .build();

    cases.forEach((resources, refs) ->
        assertThat(Resources.getResourceReferences(resources)).containsExactlyElementsOf(refs));
  }