Search in sources :

Example 1 with ExpressionModule

use of org.mule.runtime.api.el.ExpressionModule in project mule by mulesoft.

the class DefaultBindingContextBuilderTestCase method fromPreviousBindings.

@Test
public void fromPreviousBindings() {
    ExpressionModule module = ExpressionModule.builder(namespace).addBinding("id", typedValue).build();
    BindingContext previousContext = BindingContext.builder().addBinding(ID, typedValue).addBinding(OTHER_ID, typedValue).addModule(module).build();
    BindingContext context = BindingContext.builder(previousContext).build();
    assertThat(context.bindings(), hasSize(2));
    assertThat(context.identifiers(), hasItems(ID, OTHER_ID));
    assertThat(context.lookup(ID).get(), is(sameInstance(typedValue)));
    assertThat(context.lookup(OTHER_ID).get(), is(sameInstance(typedValue)));
    assertThat(context.modules(), hasSize(1));
    assertThat(context.modules(), hasItems(module));
}
Also used : ExpressionModule(org.mule.runtime.api.el.ExpressionModule) BindingContext(org.mule.runtime.api.el.BindingContext) Test(org.junit.Test)

Example 2 with ExpressionModule

use of org.mule.runtime.api.el.ExpressionModule in project mule by mulesoft.

the class DefaultBindingContextBuilderTestCase method addsBindings.

@Test
public void addsBindings() {
    ExpressionModule module = ExpressionModule.builder(namespace).addBinding(ID, typedValue).build();
    BindingContext previousContext = BindingContext.builder().addBinding(ID, typedValue).addBinding(OTHER_ID, typedValue).addModule(module).build();
    BindingContext context = builder.addAll(previousContext).build();
    assertThat(context.bindings(), hasSize(2));
    assertThat(context.identifiers(), hasItems(ID, OTHER_ID));
    assertThat(context.lookup(ID).get(), is(sameInstance(typedValue)));
    assertThat(context.lookup(OTHER_ID).get(), is(sameInstance(typedValue)));
    assertThat(context.modules(), hasSize(1));
    assertThat(context.modules(), hasItems(module));
    Collection<Binding> moduleBindings = context.modules().iterator().next().bindings();
    assertThat(moduleBindings, hasSize(1));
    assertThat(moduleBindings.iterator().next().identifier(), is(ID));
}
Also used : Binding(org.mule.runtime.api.el.Binding) ExpressionModule(org.mule.runtime.api.el.ExpressionModule) BindingContext(org.mule.runtime.api.el.BindingContext) Test(org.junit.Test)

Example 3 with ExpressionModule

use of org.mule.runtime.api.el.ExpressionModule in project mule by mulesoft.

the class DefaultExpressionModuleBuilderTestCase method shouldBeAddedToBindingContext.

@Test
public void shouldBeAddedToBindingContext() {
    BindingContext.Builder bindingContextBuilder = BindingContext.builder();
    ExpressionModule.Builder builder = ExpressionModule.builder(namespace);
    builder.addBinding("id", typedValue);
    ExpressionModule module = builder.build();
    bindingContextBuilder.addModule(module);
    BindingContext bindingContext = bindingContextBuilder.build();
    assertThat(bindingContext.modules(), hasSize(1));
    assertThat(bindingContext.modules(), hasItem(module));
}
Also used : ExpressionModule(org.mule.runtime.api.el.ExpressionModule) BindingContext(org.mule.runtime.api.el.BindingContext) Test(org.junit.Test)

Example 4 with ExpressionModule

use of org.mule.runtime.api.el.ExpressionModule in project mule by mulesoft.

the class DefaultExpressionModuleBuilderTestCase method shouldCreateTheModuleCorrectly.

@Test
public void shouldCreateTheModuleCorrectly() {
    ExpressionModule.Builder builder = ExpressionModule.builder(namespace);
    builder.addBinding(ID, typedValue);
    ExpressionModule module = builder.build();
    assertThat(module.bindings(), hasSize(1));
    assertThat(module.identifiers(), hasItem(ID));
    assertThat(module.lookup(ID).get(), is(sameInstance(typedValue)));
    assertThat(module.namespace(), is(namespace));
}
Also used : ExpressionModule(org.mule.runtime.api.el.ExpressionModule) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)4 ExpressionModule (org.mule.runtime.api.el.ExpressionModule)4 BindingContext (org.mule.runtime.api.el.BindingContext)3 Binding (org.mule.runtime.api.el.Binding)1