use of org.eclipse.vorto.model.runtime.PropertyValue 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);
}
use of org.eclipse.vorto.model.runtime.PropertyValue 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.model.runtime.PropertyValue in project vorto by eclipse.
the class TwinPayloadFactory method createFunctionBlockProperties.
private static Map<String, Object> createFunctionBlockProperties(FunctionblockValue fbData) {
Map<String, Object> result = new HashMap<String, Object>();
Map<String, Object> status = new HashMap<String, Object>();
for (PropertyValue statusProperty : fbData.getStatus()) {
status.put(statusProperty.getMeta().getName(), statusProperty.serialize());
}
if (!status.isEmpty()) {
result.put("status", status);
}
Map<String, Object> config = new HashMap<String, Object>();
for (PropertyValue configProperty : fbData.getConfiguration()) {
config.put(configProperty.getMeta().getName(), configProperty.serialize());
}
if (!config.isEmpty()) {
result.put("configuration", config);
}
return result;
}
use of org.eclipse.vorto.model.runtime.PropertyValue in project vorto by eclipse.
the class TwinPayloadFactory method createFunctionBlockProperties.
private static Map<String, Object> createFunctionBlockProperties(FunctionblockValue fbData) {
Map<String, Object> result = new HashMap<String, Object>();
Map<String, Object> status = new HashMap<String, Object>();
for (PropertyValue statusProperty : fbData.getStatus()) {
status.put(statusProperty.getMeta().getName(), statusProperty.serialize());
}
if (!status.isEmpty()) {
result.put("status", status);
}
Map<String, Object> config = new HashMap<String, Object>();
for (PropertyValue configProperty : fbData.getConfiguration()) {
config.put(configProperty.getMeta().getName(), configProperty.serialize());
}
if (!config.isEmpty()) {
result.put("configuration", config);
}
return result;
}
Aggregations