use of org.eclipse.vorto.service.mapping.spec.SpecWithSameFunctionblock in project vorto by eclipse.
the class JsonMappingTest method testDittoMappingWithInfoModelUsingSameFunctionblock.
@Test
public void testDittoMappingWithInfoModelUsingSameFunctionblock() throws Exception {
IDataMapper<DittoData> mapper = IDataMapper.newBuilder().withSpecification(new SpecWithSameFunctionblock()).buildDittoMapper();
String json = "{\"btnvalue1\" : 2, \"btnvalue2\": 10}";
DittoData mappedDittoOutput = mapper.map(DataInput.newInstance().fromJson(json), MappingContext.empty());
Feature buttonFeature = mappedDittoOutput.getFeatures().get("btn1");
assertEquals(2, buttonFeature.getStatusProperties().get("sensor_value"));
Feature button2Feature = mappedDittoOutput.getFeatures().get("btn2");
assertEquals(10, button2Feature.getStatusProperties().get("sensor_value"));
System.out.println(mappedDittoOutput.toJson());
}
Aggregations