@Test(expected = IOException.class) public void testFromJsonMissingResourceId() throws IOException { String json = "[{\"noResourceId\": \"res-undefined\"," + "\"status\": 200}]"; InputStream stream = new ByteArrayInputStream(json.getBytes(StandardCharsets.UTF_8)); MultiStatusResponse.fromJson(new ObjectMapper(), stream); }
public static MultiStatusResponse fromJson(ObjectMapper mapper, InputStream stream) throws IOException { List<Map<String, Object>> responses = mapper.readValue(stream, REF_MULTI_RESPONSE); try { Map<String, Integer> responseMap = responses.stream() .map(map -> new AbstractMap.SimpleEntry<>(extractResourceId(map), extractStatus(map))) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); return new MultiStatusResponse(responseMap); } catch (IllegalArgumentException e) { throw new IOException("Failed to parse JSON response", e); } }
MultiStatusResponse { public static MultiStatusResponse fromJson(ObjectMapper mapper, InputStream stream) throws IOException { List<Map<String, Object>> responses = mapper.readValue(stream, REF_MULTI_RESPONSE); try { Map<String, Integer> responseMap = responses.stream() .map(map -> new AbstractMap.SimpleEntry<>(extractResourceId(map), extractStatus(map))) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); return new MultiStatusResponse(responseMap); } catch (IllegalArgumentException e) { throw new IOException("Failed to parse JSON response", e); } } }
MultiStatusResponse { public static MultiStatusResponse fromJson(ObjectMapper mapper, InputStream stream) throws IOException { List<Map<String, Object>> responses = mapper.readValue(stream, REF_MULTI_RESPONSE); try { Map<String, Integer> responseMap = responses.stream() .map(map -> new AbstractMap.SimpleEntry<>(extractResourceId(map), extractStatus(map))) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); return new MultiStatusResponse(responseMap); } catch (IllegalArgumentException e) { throw new IOException("Failed to parse JSON response", e); } } MultiStatusResponse(Map<String, Integer> responses); }
MultiStatusResponse { public static MultiStatusResponse fromJson(ObjectMapper mapper, InputStream stream) throws IOException { List<Map<String, Object>> responses = mapper.readValue(stream, REF_MULTI_RESPONSE); try { Map<String, Integer> responseMap = responses.stream() .map(map -> new AbstractMap.SimpleEntry<>(extractResourceId(map), extractStatus(map))) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); return new MultiStatusResponse(responseMap); } catch (IllegalArgumentException e) { throw new IOException("Failed to parse JSON response", e); } } MultiStatusResponse(Map<String, Integer> responses); static MultiStatusResponse fromJson(ObjectMapper mapper, InputStream stream); Map<String, Integer> getResponses(); int responseCount(); boolean isAllSuccess(); boolean hasResourceId(String resId); int getStatus(String resId); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }
MultiStatusResponse { public static MultiStatusResponse fromJson(ObjectMapper mapper, InputStream stream) throws IOException { List<Map<String, Object>> responses = mapper.readValue(stream, REF_MULTI_RESPONSE); try { Map<String, Integer> responseMap = responses.stream() .map(map -> new AbstractMap.SimpleEntry<>(extractResourceId(map), extractStatus(map))) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); return new MultiStatusResponse(responseMap); } catch (IllegalArgumentException e) { throw new IOException("Failed to parse JSON response", e); } } MultiStatusResponse(Map<String, Integer> responses); static MultiStatusResponse fromJson(ObjectMapper mapper, InputStream stream); Map<String, Integer> getResponses(); int responseCount(); boolean isAllSuccess(); boolean hasResourceId(String resId); int getStatus(String resId); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }