Search in sources :

Example 1 with SpecWithConditionXpath

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"));
}
Also used : SpecWithConditionXpath(org.eclipse.vorto.service.mapping.spec.SpecWithConditionXpath) DittoData(org.eclipse.vorto.service.mapping.ditto.DittoData) Test(org.junit.Test)

Aggregations

DittoData (org.eclipse.vorto.service.mapping.ditto.DittoData)1 SpecWithConditionXpath (org.eclipse.vorto.service.mapping.spec.SpecWithConditionXpath)1 Test (org.junit.Test)1