@Test public void testRule() { Set<IntegerAnnotation> annotations = new TreeSet<>(); IntegerOntologyObjectFactory factory = new IntegerOntologyObjectFactoryImpl(); NormalizerNR2_3 normalizer = new NormalizerNR2_3(factory); IntegerObjectProperty r = factory.getDataTypeFactory().createObjectProperty( factory.getEntityManager().createNamedEntity(IntegerEntityType.OBJECT_PROPERTY, "r", false)); IntegerClass c1 = factory.getDataTypeFactory() .createClass(factory.getEntityManager().createNamedEntity(IntegerEntityType.CLASS, "C1", false)); IntegerObjectProperty s1 = factory.getDataTypeFactory().createObjectProperty( factory.getEntityManager().createNamedEntity(IntegerEntityType.OBJECT_PROPERTY, "s1", false)); IntegerClass c2 = factory.getDataTypeFactory() .createClass(factory.getEntityManager().createNamedEntity(IntegerEntityType.CLASS, "C2", false)); IntegerObjectProperty s2 = factory.getDataTypeFactory().createObjectProperty( factory.getEntityManager().createNamedEntity(IntegerEntityType.OBJECT_PROPERTY, "s2", false)); IntegerClassExpression cPrime = factory.getDataTypeFactory().createObjectSomeValuesFrom(s1, c1); IntegerClassExpression c = factory.getDataTypeFactory().createObjectSomeValuesFrom(r, cPrime); IntegerClassExpression d = factory.getDataTypeFactory().createObjectSomeValuesFrom(s2, c2); IntegerSubClassOfAxiom axiom = factory.getComplexAxiomFactory().createSubClassOfAxiom(c, d, annotations); Set<IntegerAxiom> normalizedAxioms = normalizer.apply(axiom); IntegerClassExpression a = null; for (IntegerAxiom normAxiom : normalizedAxioms) { if (normAxiom instanceof IntegerSubClassOfAxiom) { IntegerSubClassOfAxiom currentAxiom = (IntegerSubClassOfAxiom) normAxiom; IntegerClassExpression leftExpr = currentAxiom.getSubClass(); if (leftExpr instanceof IntegerObjectSomeValuesFrom) { IntegerObjectSomeValuesFrom expr = (IntegerObjectSomeValuesFrom) leftExpr; if (expr.getProperty().equals(r)) { Assert.assertTrue(Objects.isNull(a)); a = expr.getFiller(); } } } } Assert.assertTrue(Objects.nonNull(a)); Assert.assertTrue(a.isLiteral()); Set<IntegerAxiom> expectedAxioms = new HashSet<>(); expectedAxioms.add(factory.getComplexAxiomFactory().createSubClassOfAxiom(cPrime, a, annotations)); IntegerClassExpression newExpr = factory.getDataTypeFactory().createObjectSomeValuesFrom(r, a); expectedAxioms.add(factory.getComplexAxiomFactory().createSubClassOfAxiom(newExpr, d, annotations)); Assert.assertEquals(expectedAxioms, normalizedAxioms); }
@Override public Set<IntegerAxiom> apply(IntegerAxiom axiom) { Objects.requireNonNull(axiom); Set<IntegerAxiom> ret = Collections.emptySet(); if (axiom instanceof IntegerSubClassOfAxiom) { ret = applyRule((IntegerSubClassOfAxiom) axiom); } return ret; }
NormalizerNR2_3 implements NormalizationRule { @Override public Set<IntegerAxiom> apply(IntegerAxiom axiom) { Objects.requireNonNull(axiom); Set<IntegerAxiom> ret = Collections.emptySet(); if (axiom instanceof IntegerSubClassOfAxiom) { ret = applyRule((IntegerSubClassOfAxiom) axiom); } return ret; } }
NormalizerNR2_3 implements NormalizationRule { @Override public Set<IntegerAxiom> apply(IntegerAxiom axiom) { Objects.requireNonNull(axiom); Set<IntegerAxiom> ret = Collections.emptySet(); if (axiom instanceof IntegerSubClassOfAxiom) { ret = applyRule((IntegerSubClassOfAxiom) axiom); } return ret; } NormalizerNR2_3(IntegerOntologyObjectFactory factory); }
NormalizerNR2_3 implements NormalizationRule { @Override public Set<IntegerAxiom> apply(IntegerAxiom axiom) { Objects.requireNonNull(axiom); Set<IntegerAxiom> ret = Collections.emptySet(); if (axiom instanceof IntegerSubClassOfAxiom) { ret = applyRule((IntegerSubClassOfAxiom) axiom); } return ret; } NormalizerNR2_3(IntegerOntologyObjectFactory factory); @Override Set<IntegerAxiom> apply(IntegerAxiom axiom); }
NormalizerNR2_3 implements NormalizationRule { @Override public Set<IntegerAxiom> apply(IntegerAxiom axiom) { Objects.requireNonNull(axiom); Set<IntegerAxiom> ret = Collections.emptySet(); if (axiom instanceof IntegerSubClassOfAxiom) { ret = applyRule((IntegerSubClassOfAxiom) axiom); } return ret; } NormalizerNR2_3(IntegerOntologyObjectFactory factory); @Override Set<IntegerAxiom> apply(IntegerAxiom axiom);  }