use of org.mule.runtime.core.privileged.util.AttributeEvaluator in project mule by mulesoft.
the class DWAttributeEvaluatorTestCase method getMapFromJsonCar.
@Test
public void getMapFromJsonCar() throws MuleException {
AttributeEvaluator attributeEvaluator = getAttributeEvaluator("#[payload]", DataType.fromType(Map.class));
Map<String, String> car = attributeEvaluator.resolveValue(newEvent(JSON_CAR, APPLICATION_JSON));
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 plainTextValue.
@Test
public void plainTextValue() {
String staticValue = "attributeEvaluator";
AttributeEvaluator attributeEvaluator = getAttributeEvaluator(staticValue);
assertThat(attributeEvaluator.resolveValue(mockMuleEvent), is(staticValue));
}
use of org.mule.runtime.core.privileged.util.AttributeEvaluator in project mule by mulesoft.
the class DWAttributeEvaluatorTestCase method getJavaPojo.
@Test
public void getJavaPojo() throws MuleException {
AttributeEvaluator attributeEvaluator = getAttributeEvaluator(DW_CAR, DataType.fromType(Car.class));
Object car = attributeEvaluator.resolveValue(newEvent());
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 getJavaInputStreamFromStringJsonProperty.
@Test
public void getJavaInputStreamFromStringJsonProperty() throws MuleException {
AttributeEvaluator attributeEvaluator = getAttributeEvaluator("#[payload.host]", INPUT_STREAM);
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 getListOfCarsFromJsonCar.
@Test
public void getListOfCarsFromJsonCar() throws MuleException {
AttributeEvaluator attributeEvaluator = getAttributeEvaluator("#[[payload]]", CAR_LIST_DATA_TYPE);
List<Car> cars = attributeEvaluator.resolveValue(newEvent(JSON_CAR, APPLICATION_JSON));
Car car = cars.get(0);
assertThat(car, is(allOf(hasProperty("color", is("RED")), hasProperty("price", is(1000)))));
}
Aggregations