Search in sources :

Example 1 with ConfigurationState

use of org.mule.runtime.extension.api.runtime.config.ConfigurationState in project mule by mulesoft.

the class ConnectionlessMessageSourceTestCase method obtainDisconnectedSourceConfigParameters.

@Test
public void obtainDisconnectedSourceConfigParameters() throws Exception {
    Component element = locator.find(Location.builder().globalName("source").addSourcePart().build()).get();
    assertThat(element, is(instanceOf(ConfiguredComponent.class)));
    final ConfigurationInstance configurationInstance = ((ConfiguredComponent) element).getConfigurationInstance().get();
    ConfigurationState configurationState = configurationInstance.getState();
    assertThat(configurationState.getConfigParameters().size(), is(0));
    assertThat(configurationState.getConnectionParameters().size(), is(0));
}
Also used : ConfigurationState(org.mule.runtime.extension.api.runtime.config.ConfigurationState) ConfiguredComponent(org.mule.runtime.extension.api.runtime.config.ConfiguredComponent) Component(org.mule.runtime.api.component.Component) ConfigurationInstance(org.mule.runtime.extension.api.runtime.config.ConfigurationInstance) Test(org.junit.Test)

Example 2 with ConfigurationState

use of org.mule.runtime.extension.api.runtime.config.ConfigurationState in project mule by mulesoft.

the class HeisenbergMessageSourceTestCase method obtainSourceConfigParameters.

@Test
public void obtainSourceConfigParameters() throws Exception {
    Component element = locator.find(Location.builder().globalName("source").addSourcePart().build()).get();
    assertThat(element, is(instanceOf(ConfiguredComponent.class)));
    ConfiguredComponent source = (ConfiguredComponent) element;
    ConfigurationState configurationState = source.getConfigurationInstance().get().getState();
    Map<String, Object> configParameters = configurationState.getConfigParameters();
    assertThat(configParameters.size(), is(13));
    assertParameter(configParameters, "enemies", hasSize(0));
    assertParameter(configParameters, "monthlyIncomes", hasSize(2));
    assertParameter(configParameters, "cancer", is(true));
    assertParameter(configParameters, "money", equalTo(new BigDecimal("0")));
    assertParameter(configParameters, "initialHealth", is(CANCER));
    assertParameter(configParameters, "endingHealth", is(CANCER));
    assertParameter(configParameters, "name", is("Heisenberg"));
    assertParameter(configParameters, "age", is(50));
    assertParameter(configParameters, "brotherInLaw", is(notNullValue()));
    Map<String, Object> connectionParameters = configurationState.getConnectionParameters();
    assertThat(connectionParameters.size(), is(2));
    assertParameter(connectionParameters, "saulPhoneNumber", equalTo(SAUL_OFFICE_NUMBER));
}
Also used : ConfigurationState(org.mule.runtime.extension.api.runtime.config.ConfigurationState) ConfiguredComponent(org.mule.runtime.extension.api.runtime.config.ConfiguredComponent) Matchers.containsString(org.hamcrest.Matchers.containsString) Component(org.mule.runtime.api.component.Component) ConfiguredComponent(org.mule.runtime.extension.api.runtime.config.ConfiguredComponent) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 Component (org.mule.runtime.api.component.Component)2 ConfigurationState (org.mule.runtime.extension.api.runtime.config.ConfigurationState)2 ConfiguredComponent (org.mule.runtime.extension.api.runtime.config.ConfiguredComponent)2 BigDecimal (java.math.BigDecimal)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1 ConfigurationInstance (org.mule.runtime.extension.api.runtime.config.ConfigurationInstance)1