@Test public void disallowsDecodingNullString() throws IOException { try { cartographer.fromJson((String) null); fail("null map should throw Exception"); } catch (IllegalArgumentException e) { assertThat(e).hasMessage("json == null"); } }
public Map<String, Object> fromJson(String json) throws IOException { if (json == null) { throw new IllegalArgumentException("json == null"); } if (json.length() == 0) { throw new IllegalArgumentException("json empty"); } return fromJson(new StringReader(json)); }
Cartographer { public Map<String, Object> fromJson(String json) throws IOException { if (json == null) { throw new IllegalArgumentException("json == null"); } if (json.length() == 0) { throw new IllegalArgumentException("json empty"); } return fromJson(new StringReader(json)); } }
Cartographer { public Map<String, Object> fromJson(String json) throws IOException { if (json == null) { throw new IllegalArgumentException("json == null"); } if (json.length() == 0) { throw new IllegalArgumentException("json empty"); } return fromJson(new StringReader(json)); } Cartographer(boolean isLenient, boolean prettyPrint); }
Cartographer { public Map<String, Object> fromJson(String json) throws IOException { if (json == null) { throw new IllegalArgumentException("json == null"); } if (json.length() == 0) { throw new IllegalArgumentException("json empty"); } return fromJson(new StringReader(json)); } Cartographer(boolean isLenient, boolean prettyPrint); Map<String, Object> fromJson(String json); Map<String, Object> fromJson(Reader reader); String toJson(Map<?, ?> map); void toJson(Map<?, ?> map, Writer writer); }
Cartographer { public Map<String, Object> fromJson(String json) throws IOException { if (json == null) { throw new IllegalArgumentException("json == null"); } if (json.length() == 0) { throw new IllegalArgumentException("json empty"); } return fromJson(new StringReader(json)); } Cartographer(boolean isLenient, boolean prettyPrint); Map<String, Object> fromJson(String json); Map<String, Object> fromJson(Reader reader); String toJson(Map<?, ?> map); void toJson(Map<?, ?> map, Writer writer);  }