@Test public void testFailedStateResponse() throws IOException { try (InputStream responseStream = JidInfoResponseTransformerTest.class.getResourceAsStream("/jid_failed_response.json")) { saltResponseData = JsonUtil.readValue(IOUtils.toString(responseStream), HashMap.class); } Map<String, List<RunnerInfo>> result = JidInfoResponseTransformer.getSimpleStates(saltResponseData); assertThat(result, hasValue(allOf(hasItem(allOf(hasProperty("result", is(true)), hasProperty("runNum", is(3))))))); assertThat(result, hasValue(allOf(hasItem(allOf(hasProperty("result", is(false)), hasProperty("runNum", is(4))))))); }
public static Map<String, List<RunnerInfo>> getSimpleStates(Map<?, ?> map) { boolean oldSalt = isOldSalt((Map<String, List<Map<String, Object>>>) map); Map<String, Map<String, Map<String, Object>>> stringMapMap = oldSalt ? ((Map<String, List<Map<String, Map<String, Map<String, Map<String, Object>>>>>>) map).get("return").get(0).get("data") : ((Map<String, List<Map<String, Map<String, Map<String, Object>>>>>) map).get("return").get(0); Map<String, List<RunnerInfo>> result = new HashMap<>(); for (Entry<String, Map<String, Map<String, Object>>> stringMapEntry : stringMapMap.entrySet()) { try { LOGGER.debug("Convert from {}", stringMapEntry); List<RunnerInfo> runnerInfos = runnerInfoObjects(stringMapEntry.getValue()); LOGGER.debug("Converted to {}", runnerInfos); result.put(stringMapEntry.getKey(), runnerInfos); } catch (RuntimeException e) { LOGGER.info("Can't create runner info", e); if (stringMapEntry.getKey() != null) { result.put(stringMapEntry.getKey(), null); } } } return result; }
JidInfoResponseTransformer { public static Map<String, List<RunnerInfo>> getSimpleStates(Map<?, ?> map) { boolean oldSalt = isOldSalt((Map<String, List<Map<String, Object>>>) map); Map<String, Map<String, Map<String, Object>>> stringMapMap = oldSalt ? ((Map<String, List<Map<String, Map<String, Map<String, Map<String, Object>>>>>>) map).get("return").get(0).get("data") : ((Map<String, List<Map<String, Map<String, Map<String, Object>>>>>) map).get("return").get(0); Map<String, List<RunnerInfo>> result = new HashMap<>(); for (Entry<String, Map<String, Map<String, Object>>> stringMapEntry : stringMapMap.entrySet()) { try { LOGGER.debug("Convert from {}", stringMapEntry); List<RunnerInfo> runnerInfos = runnerInfoObjects(stringMapEntry.getValue()); LOGGER.debug("Converted to {}", runnerInfos); result.put(stringMapEntry.getKey(), runnerInfos); } catch (RuntimeException e) { LOGGER.info("Can't create runner info", e); if (stringMapEntry.getKey() != null) { result.put(stringMapEntry.getKey(), null); } } } return result; } }
JidInfoResponseTransformer { public static Map<String, List<RunnerInfo>> getSimpleStates(Map<?, ?> map) { boolean oldSalt = isOldSalt((Map<String, List<Map<String, Object>>>) map); Map<String, Map<String, Map<String, Object>>> stringMapMap = oldSalt ? ((Map<String, List<Map<String, Map<String, Map<String, Map<String, Object>>>>>>) map).get("return").get(0).get("data") : ((Map<String, List<Map<String, Map<String, Map<String, Object>>>>>) map).get("return").get(0); Map<String, List<RunnerInfo>> result = new HashMap<>(); for (Entry<String, Map<String, Map<String, Object>>> stringMapEntry : stringMapMap.entrySet()) { try { LOGGER.debug("Convert from {}", stringMapEntry); List<RunnerInfo> runnerInfos = runnerInfoObjects(stringMapEntry.getValue()); LOGGER.debug("Converted to {}", runnerInfos); result.put(stringMapEntry.getKey(), runnerInfos); } catch (RuntimeException e) { LOGGER.info("Can't create runner info", e); if (stringMapEntry.getKey() != null) { result.put(stringMapEntry.getKey(), null); } } } return result; } private  JidInfoResponseTransformer(); }
JidInfoResponseTransformer { public static Map<String, List<RunnerInfo>> getSimpleStates(Map<?, ?> map) { boolean oldSalt = isOldSalt((Map<String, List<Map<String, Object>>>) map); Map<String, Map<String, Map<String, Object>>> stringMapMap = oldSalt ? ((Map<String, List<Map<String, Map<String, Map<String, Map<String, Object>>>>>>) map).get("return").get(0).get("data") : ((Map<String, List<Map<String, Map<String, Map<String, Object>>>>>) map).get("return").get(0); Map<String, List<RunnerInfo>> result = new HashMap<>(); for (Entry<String, Map<String, Map<String, Object>>> stringMapEntry : stringMapMap.entrySet()) { try { LOGGER.debug("Convert from {}", stringMapEntry); List<RunnerInfo> runnerInfos = runnerInfoObjects(stringMapEntry.getValue()); LOGGER.debug("Converted to {}", runnerInfos); result.put(stringMapEntry.getKey(), runnerInfos); } catch (RuntimeException e) { LOGGER.info("Can't create runner info", e); if (stringMapEntry.getKey() != null) { result.put(stringMapEntry.getKey(), null); } } } 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>> getSimpleStates(Map<?, ?> map) { boolean oldSalt = isOldSalt((Map<String, List<Map<String, Object>>>) map); Map<String, Map<String, Map<String, Object>>> stringMapMap = oldSalt ? ((Map<String, List<Map<String, Map<String, Map<String, Map<String, Object>>>>>>) map).get("return").get(0).get("data") : ((Map<String, List<Map<String, Map<String, Map<String, Object>>>>>) map).get("return").get(0); Map<String, List<RunnerInfo>> result = new HashMap<>(); for (Entry<String, Map<String, Map<String, Object>>> stringMapEntry : stringMapMap.entrySet()) { try { LOGGER.debug("Convert from {}", stringMapEntry); List<RunnerInfo> runnerInfos = runnerInfoObjects(stringMapEntry.getValue()); LOGGER.debug("Converted to {}", runnerInfos); result.put(stringMapEntry.getKey(), runnerInfos); } catch (RuntimeException e) { LOGGER.info("Can't create runner info", e); if (stringMapEntry.getKey() != null) { result.put(stringMapEntry.getKey(), null); } } } 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);  }