@Test public void listBrokers_nonExistingCluster_throwsNotFound() throws Exception { expect(clusterManager.getCluster(CLUSTER_ID)) .andReturn(CompletableFuture.completedFuture(Optional.empty())); replay(clusterManager); try { brokerManager.listBrokers(CLUSTER_ID).get(); fail(); } catch (ExecutionException e) { assertEquals(NotFoundException.class, e.getCause().getClass()); } }
@Override public CompletableFuture<List<Broker>> listBrokers(String clusterId) { return clusterManager.getCluster(clusterId) .thenApply(cluster -> checkEntityExists(cluster, "Cluster %s cannot be found.", clusterId)) .thenApply(Cluster::getBrokers); }
BrokerManagerImpl implements BrokerManager { @Override public CompletableFuture<List<Broker>> listBrokers(String clusterId) { return clusterManager.getCluster(clusterId) .thenApply(cluster -> checkEntityExists(cluster, "Cluster %s cannot be found.", clusterId)) .thenApply(Cluster::getBrokers); } }
BrokerManagerImpl implements BrokerManager { @Override public CompletableFuture<List<Broker>> listBrokers(String clusterId) { return clusterManager.getCluster(clusterId) .thenApply(cluster -> checkEntityExists(cluster, "Cluster %s cannot be found.", clusterId)) .thenApply(Cluster::getBrokers); } @Inject  BrokerManagerImpl(ClusterManager clusterManager); }
BrokerManagerImpl implements BrokerManager { @Override public CompletableFuture<List<Broker>> listBrokers(String clusterId) { return clusterManager.getCluster(clusterId) .thenApply(cluster -> checkEntityExists(cluster, "Cluster %s cannot be found.", clusterId)) .thenApply(Cluster::getBrokers); } @Inject  BrokerManagerImpl(ClusterManager clusterManager); @Override CompletableFuture<List<Broker>> listBrokers(String clusterId); @Override CompletableFuture<Optional<Broker>> getBroker(String clusterId, int brokerId); @Override CompletableFuture<List<Broker>> listLocalBrokers(); }
BrokerManagerImpl implements BrokerManager { @Override public CompletableFuture<List<Broker>> listBrokers(String clusterId) { return clusterManager.getCluster(clusterId) .thenApply(cluster -> checkEntityExists(cluster, "Cluster %s cannot be found.", clusterId)) .thenApply(Cluster::getBrokers); } @Inject  BrokerManagerImpl(ClusterManager clusterManager); @Override CompletableFuture<List<Broker>> listBrokers(String clusterId); @Override CompletableFuture<Optional<Broker>> getBroker(String clusterId, int brokerId); @Override CompletableFuture<List<Broker>> listLocalBrokers();  }