Search in sources :

Example 1 with SpecWithTwoFunctionblocksWithNestedEntity

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

the class DataMapperTest method testMappingWithEntityUnmapped.

@Test
public void testMappingWithEntityUnmapped() throws Exception {
    IDataMapper mapper = IDataMapper.newBuilder().withSpecification(new SpecWithTwoFunctionblocksWithNestedEntity()).build();
    final String sampleDeviceData = "{\"temperature\" : 20.3 }";
    IPayloadDeserializer deserializer = new JSONDeserializer();
    InfomodelValue mappedOutput = mapper.mapSource(deserializer.deserialize(sampleDeviceData));
    EntityPropertyValue temperatureValue = (EntityPropertyValue) mappedOutput.get("outdoorTemperature").getStatusProperty("value").get();
    assertEquals(20.3, temperatureValue.getValue().getPropertyValue("value").get().getValue());
    assertNull(mappedOutput.get("humidity"));
}
Also used : EntityPropertyValue(org.eclipse.vorto.model.runtime.EntityPropertyValue) IPayloadDeserializer(org.eclipse.vorto.mapping.engine.decoder.IPayloadDeserializer) IDataMapper(org.eclipse.vorto.mapping.engine.IDataMapper) SpecWithTwoFunctionblocksWithNestedEntity(org.eclipse.vorto.service.mapping.spec.SpecWithTwoFunctionblocksWithNestedEntity) 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 EntityPropertyValue (org.eclipse.vorto.model.runtime.EntityPropertyValue)1 InfomodelValue (org.eclipse.vorto.model.runtime.InfomodelValue)1 SpecWithTwoFunctionblocksWithNestedEntity (org.eclipse.vorto.service.mapping.spec.SpecWithTwoFunctionblocksWithNestedEntity)1 Test (org.junit.Test)1