use of org.eclipse.vorto.service.mapping.spec.SpecWithTimestamp in project vorto by eclipse.
the class JsonMappingTest method testDittoMappingTimestamp.
@Test
public void testDittoMappingTimestamp() throws Exception {
IDataMapper<DittoData> mapper = IDataMapper.newBuilder().withSpecification(new SpecWithTimestamp()).buildDittoMapper();
final Date timestamp = new Date();
String json = "{\"time\" : " + timestamp.getTime() + "}";
DittoData mappedDittoOutput = mapper.map(DataInput.newInstance().fromJson(json), MappingContext.empty());
Feature buttonFeature = mappedDittoOutput.getFeatures().get("button");
assertEquals(JSON_DATE_FORMAT.format(timestamp), buttonFeature.getStatusProperties().get("sensor_value"));
System.out.println(mappedDittoOutput.toJson());
}
Aggregations