Fault { public static Fault createFromJson(String json) { Fault fault = new Fault(null, 0); try (JsonReader reader = Json.createReader(new StringReader(json))) { JsonObject root = reader.readObject(); fault.message = root.getString(Constants.Message.Fault.MESSAGE); fault.classname = root.getString(Constants.Message.Fault.CLASSNAME); } return fault; } Fault(Throwable t, int stacktracelength); String getMessage(); String getClassname(); String[] getStacktrace(); Throwable getThrowable(); static Fault createFromJson(String json); String toJson(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj);  }
@Test public void testCreateFromJson() throws Exception { System.out.println("createFromJson"); String expResult = "ExceptionMssage"; String expResult2 = "java.lang.Exception"; try { throw new Exception(expResult); } catch (Exception e) { Fault instance = new Fault(e, 5); Fault result = Fault.createFromJson(instance.toJson()); assertThat(result.getMessage()).isEqualTo(expResult); assertThat(result.getClassname()).isEqualTo(expResult2); assertThat(instance.toJson()).isEqualTo(instance.toString()); } }