### Question:
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);  }### Answer:
@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); } } }
@Test public void testResultSummaryWithStderr() { Map<String, List<RunnerInfo>> res = JidInfoResponseTransformer.getHighStates(saltResponseData); RunnerInfo extraInfo = res.get("host-10-0-0-6.openstacklocal").get(18); Map<String, String> expectedErrorResultSummary = Map.of( "Comment", "Command \"/opt/ambari-server/install-mpack-1.sh\" run", "Stderr", "+ ARGS= + echo yes + ambari-server install-mpack --" ); assertEquals("Command \"/opt/ambari-server/install-mpack-1.sh\" run", extraInfo.getComment()); assertEquals("+ ARGS= + echo yes + ambari-server install-mpack --", extraInfo.getStderr()); assertEquals(expectedErrorResultSummary, extraInfo.getErrorResultSummary()); }
@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()); }