Search in sources :

Example 11 with IMappingSpecification

use of org.eclipse.vorto.mapping.engine.model.spec.IMappingSpecification in project vorto by eclipse.

the class ConfigurationMappingTest method testMapConfigurationSource.

@Test
public void testMapConfigurationSource() throws Exception {
    IMappingSpecification spec = new SpecWithConfiguration2();
    IDataMapper mapper = IDataMapper.newBuilder().withSpecification(spec).registerConverterFunction(new ClassFunction("button", ConfigurationMappingTest.class)).build();
    Map<String, Object> source = new HashMap<String, Object>(1);
    source.put("e", true);
    InfomodelValue mapped = mapper.mapSource(source);
    assertEquals(1, mapped.get("button").getConfiguration().size());
    assertEquals(true, mapped.get("button").getConfiguration().get(0).getValue());
}
Also used : IMappingSpecification(org.eclipse.vorto.mapping.engine.model.spec.IMappingSpecification) HashMap(java.util.HashMap) IDataMapper(org.eclipse.vorto.mapping.engine.IDataMapper) ClassFunction(org.eclipse.vorto.mapping.engine.functions.ClassFunction) InfomodelValue(org.eclipse.vorto.model.runtime.InfomodelValue) SpecWithConfiguration2(org.eclipse.vorto.service.mapping.spec.SpecWithConfiguration2) Test(org.junit.Test)

Aggregations

IMappingSpecification (org.eclipse.vorto.mapping.engine.model.spec.IMappingSpecification)11 Test (org.junit.Test)10 IDataMapper (org.eclipse.vorto.mapping.engine.IDataMapper)4 InfomodelValue (org.eclipse.vorto.model.runtime.InfomodelValue)3 SpecWithConfiguration (org.eclipse.vorto.service.mapping.spec.SpecWithConfiguration)3 JSONDeserializer (org.eclipse.vorto.mapping.engine.decoder.JSONDeserializer)2 ClassFunction (org.eclipse.vorto.mapping.engine.functions.ClassFunction)2 ModelId (org.eclipse.vorto.model.ModelId)2 PropertyValue (org.eclipse.vorto.model.runtime.PropertyValue)2 HashMap (java.util.HashMap)1 IPayloadDeserializer (org.eclipse.vorto.mapping.engine.decoder.IPayloadDeserializer)1 MappingSpecification (org.eclipse.vorto.mapping.engine.model.spec.MappingSpecification)1 Infomodel (org.eclipse.vorto.model.Infomodel)1 ModelContent (org.eclipse.vorto.model.ModelContent)1 EntityPropertyValue (org.eclipse.vorto.model.runtime.EntityPropertyValue)1 SpecWithConfiguration2 (org.eclipse.vorto.service.mapping.spec.SpecWithConfiguration2)1