use of org.mule.runtime.extension.api.declaration.type.DefaultExtensionsTypeLoaderFactory in project mule by mulesoft.
the class ValueProvidersParameterDeclarationEnricher method enrichParameter.
/**
* Enriches a parameter that has an associated {@link ValueProvider}
*
* @param resolverClass the class of the {@link ValueProvider}
* @param paramDeclaration {@link ParameterDeclaration} or {@link ParameterGroupDeclaration} paramDeclaration
* @param containerParameterNames parameters container's names
*/
private void enrichParameter(OfValues resolverClass, BaseDeclaration paramDeclaration, Consumer<ValueProviderModel> valueProviderModelConsumer, Integer partOrder, Map<String, String> containerParameterNames, String name) {
ValueProviderFactoryModelPropertyBuilder propertyBuilder = ValueProviderFactoryModelProperty.builder(resolverClass.value());
ParameterizableTypeWrapper resolverClassWrapper = new ParameterizableTypeWrapper(resolverClass.value(), new DefaultExtensionsTypeLoaderFactory().createTypeLoader());
List<ExtensionParameter> resolverParameters = resolverClassWrapper.getParametersAnnotatedWith(Parameter.class);
resolverParameters.forEach(param -> propertyBuilder.withInjectableParameter(param.getName(), param.getType().asMetadataType(), param.isRequired()));
Reference<Boolean> requiresConfiguration = new Reference<>(false);
Reference<Boolean> requiresConnection = new Reference<>(false);
enrichWithConnection(propertyBuilder, resolverClassWrapper).ifPresent(field -> requiresConnection.set(true));
enrichWithConfiguration(propertyBuilder, resolverClassWrapper).ifPresent(field -> requiresConfiguration.set(true));
paramDeclaration.addModelProperty(propertyBuilder.build());
valueProviderModelConsumer.accept(new ValueProviderModel(getRequiredParametersAliases(resolverParameters, containerParameterNames), requiresConfiguration.get(), requiresConnection.get(), resolverClass.open(), partOrder, name));
}
use of org.mule.runtime.extension.api.declaration.type.DefaultExtensionsTypeLoaderFactory in project mule by mulesoft.
the class OperationMessageProcessorTestCase method setUpOperationReturning.
private void setUpOperationReturning(Object payload, Type type) throws InitialisationException {
messageProcessor = createOperationMessageProcessor();
MetadataType mapType = new DefaultExtensionsTypeLoaderFactory().createTypeLoader().load(type);
when(operationModel.getOutput()).thenReturn(new ImmutableOutputModel("desc", mapType, false, emptySet()));
initialiseIfNeeded(messageProcessor, muleContext);
when(operationExecutor.execute(any(ExecutionContext.class))).thenReturn(just(payload));
}
Aggregations