Throwable e = prepareThrowable();
assertThat(e.getClass().getName()).isEqualTo(
"com.google.gwt.core.ext.UnableToCompleteException");
// try plain
{
DesignerException result = (DesignerException) GwtExceptionRewriter.INSTANCE.rewrite(e);
assertThat(result.getCode()).isEqualTo(HostedModeException.MODULE_LOADING_ERROR2);
// at testing time we don't have logger
assertEquals("<none>", result.getParameters()[0]);
}
// try wrapped (1 level)
{
Throwable wrapper = new RuntimeException(e);
DesignerException result = (DesignerException) GwtExceptionRewriter.INSTANCE.rewrite(wrapper);
assertThat(result.getCode()).isEqualTo(HostedModeException.MODULE_LOADING_ERROR2);
}
// try wrapped (2 levels)
{
Throwable wrapper_1 = new InvocationTargetException(e);
Throwable wrapper_2 = new RuntimeException(wrapper_1);
DesignerException result =
(DesignerException) GwtExceptionRewriter.INSTANCE.rewrite(wrapper_2);
assertThat(result.getCode()).isEqualTo(HostedModeException.MODULE_LOADING_ERROR2);
}
}