use of org.eclipse.vorto.mapping.engine.functions.ClassFunction in project vorto by eclipse.
the class ConfigurationMappingTest method testMapSimpleConfigValue.
@Test
public void testMapSimpleConfigValue() throws Exception {
IMappingSpecification spec = new SpecWithConfiguration();
IDataMapper mapper = IDataMapper.newBuilder().withSpecification(spec).registerConverterFunction(new ClassFunction("button", ConfigurationMappingTest.class)).build();
PropertyValue newValue = ModelValueFactory.createFBPropertyValue(spec.getFunctionBlock("button"), "enable", true);
PropertyValue oldValue = ModelValueFactory.createFBPropertyValue(spec.getFunctionBlock("button"), "enable", false);
Object mapped = mapper.mapTarget(newValue, Optional.of(oldValue), "button");
assertEquals("1", mapped);
}
use of org.eclipse.vorto.mapping.engine.functions.ClassFunction 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());
}
Aggregations