@Test public void submit() { Set<String> targets = new HashSet<>(); targets.add("10-0-0-1.example.com"); targets.add("10-0-0-2.example.com"); targets.add("10-0-0-3.example.com"); Set<Node> allNode = new HashSet<>(); allNode.add(new Node("10.0.0.1", "5.5.5.1", "i-1234", "m5.xlarge", "10-0-0-1.example.com", "hg")); allNode.add(new Node("10.0.0.2", "5.5.5.2", "i-1234", "m5.xlarge", "10-0-0-2.example.com", "hg")); allNode.add(new Node("10.0.0.3", "5.5.5.3", "i-1234", "m5.xlarge", "10-0-0-3.example.com", "hg")); PowerMockito.mockStatic(SaltStates.class); ApplyResponse applyResponse = new ApplyResponse(); List<Map<String, JsonNode>> result = new ArrayList<>(); Map<String, JsonNode> nodes = new HashMap<>(); ObjectMapper objectMapper = new ObjectMapper(); nodes.put("10-0-0-1.example.com", objectMapper.valueToTree("something")); nodes.put("10-0-0-2.example.com", objectMapper.valueToTree("something")); result.add(nodes); applyResponse.setResult(result); PowerMockito.when(SaltStates.syncAll(any())).thenReturn(applyResponse); SyncAllRunner syncAllRunner = new SyncAllRunner(targets, allNode); SaltConnector saltConnector = Mockito.mock(SaltConnector.class); String missingIps = syncAllRunner.submit(saltConnector); assertThat(syncAllRunner.getTargetHostnames(), hasItems("10-0-0-3.example.com")); assertEquals("[10-0-0-3.example.com]", missingIps); }
@Override public String submit(SaltConnector saltConnector) { ApplyResponse grainsResult = SaltStates.syncAll(saltConnector); Set<String> strings = collectMissingHostnames(collectSucceededNodes(grainsResult)); setTargetHostnames(strings); return strings.toString(); }
SyncAllRunner extends BaseSaltJobRunner { @Override public String submit(SaltConnector saltConnector) { ApplyResponse grainsResult = SaltStates.syncAll(saltConnector); Set<String> strings = collectMissingHostnames(collectSucceededNodes(grainsResult)); setTargetHostnames(strings); return strings.toString(); } }
SyncAllRunner extends BaseSaltJobRunner { @Override public String submit(SaltConnector saltConnector) { ApplyResponse grainsResult = SaltStates.syncAll(saltConnector); Set<String> strings = collectMissingHostnames(collectSucceededNodes(grainsResult)); setTargetHostnames(strings); return strings.toString(); } SyncAllRunner(Set<String> targetHostnames, Set<Node> allNode); }
SyncAllRunner extends BaseSaltJobRunner { @Override public String submit(SaltConnector saltConnector) { ApplyResponse grainsResult = SaltStates.syncAll(saltConnector); Set<String> strings = collectMissingHostnames(collectSucceededNodes(grainsResult)); setTargetHostnames(strings); return strings.toString(); } SyncAllRunner(Set<String> targetHostnames, Set<Node> allNode); @Override String submit(SaltConnector saltConnector); @Override String toString(); }
SyncAllRunner extends BaseSaltJobRunner { @Override public String submit(SaltConnector saltConnector) { ApplyResponse grainsResult = SaltStates.syncAll(saltConnector); Set<String> strings = collectMissingHostnames(collectSucceededNodes(grainsResult)); setTargetHostnames(strings); return strings.toString(); } SyncAllRunner(Set<String> targetHostnames, Set<Node> allNode); @Override String submit(SaltConnector saltConnector); @Override String toString();  }