use of org.mule.runtime.api.metadata.TypedValue in project mule by mulesoft.
the class AbstractRemoveVariablePropertyProcessorTestCase method testRemoveVariableExpressionKeyNullValue.
// Don't fail.
@Test
public void testRemoveVariableExpressionKeyNullValue() throws MuleException {
TypedValue typedValue = new TypedValue(null, OBJECT);
when(mockExpressionManager.evaluate(eq(NULL_EXPRESSION), eq(DataType.STRING), any(), eq(event))).thenReturn(typedValue);
removeVariableProcessor.setIdentifier(NULL_EXPRESSION);
removeVariableProcessor.initialise();
event = removeVariableProcessor.process(event);
}
use of org.mule.runtime.api.metadata.TypedValue in project mule by mulesoft.
the class ExtensionActivator method registerExpressionFunctions.
private void registerExpressionFunctions(Stream<FunctionModel> functions, ExpressionModule.Builder module) {
final FunctionParameterDefaultValueResolverFactory valueResolverFactory = (defaultValue, type) -> context -> {
ExtendedExpressionManager em = muleContext.getExpressionManager();
String value = String.valueOf(defaultValue);
return em.isExpression(value) ? em.evaluate(value, type, context) : new TypedValue<>(defaultValue, type);
};
functions.forEach(function -> function.getModelProperty(FunctionExecutorModelProperty.class).ifPresent(mp -> {
FunctionExecutor executor = mp.getExecutorFactory().createExecutor(function, valueResolverFactory);
lifecycleAwareElements.add(executor);
module.addBinding(function.getName(), new TypedValue<>(executor, fromFunction(executor)));
}));
}
use of org.mule.runtime.api.metadata.TypedValue in project mule by mulesoft.
the class NotificationHelperTestCase method before.
@Before
public void before() {
when(muleContext.getNotificationManager()).thenReturn(eventNotificationHandler);
when(event.getMessage()).thenReturn(message);
when(message.getPayload()).thenReturn(new TypedValue("", DataType.STRING));
initMocks(eventNotificationHandler);
helper = new NotificationHelper(eventNotificationHandler, TestServerNotification.class, false);
}
use of org.mule.runtime.api.metadata.TypedValue in project mule by mulesoft.
the class DefaultMuleMessageBuilderTestCase method copyPreservesDataType.
@Test
public void copyPreservesDataType() {
Apple apple = new Apple();
long appleSize = 111;
Message message = new DefaultMessageBuilder().payload(new TypedValue(apple, fromObject(apple), OptionalLong.of(appleSize))).build();
Message copy = new DefaultMessageBuilder(message).build();
assertThat(copy.getPayload(), is(message.getPayload()));
assertThat(copy.getAttributes(), is(message.getAttributes()));
assertThat(message.getPayload().getByteLength().getAsLong(), is(appleSize));
assertThat(copy.getPayload().getByteLength().getAsLong(), is(appleSize));
}
use of org.mule.runtime.api.metadata.TypedValue in project mule by mulesoft.
the class DefaultMuleMessageBuilderTestCase method wholePayload.
@Test
public void wholePayload() {
Message message = Message.builder().payload(new TypedValue<>(EMPTY_JSON, JSON_STRING)).build();
assertThat(message.getPayload().getValue(), equalTo(EMPTY_JSON));
assertThat(message.getPayload().getDataType().getType(), equalTo(String.class));
assertThat(message.getPayload().getDataType().getMediaType(), is(APPLICATION_JSON));
}
Aggregations