use of fr.lirmm.graphik.graal.api.core.mapper.Mapper in project graal by graphik-team.
the class KBBuilderTest method testAddAtomMapper.
/**
* Test method for {@link fr.lirmm.graphik.graal.kb.KBBuilder#add(fr.lirmm.graphik.graal.api.core.Atom, fr.lirmm.graphik.graal.api.core.mapper.Mapper)}.
* @throws ParseException
* @throws KBBuilderException
* @throws AtomSetException
*/
@Test
public void testAddAtomMapper() throws ParseException, KBBuilderException, AtomSetException {
// Given
KBBuilder kbb = new KBBuilder();
Atom a = DlgpParser.parseAtom("p(a).");
Mapper mapper = new PrefixMapper("graphik#");
// When
kbb.add(a, mapper);
KnowledgeBase kb = kbb.build();
// Then
Assert.assertTrue(kb.getFacts().contains(DlgpParser.parseAtom("<graphik#p>(a).")));
}
use of fr.lirmm.graphik.graal.api.core.mapper.Mapper in project graal by graphik-team.
the class KBBuilderTest method testAddRulesCloseableIteratorOfObjectMapper.
/**
* Test method for {@link fr.lirmm.graphik.graal.kb.KBBuilder#addRules(fr.lirmm.graphik.util.stream.CloseableIterator, fr.lirmm.graphik.graal.api.core.mapper.Mapper)}.
* @throws KBBuilderException
* @throws ParseException
* @throws AtomSetException
*/
@Test
public void testAddRulesCloseableIteratorOfObjectMapper() throws KBBuilderException, ParseException, AtomSetException {
// Given
KBBuilder kbb = new KBBuilder();
Parser<Object> parser = new DlgpParser("[R1] p(X) :- q(X). p(a).");
Mapper mapper = new PrefixMapper("graphik#");
// When
kbb.addRules(parser, mapper);
KnowledgeBase kb = kbb.build();
// Then
Assert.assertEquals(DlgpParser.parseRule("[R1] <graphik#p>(X) :- <graphik#q>(X)."), kb.getRule("R1"));
Assert.assertFalse(kb.getFacts().contains(DlgpParser.parseAtom("p(a).")));
}
use of fr.lirmm.graphik.graal.api.core.mapper.Mapper in project graal by graphik-team.
the class PrefixMapperTest method testUnmapPredicate.
/**
* Test method for {@link fr.lirmm.graphik.graal.core.mapper.PrefixMapper#unmap(fr.lirmm.graphik.graal.api.core.Predicate)}.
*/
@Test
public void testUnmapPredicate() {
// Given
Predicate p = new Predicate("prefix#p", 1);
Mapper mapper = new PrefixMapper("prefix#");
// When
Predicate mapped = mapper.unmap(p);
// Then
Assert.assertEquals(new Predicate("p", 1), mapped);
}
Aggregations