FaultUtils { protected static List<Cause> appendThrowableToCauses(Throwable e, List<Cause> causes) { Cause.Builder causeBuilder = Cause.newBuilder(); causeBuilder.setCode(e.getClass().getName()); causeBuilder.setMessage(e.getMessage()); causes.add(causeBuilder.build()); if (e.getCause()!=null) { return appendThrowableToCauses( e.getCause(),causes); } else { return causes; } } private  FaultUtils(); static Fault exceptionToFault(CharSequence entityId, Throwable throwable,
			Map<CharSequence, CharSequence> auditSupplementaryData);  }
@Test public void testAppendThrowableToCauses() throws Exception { Throwable causeThrowable = new InvalidParameterException("cause message"); Throwable rootThrowable = new RuntimeException("root meesage", causeThrowable); List<Cause> causes = FaultUtils.appendThrowableToCauses(rootThrowable, new ArrayList<>()); assertEquals(2, causes.size()); assertEquals(rootThrowable.getClass().getName(), causes.get(0).getCode()); assertEquals(rootThrowable.getMessage(), causes.get(0).getMessage()); assertEquals(causeThrowable.getClass().getName(), causes.get(1).getCode()); assertEquals(causeThrowable.getMessage(), causes.get(1).getMessage()); }