use of org.mule.runtime.api.meta.model.error.ErrorModel in project mule by mulesoft.
the class SoapModelLoaderDelegate method declare.
/**
* {@inheritDoc}
*/
public ExtensionDeclarer declare(ExtensionLoadingContext context) {
final SoapExtensionTypeWrapper<?> extension = getSoapExtensionType(this.extensionType, typeLoader);
List<MessageDispatcherProviderTypeWrapper> customTransportProviders = extension.getDispatcherProviders();
ExtensionDeclarer extensionDeclarer = getExtensionDeclarer(context);
declareSubtypes(extensionDeclarer, customTransportProviders);
Set<ErrorModel> soapErrors = getSoapErrors(extensionDeclarer);
soapErrors.forEach(extensionDeclarer::withErrorModel);
ConfigurationDeclarer configDeclarer = getConfigDeclarer(extensionDeclarer, extension, soapErrors);
extension.getSoapServiceProviders().forEach(provider -> serviceProviderDeclarer.declare(configDeclarer, provider, !customTransportProviders.isEmpty()));
return extensionDeclarer;
}
use of org.mule.runtime.api.meta.model.error.ErrorModel in project mule by mulesoft.
the class ErrorsModelFactory method toErrorModel.
/**
* @param errorTypeDefinition
* @param errorModelMap
* @return
*/
private ErrorModel toErrorModel(ErrorTypeDefinition<?> errorTypeDefinition, Map<String, ErrorModel> errorModelMap) {
if (errorModelMap.containsKey(toIdentifier(errorTypeDefinition))) {
return errorModelMap.get(toIdentifier(errorTypeDefinition));
} else {
ErrorModelBuilder builder = newError(errorTypeDefinition.getType(), getErrorNamespace(errorTypeDefinition));
builder.withParent(toErrorModel(errorTypeDefinition.getParent().orElse(ANY), errorModelMap));
ErrorModel errorModel = builder.build();
errorModelMap.put(toIdentifier(errorTypeDefinition), errorModel);
return errorModel;
}
}
use of org.mule.runtime.api.meta.model.error.ErrorModel in project mule by mulesoft.
the class ExtensionErrorsRegistrantTestCase method operationTriesToAddInternalErrorType.
@Test
public void operationTriesToAddInternalErrorType() {
ErrorTypeRepository repository = mock(ErrorTypeRepository.class);
when(repository.getErrorType(any())).then((e) -> typeRepository.getErrorType(((ComponentIdentifier) e.getArguments()[0])));
ErrorModel internalRepeatedError = ErrorModelBuilder.newError(SOURCE_RESPONSE_GENERATE).build();
when(operationWithError.getErrorModels()).thenReturn(singleton(internalRepeatedError));
when(extensionModel.getOperationModels()).thenReturn(singletonList(operationWithError));
when(extensionModel.getErrorModels()).thenReturn(singleton(internalRepeatedError));
ErrorTypeLocator mockTypeLocator = mock(ErrorTypeLocator.class);
errorsRegistrant = new ExtensionErrorsRegistrant(typeRepository, mockTypeLocator);
errorsRegistrant.registerErrors(extensionModel);
verify(repository, times(0)).addErrorType(any(), any());
}
use of org.mule.runtime.api.meta.model.error.ErrorModel in project mule by mulesoft.
the class ErrorsDeclarationEnricherTestCase method extensionErrorsInheritFromMuleErrors.
@Test
public void extensionErrorsInheritFromMuleErrors() {
extensionModel = loadExtension(HeisenbergExtension.class);
OperationModel cureCancer = getNamedObject(extensionModel.getOperationModels(), "cureCancer");
assertThat(cureCancer.getErrorModels(), hasItem(hasProperty(TYPE, is(HEALTH.getType()))));
Optional<ErrorModel> healthError = extensionModel.getErrorModels().stream().filter(errorModel -> errorModel.getType().equals(HEALTH.getType())).findFirst();
assertThat(healthError.isPresent(), is(true));
Optional<ErrorModel> optConnectivityError = healthError.get().getParent();
assertThat(optConnectivityError.isPresent(), is(true));
ErrorModel connectivityError = optConnectivityError.get();
assertThat(connectivityError.getType(), is(CONNECTIVITY_ERROR_IDENTIFIER));
assertThat(connectivityError.getNamespace(), is(HEISENBERG));
Optional<ErrorModel> optMuleConnectivityError = connectivityError.getParent();
assertThat(optMuleConnectivityError.isPresent(), is(true));
ErrorModel muleConnectivityError = optMuleConnectivityError.get();
assertThat(muleConnectivityError.getType(), is(CONNECTIVITY_ERROR_IDENTIFIER));
assertThat(muleConnectivityError.getNamespace(), is(MULE_NAMESPACE));
}
use of org.mule.runtime.api.meta.model.error.ErrorModel in project mule by mulesoft.
the class ErrorsDeclarationEnricherTestCase method operationThrowsOverridesExtensionThrows.
@Test
public void operationThrowsOverridesExtensionThrows() {
extensionModel = loadExtension(HeisenbergWithOperationThrows.class);
OperationModel someOperation = extensionModel.getOperationModel("someOperation").get();
Optional<ErrorModel> operationError = someOperation.getErrorModels().stream().filter(errorModel -> errorModel.getType().equals(OPERATION.getType())).findFirst();
assertThat(operationError.isPresent(), is(true));
}
Aggregations