Search in sources :

Example 1 with Transactor

use of org.neo4j.server.helpers.Transactor in project neo4j by neo4j.

the class NeoWebServerJAXRSIT method createSimpleDatabase.

private static int createSimpleDatabase(final GraphDatabaseAPI graph) {
    final var numberOfNodes = 10;
    new Transactor(graph, tx -> {
        for (var i = 0; i < numberOfNodes; i++) {
            tx.createNode();
        }
        for (var node1 : tx.getAllNodes()) {
            for (var node2 : tx.getAllNodes()) {
                if (node1.equals(node2)) {
                    continue;
                }
                node1.createRelationshipTo(node2, RelationshipType.withName("REL"));
            }
        }
    }).execute();
    return numberOfNodes;
}
Also used : ExclusiveWebContainerTestBase(org.neo4j.test.server.ExclusiveWebContainerTestBase) BodyHandlers.discarding(java.net.http.HttpResponse.BodyHandlers.discarding) DummyThirdPartyWebService(org.dummy.web.service.DummyThirdPartyWebService) HttpClient.newBuilder(java.net.http.HttpClient.newBuilder) NORMAL(java.net.http.HttpClient.Redirect.NORMAL) Test(org.junit.Test) CommunityWebContainerBuilder(org.neo4j.server.helpers.CommunityWebContainerBuilder) HttpRequest(java.net.http.HttpRequest) GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) TestWebContainer(org.neo4j.server.helpers.TestWebContainer) WebContainerHelper(org.neo4j.server.helpers.WebContainerHelper) FunctionalTestHelper(org.neo4j.server.helpers.FunctionalTestHelper) After(org.junit.After) HttpClient(java.net.http.HttpClient) RelationshipType(org.neo4j.graphdb.RelationshipType) URI(java.net.URI) Transactor(org.neo4j.server.helpers.Transactor) BodyHandlers.ofString(java.net.http.HttpResponse.BodyHandlers.ofString) Assert.assertEquals(org.junit.Assert.assertEquals) Transactor(org.neo4j.server.helpers.Transactor)

Example 2 with Transactor

use of org.neo4j.server.helpers.Transactor in project neo4j by neo4j.

the class NeoServerJAXRSIT method createSimpleDatabase.

private int createSimpleDatabase(final GraphDatabaseAPI graph) {
    final int numberOfNodes = 10;
    new Transactor(graph, new UnitOfWork() {

        @Override
        public void doWork() {
            for (int i = 0; i < numberOfNodes; i++) {
                graph.createNode();
            }
            for (Node n1 : graph.getAllNodes()) {
                for (Node n2 : graph.getAllNodes()) {
                    if (n1.equals(n2)) {
                        continue;
                    }
                    n1.createRelationshipTo(n2, RelationshipType.withName("REL"));
                }
            }
        }
    }).execute();
    return numberOfNodes;
}
Also used : UnitOfWork(org.neo4j.server.helpers.UnitOfWork) Node(org.neo4j.graphdb.Node) Transactor(org.neo4j.server.helpers.Transactor)

Aggregations

Transactor (org.neo4j.server.helpers.Transactor)2 URI (java.net.URI)1 HttpClient (java.net.http.HttpClient)1 NORMAL (java.net.http.HttpClient.Redirect.NORMAL)1 HttpClient.newBuilder (java.net.http.HttpClient.newBuilder)1 HttpRequest (java.net.http.HttpRequest)1 BodyHandlers.discarding (java.net.http.HttpResponse.BodyHandlers.discarding)1 BodyHandlers.ofString (java.net.http.HttpResponse.BodyHandlers.ofString)1 DummyThirdPartyWebService (org.dummy.web.service.DummyThirdPartyWebService)1 After (org.junit.After)1 Assert.assertEquals (org.junit.Assert.assertEquals)1 Test (org.junit.Test)1 Node (org.neo4j.graphdb.Node)1 RelationshipType (org.neo4j.graphdb.RelationshipType)1 GraphDatabaseAPI (org.neo4j.kernel.internal.GraphDatabaseAPI)1 CommunityWebContainerBuilder (org.neo4j.server.helpers.CommunityWebContainerBuilder)1 FunctionalTestHelper (org.neo4j.server.helpers.FunctionalTestHelper)1 TestWebContainer (org.neo4j.server.helpers.TestWebContainer)1 UnitOfWork (org.neo4j.server.helpers.UnitOfWork)1 WebContainerHelper (org.neo4j.server.helpers.WebContainerHelper)1