@Test public void testWithOrdering() { Map<String, List<RunnerInfo>> res = JidInfoResponseTransformer.getHighStates(saltResponseData); for (List<RunnerInfo> value : res.values()) { int current = -1; List<RunnerInfo> runnerInfoList = value; for (RunnerInfo runnerInfo : runnerInfoList) { int former = current; current = Math.max(current, runnerInfo.getRunNum()); assertTrue("SaltStates are not properly ordered", former < current); } } }
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);  }