use of fr.lirmm.graphik.graal.api.core.Ontology in project graal by graphik-team.
the class DefaultOntologyTest method testSize.
/**
* Test method for
* {@link fr.lirmm.graphik.graal.core.ruleset.DefaultOntology#size()}.
*/
@Test
public void testSize() {
// given
Ontology onto = new DefaultOntology();
onto.add(r1);
onto.add(noName);
onto.add(r1);
// when
int size = onto.size();
// then
Assert.assertEquals(2, size);
}
use of fr.lirmm.graphik.graal.api.core.Ontology in project graal by graphik-team.
the class ChaseTest method test.
@Test
public void test() throws ParseException, ChaseException {
Ontology onto = new DefaultOntology();
onto.add(DlgpParser.parseRule("p(X) :- q(X)."));
onto.add(DlgpParser.parseRule("q(X) :- p(X)."));
InMemoryAtomSet store = new DefaultInMemoryGraphStore();
store.add(DlgpParser.parseAtom("p(a)."));
Chase chase = new BreadthFirstChase(onto, store);
Assert.assertTrue(chase.hasNext());
chase.next();
Assert.assertTrue(chase.hasNext());
chase.next();
Assert.assertFalse(chase.hasNext());
}
use of fr.lirmm.graphik.graal.api.core.Ontology in project graal by graphik-team.
the class KBBuilderTest method testSetOntology.
/**
* Test method for {@link fr.lirmm.graphik.graal.kb.KBBuilder#setOntology(fr.lirmm.graphik.graal.api.core.RuleSet)}.
* @throws ParseException
*/
@Test
public void testSetOntology() throws ParseException {
// Given
KBBuilder kbb = new KBBuilder();
Ontology ontology = new DefaultOntology();
Rule r1 = DlgpParser.parseRule("[R1] p(X) :- q(X).");
ontology.add(r1);
// When
kbb.setOntology(ontology);
KnowledgeBase kb = kbb.build();
// Then
Assert.assertEquals(r1, kb.getRule("R1"));
Assert.assertEquals(1, kb.getOntology().size());
}
use of fr.lirmm.graphik.graal.api.core.Ontology in project graal by graphik-team.
the class DefaultOntologyTest method testGetRuleNames.
// /////////////////////////////////////////////////////////////////////////
//
// /////////////////////////////////////////////////////////////////////////
/**
* Test method for
* {@link fr.lirmm.graphik.graal.core.ruleset.DefaultOntology#getRuleNames()}.
*/
@Test
public void testGetRuleNames() {
// given
Ontology onto = new DefaultOntology();
onto.add(r1);
onto.add(noName);
// when
Set<String> ruleNames = onto.getRuleNames();
// then
Assert.assertTrue(ruleNames.contains(r1.getLabel()));
Assert.assertEquals(2, ruleNames.size());
}
use of fr.lirmm.graphik.graal.api.core.Ontology in project graal by graphik-team.
the class DefaultOntologyTest method testContainsSameRuleLabel.
/**
* Test method for
* {@link fr.lirmm.graphik.graal.core.ruleset.DefaultOntology#contains(fr.lirmm.graphik.graal.api.core.Rule)}.
*/
@Test
public void testContainsSameRuleLabel() {
// given
Ontology onto = new DefaultOntology();
onto.add(same1);
// when
boolean b = onto.contains(same2);
// then
Assert.assertFalse(b);
}
Aggregations