use of com.helger.commons.exception.mock.MockRuntimeException in project ph-commons by phax.
the class SingleErrorTest method testLinkedException.
@Test
public void testLinkedException() {
final Locale aDisplayLocale = Locale.US;
final MockRuntimeException ex = new MockRuntimeException("msg");
final SingleError aErr = SingleError.builder().linkedException(ex).build();
assertEquals(EErrorLevel.ERROR, aErr.getErrorLevel());
assertNull(aErr.getErrorID());
assertNull(aErr.getErrorFieldName());
assertNotNull(aErr.getErrorLocation());
assertFalse(aErr.getErrorLocation().isAnyInformationPresent());
assertNull(aErr.getErrorTexts());
assertNull(aErr.getErrorText(aDisplayLocale));
assertSame(ex, aErr.getLinkedException());
assertNull(aErr.getLinkedExceptionCause());
assertEquals("msg", aErr.getLinkedExceptionMessage());
assertNotNull(aErr.getLinkedExceptionStackTrace());
assertEquals("[error] (" + ex.getClass().getName() + ": msg)", aErr.getAsString(aDisplayLocale));
assertEquals(aErr, SingleError.builder(aErr).build());
}
use of com.helger.commons.exception.mock.MockRuntimeException in project ph-commons by phax.
the class SingleErrorTest method testAll.
@Test
public void testAll() {
final Locale aDisplayLocale = Locale.US;
final MockRuntimeException ex = new MockRuntimeException("exception msg");
final SingleError aErr = SingleError.builder().errorID("id1").errorFieldName("field").errorLocation(new SimpleLocation("file.xml", 4, 13)).errorText("abc").linkedException(ex).build();
assertEquals(EErrorLevel.ERROR, aErr.getErrorLevel());
assertEquals("id1", aErr.getErrorID());
assertEquals("field", aErr.getErrorFieldName());
assertNotNull(aErr.getErrorLocation());
assertTrue(aErr.getErrorLocation().isAnyInformationPresent());
assertNotNull(aErr.getErrorTexts());
assertEquals("abc", aErr.getErrorText(aDisplayLocale));
assertSame(ex, aErr.getLinkedException());
assertNull(aErr.getLinkedExceptionCause());
assertEquals("exception msg", aErr.getLinkedExceptionMessage());
assertNotNull(aErr.getLinkedExceptionStackTrace());
assertEquals("[error] [id1] in field @ file.xml(4:13) abc (" + ex.getClass().getName() + ": exception msg)", aErr.getAsString(aDisplayLocale));
assertEquals(aErr, SingleError.builder(aErr).build());
}
Aggregations