Search in sources :

Example 1 with ResolverSetResult

use of org.mule.runtime.module.extension.internal.runtime.resolver.ResolverSetResult in project mule by mulesoft.

the class DynamicConfigurationProvider method get.

/**
 * Evaluates {@link #resolverSet} using the given {@code event} and returns an instance produced with the result. For equivalent
 * {@link ResolverSetResult}s it will return the same instance.
 *
 * @param event the current {@code event}
 * @return the resolved {@link ConfigurationInstance}
 */
@Override
public ConfigurationInstance get(Event event) {
    return withContextClassLoader(getExtensionClassLoader(), () -> {
        ResolverSetResult result = resolverSet.resolve(from((CoreEvent) event));
        ResolverSetResult providerResult = null;
        if (connectionProviderResolver.getResolverSet().isPresent()) {
            providerResult = ((ResolverSet) connectionProviderResolver.getResolverSet().get()).resolve(from((CoreEvent) event));
        }
        return getConfiguration(new Pair<>(result, providerResult), (CoreEvent) event);
    });
}
Also used : CoreEvent(org.mule.runtime.core.api.event.CoreEvent) ResolverSetResult(org.mule.runtime.module.extension.internal.runtime.resolver.ResolverSetResult)

Example 2 with ResolverSetResult

use of org.mule.runtime.module.extension.internal.runtime.resolver.ResolverSetResult in project mule by mulesoft.

the class OAuthConnectionProviderObjectBuilder method build.

@Override
public Pair<ConnectionProvider<C>, ResolverSetResult> build(ValueResolvingContext context) throws MuleException {
    ResolverSetResult result = resolverSet.resolve(context);
    ConnectionProvider<C> provider = super.doBuild(result);
    OAuthConfig config = new OAuthConfig(ownerConfigName, buildAuthCodeConfig(context.getEvent()), buildOAuthCallbackConfig(context.getEvent()), buildOAuthObjectStoreConfig(context.getEvent()), grantType, getCustomParameters(result), getCallbackValues());
    provider = new OAuthConnectionProviderWrapper<>(provider, config, getCallbackValues(), oauthManager, reconnectionConfig);
    return new Pair<>(provider, result);
}
Also used : ResolverSetResult(org.mule.runtime.module.extension.internal.runtime.resolver.ResolverSetResult) Pair(org.mule.runtime.api.util.Pair)

Example 3 with ResolverSetResult

use of org.mule.runtime.module.extension.internal.runtime.resolver.ResolverSetResult in project mule by mulesoft.

the class DynamicConfigurationProvider method createConfiguration.

private ConfigurationInstance createConfiguration(Pair<ResolverSetResult, ResolverSetResult> values, CoreEvent event) throws MuleException {
    ConfigurationInstance configuration;
    ResolverSetResult connectionProviderValues = values.getSecond();
    if (connectionProviderValues != null) {
        configuration = configurationInstanceFactory.createConfiguration(getName(), values.getFirst(), event, connectionProviderResolver, connectionProviderValues);
    } else {
        configuration = configurationInstanceFactory.createConfiguration(getName(), values.getFirst(), event, ofNullable(connectionProviderResolver));
    }
    registerConfiguration(configuration);
    return configuration;
}
Also used : ResolverSetResult(org.mule.runtime.module.extension.internal.runtime.resolver.ResolverSetResult) ConfigurationInstance(org.mule.runtime.extension.api.runtime.config.ConfigurationInstance)

Example 4 with ResolverSetResult

use of org.mule.runtime.module.extension.internal.runtime.resolver.ResolverSetResult in project mule by mulesoft.

the class ConfigurationInstanceFactoryTestCase method createFromResolverSetResult.

@Test
public void createFromResolverSetResult() throws Exception {
    ResolverSetResult result = ResolverSetResult.newBuilder().build();
    ConfigurationInstance configurationInstance = factory.createConfiguration(CONFIG_NAME, result, event, empty());
    assertConfiguration(configurationInstance);
    assertThat(configurationInstance.getConnectionProvider().isPresent(), is(false));
}
Also used : ResolverSetResult(org.mule.runtime.module.extension.internal.runtime.resolver.ResolverSetResult) ConfigurationInstance(org.mule.runtime.extension.api.runtime.config.ConfigurationInstance) ExtensionsTestUtils.mockConfigurationInstance(org.mule.test.module.extension.internal.util.ExtensionsTestUtils.mockConfigurationInstance) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Example 5 with ResolverSetResult

use of org.mule.runtime.module.extension.internal.runtime.resolver.ResolverSetResult in project mule by mulesoft.

the class DynamicConfigurationProviderTestCase method makeAlternateInstance.

private HeisenbergExtension makeAlternateInstance() throws Exception {
    ResolverSetResult alternateResult = mock(ResolverSetResult.class, Mockito.RETURNS_DEEP_STUBS);
    when(alternateResult.asMap()).thenReturn(new HashMap<>());
    mockConfigurationInstance(configurationModel, MODULE_CLASS.newInstance());
    when(resolverSet.resolve(from(event))).thenReturn(alternateResult);
    return (HeisenbergExtension) provider.get(event).getValue();
}
Also used : HeisenbergExtension(org.mule.test.heisenberg.extension.HeisenbergExtension) ResolverSetResult(org.mule.runtime.module.extension.internal.runtime.resolver.ResolverSetResult)

Aggregations

ResolverSetResult (org.mule.runtime.module.extension.internal.runtime.resolver.ResolverSetResult)5 ConfigurationInstance (org.mule.runtime.extension.api.runtime.config.ConfigurationInstance)2 Test (org.junit.Test)1 Pair (org.mule.runtime.api.util.Pair)1 CoreEvent (org.mule.runtime.core.api.event.CoreEvent)1 SmallTest (org.mule.tck.size.SmallTest)1 HeisenbergExtension (org.mule.test.heisenberg.extension.HeisenbergExtension)1 ExtensionsTestUtils.mockConfigurationInstance (org.mule.test.module.extension.internal.util.ExtensionsTestUtils.mockConfigurationInstance)1