package org.apache.rya.reasoning;



import org.apache.rya.api.domain.RyaStatement;
import org.apache.rya.api.domain.RyaIRI;
import org.eclipse.rdf4j.model.BNode;
import org.eclipse.rdf4j.model.IRI;
import org.eclipse.rdf4j.model.Literal;
import org.eclipse.rdf4j.model.Resource;
import org.eclipse.rdf4j.model.Statement;
import org.eclipse.rdf4j.model.Value;
import org.eclipse.rdf4j.model.ValueFactory;
import org.eclipse.rdf4j.model.impl.SimpleValueFactory;
import org.eclipse.rdf4j.model.vocabulary.XMLSchema;

public class TestUtils {
    private static final ValueFactory VALUE_FACTORY = SimpleValueFactory.getInstance();
    public static final String TEST_PREFIX = "http://test.test";
    public static final IRI NODE = uri("http://thisnode.test", "x");

    public static IRI uri(String prefix, String u) {
        if (prefix.length() > 0) {
            u = prefix + "#" + u;
        }
        return VALUE_FACTORY.createIRI(u);
    }

    public static IRI uri(String u) {
        return uri(TEST_PREFIX, u);
    }

    public static Fact fact(Resource s, IRI p, Value o) {
        return new Fact(s, p, o);
    }

    public static Statement statement(Resource s, IRI p, Value o) {
        return VALUE_FACTORY.createStatement(s, p, o);
    }

    public static Literal intLiteral(String s) {
        return VALUE_FACTORY.createLiteral(s, XMLSchema.INT);
    }

    public static Literal stringLiteral(String s) {
        return VALUE_FACTORY.createLiteral(s, XMLSchema.STRING);
    }

    public static Literal stringLiteral(String s, String lang) {
        return VALUE_FACTORY.createLiteral(s, lang);
    }

    public static BNode bnode(String id) {
        return VALUE_FACTORY.createBNode(id);
    }

    public static RyaStatement ryaStatement(String s, String p, String o) {
        return new RyaStatement(new RyaIRI(TEST_PREFIX + "#" + s),
            new RyaIRI(TEST_PREFIX + "#" + p), new RyaIRI(TEST_PREFIX + "#" + o));
    }
}
