@Test public void buildErrorFromMuleException() { MuleException exception = new DefaultMuleException(new RuntimeException(EXCEPTION_MESSAGE)); Error error = builder(exception).errorType(mockErrorType).build(); assertThat(error.getCause(), is(exception)); assertThat(error.getDescription(), containsString(EXCEPTION_MESSAGE)); assertThat(error.getDetailedDescription(), containsString(EXCEPTION_MESSAGE)); assertThat(error.getErrorType(), is(mockErrorType)); assertThat(error.getChildErrors(), is(empty())); }
@Test public void buildErrorFromException() { RuntimeException exception = new RuntimeException(EXCEPTION_MESSAGE); Error error = builder(exception).errorType(mockErrorType).build(); assertThat(error.getCause(), is(exception)); assertThat(error.getDescription(), is(EXCEPTION_MESSAGE)); assertThat(error.getDetailedDescription(), is(EXCEPTION_MESSAGE)); assertThat(error.getErrorType(), is(mockErrorType)); assertThat(error.getChildErrors(), is(empty())); }
@Test public void buildErrorFromCustomException() { Error error = builder(new ComposedErrorMessageAwareException(createStaticMessage(EXCEPTION_MESSAGE))) .errorType(mockErrorType) .build(); assertThat(error.getDescription(), is(EXCEPTION_MESSAGE)); assertThat(error.getDetailedDescription(), is(EXCEPTION_MESSAGE)); assertThat(error.getCause(), is(instanceOf(ComposedErrorMessageAwareException.class))); assertThat(error.getErrorType(), is(mockErrorType)); assertThat(error.getErrorMessage().getPayload().getValue(), is(TEST_PAYLOAD)); List<Error> childErrors = error.getChildErrors(); assertThat(childErrors, hasSize(2)); assertThat(childErrors.get(0).getCause(), is(instanceOf(RuntimeException.class))); assertThat(childErrors.get(1).getCause(), is(instanceOf(IOException.class))); }
@Test public void buildError() { String detailedDescription = "detailed description"; String description = "description"; ErrorType errorType = mockErrorType; Message errorMessage = of(null); IllegalArgumentException exception = new IllegalArgumentException("some message"); Error error = builder() .errorType(errorType) .description(description) .detailedDescription(detailedDescription) .exception(exception) .errorMessage(errorMessage) .build(); assertThat(error.getDescription(), is(description)); assertThat(error.getDetailedDescription(), is(detailedDescription)); assertThat(error.getCause(), is(exception)); assertThat(error.getErrorType(), is(errorType)); assertThat(error.getErrorMessage(), is(errorMessage)); assertThat(error.getChildErrors(), is(empty())); }
/** * Constructor to create a new builder using the information of another error for default error parametrization. * * @param e the error to base on */ private ErrorBuilder(Error e) { this.description = e.getDescription(); this.detailedDescription = e.getDetailedDescription(); this.exception = e.getCause(); this.errorType = e.getErrorType(); this.errorMessage = e.getErrorMessage(); this.errors = e.getChildErrors(); }
@Test public void buildErrorFromException() { RuntimeException exception = new RuntimeException(EXCEPTION_MESSAGE); Error error = builder(exception).errorType(mockErrorType).build(); assertThat(error.getCause(), is(exception)); assertThat(error.getDescription(), is(EXCEPTION_MESSAGE)); assertThat(error.getDetailedDescription(), is(EXCEPTION_MESSAGE)); assertThat(error.getErrorType(), is(mockErrorType)); assertThat(error.getChildErrors(), is(empty())); }
@Test public void buildErrorFromMuleException() { MuleException exception = new DefaultMuleException(new RuntimeException(EXCEPTION_MESSAGE)); Error error = builder(exception).errorType(mockErrorType).build(); assertThat(error.getCause(), is(exception)); assertThat(error.getDescription(), containsString(EXCEPTION_MESSAGE)); assertThat(error.getDetailedDescription(), containsString(EXCEPTION_MESSAGE)); assertThat(error.getErrorType(), is(mockErrorType)); assertThat(error.getChildErrors(), is(empty())); }
@Test public void buildErrorFromCustomException() { Error error = builder(new ComposedErrorMessageAwareException(createStaticMessage(EXCEPTION_MESSAGE))) .errorType(mockErrorType) .build(); assertThat(error.getDescription(), is(EXCEPTION_MESSAGE)); assertThat(error.getDetailedDescription(), is(EXCEPTION_MESSAGE)); assertThat(error.getCause(), is(instanceOf(ComposedErrorMessageAwareException.class))); assertThat(error.getErrorType(), is(mockErrorType)); assertThat(error.getErrorMessage().getPayload().getValue(), is(TEST_PAYLOAD)); List<Error> childErrors = error.getChildErrors(); assertThat(childErrors, hasSize(2)); assertThat(childErrors.get(0).getCause(), is(instanceOf(RuntimeException.class))); assertThat(childErrors.get(1).getCause(), is(instanceOf(IOException.class))); }
@Test public void buildError() { String detailedDescription = "detailed description"; String description = "description"; ErrorType errorType = mockErrorType; Message errorMessage = of(null); IllegalArgumentException exception = new IllegalArgumentException("some message"); Error error = builder() .errorType(errorType) .description(description) .detailedDescription(detailedDescription) .exception(exception) .errorMessage(errorMessage) .build(); assertThat(error.getDescription(), is(description)); assertThat(error.getDetailedDescription(), is(detailedDescription)); assertThat(error.getCause(), is(exception)); assertThat(error.getErrorType(), is(errorType)); assertThat(error.getErrorMessage(), is(errorMessage)); assertThat(error.getChildErrors(), is(empty())); }