When writing a UVL model with a constraint such as A or B or C, it is correctly written as A | B | C. But when parsing it, it is parsed as (A or B) or C.
Here is a failing test case demonstrating this behavior:
@Test
void multiOr() {
FeatureModel uvlModel = new FeatureModel();
Feature root = new Feature("root");
uvlModel.getFeatureMap().put("root", root);
uvlModel.setRootFeature(root);
Group uvlRootGroup = new Group(Group.GroupType.OPTIONAL);
root.addChildren(uvlRootGroup);
Feature a = new Feature("A");
Feature b = new Feature("B");
Feature c = new Feature("C");
uvlRootGroup.getFeatures().add(a);
uvlRootGroup.getFeatures().add(b);
uvlRootGroup.getFeatures().add(c);
uvlModel.getFeatureMap().put("A", a);
uvlModel.getFeatureMap().put("B", b);
uvlModel.getFeatureMap().put("C", c);
OrConstraint constraint = new OrConstraint(
new LiteralConstraint(a),
new LiteralConstraint(b),
new LiteralConstraint(c));
uvlModel.getOwnConstraints().add(constraint);
assertEquals(constraint, new UVLModelFactory().parse(uvlModel.toString()).getConstraints().get(0));
}
When writing a UVL model with a constraint such as A or B or C, it is correctly written as
A | B | C. But when parsing it, it is parsed as (A or B) or C.Here is a failing test case demonstrating this behavior: