@Test(expected = RuntimeException.class) public void parseFromJsonThrowsRuntimeExceptionOnMalformedJson() { parser.parseFromJson("This is invalid json"); }
public SubmissionResult parseFromJson(String json) { if (json.trim().isEmpty()) { throw new IllegalArgumentException("Empty input"); } try { Gson gson = new GsonBuilder().registerTypeAdapter(SubmissionResult.Status.class, new StatusDeserializer()) .registerTypeAdapter(StackTraceElement.class, new StackTraceSerializer()).create(); return gson.fromJson(json, SubmissionResult.class); } catch (RuntimeException e) { throw new RuntimeException("Failed to parse submission result: " + e.getMessage(), e); } }
SubmissionResultParser { public SubmissionResult parseFromJson(String json) { if (json.trim().isEmpty()) { throw new IllegalArgumentException("Empty input"); } try { Gson gson = new GsonBuilder().registerTypeAdapter(SubmissionResult.Status.class, new StatusDeserializer()) .registerTypeAdapter(StackTraceElement.class, new StackTraceSerializer()).create(); return gson.fromJson(json, SubmissionResult.class); } catch (RuntimeException e) { throw new RuntimeException("Failed to parse submission result: " + e.getMessage(), e); } } }
SubmissionResultParser { public SubmissionResult parseFromJson(String json) { if (json.trim().isEmpty()) { throw new IllegalArgumentException("Empty input"); } try { Gson gson = new GsonBuilder().registerTypeAdapter(SubmissionResult.Status.class, new StatusDeserializer()) .registerTypeAdapter(StackTraceElement.class, new StackTraceSerializer()).create(); return gson.fromJson(json, SubmissionResult.class); } catch (RuntimeException e) { throw new RuntimeException("Failed to parse submission result: " + e.getMessage(), e); } }  }
SubmissionResultParser { public SubmissionResult parseFromJson(String json) { if (json.trim().isEmpty()) { throw new IllegalArgumentException("Empty input"); } try { Gson gson = new GsonBuilder().registerTypeAdapter(SubmissionResult.Status.class, new StatusDeserializer()) .registerTypeAdapter(StackTraceElement.class, new StackTraceSerializer()).create(); return gson.fromJson(json, SubmissionResult.class); } catch (RuntimeException e) { throw new RuntimeException("Failed to parse submission result: " + e.getMessage(), e); } }  SubmissionResult parseFromJson(String json); }
SubmissionResultParser { public SubmissionResult parseFromJson(String json) { if (json.trim().isEmpty()) { throw new IllegalArgumentException("Empty input"); } try { Gson gson = new GsonBuilder().registerTypeAdapter(SubmissionResult.Status.class, new StatusDeserializer()) .registerTypeAdapter(StackTraceElement.class, new StackTraceSerializer()).create(); return gson.fromJson(json, SubmissionResult.class); } catch (RuntimeException e) { throw new RuntimeException("Failed to parse submission result: " + e.getMessage(), e); } }  SubmissionResult parseFromJson(String json);  }