use of org.eclipse.vorto.service.mapping.spec.SpecWithConditionXpath in project vorto by eclipse.
the class JsonMappingTest method testMapWithJxpathCondition.
@Test
public void testMapWithJxpathCondition() throws Exception {
IDataMapper<DittoData> mapper = IDataMapper.newBuilder().withSpecification(new SpecWithConditionXpath()).buildDittoMapper();
String json = "{\"data\" : [{\"id\": 100,\"value\": \"x\"},{\"id\": 200,\"value\": \"y\"}]}";
DittoData mappedDittoOutput = mapper.map(DataInput.newInstance().fromJson(json), MappingContext.empty());
assertEquals(100.0, mappedDittoOutput.getFeatures().get("button").getStatusProperties().get("sensor_value"));
}
Aggregations