Search in sources :

Example 21 with Predicate

use of fr.lirmm.graphik.graal.api.core.Predicate in project graal by graphik-team.

the class PrefixMapperTest method testInverseMap.

/**
 * Test method for {@link fr.lirmm.graphik.graal.core.mapper.AbstractMapper#inverse()}.
 */
@Test
public void testInverseMap() {
    // Given
    Predicate p = new Predicate("prefix#p", 1);
    Mapper mapper = new PrefixMapper("prefix#");
    // When
    Predicate mapped = mapper.inverse().map(p);
    // Then
    Assert.assertEquals(new Predicate("p", 1), mapped);
}
Also used : Mapper(fr.lirmm.graphik.graal.api.core.mapper.Mapper) Predicate(fr.lirmm.graphik.graal.api.core.Predicate) Test(org.junit.Test)

Example 22 with Predicate

use of fr.lirmm.graphik.graal.api.core.Predicate in project graal by graphik-team.

the class PrefixMapperTest method testMapPredicate.

/**
 * Test method for {@link fr.lirmm.graphik.graal.core.mapper.PrefixMapper#map(fr.lirmm.graphik.graal.api.core.Predicate)}.
 */
@Test
public void testMapPredicate() {
    // Given
    Predicate p = new Predicate("p", 1);
    Mapper mapper = new PrefixMapper("prefix#");
    // When
    Predicate mapped = mapper.map(p);
    // Then
    Assert.assertEquals(new Predicate("prefix#p", 1), mapped);
}
Also used : Mapper(fr.lirmm.graphik.graal.api.core.mapper.Mapper) Predicate(fr.lirmm.graphik.graal.api.core.Predicate) Test(org.junit.Test)

Example 23 with Predicate

use of fr.lirmm.graphik.graal.api.core.Predicate in project graal by graphik-team.

the class PrefixMapperTest method testInverseUnmap.

/**
 * Test method for {@link fr.lirmm.graphik.graal.core.mapper.AbstractMapper#inverse()}.
 */
@Test
public void testInverseUnmap() {
    // Given
    Predicate p = new Predicate("p", 1);
    Mapper mapper = new PrefixMapper("prefix#");
    // When
    Predicate mapped = mapper.inverse().unmap(p);
    // Then
    Assert.assertEquals(new Predicate("prefix#p", 1), mapped);
}
Also used : Mapper(fr.lirmm.graphik.graal.api.core.mapper.Mapper) Predicate(fr.lirmm.graphik.graal.api.core.Predicate) Test(org.junit.Test)

Example 24 with Predicate

use of fr.lirmm.graphik.graal.api.core.Predicate in project graal by graphik-team.

the class AtomTest method constructorTest.

@Test
public void constructorTest() {
    Predicate predicate = new Predicate("pred", 3);
    Term[] terms = new Term[3];
    terms[0] = new DefaultVariable("X");
    terms[1] = new DefaultConstant("a");
    terms[2] = new DefaultConstant("b");
    Atom atom = new DefaultAtom(predicate, Arrays.asList(terms));
    Assert.assertTrue(atom.getPredicate().equals(predicate));
    Assert.assertTrue(atom.getTerm(0).equals(terms[0]));
    Assert.assertTrue(atom.getTerm(1).equals(terms[1]));
    Assert.assertTrue(atom.getTerm(2).equals(terms[2]));
    Assert.assertTrue("The list eiuae ", atom.getTerms().equals(Arrays.asList(terms)));
}
Also used : DefaultAtom(fr.lirmm.graphik.graal.core.DefaultAtom) Term(fr.lirmm.graphik.graal.api.core.Term) DefaultAtom(fr.lirmm.graphik.graal.core.DefaultAtom) Atom(fr.lirmm.graphik.graal.api.core.Atom) Predicate(fr.lirmm.graphik.graal.api.core.Predicate) Test(org.junit.Test)

Example 25 with Predicate

use of fr.lirmm.graphik.graal.api.core.Predicate in project graal by graphik-team.

the class AtomTest method setterTest.

@Test
public void setterTest() {
    Predicate predicate = new Predicate("pred", 3);
    Term[] terms = new Term[3];
    terms[0] = new DefaultVariable("X");
    terms[1] = new DefaultConstant("a");
    terms[2] = new DefaultConstant("b");
    Atom atom = new DefaultAtom(predicate, Arrays.asList(terms));
    Term newTerm = new DefaultConstant("new");
    Predicate newPredicate = new Predicate("newPred", 3);
    atom.setPredicate(newPredicate);
    Assert.assertTrue(atom.getPredicate().equals(newPredicate));
    atom.setTerm(2, newTerm);
    Assert.assertTrue(atom.getTerm(2).equals(newTerm));
}
Also used : DefaultAtom(fr.lirmm.graphik.graal.core.DefaultAtom) Term(fr.lirmm.graphik.graal.api.core.Term) DefaultAtom(fr.lirmm.graphik.graal.core.DefaultAtom) Atom(fr.lirmm.graphik.graal.api.core.Atom) Predicate(fr.lirmm.graphik.graal.api.core.Predicate) Test(org.junit.Test)

Aggregations

Predicate (fr.lirmm.graphik.graal.api.core.Predicate)77 Atom (fr.lirmm.graphik.graal.api.core.Atom)35 DefaultAtom (fr.lirmm.graphik.graal.core.DefaultAtom)28 Term (fr.lirmm.graphik.graal.api.core.Term)27 Test (org.junit.Test)25 Substitution (fr.lirmm.graphik.graal.api.core.Substitution)16 LinkedList (java.util.LinkedList)16 Theory (org.junit.experimental.theories.Theory)14 AtomSetException (fr.lirmm.graphik.graal.api.core.AtomSetException)9 Rule (fr.lirmm.graphik.graal.api.core.Rule)9 IteratorException (fr.lirmm.graphik.util.stream.IteratorException)9 LinkedListRuleSet (fr.lirmm.graphik.graal.core.ruleset.LinkedListRuleSet)7 DefaultURI (fr.lirmm.graphik.util.DefaultURI)7 TreeSet (java.util.TreeSet)7 ConjunctiveQuery (fr.lirmm.graphik.graal.api.core.ConjunctiveQuery)6 InMemoryAtomSet (fr.lirmm.graphik.graal.api.core.InMemoryAtomSet)6 RuleSet (fr.lirmm.graphik.graal.api.core.RuleSet)6 Variable (fr.lirmm.graphik.graal.api.core.Variable)6 ConversionException (fr.lirmm.graphik.util.stream.converter.ConversionException)6 Pair (org.apache.commons.lang3.tuple.Pair)6