Search in sources :

Example 1 with JarBuilder

use of org.neo4j.doc.kernel.impl.proc.JarBuilder in project neo4j-documentation by neo4j.

the class ProcedureExampleDocTest method listDenseNodesShouldWork.

@Test
void listDenseNodesShouldWork() throws Throwable {
    // Given
    new JarBuilder().createJarFor(directory.resolve("myProcedures.jar").toFile(), ProcedureExample.class);
    managementService = new DatabaseManagementServiceBuilder(directory).setConfig(GraphDatabaseSettings.plugin_dir, directory.toAbsolutePath()).build();
    db = managementService.database(DEFAULT_DATABASE_NAME);
    try (Transaction transaction = db.beginTx()) {
        Node node1 = transaction.createNode();
        Node node2 = transaction.createNode();
        Node node3 = transaction.createNode();
        node1.createRelationshipTo(node1, RelationshipType.withName("KNOWS"));
        node1.createRelationshipTo(node2, RelationshipType.withName("KNOWS"));
        node1.createRelationshipTo(node3, RelationshipType.withName("KNOWS"));
        // When
        Result res = transaction.execute("CALL org.neo4j.examples.findDenseNodes(2)");
        // Then
        assertEquals(map("degree", 3L, "nodeId", node1.getId()), res.next());
        assertFalse(res.hasNext());
    }
}
Also used : Transaction(org.neo4j.graphdb.Transaction) Node(org.neo4j.graphdb.Node) DatabaseManagementServiceBuilder(org.neo4j.dbms.api.DatabaseManagementServiceBuilder) JarBuilder(org.neo4j.doc.kernel.impl.proc.JarBuilder) Result(org.neo4j.graphdb.Result) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)1 DatabaseManagementServiceBuilder (org.neo4j.dbms.api.DatabaseManagementServiceBuilder)1 JarBuilder (org.neo4j.doc.kernel.impl.proc.JarBuilder)1 Node (org.neo4j.graphdb.Node)1 Result (org.neo4j.graphdb.Result)1 Transaction (org.neo4j.graphdb.Transaction)1