@Test public void testResultSummary() { Map<String, List<RunnerInfo>> res = JidInfoResponseTransformer.getHighStates(saltResponseData); RunnerInfo noExtraInfo = res.get("host-10-0-0-6.openstacklocal").get(0); Map<String, String> expectedErrorResultSummary = Map.of( "Name", "/etc/hosts", "Comment", "No changes needed to be made" ); assertEquals("No changes needed to be made", noExtraInfo.getComment()); assertEquals("null", noExtraInfo.getStderr()); assertEquals(expectedErrorResultSummary, noExtraInfo.getErrorResultSummary()); }
public static Map<String, List<RunnerInfo>> getHighStates(Map<String, List<Map<String, Object>>> map) { Map<String, Object> stringObjectMap; stringObjectMap = isOldSalt(map) ? (Map<String, Object>) map.get("return").get(0).get("data") : map.get("return").get(0); Map<String, List<RunnerInfo>> result = new HashMap<>(); for (Entry<String, Object> stringObjectEntry : stringObjectMap.entrySet()) { if (stringObjectEntry.getValue() instanceof Map) { Map<String, Map<String, Object>> mapValue = (Map<String, Map<String, Object>>) stringObjectEntry.getValue(); result.put(stringObjectEntry.getKey(), runnerInfoObjects(mapValue)); } else if (stringObjectEntry.getValue() instanceof List) { List<String> listValue = (List<String>) stringObjectEntry.getValue(); if (!listValue.isEmpty()) { String errorMessage = listValue.stream().reduce((s, s2) -> s + "; " + s2).get(); throw new RuntimeException("Salt execution went wrong: " + errorMessage); } } else { throw new UnsupportedOperationException("Not supported Salt response: " + stringObjectEntry.getValue().getClass()); } } return result; }
JidInfoResponseTransformer { public static Map<String, List<RunnerInfo>> getHighStates(Map<String, List<Map<String, Object>>> map) { Map<String, Object> stringObjectMap; stringObjectMap = isOldSalt(map) ? (Map<String, Object>) map.get("return").get(0).get("data") : map.get("return").get(0); Map<String, List<RunnerInfo>> result = new HashMap<>(); for (Entry<String, Object> stringObjectEntry : stringObjectMap.entrySet()) { if (stringObjectEntry.getValue() instanceof Map) { Map<String, Map<String, Object>> mapValue = (Map<String, Map<String, Object>>) stringObjectEntry.getValue(); result.put(stringObjectEntry.getKey(), runnerInfoObjects(mapValue)); } else if (stringObjectEntry.getValue() instanceof List) { List<String> listValue = (List<String>) stringObjectEntry.getValue(); if (!listValue.isEmpty()) { String errorMessage = listValue.stream().reduce((s, s2) -> s + "; " + s2).get(); throw new RuntimeException("Salt execution went wrong: " + errorMessage); } } else { throw new UnsupportedOperationException("Not supported Salt response: " + stringObjectEntry.getValue().getClass()); } } return result; } }
JidInfoResponseTransformer { public static Map<String, List<RunnerInfo>> getHighStates(Map<String, List<Map<String, Object>>> map) { Map<String, Object> stringObjectMap; stringObjectMap = isOldSalt(map) ? (Map<String, Object>) map.get("return").get(0).get("data") : map.get("return").get(0); Map<String, List<RunnerInfo>> result = new HashMap<>(); for (Entry<String, Object> stringObjectEntry : stringObjectMap.entrySet()) { if (stringObjectEntry.getValue() instanceof Map) { Map<String, Map<String, Object>> mapValue = (Map<String, Map<String, Object>>) stringObjectEntry.getValue(); result.put(stringObjectEntry.getKey(), runnerInfoObjects(mapValue)); } else if (stringObjectEntry.getValue() instanceof List) { List<String> listValue = (List<String>) stringObjectEntry.getValue(); if (!listValue.isEmpty()) { String errorMessage = listValue.stream().reduce((s, s2) -> s + "; " + s2).get(); throw new RuntimeException("Salt execution went wrong: " + errorMessage); } } else { throw new UnsupportedOperationException("Not supported Salt response: " + stringObjectEntry.getValue().getClass()); } } return result; } private  JidInfoResponseTransformer(); }
JidInfoResponseTransformer { public static Map<String, List<RunnerInfo>> getHighStates(Map<String, List<Map<String, Object>>> map) { Map<String, Object> stringObjectMap; stringObjectMap = isOldSalt(map) ? (Map<String, Object>) map.get("return").get(0).get("data") : map.get("return").get(0); Map<String, List<RunnerInfo>> result = new HashMap<>(); for (Entry<String, Object> stringObjectEntry : stringObjectMap.entrySet()) { if (stringObjectEntry.getValue() instanceof Map) { Map<String, Map<String, Object>> mapValue = (Map<String, Map<String, Object>>) stringObjectEntry.getValue(); result.put(stringObjectEntry.getKey(), runnerInfoObjects(mapValue)); } else if (stringObjectEntry.getValue() instanceof List) { List<String> listValue = (List<String>) stringObjectEntry.getValue(); if (!listValue.isEmpty()) { String errorMessage = listValue.stream().reduce((s, s2) -> s + "; " + s2).get(); throw new RuntimeException("Salt execution went wrong: " + errorMessage); } } else { throw new UnsupportedOperationException("Not supported Salt response: " + stringObjectEntry.getValue().getClass()); } } return result; } private  JidInfoResponseTransformer(); static Map<String, List<RunnerInfo>> getHighStates(Map<String, List<Map<String, Object>>> map); static Map<String, List<RunnerInfo>> getSimpleStates(Map<?, ?> map); }
JidInfoResponseTransformer { public static Map<String, List<RunnerInfo>> getHighStates(Map<String, List<Map<String, Object>>> map) { Map<String, Object> stringObjectMap; stringObjectMap = isOldSalt(map) ? (Map<String, Object>) map.get("return").get(0).get("data") : map.get("return").get(0); Map<String, List<RunnerInfo>> result = new HashMap<>(); for (Entry<String, Object> stringObjectEntry : stringObjectMap.entrySet()) { if (stringObjectEntry.getValue() instanceof Map) { Map<String, Map<String, Object>> mapValue = (Map<String, Map<String, Object>>) stringObjectEntry.getValue(); result.put(stringObjectEntry.getKey(), runnerInfoObjects(mapValue)); } else if (stringObjectEntry.getValue() instanceof List) { List<String> listValue = (List<String>) stringObjectEntry.getValue(); if (!listValue.isEmpty()) { String errorMessage = listValue.stream().reduce((s, s2) -> s + "; " + s2).get(); throw new RuntimeException("Salt execution went wrong: " + errorMessage); } } else { throw new UnsupportedOperationException("Not supported Salt response: " + stringObjectEntry.getValue().getClass()); } } return result; } private  JidInfoResponseTransformer(); static Map<String, List<RunnerInfo>> getHighStates(Map<String, List<Map<String, Object>>> map); static Map<String, List<RunnerInfo>> getSimpleStates(Map<?, ?> map);  }