diff --git a/src/tests/meta/MetaResourceVariableTest.java b/src/tests/meta/MetaResourceVariableTest.java index 6eef567..2afdb18 100644 --- a/src/tests/meta/MetaResourceVariableTest.java +++ b/src/tests/meta/MetaResourceVariableTest.java @@ -14,6 +14,7 @@ import models.meta.MetaEvaluatableTermVariable; import models.meta.MetaRDLTermVariable; import models.meta.MetaResourceVariable; +import models.meta.OrderConstraint; public class MetaResourceVariableTest { @@ -47,4 +48,80 @@ assertFalse(x.isMatchedBy(depTerm)); } + @Test + void MetaResourceVariableMathcingWithConstantOrderEQ() { + ResourceVariable a = new ResourceVariable("a", INT, 1); + MetaResourceVariable x = new MetaResourceVariable(new Variable("x"), parse("0")); + MetaResourceVariable y = new MetaResourceVariable(new Variable("y"), parse("1")); + //a(1) does not match x(=0) + assertFalse(x.isMatchedBy(a)); + //a(1) matches y(=1) + assertTrue(y.isMatchedBy(a)); + } + + @Test + void MetaResourceVariableMathcingWithConstantOrderLT() { + ResourceVariable a = new ResourceVariable("a", INT, 1); + MetaResourceVariable x = new MetaResourceVariable(new Variable("x"), OrderConstraint.LT, parse("0")); + MetaResourceVariable y = new MetaResourceVariable(new Variable("y"), OrderConstraint.LT, parse("1")); + MetaResourceVariable z = new MetaResourceVariable(new Variable("z"), OrderConstraint.LT, parse("2")); + //a(1) does not match x(<0) + assertFalse(x.isMatchedBy(a)); + //a(1) matches y(<1) + assertFalse(y.isMatchedBy(a)); + //a(1) matches z(<2) + assertTrue(z.isMatchedBy(a)); + } + + @Test + void MetaResourceVariableMathcingWithConstantOrderLE() { + ResourceVariable a = new ResourceVariable("a", INT, 1); + MetaResourceVariable x = new MetaResourceVariable(new Variable("x"), OrderConstraint.LE, parse("0")); + MetaResourceVariable y = new MetaResourceVariable(new Variable("y"), OrderConstraint.LE, parse("1")); + MetaResourceVariable z = new MetaResourceVariable(new Variable("z"), OrderConstraint.LE, parse("2")); + //a(1) does not match x(<=0) + assertFalse(x.isMatchedBy(a)); + //a(1) matches y(<=1) + assertTrue(y.isMatchedBy(a)); + //a(1) matches z(<=2) + assertTrue(z.isMatchedBy(a)); + } + + @Test + void MetaResourceVariableMathcingWithConstantOrderGT() { + ResourceVariable a = new ResourceVariable("a", INT, 1); + MetaResourceVariable x = new MetaResourceVariable(new Variable("x"), OrderConstraint.GT, parse("0")); + MetaResourceVariable y = new MetaResourceVariable(new Variable("y"), OrderConstraint.GT, parse("1")); + MetaResourceVariable z = new MetaResourceVariable(new Variable("z"), OrderConstraint.GT, parse("2")); + //a(1) does not match x(>0) + assertTrue(x.isMatchedBy(a)); + //a(1) matches y(>1) + assertFalse(y.isMatchedBy(a)); + //a(1) matches z(>2) + assertFalse(z.isMatchedBy(a)); + } + + @Test + void MetaResourceVariableMathcingWithConstantOrderGE() { + ResourceVariable a = new ResourceVariable("a", INT, 1); + MetaResourceVariable x = new MetaResourceVariable(new Variable("x"), OrderConstraint.GE, parse("0")); + MetaResourceVariable y = new MetaResourceVariable(new Variable("y"), OrderConstraint.GE, parse("1")); + MetaResourceVariable z = new MetaResourceVariable(new Variable("z"), OrderConstraint.GE, parse("2")); + //a(1) does not match x(>=0) + assertTrue(x.isMatchedBy(a)); + //a(1) matches y(>=1) + assertTrue(y.isMatchedBy(a)); + //a(1) matches z(>2) + assertFalse(z.isMatchedBy(a)); + } + + @Test + void MetaResourceVariableMathcingWithEqOrder() { + ResourceVariable a = new ResourceVariable("a", INT, 0); + MetaResourceVariable x = new MetaResourceVariable(new Variable("x"), parse("x")); + + //a(0) matches x(x) + assertTrue(x.isMatchedBy(a)); + } + }