Search in sources :

Example 11 with ConnectionProviderModel

use of org.mule.runtime.api.meta.model.connection.ConnectionProviderModel 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()));
}
Also used : SourceModel(org.mule.runtime.api.meta.model.source.SourceModel) ConstructModel(org.mule.runtime.api.meta.model.construct.ConstructModel) ConfigurationModel(org.mule.runtime.api.meta.model.config.ConfigurationModel) SchemaBuilder(org.mule.runtime.module.extension.internal.capability.xml.schema.builder.SchemaBuilder) XmlDslModel(org.mule.runtime.api.meta.model.XmlDslModel) IdempotentExtensionWalker(org.mule.runtime.api.meta.model.util.IdempotentExtensionWalker) ConnectionProviderModel(org.mule.runtime.api.meta.model.connection.ConnectionProviderModel) OperationModel(org.mule.runtime.api.meta.model.operation.OperationModel)

Example 12 with ConnectionProviderModel

use of org.mule.runtime.api.meta.model.connection.ConnectionProviderModel 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");
}
Also used : ConfigurationModel(org.mule.runtime.api.meta.model.config.ConfigurationModel) ParameterModel(org.mule.runtime.api.meta.model.parameter.ParameterModel) ConnectionProviderModel(org.mule.runtime.api.meta.model.connection.ConnectionProviderModel) OperationModel(org.mule.runtime.api.meta.model.operation.OperationModel)

Example 13 with ConnectionProviderModel

use of org.mule.runtime.api.meta.model.connection.ConnectionProviderModel in project mule by mulesoft.

the class ConfigurationProviderToolingAdapter method withConnectionProviderInfo.

private <T> T withConnectionProviderInfo(WithConnectionProviderCallable<T> withConnectionProviderCallable) throws ValueResolvingException {
    ConnectionProvider<?> connectionProvider = configuration.getConnectionProvider().orElseThrow(() -> new ValueResolvingException("Unable to obtain the Connection Provider Instance", UNKNOWN));
    ConnectionProvider unwrap = unwrapProviderWrapper(connectionProvider);
    ConnectionProviderModel connectionProviderModel = getConnectionProviderModel(unwrap.getClass(), getAllConnectionProviders(getExtensionModel(), getConfigurationModel())).orElseThrow(() -> new ValueResolvingException("Internal error. Unable to obtain the Connection Provider Model", UNKNOWN));
    return withConnectionProviderCallable.call(unwrap, connectionProviderModel);
}
Also used : IntrospectionUtils.getConnectionProviderModel(org.mule.runtime.module.extension.internal.util.IntrospectionUtils.getConnectionProviderModel) ConnectionProviderModel(org.mule.runtime.api.meta.model.connection.ConnectionProviderModel) ValueResolvingException(org.mule.runtime.extension.api.values.ValueResolvingException) ConnectionProvider(org.mule.runtime.api.connection.ConnectionProvider)

Example 14 with ConnectionProviderModel

use of org.mule.runtime.api.meta.model.connection.ConnectionProviderModel in project mule by mulesoft.

the class ComplexExtensionDeclarationTestCase method connectionProvider.

@Test
public void connectionProvider() {
    ConnectionProviderModel provider = extensionModel.getConfigurationModel(REQUESTER_CONFIG_NAME).get().getConnectionProviders().get(0);
    assertThat(provider.getName(), is(REQUESTER_PROVIDER));
}
Also used : ConnectionProviderModel(org.mule.runtime.api.meta.model.connection.ConnectionProviderModel) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Example 15 with ConnectionProviderModel

use of org.mule.runtime.api.meta.model.connection.ConnectionProviderModel in project mule by mulesoft.

the class DefaultExtensionModelFactoryTestCase method exportedLibraries.

@Test
public void exportedLibraries() {
    ExtensionModel extensionModel = createExtension(HeisenbergExtension.class);
    assertExternalLibraries(extensionModel);
    new IdempotentExtensionWalker() {

        @Override
        protected void onConfiguration(ConfigurationModel model) {
            assertExternalLibraries(model);
        }

        @Override
        protected void onConnectionProvider(ConnectionProviderModel model) {
            assertExternalLibraries(model);
        }
    }.walk(extensionModel);
}
Also used : ConfigurationModel(org.mule.runtime.api.meta.model.config.ConfigurationModel) ExtensionModel(org.mule.runtime.api.meta.model.ExtensionModel) IdempotentExtensionWalker(org.mule.runtime.api.meta.model.util.IdempotentExtensionWalker) ConnectionProviderModel(org.mule.runtime.api.meta.model.connection.ConnectionProviderModel) Test(org.junit.Test) SmallTest(org.mule.tck.size.SmallTest)

Aggregations

ConnectionProviderModel (org.mule.runtime.api.meta.model.connection.ConnectionProviderModel)19 ConfigurationModel (org.mule.runtime.api.meta.model.config.ConfigurationModel)12 ExtensionModel (org.mule.runtime.api.meta.model.ExtensionModel)8 OperationModel (org.mule.runtime.api.meta.model.operation.OperationModel)8 IdempotentExtensionWalker (org.mule.runtime.api.meta.model.util.IdempotentExtensionWalker)8 Test (org.junit.Test)7 SourceModel (org.mule.runtime.api.meta.model.source.SourceModel)7 ParameterModel (org.mule.runtime.api.meta.model.parameter.ParameterModel)6 List (java.util.List)4 Optional (java.util.Optional)4 Reference (org.mule.runtime.api.util.Reference)4 SmallTest (org.mule.tck.size.SmallTest)4 Arrays (java.util.Arrays)3 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 Collectors.toList (java.util.stream.Collectors.toList)3 ObjectType (org.mule.metadata.api.model.ObjectType)3 StringType (org.mule.metadata.api.model.StringType)3 Arrays.asList (java.util.Arrays.asList)2 NoSuchElementException (java.util.NoSuchElementException)2