@Test public void testExceptions() { assertThatExceptionOfType(JSONStructureException.class).isThrownBy(() -> { JsonResponseTranslator.load(new File(folder.getRoot().getAbsolutePath() + "/idontexist.json")); }); assertThatExceptionOfType(JSONStructureException.class).isThrownBy(() -> { JsonResponseTranslator.load("iamnot a json string at all"); }); assertThatExceptionOfType(JSONStructureException.class).isThrownBy(() -> { try (ByteArrayInputStream is = new ByteArrayInputStream("fjskfjdskalfjdkslajdf".getBytes())) { JsonResponseTranslator.load(is); } }); }
public static Response load(String jsonString) throws JSONStructureException { try { GsonJsonResponse jsonResponse = gson.fromJson(new StringReader(jsonString), GsonJsonResponse.class); jsonResponse.postFromJsonSerialization(); return jsonResponse.toXacmlResponse(); } catch (JsonSyntaxException | JsonIOException e) { throw new JSONStructureException("Failed to load json string " + jsonString.substring(0, 20), e); } }
JsonResponseTranslator { public static Response load(String jsonString) throws JSONStructureException { try { GsonJsonResponse jsonResponse = gson.fromJson(new StringReader(jsonString), GsonJsonResponse.class); jsonResponse.postFromJsonSerialization(); return jsonResponse.toXacmlResponse(); } catch (JsonSyntaxException | JsonIOException e) { throw new JSONStructureException("Failed to load json string " + jsonString.substring(0, 20), e); } } }
JsonResponseTranslator { public static Response load(String jsonString) throws JSONStructureException { try { GsonJsonResponse jsonResponse = gson.fromJson(new StringReader(jsonString), GsonJsonResponse.class); jsonResponse.postFromJsonSerialization(); return jsonResponse.toXacmlResponse(); } catch (JsonSyntaxException | JsonIOException e) { throw new JSONStructureException("Failed to load json string " + jsonString.substring(0, 20), e); } } private  JsonResponseTranslator(); }
JsonResponseTranslator { public static Response load(String jsonString) throws JSONStructureException { try { GsonJsonResponse jsonResponse = gson.fromJson(new StringReader(jsonString), GsonJsonResponse.class); jsonResponse.postFromJsonSerialization(); return jsonResponse.toXacmlResponse(); } catch (JsonSyntaxException | JsonIOException e) { throw new JSONStructureException("Failed to load json string " + jsonString.substring(0, 20), e); } } private  JsonResponseTranslator(); static Response load(String jsonString); static Response load(File jsonFile); static Response load(InputStream is); static String toString(Response response, boolean prettyPrint); }
JsonResponseTranslator { public static Response load(String jsonString) throws JSONStructureException { try { GsonJsonResponse jsonResponse = gson.fromJson(new StringReader(jsonString), GsonJsonResponse.class); jsonResponse.postFromJsonSerialization(); return jsonResponse.toXacmlResponse(); } catch (JsonSyntaxException | JsonIOException e) { throw new JSONStructureException("Failed to load json string " + jsonString.substring(0, 20), e); } } private  JsonResponseTranslator(); static Response load(String jsonString); static Response load(File jsonFile); static Response load(InputStream is); static String toString(Response response, boolean prettyPrint);  }