Search in sources :

Example 1 with SpecWithNestedEnum

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

the class DataMapperTest method testMappingWithEnum.

@Test
public void testMappingWithEnum() throws Exception {
    IDataMapper mapper = IDataMapper.newBuilder().withSpecification(new SpecWithNestedEnum()).build();
    final String sampleDeviceData = "{\"temperature\" : 20.3 }";
    IPayloadDeserializer deserializer = new JSONDeserializer();
    InfomodelValue mappedOutput = mapper.mapSource(deserializer.deserialize(sampleDeviceData));
    assertEquals(20.3, mappedOutput.get("outdoorTemperature").getStatusProperty("value").get().getValue());
    assertEquals("Celcius", mappedOutput.get("outdoorTemperature").getStatusProperty("unit").get().getValue());
}
Also used : SpecWithNestedEnum(org.eclipse.vorto.service.mapping.spec.SpecWithNestedEnum) IPayloadDeserializer(org.eclipse.vorto.mapping.engine.decoder.IPayloadDeserializer) IDataMapper(org.eclipse.vorto.mapping.engine.IDataMapper) JSONDeserializer(org.eclipse.vorto.mapping.engine.decoder.JSONDeserializer) InfomodelValue(org.eclipse.vorto.model.runtime.InfomodelValue) Test(org.junit.Test)

Aggregations

IDataMapper (org.eclipse.vorto.mapping.engine.IDataMapper)1 IPayloadDeserializer (org.eclipse.vorto.mapping.engine.decoder.IPayloadDeserializer)1 JSONDeserializer (org.eclipse.vorto.mapping.engine.decoder.JSONDeserializer)1 InfomodelValue (org.eclipse.vorto.model.runtime.InfomodelValue)1 SpecWithNestedEnum (org.eclipse.vorto.service.mapping.spec.SpecWithNestedEnum)1 Test (org.junit.Test)1