use of org.eclipse.vorto.service.mapping.spec.SpecWithCondition in project vorto by eclipse.
the class JsonMappingTest method testMapWithSimpleCondition.
@Test
public void testMapWithSimpleCondition() throws Exception {
IDataMapper<DittoData> mapper = IDataMapper.newBuilder().withSpecification(new SpecWithCondition()).buildDittoMapper();
String json = "{\"count\" : 2 }";
DittoData mappedDittoOutput = mapper.map(DataInput.newInstance().fromJson(json), MappingContext.empty());
assertNull(mappedDittoOutput.getFeatures().get("button").getStatusProperties().get("sensor_value"));
assertEquals(2, mappedDittoOutput.getFeatures().get("button").getStatusProperties().get("sensor_value2"));
json = "{\"count\" : 0 }";
mappedDittoOutput = mapper.map(DataInput.newInstance().fromJson(json), MappingContext.empty());
assertEquals(0, mappedDittoOutput.getFeatures().get("button").getStatusProperties().get("sensor_value"));
assertNull(mappedDittoOutput.getFeatures().get("button").getStatusProperties().get("sensor_value2"));
}
Aggregations