@Test public void invokesManagerAsynchronouslyForAllClusters() throws Exception { when(data.listClusters(any())) .thenReturn(new ListClustersResponse(Arrays.asList(CLUSTER1, CLUSTER2))); when(manager.triggerAsync(input.capture())).thenReturn(CompletableFuture.completedFuture(null)); ReconcilerHandler handler = new ReconcilerHandler(data, manager); handler.handleRequest(new CloudWatchEvent<>(), null); assertThat( input.getAllValues(), hasItems(new ManagerInput(CLUSTER1), new ManagerInput(CLUSTER2))); }
@Override @SneakyThrows public Void handleRequest(CloudWatchEvent<Map> input, Context context) { log.debug("Reconciler request: {}", input); ListClustersResponse r = dataService.listClusters(ListClustersRequest.builder().build()); List<Cluster> clusters = r.getClusters(); clusters .stream() .map(c -> stateFunction.triggerAsync(new ManagerInput(c))) .collect(CompletableFutures.joinList()) .join(); return null; }
ReconcilerHandler implements RequestHandler<CloudWatchEvent<Map>, Void> { @Override @SneakyThrows public Void handleRequest(CloudWatchEvent<Map> input, Context context) { log.debug("Reconciler request: {}", input); ListClustersResponse r = dataService.listClusters(ListClustersRequest.builder().build()); List<Cluster> clusters = r.getClusters(); clusters .stream() .map(c -> stateFunction.triggerAsync(new ManagerInput(c))) .collect(CompletableFutures.joinList()) .join(); return null; } }
ReconcilerHandler implements RequestHandler<CloudWatchEvent<Map>, Void> { @Override @SneakyThrows public Void handleRequest(CloudWatchEvent<Map> input, Context context) { log.debug("Reconciler request: {}", input); ListClustersResponse r = dataService.listClusters(ListClustersRequest.builder().build()); List<Cluster> clusters = r.getClusters(); clusters .stream() .map(c -> stateFunction.triggerAsync(new ManagerInput(c))) .collect(CompletableFutures.joinList()) .join(); return null; }  }
ReconcilerHandler implements RequestHandler<CloudWatchEvent<Map>, Void> { @Override @SneakyThrows public Void handleRequest(CloudWatchEvent<Map> input, Context context) { log.debug("Reconciler request: {}", input); ListClustersResponse r = dataService.listClusters(ListClustersRequest.builder().build()); List<Cluster> clusters = r.getClusters(); clusters .stream() .map(c -> stateFunction.triggerAsync(new ManagerInput(c))) .collect(CompletableFutures.joinList()) .join(); return null; }  @Override @SneakyThrows // TODO add checked exception handling Void handleRequest(CloudWatchEvent<Map> input, Context context); }
ReconcilerHandler implements RequestHandler<CloudWatchEvent<Map>, Void> { @Override @SneakyThrows public Void handleRequest(CloudWatchEvent<Map> input, Context context) { log.debug("Reconciler request: {}", input); ListClustersResponse r = dataService.listClusters(ListClustersRequest.builder().build()); List<Cluster> clusters = r.getClusters(); clusters .stream() .map(c -> stateFunction.triggerAsync(new ManagerInput(c))) .collect(CompletableFutures.joinList()) .join(); return null; }  @Override @SneakyThrows // TODO add checked exception handling Void handleRequest(CloudWatchEvent<Map> input, Context context);  }