use of de.fraunhofer.iosb.ilt.faaast.service.model.value.RangeValue in project FAAAST-Service by FraunhoferIOSB.
the class ElementValueMapperTest method testRangeToValueMapping.
@Test
public void testRangeToValueMapping() {
RangeValue expected = RangeValue.builder().min(new DoubleValue(2.3)).max(new DoubleValue(5.1)).build();
SubmodelElement input = new DefaultRange.Builder().valueType(expected.getMin().getDataType().getName()).min(expected.getMin().asString()).max(expected.getMax().asString()).build();
ElementValue actual = ElementValueMapper.toValue(input);
Assert.assertEquals(expected, actual);
}
use of de.fraunhofer.iosb.ilt.faaast.service.model.value.RangeValue in project FAAAST-Service by FraunhoferIOSB.
the class RangeValueMapper method toValue.
@Override
public RangeValue toValue(Range submodelElement) {
if (submodelElement == null) {
return null;
}
RangeValue rangeValue = new RangeValue();
try {
rangeValue.setMin(TypedValueFactory.create(submodelElement.getValueType(), submodelElement.getMin()));
rangeValue.setMax(TypedValueFactory.create(submodelElement.getValueType(), submodelElement.getMax()));
} catch (ValueFormatException ex) {
// TODO properly throw?
throw new RuntimeException("invalid data value");
}
return rangeValue;
}
use of de.fraunhofer.iosb.ilt.faaast.service.model.value.RangeValue in project FAAAST-Service by FraunhoferIOSB.
the class ElementValueMapperTest method testRangeSetValueMapping.
@Test
public void testRangeSetValueMapping() {
SubmodelElement actual = new DefaultRange.Builder().build();
RangeValue value = RangeValue.builder().min(new DoubleValue(2.3)).max(new DoubleValue(5.1)).build();
SubmodelElement expected = new DefaultRange.Builder().valueType(value.getMin().getDataType().getName()).min(value.getMin().asString()).max(value.getMax().asString()).build();
ElementValueMapper.setValue(actual, value);
Assert.assertEquals(expected, actual);
}
Aggregations