Search in sources :

Example 1 with SpecWithPropertyConditionXpath

use of org.eclipse.vorto.service.mapping.spec.SpecWithPropertyConditionXpath in project vorto by eclipse.

the class DataMapperTest method testMapWithJxpathCondition.

@Test
public void testMapWithJxpathCondition() throws Exception {
    IDataMapper mapper = IDataMapper.newBuilder().withSpecification(new SpecWithPropertyConditionXpath()).build();
    String json = "{\"data\" : [{\"id\": 100,\"value\": \"x\"},{\"id\": 200,\"value\": \"y\"}]}";
    IPayloadDeserializer deserializer = new JSONDeserializer();
    InfomodelValue mappedOutput = mapper.mapSource(deserializer.deserialize(json));
    assertEquals(100.0, mappedOutput.get("button").getStatusProperty("sensor_value").get().getValue());
}
Also used : SpecWithPropertyConditionXpath(org.eclipse.vorto.service.mapping.spec.SpecWithPropertyConditionXpath) IPayloadDeserializer(org.eclipse.vorto.mapping.engine.decoder.IPayloadDeserializer) IDataMapper(org.eclipse.vorto.mapping.engine.IDataMapper) JSONDeserializer(org.eclipse.vorto.mapping.engine.decoder.JSONDeserializer) InfomodelValue(org.eclipse.vorto.model.runtime.InfomodelValue) Test(org.junit.Test)

Aggregations

IDataMapper (org.eclipse.vorto.mapping.engine.IDataMapper)1 IPayloadDeserializer (org.eclipse.vorto.mapping.engine.decoder.IPayloadDeserializer)1 JSONDeserializer (org.eclipse.vorto.mapping.engine.decoder.JSONDeserializer)1 InfomodelValue (org.eclipse.vorto.model.runtime.InfomodelValue)1 SpecWithPropertyConditionXpath (org.eclipse.vorto.service.mapping.spec.SpecWithPropertyConditionXpath)1 Test (org.junit.Test)1