Search in sources :

Example 1 with SpecWithSameFunctionblock

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

Aggregations

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