Search in sources :

Example 1 with SpecWithTypeConversion

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

the class JsonMappingTest method testDittoMappingTypeConversion.

@Test
public void testDittoMappingTypeConversion() throws Exception {
    IDataMapper<DittoData> mapper = IDataMapper.newBuilder().withSpecification(new SpecWithTypeConversion()).buildDittoMapper();
    String json = "[{\"lng\" : 0.002322},{\"lng\" : 0.002222}]";
    DittoData mappedDittoOutput = mapper.map(DataInput.newInstance().fromJson(json), MappingContext.empty());
    Feature buttonFeature = mappedDittoOutput.getFeatures().get("button");
    assertEquals("0.002322", buttonFeature.getStatusProperties().get("sensor_value"));
    System.out.println(mappedDittoOutput.toJson());
}
Also used : SpecWithTypeConversion(org.eclipse.vorto.service.mapping.spec.SpecWithTypeConversion) 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 SpecWithTypeConversion (org.eclipse.vorto.service.mapping.spec.SpecWithTypeConversion)1 Test (org.junit.Test)1