use of org.mule.runtime.api.meta.model.config.ConfigurationModel in project mule by mulesoft.
the class SoapExtensionWithCustomTransportsDeclarationTestCase method assertSoapExtensionModel.
@Test
public void assertSoapExtensionModel() {
Map<String, Object> params = new HashMap<>();
params.put(TYPE_PROPERTY_NAME, RickAndMortyExtension.class.getName());
params.put(VERSION, getProductVersion());
ExtensionModel model = loader.loadExtensionModel(RickAndMortyExtension.class.getClassLoader(), getDefault(emptySet()), params);
assertThat(model.getConfigurationModels(), hasSize(1));
ConfigurationModel configuration = model.getConfigurationModels().get(0);
assertThat(configuration.getName(), is(DEFAULT_CONFIG_NAME));
assertThat(configuration.getDescription(), is(DEFAULT_CONFIG_DESCRIPTION));
assertThat(configuration.getOperationModels(), hasSize(1));
assertSubtypes(model);
List<ConnectionProviderModel> providers = configuration.getConnectionProviders();
assertThat(providers, hasSize(1));
assertConnectionProvider(providers.get(0), "rick-and-morty-connection", "", true, new ParameterProber("wsdlUrl", StringType.class), new ParameterProber("port", StringType.class), new ParameterProber("service", StringType.class), new ParameterProber("transport", ObjectType.class));
}
use of org.mule.runtime.api.meta.model.config.ConfigurationModel in project mule by mulesoft.
the class DefaultExtensionSchemaGenerator method generate.
/**
* {@inheritDoc}
*/
@Override
public String generate(ExtensionModel extensionModel, DslResolvingContext dslContext) {
XmlDslModel xmlDslModel = extensionModel.getXmlDslModel();
validate(extensionModel, xmlDslModel);
SchemaBuilder schemaBuilder = SchemaBuilder.newSchema(extensionModel, xmlDslModel, dslContext);
new IdempotentExtensionWalker() {
@Override
public void onConfiguration(ConfigurationModel model) {
schemaBuilder.registerConfigElement(model);
}
@Override
protected void onConstruct(ConstructModel model) {
schemaBuilder.registerOperation(model);
}
@Override
public void onOperation(OperationModel model) {
schemaBuilder.registerOperation(model);
}
@Override
public void onConnectionProvider(ConnectionProviderModel model) {
schemaBuilder.registerConnectionProviderElement(model);
}
@Override
public void onSource(SourceModel model) {
schemaBuilder.registerMessageSource(model);
}
}.walk(extensionModel);
schemaBuilder.registerEnums();
// Make sure the XML libs use the container classloader internally
return withContextClassLoader(DefaultExtensionSchemaGenerator.class.getClassLoader(), () -> renderSchema(schemaBuilder.build()));
}
use of org.mule.runtime.api.meta.model.config.ConfigurationModel in project mule by mulesoft.
the class ConfigurationProviderObjectFactory method createInnerInstance.
private ConfigurationProvider createInnerInstance() throws ConfigurationException {
if (expirationPolicy == null) {
expirationPolicy = muleContext.getConfiguration().getDynamicConfigExpiration().getExpirationPolicy();
}
ResolverSet resolverSet = getParametersResolver().getParametersAsHashedResolverSet(configurationModel, muleContext);
final ConnectionProviderValueResolver connectionProviderResolver = getConnectionProviderResolver();
return withContextClassLoader(getExtensionClassLoader(), () -> {
connectionProviderResolver.getResolverSet().ifPresent((CheckedConsumer) resolver -> initialiseIfNeeded(resolver, true, muleContext));
ConfigurationProvider configurationProvider;
try {
if (resolverSet.isDynamic() || connectionProviderResolver.isDynamic()) {
configurationProvider = configurationProviderFactory.createDynamicConfigurationProvider(name, extensionModel, configurationModel, resolverSet, connectionProviderResolver, expirationPolicy, reflectionCache, muleContext);
} else {
configurationProvider = configurationProviderFactory.createStaticConfigurationProvider(name, extensionModel, configurationModel, resolverSet, connectionProviderResolver, reflectionCache, muleContext);
}
} catch (Exception e) {
throw new MuleRuntimeException(createStaticMessage(format("Could not create an implicit configuration '%s' for the extension '%s'", configurationModel.getName(), extensionModel.getName())), e);
}
return configurationProvider;
});
}
use of org.mule.runtime.api.meta.model.config.ConfigurationModel in project mule by mulesoft.
the class ExtensionDescriptionDocumenterTestCase method assertDescriptionsSingleConfig.
private void assertDescriptionsSingleConfig(ExtensionModel extensionModel) {
assertThat(extensionModel.getConfigurationModels(), hasSize(1));
assertThat(extensionModel.getOperationModels(), hasSize(1));
OperationModel withParameterGroup = extensionModel.getOperationModels().get(0);
assertDescription(withParameterGroup, "Operation with parameter group");
List<ParameterModel> operationParams = withParameterGroup.getAllParameterModels();
assertDescription(operationParams.get(0), "value param description");
assertDescription(operationParams.get(1), "First Description");
assertDescription(operationParams.get(2), "Second Description");
ConfigurationModel config = extensionModel.getConfigurationModels().get(0);
assertDescription(extensionModel, "Test Extension Description with single config");
assertDescription(config, DEFAULT_CONFIG_DESCRIPTION);
assertDescription(config.getAllParameterModels().get(0), "Config parameter");
assertDescription(config.getAllParameterModels().get(1), "Config Parameter with an Optional value");
assertThat(config.getOperationModels(), hasSize(1));
assertDescription(config.getOperationModels().get(0), "Operation with description");
ConnectionProviderModel provider = config.getConnectionProviders().get(0);
assertDescription(provider, "Provider description");
assertDescription(provider.getAllParameterModels().get(0), "Connection Param Description");
assertDescription(provider.getAllParameterModels().get(1), "First Description");
assertDescription(provider.getAllParameterModels().get(2), "Second Description");
}
use of org.mule.runtime.api.meta.model.config.ConfigurationModel in project mule by mulesoft.
the class ExtensionDescriptionDocumenterTestCase method assertDescriptionsMultipleConfigs.
private void assertDescriptionsMultipleConfigs(ExtensionModel declaration) {
List<ConfigurationModel> configurations = declaration.getConfigurationModels();
assertDescription(declaration, "Test Extension Description");
assertThat(configurations, hasSize(2));
ConfigurationModel first = configurations.get(1);
assertDescription(first, "This is some Config documentation.");
assertDescription(first.getConnectionProviders().get(0), "Another Provider Documentation");
assertDescription(first.getConnectionProviders().get(1), "Provider Documentation");
ConfigurationModel second = configurations.get(0);
assertDescription(second, "This is some Another Config documentation.");
assertDescription(second.getConnectionProviders().get(0), "Another Provider Documentation");
List<ParameterModel> params = first.getAllParameterModels();
assertDescription(params.get(0), "Config parameter");
assertDescription(params.get(1), "Config Parameter with an Optional value");
assertDescription(params.get(2), EXPIRATION_POLICY_DESCRIPTION);
assertDescription(params.get(3), "Group parameter 1");
assertDescription(params.get(4), "Group parameter 2");
assertDescription(params.get(5), "Param with alias");
List<OperationModel> operations = declaration.getOperationModels();
OperationModel operation = getOperationByName(operations, "operation");
assertDescription(operation, "Test Operation");
assertDescription(operation.getAllParameterModels().get(0), "test value");
OperationModel inheritedOperation = getOperationByName(operations, "inheritedOperation");
assertDescription(inheritedOperation, "Inherited Operation Documentation");
assertDescription(inheritedOperation.getAllParameterModels().get(0), "parameter documentation for an inherited operation.");
OperationModel greetFriend = getOperationByName(operations, "greetFriend");
assertDescription(greetFriend, "This method greets a friend");
assertDescription(greetFriend.getAllParameterModels().get(0), "This is one of my friends");
assertDescription(greetFriend.getAllParameterModels().get(1), "Some other friend");
List<OperationModel> connectedOperations = first.getOperationModels();
OperationModel connectedOpe = connectedOperations.get(0);
assertDescription(connectedOpe, "Test Operation with blank parameter description");
assertDescription(connectedOpe.getAllParameterModels().get(0), "");
}
Aggregations