use of org.eclipse.vorto.service.mapping.spec.SpecWithConditionalProperties in project vorto by eclipse.
the class DataMapperTest method testMapWithSimpleCondition.
@Test
public void testMapWithSimpleCondition() throws Exception {
IDataMapper mapper = IDataMapper.newBuilder().withSpecification(new SpecWithConditionalProperties()).build();
String json = "{\"count\" : 2 }";
IPayloadDeserializer deserializer = new JSONDeserializer();
InfomodelValue mappedOutput = mapper.mapSource(deserializer.deserialize(json));
assertFalse(mappedOutput.get("button").getStatusProperty("sensor_value").isPresent());
assertEquals(2.0, mappedOutput.get("button").getStatusProperty("sensor_value2").get().getValue());
json = "{\"count\" : 0 }";
mappedOutput = mapper.mapSource(deserializer.deserialize(json));
assertEquals(0.0, mappedOutput.get("button").getStatusProperty("sensor_value").get().getValue());
assertFalse(mappedOutput.get("button").getStatusProperty("sensor_value2").isPresent());
}
Aggregations