use of org.mule.runtime.core.api.event.CoreEvent in project mule by mulesoft.
the class DataWeaveExpressionLanguageAdaptorTestCase method dataTypeBinding.
@Test
public void dataTypeBinding() throws Exception {
CoreEvent event = getEventWithError(empty());
InternalMessage message = mock(InternalMessage.class, RETURNS_DEEP_STUBS);
when(event.getMessage()).thenReturn(message);
TypedValue payload = new TypedValue<>("hey", STRING);
TypedValue attributes = new TypedValue<>(null, OBJECT);
when(message.getPayload()).thenReturn(payload);
when(message.getAttributes()).thenReturn(attributes);
TypedValue result = expressionLanguage.evaluate(DATA_TYPE, event, BindingContext.builder().build());
assertThat(result.getValue(), is(equalTo(STRING)));
assertThat(result.getDataType(), is(assignableTo(fromType(DataType.class))));
}
use of org.mule.runtime.core.api.event.CoreEvent in project mule by mulesoft.
the class DataWeaveExpressionLanguageAdaptorTestCase method itemSequenceInfoBinding.
@Test
public void itemSequenceInfoBinding() throws Exception {
CoreEvent event = spy(testEvent());
when(event.getItemSequenceInfo()).thenReturn(of(ItemSequenceInfo.of(43, 100)));
TypedValue result = expressionLanguage.evaluate(ITEM_SEQUENCE_INFO + ".position", event, BindingContext.builder().build());
assertThat(result.getValue(), is(43));
result = expressionLanguage.evaluate(ITEM_SEQUENCE_INFO + ".sequenceSize", event, BindingContext.builder().build());
assertThat(result.getValue(), is(100));
}
use of org.mule.runtime.core.api.event.CoreEvent in project mule by mulesoft.
the class DataWeaveExpressionLanguageAdaptorTestCase method accessServerFileSeparator.
@Test
public void accessServerFileSeparator() throws MuleException {
CoreEvent event = testEvent();
when(registry.lookupByName("myBean")).thenReturn(of(new MyBean("DataWeave")));
TypedValue evaluate = expressionLanguage.evaluate("server.fileSeparator", event, BindingContext.builder().build());
assertThat(evaluate.getValue(), is(FILE_SEPARATOR));
}
use of org.mule.runtime.core.api.event.CoreEvent in project mule by mulesoft.
the class DataWeaveExpressionLanguageAdaptorTestCase method authenticationBinding.
@Test
public void authenticationBinding() throws Exception {
CoreEvent event = spy(testEvent());
Authentication authentication = new DefaultMuleAuthentication(new DefaultMuleCredentials("username", "password".toCharArray()));
when(event.getAuthentication()).thenReturn(of(authentication));
TypedValue result = expressionLanguage.evaluate(AUTHENTICATION, event, BindingContext.builder().build());
assertThat(result.getValue(), is(instanceOf(Authentication.class)));
assertThat(result.getValue(), is(authentication));
assertThat(result.getDataType().getType(), is(equalTo(Authentication.class)));
}
use of org.mule.runtime.core.api.event.CoreEvent in project mule by mulesoft.
the class DataWeaveExpressionLanguageAdaptorTestCase method messageBinding.
@Test
public void messageBinding() throws Exception {
CoreEvent event = testEvent();
TypedValue result = expressionLanguage.evaluate(MESSAGE, event, BindingContext.builder().build());
assertThat(result.getValue(), is(instanceOf(Message.class)));
assertEquals(((Message) result.getValue()).getPayload(), event.getMessage().getPayload());
}
Aggregations