@Test public void getCluster_otherClusterId_returnsEmpty() throws Exception { expect(adminClient.describeCluster(anyObject())).andReturn(describeClusterResult); expect(describeClusterResult.clusterId()).andReturn(KafkaFuture.completedFuture(CLUSTER_ID)); expect(describeClusterResult.controller()).andReturn(KafkaFuture.completedFuture(NODE_1)); expect(describeClusterResult.nodes()).andReturn(KafkaFuture.completedFuture(NODES)); replay(adminClient, describeClusterResult); Optional<Cluster> cluster = clusterManager.getCluster("foobar").get(); assertFalse(cluster.isPresent()); }
@Override public CompletableFuture<Optional<Cluster>> getCluster(String clusterId) { requireNonNull(clusterId); return listClusters() .thenApply(clusters -> findEntityByKey(clusters, Cluster::getClusterId, clusterId)); }
ClusterManagerImpl implements ClusterManager { @Override public CompletableFuture<Optional<Cluster>> getCluster(String clusterId) { requireNonNull(clusterId); return listClusters() .thenApply(clusters -> findEntityByKey(clusters, Cluster::getClusterId, clusterId)); } }
ClusterManagerImpl implements ClusterManager { @Override public CompletableFuture<Optional<Cluster>> getCluster(String clusterId) { requireNonNull(clusterId); return listClusters() .thenApply(clusters -> findEntityByKey(clusters, Cluster::getClusterId, clusterId)); } @Inject  ClusterManagerImpl(Admin adminClient); }
ClusterManagerImpl implements ClusterManager { @Override public CompletableFuture<Optional<Cluster>> getCluster(String clusterId) { requireNonNull(clusterId); return listClusters() .thenApply(clusters -> findEntityByKey(clusters, Cluster::getClusterId, clusterId)); } @Inject  ClusterManagerImpl(Admin adminClient); @Override CompletableFuture<List<Cluster>> listClusters(); @Override CompletableFuture<Optional<Cluster>> getCluster(String clusterId); @Override CompletableFuture<Cluster> getLocalCluster(); }
ClusterManagerImpl implements ClusterManager { @Override public CompletableFuture<Optional<Cluster>> getCluster(String clusterId) { requireNonNull(clusterId); return listClusters() .thenApply(clusters -> findEntityByKey(clusters, Cluster::getClusterId, clusterId)); } @Inject  ClusterManagerImpl(Admin adminClient); @Override CompletableFuture<List<Cluster>> listClusters(); @Override CompletableFuture<Optional<Cluster>> getCluster(String clusterId); @Override CompletableFuture<Cluster> getLocalCluster();  }