use of org.mule.runtime.extension.api.runtime.config.ConfigurationInstance 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));
}
use of org.mule.runtime.extension.api.runtime.config.ConfigurationInstance in project mule by mulesoft.
the class DynamicConfigurationProviderTestCase method getExpired.
@Test
public void getExpired() throws Exception {
HeisenbergExtension instance1 = (HeisenbergExtension) provider.get(event).getValue();
HeisenbergExtension instance2 = makeAlternateInstance();
DynamicConfigurationProvider provider = (DynamicConfigurationProvider) this.provider;
timeSupplier.move(1, MINUTES);
List<ConfigurationInstance> expired = provider.getExpired();
assertThat(expired.isEmpty(), is(true));
timeSupplier.move(10, MINUTES);
expired = provider.getExpired();
assertThat(expired.isEmpty(), is(false));
List<Object> configs = expired.stream().map(config -> config.getValue()).collect(toImmutableList());
assertThat(configs, containsInAnyOrder(instance1, instance2));
}
use of org.mule.runtime.extension.api.runtime.config.ConfigurationInstance in project mule by mulesoft.
the class ExtensionConnectionSupplierTestCase method xaTransaction.
@Test
public void xaTransaction() throws Exception {
muleContext.setTransactionManager(mock(TransactionManager.class, RETURNS_DEEP_STUBS));
XaTransaction transaction = spy(new XaTransaction(muleContext));
XATransactionalConnection connection = mock(XATransactionalConnection.class, RETURNS_DEEP_STUBS);
Object config = new Object();
ExecutionContextAdapter operationContext = mock(ExecutionContextAdapter.class, RETURNS_DEEP_STUBS);
ConnectionProvider connectionProvider = mock(ConnectionProvider.class);
ConfigurationInstance configurationInstance = mock(ConfigurationInstance.class);
when(configurationInstance.getConnectionProvider()).thenReturn(of(connectionProvider));
when(operationContext.getConfiguration()).thenReturn(of(configurationInstance));
when(configurationInstance.getValue()).thenReturn(config);
when(connectionProvider.connect()).thenReturn(connection);
TransactionConfig transactionConfig = mock(TransactionConfig.class);
when(transactionConfig.getAction()).thenReturn(ACTION_ALWAYS_JOIN);
when(transactionConfig.isTransacted()).thenReturn(true);
when(operationContext.getTransactionConfig()).thenReturn(of(transactionConfig));
connectionManager.bind(config, connectionProvider);
TransactionCoordination.getInstance().bindTransaction(transaction);
adapter.getConnection(operationContext);
verify(transaction).bindResource(any(), any(XAExtensionTransactionalResource.class));
}
use of org.mule.runtime.extension.api.runtime.config.ConfigurationInstance in project mule by mulesoft.
the class DefaultExtensionManager method getConfiguration.
/**
* {@inheritDoc}
*/
@Override
public Optional<ConfigurationInstance> getConfiguration(ExtensionModel extensionModel, ComponentModel componentModel, CoreEvent muleEvent) {
ConfigurationInstance instance = getConfigurationProvider(extensionModel, componentModel).map(p -> p.get(muleEvent)).orElse(null);
if (instance != null) {
return of(instance);
}
Optional<ConfigurationModel> configurationModel = getConfigurationModelForExtension(extensionModel, getConfigurationForComponent(extensionModel, componentModel));
if (configurationModel.isPresent()) {
createImplicitConfiguration(extensionModel, configurationModel.get(), muleEvent);
return of(getConfiguration(getImplicitConfigurationProviderName(extensionModel, configurationModel.get()), muleEvent));
}
return empty();
}
use of org.mule.runtime.extension.api.runtime.config.ConfigurationInstance in project mule by mulesoft.
the class DefaultExtensionManagerTestCase method getConfigurationByName.
@Test
public void getConfigurationByName() throws Exception {
registerConfigurationProvider();
ConfigurationInstance configurationInstance = extensionsManager.getConfiguration(EXTENSION1_CONFIG_INSTANCE_NAME, event);
assertThat(configurationInstance.getValue(), is(sameInstance(configInstance)));
}
Aggregations