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")));
}
Aggregations