Fault { public String[] getStacktrace() { if (throwable != null && stacktracelength > 0) { Throwable t = throwable; if (throwable.getCause() != null) { t = throwable.getCause(); } StackTraceElement[] stackTraces = t.getStackTrace(); int nb = Math.min(stackTraces.length, stacktracelength); String[] result = new String[nb]; for (int i = 0; i < nb; i++) { result[i] = stackTraces[i].toString(); } return result; } return new String[]{}; } 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 testGetStacktrace() { System.out.println("getStacktrace"); int expResult = 5; try { throw new Exception(); } catch (Exception e) { Fault instance = new Fault(e, expResult); int result = instance.getStacktrace().length; assertThat(result).isEqualTo(expResult); } expResult = 10; try { throw new Exception(); } catch (Exception e) { Fault instance = new Fault(e, expResult); int result = instance.getStacktrace().length; assertThat(result).isEqualTo(expResult); } try { throw new Exception(); } catch (Exception e) { try { throw new Exception(e); } catch (Exception e1) { Fault instance = new Fault(e1, expResult); int result = instance.getStacktrace().length; assertThat(result).isEqualTo(expResult); } } }