@Test public void shouldCollectPathsFromEmptyJsonObject() { final List<String> paths = inspector.getPaths(JSON_INSTANCE_KIND, "", "{}", Optional.empty()); assertThat(paths).isEmpty(); }
@Override @SuppressWarnings("unchecked") public List<String> getPaths(String kind, String type, String specification, Optional<byte[]> exemplar) { if (specification == null) { return Collections.emptyList(); } String context = null; final List<String> paths = new ArrayList<>(); try { Map<String, Object> json; if (JsonUtils.isJsonArray(specification)) { List<Object> items = JsonUtils.reader().forType(List.class).readValue(specification); paths.addAll(COLLECTION_PATHS); context = ARRAY_CONTEXT; if (items.isEmpty()) { return Collections.unmodifiableList(paths); } json = (Map<String, Object>) items.get(0); } else { json = JsonUtils.reader().forType(Map.class).readValue(specification); } fetchPaths(context, paths, json); } catch (final IOException e) { LOG.warn("Unable to parse the given JSON instance, increase log level to DEBUG to see the instance being parsed"); LOG.debug(specification); LOG.trace("Unable to parse the given JSON instance", e); } return Collections.unmodifiableList(paths); }
JsonInstanceInspector implements Inspector { @Override @SuppressWarnings("unchecked") public List<String> getPaths(String kind, String type, String specification, Optional<byte[]> exemplar) { if (specification == null) { return Collections.emptyList(); } String context = null; final List<String> paths = new ArrayList<>(); try { Map<String, Object> json; if (JsonUtils.isJsonArray(specification)) { List<Object> items = JsonUtils.reader().forType(List.class).readValue(specification); paths.addAll(COLLECTION_PATHS); context = ARRAY_CONTEXT; if (items.isEmpty()) { return Collections.unmodifiableList(paths); } json = (Map<String, Object>) items.get(0); } else { json = JsonUtils.reader().forType(Map.class).readValue(specification); } fetchPaths(context, paths, json); } catch (final IOException e) { LOG.warn("Unable to parse the given JSON instance, increase log level to DEBUG to see the instance being parsed"); LOG.debug(specification); LOG.trace("Unable to parse the given JSON instance", e); } return Collections.unmodifiableList(paths); } }
JsonInstanceInspector implements Inspector { @Override @SuppressWarnings("unchecked") public List<String> getPaths(String kind, String type, String specification, Optional<byte[]> exemplar) { if (specification == null) { return Collections.emptyList(); } String context = null; final List<String> paths = new ArrayList<>(); try { Map<String, Object> json; if (JsonUtils.isJsonArray(specification)) { List<Object> items = JsonUtils.reader().forType(List.class).readValue(specification); paths.addAll(COLLECTION_PATHS); context = ARRAY_CONTEXT; if (items.isEmpty()) { return Collections.unmodifiableList(paths); } json = (Map<String, Object>) items.get(0); } else { json = JsonUtils.reader().forType(Map.class).readValue(specification); } fetchPaths(context, paths, json); } catch (final IOException e) { LOG.warn("Unable to parse the given JSON instance, increase log level to DEBUG to see the instance being parsed"); LOG.debug(specification); LOG.trace("Unable to parse the given JSON instance", e); } return Collections.unmodifiableList(paths); }  }
JsonInstanceInspector implements Inspector { @Override @SuppressWarnings("unchecked") public List<String> getPaths(String kind, String type, String specification, Optional<byte[]> exemplar) { if (specification == null) { return Collections.emptyList(); } String context = null; final List<String> paths = new ArrayList<>(); try { Map<String, Object> json; if (JsonUtils.isJsonArray(specification)) { List<Object> items = JsonUtils.reader().forType(List.class).readValue(specification); paths.addAll(COLLECTION_PATHS); context = ARRAY_CONTEXT; if (items.isEmpty()) { return Collections.unmodifiableList(paths); } json = (Map<String, Object>) items.get(0); } else { json = JsonUtils.reader().forType(Map.class).readValue(specification); } fetchPaths(context, paths, json); } catch (final IOException e) { LOG.warn("Unable to parse the given JSON instance, increase log level to DEBUG to see the instance being parsed"); LOG.debug(specification); LOG.trace("Unable to parse the given JSON instance", e); } return Collections.unmodifiableList(paths); }  @Override @SuppressWarnings("unchecked") List<String> getPaths(String kind, String type, String specification, Optional<byte[]> exemplar); @Override boolean supports(String kind, String type, String specification, Optional<byte[]> optional); }
JsonInstanceInspector implements Inspector { @Override @SuppressWarnings("unchecked") public List<String> getPaths(String kind, String type, String specification, Optional<byte[]> exemplar) { if (specification == null) { return Collections.emptyList(); } String context = null; final List<String> paths = new ArrayList<>(); try { Map<String, Object> json; if (JsonUtils.isJsonArray(specification)) { List<Object> items = JsonUtils.reader().forType(List.class).readValue(specification); paths.addAll(COLLECTION_PATHS); context = ARRAY_CONTEXT; if (items.isEmpty()) { return Collections.unmodifiableList(paths); } json = (Map<String, Object>) items.get(0); } else { json = JsonUtils.reader().forType(Map.class).readValue(specification); } fetchPaths(context, paths, json); } catch (final IOException e) { LOG.warn("Unable to parse the given JSON instance, increase log level to DEBUG to see the instance being parsed"); LOG.debug(specification); LOG.trace("Unable to parse the given JSON instance", e); } return Collections.unmodifiableList(paths); }  @Override @SuppressWarnings("unchecked") List<String> getPaths(String kind, String type, String specification, Optional<byte[]> exemplar); @Override boolean supports(String kind, String type, String specification, Optional<byte[]> optional);  }