private void createNode() { try ( Transaction tx = db.beginTx() ) { db.createNode(); tx.success(); } }
private Neo4jMatchers.Deferred<Label> labels( final Node myNode ) { return new Neo4jMatchers.Deferred<Label>( dbRule.getGraphDatabaseAPI() ) { @Override protected Iterable<Label> manifest() { return myNode.getLabels(); } }; } }
try ( Transaction tx = db.beginTx() ) db.createNode( LABEL ).setProperty( KEY, id ); try ( Transaction tx = db.beginTx() ) for ( int id = 0; id < IDS; id++ ) iterators.add( db.findNodes( LABEL, KEY, id ) );
private void addLabels( long nodeId, int startLabelIndex, int count ) { try ( Transaction tx = dbRule.beginTx() ) { Node node = dbRule.getNodeById( nodeId ); int endLabelIndex = startLabelIndex + count; for ( int i = startLabelIndex; i < endLabelIndex; i++ ) { node.addLabel( labelWithIndex( i ) ); } tx.success(); } }
private WorkerCommand<Void,Void> nodeCreator() { return state -> { try ( Transaction tx = db.beginTx() ) { createRoundOfNodes(); tx.success(); } return null; }; }
@Test public void noExtraCreatedNodes() { try (Transaction tx = graphDb.beginTx()) { assertEquals(size(graphDb.getAllNodes()), 2); tx.success(); } }
private void createRoundOfNodes() { for ( int id = 0; id < IDS; id++ ) { db.createNode( LABEL ).setProperty( KEY, id ); } }
@After public void tearDown() { dbRule.shutdown(); }
static Node getNode(String iri) { Long id = graph.getNode(iri).get(); return graphDb.getNodeById(id); }
@Test public void testEquivalentToIntersectionOf() { Node anonymousClass = graphDb.findNodes(OwlLabels.OWL_INTERSECTION_OF).next(); Node fillerClass = getNode("http://example.org/fillerClass"); RelationshipType p = RelationshipType.withName("http://example.org/p"); Relationship r = getOnlyElement(GraphUtil.getRelationships(anonymousClass, fillerClass, p)); assertThat(GraphUtil.getProperty(r, CommonProperties.CONVENIENCE, Boolean.class), is(Optional.of(true))); assertThat(GraphUtil.getProperty(r, CommonProperties.OWL_TYPE, String.class), is(Optional.of(OwlRelationships.OPERAND.name()))); }
@Test public void supportEmptySchemaDefinition() { Neo4jConfiguration configuration = new Neo4jConfiguration(); configuration.setLocation(graphPath.getRoot().getAbsolutePath()); Neo4jModule.setupSchemaIndexes(graphDb, configuration); try (Transaction tx = graphDb.beginTx()) { assertThat(graphDb.schema().getIndexes().iterator().hasNext(), is(false)); tx.success(); tx.close(); } }
private void removeLabels( long nodeId, int startLabelIndex, int count ) { try ( Transaction tx = dbRule.beginTx() ) { Node node = dbRule.getNodeById( nodeId ); int endLabelIndex = startLabelIndex + count; for ( int i = startLabelIndex; i < endLabelIndex; i++ ) { node.removeLabel( labelWithIndex( i ) ); } tx.success(); } }
@Before public void startTransaction() { tx = graphDb.beginTx(); }
@Test public void noEquivalentPropertyEdge() { try (Transaction tx = graphDb.beginTx()) { for (Node n : graphDb.getAllNodes()) { assertFalse(n.hasRelationship(RelationshipType.withName("equivalentProperty"))); } tx.success(); } }
@Before public void addNodes() throws Exception { a = graphDb.createNode(); b = graphDb.createNode(); c = graphDb.createNode(); d = graphDb.createNode(); e = graphDb.createNode(); f = graphDb.createNode(); g = graphDb.createNode(); h = graphDb.createNode(); i = graphDb.createNode(); j = graphDb.createNode(); b.createRelationshipTo(a, OwlRelationships.RDFS_SUBCLASS_OF); c.createRelationshipTo(b, OwlRelationships.RDFS_SUBCLASS_OF); d.createRelationshipTo(c, OwlRelationships.RDFS_SUBCLASS_OF); i.createRelationshipTo(h, OwlRelationships.RDFS_SUBCLASS_OF); i.createRelationshipTo(g, OwlRelationships.RDFS_SUBCLASS_OF); h.createRelationshipTo(j, OwlRelationships.RDFS_SUBCLASS_OF); g.createRelationshipTo(j, OwlRelationships.RDFS_SUBCLASS_OF); e.createRelationshipTo(b, fizz); graphApi = new GraphApi(graphDb, cypherUtil, curieUtil); }
@AfterClass public static void shutdown() { graphDb.shutdown(); }
static protected Node createNode(String iri) { long node = graph.createNode(iri); graph.setNodeProperty(node, CommonProperties.IRI, iri); if (iri.startsWith("_:")) { graph.addLabel(node, OwlLabels.OWL_ANONYMOUS); } return graphDb.getNodeById(node); }
protected GraphDatabaseAPI db() { return rule.getGraphDatabaseAPI(); }