Search in sources :

Example 1 with SpecWithConditionedRules

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

the class JsonMappingTest method testMapSingleFunctionblockOfInfomodel2.

@Test
public void testMapSingleFunctionblockOfInfomodel2() {
    IDataMapper<DittoData> mapper = IDataMapper.newBuilder().withSpecification(new SpecWithConditionedRules()).buildDittoMapper();
    final String sampleHomeConnectRESTResponse = "{\"data\" : { \"key\" : \"DoorState\", \"value\" : \"Locked\"}}";
    DittoData mappedDittoOutput = mapper.map(DataInput.newInstance().fromJson(sampleHomeConnectRESTResponse), MappingContext.empty());
    System.out.println(mappedDittoOutput.toJson());
    assertFalse(mappedDittoOutput.getFeatures().containsKey("operationState"));
    Feature doorStateFeature = mappedDittoOutput.getFeatures().get("doorState");
    assertEquals("Locked", (String) doorStateFeature.getStatusProperties().get("sensor_value"));
}
Also used : SpecWithConditionedRules(org.eclipse.vorto.service.mapping.spec.SpecWithConditionedRules) Feature(org.eclipse.vorto.service.mapping.ditto.Feature) DittoData(org.eclipse.vorto.service.mapping.ditto.DittoData) Test(org.junit.Test)

Aggregations

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