RealNodeRepository implements NodeRepository { @Override public List<NodeSpec> getNodes(String baseHostName) { String path = "/nodes/v2/node/?recursive=true&parentHost=" + baseHostName; final GetNodesResponse nodesForHost = configServerApi.get(path, GetNodesResponse.class); return nodesForHost.nodes.stream() .map(RealNodeRepository::createNodeSpec) .collect(Collectors.toList()); } RealNodeRepository(ConfigServerApi configServerApi); @Override void addNodes(List<AddNode> nodes); @Override List<NodeSpec> getNodes(String baseHostName); @Override Optional<NodeSpec> getOptionalNode(String hostName); @Override Map<String, Acl> getAcls(String hostName); @Override void updateNodeAttributes(String hostName, NodeAttributes nodeAttributes); @Override void setNodeState(String hostName, NodeState nodeState); static NodeRepositoryNode nodeRepositoryNodeFromNodeAttributes(NodeAttributes nodeAttributes);  }
@Test public void testGetContainersToRunApi() { String dockerHostHostname = "dockerhost1.yahoo.com"; List<NodeSpec> containersToRun = nodeRepositoryApi.getNodes(dockerHostHostname); assertThat(containersToRun.size(), is(1)); NodeSpec node = containersToRun.get(0); assertThat(node.hostname(), is("host4.yahoo.com")); assertThat(node.wantedDockerImage().get(), is(DockerImage.fromString("docker-registry.domain.tld:8080/dist/vespa:6.42.0"))); assertThat(node.state(), is(NodeState.active)); assertThat(node.wantedRestartGeneration().get(), is(0L)); assertThat(node.currentRestartGeneration().get(), is(0L)); assertEquals(1, node.vcpu(), delta); assertEquals(4, node.memoryGb(), delta); assertEquals(100, node.diskGb(), delta); }