use of org.mule.runtime.api.message.ErrorType in project mule by mulesoft.
the class ExtensionErrorsRegistrant method getErrorType.
private ErrorType getErrorType(ErrorModel errorModel, ExtensionModel extensionModel) {
ComponentIdentifier identifier = createIdentifier(errorModel.getType(), errorModel.getNamespace());
Optional<ErrorType> optionalError = errorTypeRepository.getErrorType(identifier);
return optionalError.orElseGet(() -> createErrorType(errorModel, identifier, extensionModel));
}
use of org.mule.runtime.api.message.ErrorType in project mule by mulesoft.
the class ExtensionErrorsRegistrantTestCase method lookupErrorsForOperation.
@Test
public void lookupErrorsForOperation() {
when(extensionModel.getErrorModels()).thenReturn(singleton(extensionConnectivityError));
errorsRegistrant.registerErrors(extensionModel);
ErrorType errorType = typeLocator.lookupComponentErrorType(OPERATION_IDENTIFIER, ConnectionException.class);
assertThat(errorType.getIdentifier(), is(CONNECTIVITY_ERROR_IDENTIFIER));
assertThat(errorType.getNamespace(), is(EXTENSION_PREFIX.toUpperCase()));
ErrorType muleConnectivityError = errorType.getParentErrorType();
assertThat(muleConnectivityError.getNamespace(), is(MULE_CONNECTIVITY_ERROR.getNamespace()));
assertThat(muleConnectivityError.getIdentifier(), is(MULE_CONNECTIVITY_ERROR.getType()));
ErrorType anyErrorType = muleConnectivityError.getParentErrorType();
assertThat(anyErrorType.getNamespace(), is(MULE));
assertThat(anyErrorType.getIdentifier(), is(ANY));
assertThat(anyErrorType.getParentErrorType(), is(nullValue()));
}
use of org.mule.runtime.api.message.ErrorType in project mule by mulesoft.
the class ExtensionErrorsRegistrantTestCase method registerErrorTypes.
@Test
public void registerErrorTypes() {
when(extensionModel.getErrorModels()).thenReturn(singleton(oauthExtensionConnectivityError));
errorsRegistrant.registerErrors(extensionModel);
Optional<ErrorType> optionalOAuthType = typeRepository.lookupErrorType(builder().name(OAUTH_TEST_CONNECTIVITY_ERROR_TYPE).namespace(EXTENSION_PREFIX).build());
Optional<ErrorType> optionalConnectivityType = typeRepository.lookupErrorType(builder().name(TEST_CONNECTIVITY_ERROR_TYPE).namespace(EXTENSION_PREFIX).build());
assertThat(optionalOAuthType.isPresent(), is(true));
assertThat(optionalConnectivityType.isPresent(), is(true));
ErrorType parentErrorType = optionalOAuthType.get().getParentErrorType();
assertThat(parentErrorType, is(optionalConnectivityType.get()));
}
use of org.mule.runtime.api.message.ErrorType in project mule by mulesoft.
the class ErrorBuilderTestCase method givesStringRepresentation.
@Test
public void givesStringRepresentation() {
ErrorType anyError = ErrorTypeBuilder.builder().namespace("MULE").identifier("ANY").build();
ErrorType testError = ErrorTypeBuilder.builder().namespace("MULE").identifier("TEST").parentErrorType(anyError).build();
Error error = builder(new ComposedErrorMessageAwareException(createStaticMessage(EXCEPTION_MESSAGE), testError)).errorType(testError).build();
assertThat(error.toString(), is("\norg.mule.runtime.core.internal.message.ErrorBuilder$ErrorImplementation\n" + "{\n" + " description=message\n" + " detailedDescription=message\n" + " errorType=MULE:TEST\n" + " cause=org.mule.runtime.core.api.message.ErrorBuilderTestCase$ComposedErrorMessageAwareException\n" + " errorMessage=\n" + "org.mule.runtime.core.internal.message.DefaultMessageBuilder$MessageImplementation\n" + "{\n" + " payload=test\n" + " mediaType=*/*\n" + " attributes=<not set>\n" + " attributesMediaType=*/*\n" + "}\n" + " childErrors=[\n" + "org.mule.runtime.core.internal.message.ErrorBuilder$ErrorImplementation\n" + "{\n" + " description=unknown description\n" + " detailedDescription=unknown description\n" + " errorType=MULE:TEST\n" + " cause=java.lang.RuntimeException\n" + " errorMessage=-\n" + " childErrors=[]\n" + "}, \n" + "org.mule.runtime.core.internal.message.ErrorBuilder$ErrorImplementation\n" + "{\n" + " description=unknown description\n" + " detailedDescription=unknown description\n" + " errorType=MULE:TEST\n" + " cause=java.io.IOException\n" + " errorMessage=-\n" + " childErrors=[]\n" + "}]\n" + "}"));
}
use of org.mule.runtime.api.message.ErrorType in project mule by mulesoft.
the class ErrorBuilderTestCase method buildError.
@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()));
}
Aggregations