Search in sources :

Example 1 with SpecWithByteArrayConverter

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

the class BinaryMappingTest method testMappingWithBinary.

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