Search in sources :

Example 1 with SpecWithConfiguration2

use of org.eclipse.vorto.service.mapping.spec.SpecWithConfiguration2 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

HashMap (java.util.HashMap)1 IDataMapper (org.eclipse.vorto.mapping.engine.IDataMapper)1 ClassFunction (org.eclipse.vorto.mapping.engine.functions.ClassFunction)1 IMappingSpecification (org.eclipse.vorto.mapping.engine.model.spec.IMappingSpecification)1 InfomodelValue (org.eclipse.vorto.model.runtime.InfomodelValue)1 SpecWithConfiguration2 (org.eclipse.vorto.service.mapping.spec.SpecWithConfiguration2)1 Test (org.junit.Test)1