use of org.mule.runtime.core.privileged.util.AttributeEvaluator in project mule by mulesoft.
the class DWAttributeEvaluatorTestCase method getListOfMapsFromJsonCar.
@Test
public void getListOfMapsFromJsonCar() throws MuleException {
AttributeEvaluator attributeEvaluator = getAttributeEvaluator("#[[payload as Object]]", DataType.fromType(List.class));
List<Map<String, String>> cars = attributeEvaluator.resolveValue(newEvent(JSON_CAR, APPLICATION_JSON));
Map<String, String> car = cars.get(0);
assertThat(car, hasEntry(is("price"), is(1000)));
assertThat(car, hasEntry(is("color"), is("RED")));
}
use of org.mule.runtime.core.privileged.util.AttributeEvaluator in project mule by mulesoft.
the class DWAttributeEvaluatorTestCase method getJavaCarFromJsonCar.
@Test
public void getJavaCarFromJsonCar() throws MuleException {
AttributeEvaluator attributeEvaluator = getAttributeEvaluator("#[payload]", CAR_DATA_TYPE);
Object car = attributeEvaluator.resolveValue(newEvent(JSON_CAR, APPLICATION_JSON));
assertThat(car, is(allOf(hasProperty("color", is("RED")), hasProperty("price", is(1000)))));
}
use of org.mule.runtime.core.privileged.util.AttributeEvaluator in project mule by mulesoft.
the class DWAttributeEvaluatorTestCase method getBooleanValue.
@Test
public void getBooleanValue() throws MuleException {
AttributeEvaluator attributeEvaluator = getAttributeEvaluator("#[payload.ok]", BOOLEAN);
Boolean bool = attributeEvaluator.resolveValue(newEvent("{\"ok\" : true}", APPLICATION_JSON));
assertThat(bool, is(true));
}
use of org.mule.runtime.core.privileged.util.AttributeEvaluator in project mule by mulesoft.
the class DWAttributeEvaluatorTestCase method getJavaObjectFromStringJsonProperty.
@Test
public void getJavaObjectFromStringJsonProperty() throws MuleException {
AttributeEvaluator attributeEvaluator = getAttributeEvaluator("#[payload.host]", OBJECT);
CoreEvent event = newEvent(HOST_PORT_JSON, APPLICATION_JSON);
Object resolveValue = attributeEvaluator.resolveValue(event);
assertThat(IOUtils.toString((InputStream) ((CursorProvider) resolveValue).openCursor()), is("\"0.0.0.0\""));
}
use of org.mule.runtime.core.privileged.util.AttributeEvaluator in project mule by mulesoft.
the class DWAttributeEvaluatorTestCase method resolveIntegerValueFromJsonObject.
@Test
public void resolveIntegerValueFromJsonObject() throws MuleException {
AttributeEvaluator attributeEvaluator = getAttributeEvaluator("#[payload.port]", NUMBER);
Integer port = attributeEvaluator.resolveValue(newEvent(HOST_PORT_JSON, APPLICATION_JSON));
assertThat(port, is(8081));
}
Aggregations