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));
}
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));
}
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));
}
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));
}
Aggregations