use of org.apache.rya.accumulo.AccumuloRdfConfiguration in project incubator-rya by apache.
the class InferenceEngineTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
dao = new AccumuloRyaDAO();
connector = new MockInstance().getConnector("", new PasswordToken(""));
dao.setConnector(connector);
conf = new AccumuloRdfConfiguration();
dao.setConf(conf);
dao.init();
store = new RdfCloudTripleStore();
store.setConf(conf);
store.setRyaDAO(dao);
inferenceEngine = new InferenceEngine();
inferenceEngine.setRyaDAO(dao);
store.setInferenceEngine(inferenceEngine);
inferenceEngine.refreshGraph();
store.initialize();
repository = new SailRepository(store);
conn = repository.getConnection();
}
use of org.apache.rya.accumulo.AccumuloRdfConfiguration in project incubator-rya by apache.
the class IntersectionOfVisitorTest method testIntersectionOfDisabled.
@Test
public void testIntersectionOfDisabled() throws Exception {
// Configure a mock instance engine with an ontology:
final InferenceEngine inferenceEngine = mock(InferenceEngine.class);
final Map<Resource, List<Set<Resource>>> intersections = new HashMap<>();
final List<Set<Resource>> motherIntersections = Arrays.asList(Sets.newHashSet(ANIMAL, FEMALE, PARENT), Sets.newHashSet(FEMALE, LEADER, NUN));
final List<Set<Resource>> fatherIntersections = Arrays.asList(Sets.newHashSet(MAN, PARENT));
intersections.put(MOTHER, motherIntersections);
when(inferenceEngine.getIntersectionsImplying(MOTHER)).thenReturn(motherIntersections);
when(inferenceEngine.getIntersectionsImplying(FATHER)).thenReturn(fatherIntersections);
// Query for a specific type and rewrite using the visitor:
final Projection query = new Projection(new StatementPattern(new Var("s"), new Var("p", RDF.TYPE), new Var("o", MOTHER)), new ProjectionElemList(new ProjectionElem("s", "subject")));
final AccumuloRdfConfiguration disabledConf = conf.clone();
disabledConf.setInferIntersectionOf(false);
query.visit(new IntersectionOfVisitor(disabledConf, inferenceEngine));
// Expected structure: the original statement:
assertTrue(query.getArg() instanceof StatementPattern);
final StatementPattern actualMotherSp = (StatementPattern) query.getArg();
final StatementPattern expectedMotherSp = new StatementPattern(new Var("s"), new Var("p", RDF.TYPE), new Var("o", MOTHER));
assertEquals(expectedMotherSp, actualMotherSp);
// Query for a specific type and rewrite using the visitor:
final Projection query2 = new Projection(new StatementPattern(new Var("s"), new Var("p", RDF.TYPE), new Var("o", FATHER)), new ProjectionElemList(new ProjectionElem("s", "subject")));
query2.visit(new IntersectionOfVisitor(disabledConf, inferenceEngine));
// Expected structure: the original statement:
assertTrue(query2.getArg() instanceof StatementPattern);
final StatementPattern actualFatherSp = (StatementPattern) query2.getArg();
final StatementPattern expectedFatherSp = new StatementPattern(new Var("s"), new Var("p", RDF.TYPE), new Var("o", FATHER));
assertEquals(expectedFatherSp, actualFatherSp);
}
use of org.apache.rya.accumulo.AccumuloRdfConfiguration in project incubator-rya by apache.
the class PropertyChainTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
connector = new MockInstance(instance).getConnector(user, pwd.getBytes());
connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_SPO_SUFFIX);
connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_PO_SUFFIX);
connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_OSP_SUFFIX);
connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_NS_SUFFIX);
SecurityOperations secOps = connector.securityOperations();
secOps.createUser(user, pwd.getBytes(), auths);
secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_SPO_SUFFIX, TablePermission.READ);
secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_PO_SUFFIX, TablePermission.READ);
secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_OSP_SUFFIX, TablePermission.READ);
secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_NS_SUFFIX, TablePermission.READ);
conf = new AccumuloRdfConfiguration();
ryaDAO = new AccumuloRyaDAO();
ryaDAO.setConnector(connector);
conf.setTablePrefix(tablePrefix);
ryaDAO.setConf(conf);
ryaDAO.init();
}
use of org.apache.rya.accumulo.AccumuloRdfConfiguration in project incubator-rya by apache.
the class SameAsTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
connector = new MockInstance(instance).getConnector(user, pwd.getBytes());
connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_SPO_SUFFIX);
connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_PO_SUFFIX);
connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_OSP_SUFFIX);
connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_NS_SUFFIX);
SecurityOperations secOps = connector.securityOperations();
secOps.createUser(user, pwd.getBytes(), auths);
secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_SPO_SUFFIX, TablePermission.READ);
secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_PO_SUFFIX, TablePermission.READ);
secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_OSP_SUFFIX, TablePermission.READ);
secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_NS_SUFFIX, TablePermission.READ);
conf = new AccumuloRdfConfiguration();
ryaDAO = new AccumuloRyaDAO();
ryaDAO.setConnector(connector);
conf.setTablePrefix(tablePrefix);
ryaDAO.setConf(conf);
ryaDAO.init();
}
use of org.apache.rya.accumulo.AccumuloRdfConfiguration in project incubator-rya by apache.
the class OneOfVisitorTest method testOneOfDisabled.
@Test
public void testOneOfDisabled() throws Exception {
// Configure a mock instance engine with an ontology:
final InferenceEngine inferenceEngine = mock(InferenceEngine.class);
when(inferenceEngine.isEnumeratedType(SUITS)).thenReturn(true);
when(inferenceEngine.getEnumeration(SUITS)).thenReturn(CARD_SUIT_ENUMERATION);
when(inferenceEngine.isEnumeratedType(RANKS)).thenReturn(true);
when(inferenceEngine.getEnumeration(RANKS)).thenReturn(CARD_RANK_ENUMERATION);
// Query for a Suits and rewrite using the visitor:
final Projection query = new Projection(new StatementPattern(new Var("s"), new Var("p", RDF.TYPE), new Var("o", SUITS)), new ProjectionElemList(new ProjectionElem("s", "subject")));
final AccumuloRdfConfiguration disabledConf = conf.clone();
disabledConf.setInferOneOf(false);
query.visit(new OneOfVisitor(disabledConf, inferenceEngine));
// Expected structure: the original statement:
assertTrue(query.getArg() instanceof StatementPattern);
final StatementPattern actualCardSuitSp = (StatementPattern) query.getArg();
final StatementPattern expectedCardSuitSp = new StatementPattern(new Var("s"), new Var("p", RDF.TYPE), new Var("o", SUITS));
assertEquals(expectedCardSuitSp, actualCardSuitSp);
}
Aggregations