### Question:
AdapterException extends Exception { public static void throwAsAdapterException(AdapterLogId id, String message, Throwable t) throws AdapterException { throw asAdapterException(id, message, t); } AdapterException(AdapterLogId id, String message, Throwable cause);  AdapterException(AdapterLogId id, String message);  AdapterException(AdapterLogId id, Throwable cause); static void throwAsAdapterException(AdapterLogId id, String message, Throwable t); static AdapterException asAdapterException(AdapterLogId id, String message, Throwable t);  }### Answer:
@Test public void throwAsAdapterException_throws_adapter_exception_when_exception_is_runtime_exception() throws Exception { RuntimeException cause = new RuntimeException(); expected.expect(AdapterException.class); expected.expectMessage("x:message1"); expected.expectCause(equalTo(cause)); throwAsAdapterException(new AdapterLogId("x",null),"message1", cause); }
@Test public void throwAsAdapterException_throws_adapter_exception_with_traceid_when_exception_is_runtime_exception() throws Exception { RuntimeException cause = new RuntimeException(); expected.expect(AdapterException.class); expected.expectMessage("traceId x:message1"); expected.expectCause(equalTo(cause)); throwAsAdapterException(new AdapterLogId("x","traceId"),"message1", cause); }
@Test public void throwAsAdapterException_rethrows_adapter_exception_when_exception_is_adapter_exception() throws Exception { AdapterException cause = new AdapterException(new AdapterLogId("y",null),"originMessage"); expected.expect(AdapterException.class); expected.expectMessage("y:originMessage"); throwAsAdapterException(new AdapterLogId("z",null),"otherMessage", cause); }