@Test public void getConsumer_nonExistingConsumerGroup_throwsNotFound() throws Exception { expect(consumerGroupManager.getConsumerGroup(CLUSTER_ID, CONSUMER_GROUP.getConsumerGroupId())) .andReturn(completedFuture(Optional.empty())); replay(consumerGroupManager); try { consumerManager.getConsumer( CLUSTER_ID, CONSUMER_GROUP.getConsumerGroupId(), CONSUMERS[0].getConsumerId()) .get(); fail(); } catch (ExecutionException e) { assertEquals(NotFoundException.class, e.getCause().getClass()); } }
@Override public CompletableFuture<Optional<Consumer>> getConsumer( String clusterId, String consumerGroupId, String consumerId) { return listConsumers(clusterId, consumerGroupId) .thenApply( consumers -> findEntityByKey(consumers, Consumer::getConsumerId, consumerId)); }
ConsumerManagerImpl implements ConsumerManager { @Override public CompletableFuture<Optional<Consumer>> getConsumer( String clusterId, String consumerGroupId, String consumerId) { return listConsumers(clusterId, consumerGroupId) .thenApply( consumers -> findEntityByKey(consumers, Consumer::getConsumerId, consumerId)); } }
ConsumerManagerImpl implements ConsumerManager { @Override public CompletableFuture<Optional<Consumer>> getConsumer( String clusterId, String consumerGroupId, String consumerId) { return listConsumers(clusterId, consumerGroupId) .thenApply( consumers -> findEntityByKey(consumers, Consumer::getConsumerId, consumerId)); } @Inject  ConsumerManagerImpl(ConsumerGroupManager consumerGroupManager); }
ConsumerManagerImpl implements ConsumerManager { @Override public CompletableFuture<Optional<Consumer>> getConsumer( String clusterId, String consumerGroupId, String consumerId) { return listConsumers(clusterId, consumerGroupId) .thenApply( consumers -> findEntityByKey(consumers, Consumer::getConsumerId, consumerId)); } @Inject  ConsumerManagerImpl(ConsumerGroupManager consumerGroupManager); @Override CompletableFuture<List<Consumer>> listConsumers(String clusterId, String consumerGroupId); @Override CompletableFuture<Optional<Consumer>> getConsumer(
      String clusterId, String consumerGroupId, String consumerId); }
ConsumerManagerImpl implements ConsumerManager { @Override public CompletableFuture<Optional<Consumer>> getConsumer( String clusterId, String consumerGroupId, String consumerId) { return listConsumers(clusterId, consumerGroupId) .thenApply( consumers -> findEntityByKey(consumers, Consumer::getConsumerId, consumerId)); } @Inject  ConsumerManagerImpl(ConsumerGroupManager consumerGroupManager); @Override CompletableFuture<List<Consumer>> listConsumers(String clusterId, String consumerGroupId); @Override CompletableFuture<Optional<Consumer>> getConsumer(
      String clusterId, String consumerGroupId, String consumerId);  }