Search in sources :

Example 1 with Binding

use of org.mule.runtime.api.el.Binding 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)

Aggregations

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