Search in sources :

Example 1 with SpecWithConfiguration

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

the class ConfigurationMappingTest method testUnknownConfigProperty.

@Test(expected = IllegalArgumentException.class)
public void testUnknownConfigProperty() throws Exception {
    IMappingSpecification spec = new SpecWithConfiguration();
    ModelValueFactory.createFBPropertyValue(spec.getFunctionBlock("button"), "notExistProperty", true);
}
Also used : IMappingSpecification(org.eclipse.vorto.mapping.engine.model.spec.IMappingSpecification) SpecWithConfiguration(org.eclipse.vorto.service.mapping.spec.SpecWithConfiguration) Test(org.junit.Test)

Example 2 with SpecWithConfiguration

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

the class ConfigurationMappingTest method testNotExistFunction.

@Test(expected = MappingException.class)
public void testNotExistFunction() throws Exception {
    IMappingSpecification spec = new SpecWithConfiguration();
    IDataMapper mapper = IDataMapper.newBuilder().withSpecification(spec).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);
}
Also used : IMappingSpecification(org.eclipse.vorto.mapping.engine.model.spec.IMappingSpecification) IDataMapper(org.eclipse.vorto.mapping.engine.IDataMapper) PropertyValue(org.eclipse.vorto.model.runtime.PropertyValue) SpecWithConfiguration(org.eclipse.vorto.service.mapping.spec.SpecWithConfiguration) Test(org.junit.Test)

Example 3 with SpecWithConfiguration

use of org.eclipse.vorto.service.mapping.spec.SpecWithConfiguration 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);
}
Also used : IMappingSpecification(org.eclipse.vorto.mapping.engine.model.spec.IMappingSpecification) IDataMapper(org.eclipse.vorto.mapping.engine.IDataMapper) ClassFunction(org.eclipse.vorto.mapping.engine.functions.ClassFunction) PropertyValue(org.eclipse.vorto.model.runtime.PropertyValue) SpecWithConfiguration(org.eclipse.vorto.service.mapping.spec.SpecWithConfiguration) Test(org.junit.Test)

Aggregations

IMappingSpecification (org.eclipse.vorto.mapping.engine.model.spec.IMappingSpecification)3 SpecWithConfiguration (org.eclipse.vorto.service.mapping.spec.SpecWithConfiguration)3 Test (org.junit.Test)3 IDataMapper (org.eclipse.vorto.mapping.engine.IDataMapper)2 PropertyValue (org.eclipse.vorto.model.runtime.PropertyValue)2 ClassFunction (org.eclipse.vorto.mapping.engine.functions.ClassFunction)1