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;
}
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));
}
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());
});
}
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));
}
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));
}
Aggregations