@Test public void collectSucceededNodesTest() { Set<Node> allNode = allNodeWithPostFix(); baseSaltJobRunner = new BaseSaltJobRunner(targetHostnames, allNode) { @Override public String submit(SaltConnector saltConnector) { return ""; } }; ApplyResponse applyResponse = new ApplyResponse(); List<Map<String, JsonNode>> resultList = new ArrayList<>(); Map<String, JsonNode> resultMap = new HashMap<>(); ObjectMapper objectMapper = new ObjectMapper(); resultMap.put("host-10-0-0-1.example.com", objectMapper.valueToTree("10.0.0.1")); resultMap.put("host-10-0-0-2.example.com", objectMapper.valueToTree("10.0.0.2")); resultMap.put("host-10-0-0-3.example.com", objectMapper.valueToTree("10.0.0.3")); resultList.add(resultMap); applyResponse.setResult(resultList); Set<String> collectedNodes = baseSaltJobRunner.collectSucceededNodes(applyResponse); Assert.assertEquals(3L, collectedNodes.size()); Assert.assertTrue(collectedNodes.contains("host-10-0-0-1.example.com")); Assert.assertTrue(collectedNodes.contains("host-10-0-0-2.example.com")); Assert.assertTrue(collectedNodes.contains("host-10-0-0-3.example.com")); }
public Set<String> collectSucceededNodes(ApplyResponse applyResponse) { Set<String> set = new HashSet<>(); for (Map<String, JsonNode> stringObjectMap : applyResponse.getResult()) { set.addAll(new ArrayList<>(stringObjectMap.keySet())); } return set; }
BaseSaltJobRunner implements SaltJobRunner { public Set<String> collectSucceededNodes(ApplyResponse applyResponse) { Set<String> set = new HashSet<>(); for (Map<String, JsonNode> stringObjectMap : applyResponse.getResult()) { set.addAll(new ArrayList<>(stringObjectMap.keySet())); } return set; } }
BaseSaltJobRunner implements SaltJobRunner { public Set<String> collectSucceededNodes(ApplyResponse applyResponse) { Set<String> set = new HashSet<>(); for (Map<String, JsonNode> stringObjectMap : applyResponse.getResult()) { set.addAll(new ArrayList<>(stringObjectMap.keySet())); } return set; } protected  BaseSaltJobRunner(Set<String> targetHostnames, Set<Node> allNode); }
BaseSaltJobRunner implements SaltJobRunner { public Set<String> collectSucceededNodes(ApplyResponse applyResponse) { Set<String> set = new HashSet<>(); for (Map<String, JsonNode> stringObjectMap : applyResponse.getResult()) { set.addAll(new ArrayList<>(stringObjectMap.keySet())); } return set; } protected  BaseSaltJobRunner(Set<String> targetHostnames, Set<Node> allNode); @Override Set<String> getTargetHostnames(); @Override void setTargetHostnames(Set<String> targetHostnames); @Override JobId getJid(); @Override void setJid(JobId jid); @Override JobState getJobState(); @Override void setJobState(JobState jobState); @Override Multimap<String, String> getNodesWithError(); @Override void setNodesWithError(Multimap<String, String> nodesWithError); @Override StateType stateType(); Set<String> collectSucceededNodes(ApplyResponse applyResponse); Set<String> collectMissingHostnames(Collection<String> succeededHostnames); Set<Node> getAllNode(); @Override String toString(); }
BaseSaltJobRunner implements SaltJobRunner { public Set<String> collectSucceededNodes(ApplyResponse applyResponse) { Set<String> set = new HashSet<>(); for (Map<String, JsonNode> stringObjectMap : applyResponse.getResult()) { set.addAll(new ArrayList<>(stringObjectMap.keySet())); } return set; } protected  BaseSaltJobRunner(Set<String> targetHostnames, Set<Node> allNode); @Override Set<String> getTargetHostnames(); @Override void setTargetHostnames(Set<String> targetHostnames); @Override JobId getJid(); @Override void setJid(JobId jid); @Override JobState getJobState(); @Override void setJobState(JobState jobState); @Override Multimap<String, String> getNodesWithError(); @Override void setNodesWithError(Multimap<String, String> nodesWithError); @Override StateType stateType(); Set<String> collectSucceededNodes(ApplyResponse applyResponse); Set<String> collectMissingHostnames(Collection<String> succeededHostnames); Set<Node> getAllNode(); @Override String toString();  }