Search in sources :

Example 86 with Atom

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

the class AtomTest method testIndexOf.

/**
 * Test method for
 * {@link fr.lirmm.graphik.graal.core.DefaultAtom#indexOf(fr.lirmm.graphik.graal.api.core.Term)}.
 */
@Theory
public void testIndexOf(AtomFactory factory) {
    // given
    Atom a = factory.create(TestUtils.pXA);
    // when
    int index = a.indexOf(TestUtils.A);
    // then
    Assert.assertEquals(1, index);
}
Also used : Atom(fr.lirmm.graphik.graal.api.core.Atom) Theory(org.junit.experimental.theories.Theory)

Example 87 with Atom

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

the class AtomTest method testIndexOfNotFound.

/**
 * Test method for
 * {@link fr.lirmm.graphik.graal.core.DefaultAtom#indexOf(fr.lirmm.graphik.graal.api.core.Term)}.
 */
@Theory
public void testIndexOfNotFound(AtomFactory factory) {
    // given
    Atom a = factory.create(TestUtils.pXA);
    // when
    int index = a.indexOf(TestUtils.B);
    // then
    Assert.assertEquals(-1, index);
}
Also used : Atom(fr.lirmm.graphik.graal.api.core.Atom) Theory(org.junit.experimental.theories.Theory)

Example 88 with Atom

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

the class AtomTest method testDefaultAtomAtom.

/**
 * Test method for
 * {@link fr.lirmm.graphik.graal.core.DefaultAtom#DefaultAtom(fr.lirmm.graphik.graal.api.core.Atom)}.
 */
@Theory
public void testDefaultAtomAtom(AtomFactory factory) {
    // given
    Atom a = factory.create(TestUtils.pXA);
    // when
    Atom copy = new DefaultAtom(a);
    // then
    Assert.assertEquals(a.getPredicate(), copy.getPredicate());
    Assert.assertEquals(a.getTerm(0), copy.getTerm(0));
    Assert.assertEquals(a.getTerm(1), copy.getTerm(1));
}
Also used : Atom(fr.lirmm.graphik.graal.api.core.Atom) Theory(org.junit.experimental.theories.Theory)

Example 89 with Atom

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

the class DefaultAtomSetFactory method create.

@Override
public InMemoryAtomSet create(AtomSet src) throws IteratorException {
    InMemoryAtomSet atomset = this.create();
    CloseableIterator<Atom> it = src.iterator();
    while (it.hasNext()) {
        Atom a = it.next();
        atomset.add(a);
    }
    return atomset;
}
Also used : InMemoryAtomSet(fr.lirmm.graphik.graal.api.core.InMemoryAtomSet) Atom(fr.lirmm.graphik.graal.api.core.Atom)

Example 90 with Atom

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

the class AtomTest method testIndexesOfNotFound.

/**
 * Test method for
 * {@link fr.lirmm.graphik.graal.core.DefaultAtom#indexesOf(fr.lirmm.graphik.graal.api.core.Term)}.
 */
@Theory
public void testIndexesOfNotFound(AtomFactory factory) {
    // given
    Atom a = factory.create(TestUtils.pXX);
    // when
    int[] indexes = a.indexesOf(TestUtils.A);
    // then
    Assert.assertEquals(0, indexes.length);
}
Also used : Atom(fr.lirmm.graphik.graal.api.core.Atom) Theory(org.junit.experimental.theories.Theory)

Aggregations

Atom (fr.lirmm.graphik.graal.api.core.Atom)269 Test (org.junit.Test)97 Term (fr.lirmm.graphik.graal.api.core.Term)86 Rule (fr.lirmm.graphik.graal.api.core.Rule)64 Substitution (fr.lirmm.graphik.graal.api.core.Substitution)41 OWL2Parser (fr.lirmm.graphik.graal.io.owl.OWL2Parser)41 InMemoryAtomSet (fr.lirmm.graphik.graal.api.core.InMemoryAtomSet)40 LinkedList (java.util.LinkedList)40 DefaultNegativeConstraint (fr.lirmm.graphik.graal.core.DefaultNegativeConstraint)36 Predicate (fr.lirmm.graphik.graal.api.core.Predicate)35 Theory (org.junit.experimental.theories.Theory)35 ConjunctiveQuery (fr.lirmm.graphik.graal.api.core.ConjunctiveQuery)34 Variable (fr.lirmm.graphik.graal.api.core.Variable)33 DefaultAtom (fr.lirmm.graphik.graal.core.DefaultAtom)31 IteratorException (fr.lirmm.graphik.util.stream.IteratorException)29 LinkedListAtomSet (fr.lirmm.graphik.graal.core.atomset.LinkedListAtomSet)28 AtomSetException (fr.lirmm.graphik.graal.api.core.AtomSetException)27 HomomorphismException (fr.lirmm.graphik.graal.api.homomorphism.HomomorphismException)14 CloseableIteratorWithoutException (fr.lirmm.graphik.util.stream.CloseableIteratorWithoutException)14 OWL2ParserException (fr.lirmm.graphik.graal.io.owl.OWL2ParserException)13