Search in sources :

Example 1 with SpecWithBase64Converter

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

the class JsonMappingTest method testMapUsingBase64Converter.

@Test
public void testMapUsingBase64Converter() throws Exception {
    IDataMapper<DittoData> mapper = IDataMapper.newBuilder().withSpecification(new SpecWithBase64Converter()).buildDittoMapper();
    String json = "{\"data\" : \"" + Base64.encodeBase64String("20".getBytes()) + "\"}";
    DittoData mappedDittoOutput = mapper.map(DataInput.newInstance().fromJson(json), MappingContext.empty());
    assertEquals("20", new String((byte[]) mappedDittoOutput.getFeatures().get("button").getStatusProperties().get("digital_input_state")));
}
Also used : SpecWithBase64Converter(org.eclipse.vorto.service.mapping.spec.SpecWithBase64Converter) DittoData(org.eclipse.vorto.service.mapping.ditto.DittoData) Test(org.junit.Test)

Aggregations

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