Search in sources :

Example 6 with ConnectionProviderModel

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

the class MuleExtensionUtils method supportsOAuth.

/**
 * Whether at least one {@link ConnectionProviderModel} in the given {@cod extensionModel} supports OAuth authentication
 *
 * @param extensionModel a {@link ExtensionModel}
 * @return {@code true} if a {@link ConnectionProviderModel} exist which is OAuth enabled
 */
public static boolean supportsOAuth(ExtensionModel extensionModel) {
    Reference<ConnectionProviderModel> connectionProvider = new Reference<>();
    new IdempotentExtensionWalker() {

        @Override
        protected void onConnectionProvider(ConnectionProviderModel model) {
            if (model.getModelProperty(OAuthModelProperty.class).isPresent()) {
                connectionProvider.set(model);
                stop();
            }
        }
    }.walk(extensionModel);
    return connectionProvider.get() != null;
}
Also used : Reference(org.mule.runtime.api.util.Reference) IdempotentExtensionWalker(org.mule.runtime.api.meta.model.util.IdempotentExtensionWalker) ConnectionProviderModel(org.mule.runtime.api.meta.model.connection.ConnectionProviderModel)

Example 7 with ConnectionProviderModel

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

the class DefaultExtensionModelFactoryTestCase method untesteableConnetionProvider.

@Test
public void untesteableConnetionProvider() throws Exception {
    ExtensionModel extensionModel = createExtension(VeganExtension.class);
    ConnectionProviderModel connectionProviderModel = extensionModel.getConfigurationModel(APPLE).map(c -> c.getConnectionProviders().get(0)).get();
    assertThat(connectionProviderModel.supportsConnectivityTesting(), is(false));
}
Also used : Arrays(java.util.Arrays) ImportedTypeModel(org.mule.runtime.api.meta.model.ImportedTypeModel) HeisenbergOperations(org.mule.test.heisenberg.extension.HeisenbergOperations) VALIDATOR(org.mule.runtime.extension.api.stereotype.MuleStereotypes.VALIDATOR) HeisenbergScopes(org.mule.test.heisenberg.extension.HeisenbergScopes) DROP(org.mule.runtime.extension.api.runtime.source.BackPressureMode.DROP) VALIDATOR_DEFINITION(org.mule.runtime.extension.api.stereotype.MuleStereotypes.VALIDATOR_DEFINITION) Export(org.mule.runtime.extension.api.annotation.Export) KillingOperations(org.mule.test.heisenberg.extension.KillingOperations) CoreMatchers.instanceOf(org.hamcrest.CoreMatchers.instanceOf) CPU_LITE(org.mule.runtime.api.meta.model.operation.ExecutionType.CPU_LITE) Arrays.asList(java.util.Arrays.asList) OnException(org.mule.runtime.extension.api.annotation.OnException) ClassTypeLoader(org.mule.metadata.api.ClassTypeLoader) ObjectStore(org.mule.runtime.api.store.ObjectStore) MuleExtensionUtils.loadExtension(org.mule.runtime.module.extension.api.util.MuleExtensionUtils.loadExtension) SELECT(org.mule.runtime.api.meta.Category.SELECT) EmpireStereotype(org.mule.test.heisenberg.extension.stereotypes.EmpireStereotype) HeisenbergConnectionExceptionEnricher(org.mule.test.heisenberg.extension.exception.HeisenbergConnectionExceptionEnricher) CarDealer(org.mule.test.heisenberg.extension.model.CarDealer) EnumAnnotation(org.mule.metadata.api.annotation.EnumAnnotation) StringType(org.mule.metadata.api.model.StringType) Sources(org.mule.runtime.extension.api.annotation.Sources) MarvelExtension(org.mule.test.marvel.MarvelExtension) Operations(org.mule.runtime.extension.api.annotation.Operations) StereotypeModel(org.mule.runtime.api.meta.model.stereotype.StereotypeModel) Extension(org.mule.runtime.extension.api.annotation.Extension) CoreMatchers.equalTo(org.hamcrest.CoreMatchers.equalTo) ConnectionProviderModel(org.mule.runtime.api.meta.model.connection.ConnectionProviderModel) Ricin(org.mule.test.heisenberg.extension.model.Ricin) ExtensionsTypeLoaderFactory(org.mule.runtime.extension.api.declaration.type.ExtensionsTypeLoaderFactory) ExternalLibraryModel(org.mule.runtime.api.meta.model.ExternalLibraryModel) PaulMcCartneySource(org.mule.test.vegan.extension.PaulMcCartneySource) EmitsResponse(org.mule.runtime.extension.api.annotation.source.EmitsResponse) BackPressure(org.mule.runtime.extension.api.annotation.source.BackPressure) SecureHeisenbergConnectionProvider(org.mule.test.heisenberg.extension.SecureHeisenbergConnectionProvider) AbstractMuleTestCase(org.mule.tck.junit4.AbstractMuleTestCase) PAYLOAD(org.mule.runtime.extension.api.annotation.param.Optional.PAYLOAD) Matchers.hasSize(org.hamcrest.Matchers.hasSize) CoreMatchers.nullValue(org.hamcrest.CoreMatchers.nullValue) CONFIG_NAME(org.mule.test.marvel.ironman.IronMan.CONFIG_NAME) HasExternalLibraries(org.mule.runtime.api.meta.model.HasExternalLibraries) Investment(org.mule.test.heisenberg.extension.model.Investment) Test(org.junit.Test) HEISENBERG_LIB_DESCRIPTION(org.mule.test.heisenberg.extension.HeisenbergExtension.HEISENBERG_LIB_DESCRIPTION) ConfigurationModel(org.mule.runtime.api.meta.model.config.ConfigurationModel) BLOCKING(org.mule.runtime.api.meta.model.operation.ExecutionType.BLOCKING) VeganExtension(org.mule.test.vegan.extension.VeganExtension) ExtensionModel(org.mule.runtime.api.meta.model.ExtensionModel) MoneyLaunderingOperation(org.mule.test.heisenberg.extension.MoneyLaunderingOperation) STREAMING_STRATEGY_PARAMETER_NAME(org.mule.runtime.extension.api.ExtensionConstants.STREAMING_STRATEGY_PARAMETER_NAME) Streaming(org.mule.runtime.extension.api.annotation.Streaming) MediaType(org.mule.runtime.extension.api.annotation.param.MediaType) HeisenbergErrors(org.mule.test.heisenberg.extension.HeisenbergErrors) Reference(org.mule.runtime.api.util.Reference) HEISENBERG_LIB_FILE_NAME(org.mule.test.heisenberg.extension.HeisenbergExtension.HEISENBERG_LIB_FILE_NAME) NOT_SUPPORTED(org.mule.runtime.api.meta.ExpressionSupport.NOT_SUPPORTED) CoreMatchers.is(org.hamcrest.CoreMatchers.is) TEXT_PLAIN(org.mule.runtime.extension.api.annotation.param.MediaType.TEXT_PLAIN) OperationModel(org.mule.runtime.api.meta.model.operation.OperationModel) CoreMatchers.notNullValue(org.hamcrest.CoreMatchers.notNullValue) Assert.assertThat(org.junit.Assert.assertThat) SourceModel(org.mule.runtime.api.meta.model.source.SourceModel) APPLE(org.mule.test.vegan.extension.VeganExtension.APPLE) SmallTest(org.mule.tck.size.SmallTest) WAIT(org.mule.runtime.extension.api.runtime.source.BackPressureMode.WAIT) MetadataTypeUtils.getTypeId(org.mule.metadata.api.utils.MetadataTypeUtils.getTypeId) HEISENBERG(org.mule.test.heisenberg.extension.HeisenbergExtension.HEISENBERG) IdempotentExtensionWalker(org.mule.runtime.api.meta.model.util.IdempotentExtensionWalker) SubTypeMapping(org.mule.runtime.extension.api.annotation.SubTypeMapping) StreamingStrategyTypeBuilder(org.mule.runtime.extension.api.declaration.type.StreamingStrategyTypeBuilder) Weapon(org.mule.test.heisenberg.extension.model.Weapon) ConnectionProviders(org.mule.runtime.extension.api.annotation.connectivity.ConnectionProviders) HeisenbergException(org.mule.test.heisenberg.extension.exception.HeisenbergException) PROCESSOR_DEFINITION(org.mule.runtime.extension.api.stereotype.MuleStereotypes.PROCESSOR_DEFINITION) BACK_PRESSURE_STRATEGY_PARAMETER_NAME(org.mule.runtime.extension.api.ExtensionConstants.BACK_PRESSURE_STRATEGY_PARAMETER_NAME) PRIMARY_CONTENT(org.mule.runtime.api.meta.model.parameter.ParameterRole.PRIMARY_CONTENT) List(java.util.List) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) Optional(java.util.Optional) HeisenbergRouters(org.mule.test.heisenberg.extension.HeisenbergRouters) IllegalModelDefinitionException(org.mule.runtime.extension.api.exception.IllegalModelDefinitionException) ParameterModel(org.mule.runtime.api.meta.model.parameter.ParameterModel) Alias(org.mule.runtime.extension.api.annotation.Alias) HeisenbergSource(org.mule.test.heisenberg.extension.HeisenbergSource) CPU_INTENSIVE(org.mule.runtime.api.meta.model.operation.ExecutionType.CPU_INTENSIVE) ExpectedException.none(org.junit.rules.ExpectedException.none) HeisenbergConnectionProvider(org.mule.test.heisenberg.extension.HeisenbergConnectionProvider) HEISENBERG_LIB_CLASS_NAME(org.mule.test.heisenberg.extension.HeisenbergExtension.HEISENBERG_LIB_CLASS_NAME) NoSuchElementException(java.util.NoSuchElementException) HeisenbergExtension(org.mule.test.heisenberg.extension.HeisenbergExtension) ExpectedException(org.junit.rules.ExpectedException) ErrorTypes(org.mule.runtime.extension.api.annotation.error.ErrorTypes) CoreMatchers.sameInstance(org.hamcrest.CoreMatchers.sameInstance) OBJECT_STORE(org.mule.runtime.extension.api.stereotype.MuleStereotypes.OBJECT_STORE) HEISENBERG_LIB_NAME(org.mule.test.heisenberg.extension.HeisenbergExtension.HEISENBERG_LIB_NAME) BANANA(org.mule.test.vegan.extension.VeganExtension.BANANA) ExtensionModelUtils(org.mule.runtime.extension.api.util.ExtensionModelUtils) Collectors.toList(java.util.stream.Collectors.toList) Rule(org.junit.Rule) PROCESSOR(org.mule.runtime.extension.api.stereotype.MuleStereotypes.PROCESSOR) CarWash(org.mule.test.heisenberg.extension.model.CarWash) FAIL(org.mule.runtime.extension.api.runtime.source.BackPressureMode.FAIL) ExtensionModel(org.mule.runtime.api.meta.model.ExtensionModel) ConnectionProviderModel(org.mule.runtime.api.meta.model.connection.ConnectionProviderModel) Test(org.junit.Test) SmallTest(org.mule.tck.size.SmallTest)

Example 8 with ConnectionProviderModel

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

the class DeclarationBasedElementModelFactory method addConnectionProvider.

private void addConnectionProvider(ConnectionElementDeclaration connection, ConfigurationModel model, InternalComponentConfiguration.Builder configuration, DslElementModel.Builder<ConfigurationModel> configElement) {
    concat(model.getConnectionProviders().stream(), currentExtension.getConnectionProviders().stream()).filter(c -> c.getName().equals(connection.getName())).findFirst().ifPresent(provider -> {
        DslElementSyntax providerDsl = dsl.resolve(provider);
        InternalComponentConfiguration.Builder builder = InternalComponentConfiguration.builder().withIdentifier(asIdentifier(providerDsl));
        DslElementModel.Builder<ConnectionProviderModel> element = createParameterizedElementModel(provider, providerDsl, connection, builder);
        ComponentConfiguration providerConfig = builder.build();
        configuration.withNestedComponent(providerConfig);
        configElement.containing(element.withConfig(providerConfig).build());
    });
}
Also used : InternalComponentConfiguration(org.mule.runtime.dsl.internal.component.config.InternalComponentConfiguration) ComponentConfiguration(org.mule.runtime.dsl.api.component.config.ComponentConfiguration) DslElementSyntax(org.mule.runtime.extension.api.dsl.syntax.DslElementSyntax) DslElementModel(org.mule.runtime.config.api.dsl.model.DslElementModel) ConnectionProviderModel(org.mule.runtime.api.meta.model.connection.ConnectionProviderModel) InternalComponentConfiguration(org.mule.runtime.dsl.internal.component.config.InternalComponentConfiguration)

Example 9 with ConnectionProviderModel

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

the class SoapExtensionDeclarationTestCase method assertSoapExtensionModel.

@Test
public void assertSoapExtensionModel() {
    Map<String, Object> params = new HashMap<>();
    params.put(TYPE_PROPERTY_NAME, FootballSoapExtension.class.getName());
    params.put(VERSION, getProductVersion());
    ExtensionModel model = loader.loadExtensionModel(FootballSoapExtension.class.getClassLoader(), getDefault(emptySet()), params);
    assertErrorModels(model.getErrorModels());
    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));
    assertOperation(configuration.getOperationModels().get(0));
    List<ConnectionProviderModel> providers = configuration.getConnectionProviders();
    assertThat(providers, hasSize(3));
    assertConnectionProvider(providers.get(0), "base-connection", "", false, new ParameterProber("laLigaAddress", null, StringType.class, true), new ParameterProber("leaguesAddress", "http://some-url.com", StringType.class, false));
    assertConnectionProvider(providers.get(1), CALCIO_ID + "-connection", CALCIO_DESC, false);
    assertConnectionProvider(providers.get(2), "la-liga-connection", "", true, new ParameterProber("firstDivision", StringType.class), new ParameterProber("secondDivision", StringType.class), new ParameterProber("wsdlLocation", StringType.class));
}
Also used : ConfigurationModel(org.mule.runtime.api.meta.model.config.ConfigurationModel) HashMap(java.util.HashMap) FootballSoapExtension(org.mule.test.soap.extension.FootballSoapExtension) StringType(org.mule.metadata.api.model.StringType) ExtensionModel(org.mule.runtime.api.meta.model.ExtensionModel) ConnectionProviderModel(org.mule.runtime.api.meta.model.connection.ConnectionProviderModel) Test(org.junit.Test)

Example 10 with ConnectionProviderModel

use of org.mule.runtime.api.meta.model.connection.ConnectionProviderModel 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));
}
Also used : ObjectType(org.mule.metadata.api.model.ObjectType) ConfigurationModel(org.mule.runtime.api.meta.model.config.ConfigurationModel) HashMap(java.util.HashMap) StringType(org.mule.metadata.api.model.StringType) ExtensionModel(org.mule.runtime.api.meta.model.ExtensionModel) RickAndMortyExtension(org.mule.test.ram.RickAndMortyExtension) ConnectionProviderModel(org.mule.runtime.api.meta.model.connection.ConnectionProviderModel) Test(org.junit.Test)

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