use of org.mule.runtime.api.metadata.TypedValue in project mule by mulesoft.
the class IdempotentRedeliveryPolicyTestCase method testMessageRedeliveryUsingSerializationStore.
@Test
public void testMessageRedeliveryUsingSerializationStore() throws Exception {
when(expressionManager.evaluate(eq(format(SECURE_HASH_EXPR_FORMAT, "SHA-256")), eq(STRING), eq(NULL_BINDING_CONTEXT), any())).thenAnswer(inv -> {
return new TypedValue<>("" + inv.getArgumentAt(3, CoreEvent.class).getMessage().getPayload().hashCode(), STRING);
});
when(message.getPayload()).thenReturn(new TypedValue<>(STRING_MESSAGE, STRING));
reset(mockObjectStoreManager);
final ObjectStore serializationObjectStore = new SerializationObjectStore();
when(mockObjectStoreManager.createObjectStore(any(), any())).thenReturn(serializationObjectStore);
irp.initialise();
processUntilFailure();
assertThat(count.get(), equalTo(MAX_REDELIVERY_COUNT + 1));
}
use of org.mule.runtime.api.metadata.TypedValue in project mule by mulesoft.
the class ExpressionEvaluatorTestCase method handleNullEvent.
@Test
public void handleNullEvent() throws MuleException {
TypedValue evaluate = muleContext.getExpressionManager().evaluate("%dw 2.0\noutput application/json\n---\n{a: 1}");
ByteArrayBasedCursorStreamProvider value = (ByteArrayBasedCursorStreamProvider) evaluate.getValue();
String expected = "{\n" + " \"a\": 1\n" + "}";
assertThat(IOUtils.toString(value), is(expected));
}
use of org.mule.runtime.api.metadata.TypedValue in project mule by mulesoft.
the class MELAttributeEvaluatorTestCase method parenthesesInExpression.
@Test
public void parenthesesInExpression() {
when(mockExpressionManager.evaluate(anyString(), any(CoreEvent.class))).thenReturn(new TypedValue(null, OBJECT));
AttributeEvaluator attributeEvaluator = new AttributeEvaluator("#[mel:(1)]");
attributeEvaluator.initialize(mockExpressionManager);
attributeEvaluator.resolveValue(event);
verify(mockExpressionManager, never()).parse(anyString(), any(CoreEvent.class), any());
verify(mockExpressionManager).evaluate(anyString(), any(CoreEvent.class));
verify(mockExpressionManager, never()).evaluate(anyString(), any(DataType.class), any(), any(CoreEvent.class));
}
use of org.mule.runtime.api.metadata.TypedValue in project mule by mulesoft.
the class MELAttributeEvaluatorTestCase method expressionValueNoEvaluator.
@Test
public void expressionValueNoEvaluator() {
String attributeValue = "#[mel:express]";
when(mockExpressionManager.evaluate(eq(attributeValue), any(CoreEvent.class))).thenReturn(new TypedValue(null, OBJECT));
when(mockExpressionManager.isExpression(attributeValue)).thenReturn(true);
AttributeEvaluator attributeEvaluator = new AttributeEvaluator(attributeValue);
attributeEvaluator.initialize(mockExpressionManager);
attributeEvaluator.resolveValue(event);
verify(mockExpressionManager, never()).parse(anyString(), any(CoreEvent.class), any());
verify(mockExpressionManager).evaluate(anyString(), any(CoreEvent.class));
verify(mockExpressionManager, never()).evaluate(anyString(), any(DataType.class), any(), any(CoreEvent.class));
}
use of org.mule.runtime.api.metadata.TypedValue in project mule by mulesoft.
the class MELAttributeEvaluatorTestCase method expressionValue.
@Test
public void expressionValue() {
String attributeValue = "#[mel:eval:express]";
when(mockExpressionManager.evaluate(eq(attributeValue), any(CoreEvent.class))).thenReturn(new TypedValue(null, OBJECT));
when(mockExpressionManager.isExpression(attributeValue)).thenReturn(true);
AttributeEvaluator attributeEvaluator = new AttributeEvaluator(attributeValue);
attributeEvaluator.initialize(mockExpressionManager);
attributeEvaluator.resolveValue(event);
verify(mockExpressionManager, never()).parse(anyString(), any(CoreEvent.class), any());
verify(mockExpressionManager).evaluate(anyString(), any(CoreEvent.class));
verify(mockExpressionManager, never()).evaluate(anyString(), any(DataType.class), any(), any(CoreEvent.class));
}
Aggregations