### Question:
SolverScheduler implements Runnable { @Override public void run() { try { Iterator<GroupElement> solveIter = solverQueues.takeIterator(id); while (solveIter.hasNext()) { final GroupElement gElement = solveIter.next(); final Element solveElement = gElement.getElement(); final ListenableFuture<String> future = executorService.submit(new SolverRunner(gElement)); future.addListener(new Runnable() { @Override public void run() { try { solverQueues.recordProgress(id, gElement.getQueueName(), solveElement.getId(), TrackingQueue.ConsumingStatus.FINISHED_SUCCESSFULLY, future.get()); } catch (Exception e) { LOG.error("Unable to record progress for cluster {}", solveElement.getId()); } } }, executorService); } } catch (Exception e) { LOG.error("Got exception:", e); } } @Inject private  SolverScheduler(@Named("scheduler.id") String id, Solver solver,
                          ClusterStoreService clusterStoreService,
                          QueueService queueService,
                          @Named("solver.executor.service") ListeningExecutorService executorService,
                          TaskService taskService, ServerStats serverStats, IdService idService, Gson gson); @Override void run();  }### Answer:
@Test public void testAddCluster() throws Exception { String clusterName = "my-cluster"; Cluster cluster = Cluster.builder() .setID("1") .setAccount(account) .setName(clusterName) .setDescription("my cluster") .setClusterTemplate(reactorTemplate) .setProvider(provider) .build(); ClusterJob job = new ClusterJob(new JobId(cluster.getId(), 1), ClusterAction.CLUSTER_CREATE); cluster.setLatestJobId(job.getJobId()); clusterStoreService.getView(cluster.getAccount()).writeCluster(cluster); clusterStore.writeClusterJob(job); ClusterCreateRequest createRequest = ClusterCreateRequest.builder() .setName(cluster.getName()) .setDescription(cluster.getDescription()) .setClusterTemplateName(reactorTemplate.getName()) .setNumMachines(5) .setInitialLeaseDuration(0L) .build(); SolverRequest solverRequest = new SolverRequest(SolverRequest.Type.CREATE_CLUSTER, gson.toJson(createRequest)); String queueName = "tenant123"; solverQueues.add(queueName, new Element(cluster.getId(), gson.toJson(solverRequest))); solverScheduler.run(); Cluster solvedCluster = clusterStoreService.getView(cluster.getAccount()).getCluster(cluster.getId()); Assert.assertEquals(clusterName, solvedCluster.getName()); Assert.assertEquals("my cluster", solvedCluster.getDescription()); Multiset<Set<String>> serviceSetCounts = HashMultiset.create(); for (String nodeId : solvedCluster.getNodeIDs()) { Node node = clusterStore.getNode(nodeId); Set<String> serviceNames = Sets.newHashSet(Iterables.transform(node.getServices(), new Function<Service, String>() { @Nullable @Override public String apply(Service input) { return input.getName(); } })); serviceSetCounts.add(serviceNames); } Assert.assertEquals(1, serviceSetCounts.count(ImmutableSet.of("namenode", "resourcemanager", "hbasemaster"))); Assert.assertEquals(3, serviceSetCounts.count(ImmutableSet.of("datanode", "regionserver", "nodemanager"))); Assert.assertEquals(1, serviceSetCounts.count(ImmutableSet.of("reactor", "zookeeper"))); Element element = clusterQueues.take(queueName, "0"); Assert.assertEquals(cluster.getId(), element.getId()); solverQueues.removeAll(queueName); clusterQueues.removeAll(queueName); }