Examples of Neo4jTemplate


Examples of org.springframework.data.neo4j.support.Neo4jTemplate

        }
    }

    @Test
    public void testInstantiateEntity() throws Exception {
        Neo4jTemplate template = new Neo4jTemplate(graphDatabase,transactionManager);
        Transaction tx = template.getGraphDatabase().beginTx();
        try {
            Person michael = template.save(new Person("Michael", 37));
            assertNotNull(michael.getId());
        } finally {
            tx.success();tx.close();
        }
    }
View Full Code Here

Examples of org.springframework.data.neo4j.support.Neo4jTemplate

    }

    @Test(expected = DataAccessException.class)
    @Ignore
    public void shouldConvertMissingTransactionExceptionToDataAccessException() {
        Neo4jTemplate template = new Neo4jTemplate(graphDatabase, null);
        template.exec(new GraphCallback.WithoutResult() {
            @Override
            public void doWithGraphWithoutResult(GraphDatabase graph) throws Exception {
                graph.createNode(null, null);
            }
        });
View Full Code Here

Examples of org.springframework.data.neo4j.support.Neo4jTemplate

            }
        });
    }
    @Test(expected = DataAccessException.class)
    public void shouldConvertNotFoundExceptionToDataAccessException() {
        Neo4jTemplate template = new Neo4jTemplate(graphDatabase, transactionManager);
        template.exec(new GraphCallback.WithoutResult() {
            @Override
            public void doWithGraphWithoutResult(GraphDatabase graph) throws Exception {
                graph.getNodeById( Long.MAX_VALUE );
            }
        });
View Full Code Here

Examples of org.springframework.data.neo4j.support.Neo4jTemplate

        HAS
    }

    @Test
    public void testRefNode() {
        Node refNodeById = new Neo4jTemplate(graph, transactionManager).exec(new GraphCallback<Node>() {
            public Node doWithGraph(GraphDatabase graph) throws Exception {
                return graph.getNodeById( refNode.getId() );
            }
        });
View Full Code Here

Examples of org.springframework.data.neo4j.support.Neo4jTemplate

        }
    }

    @Test
    public void testSingleNode() {
        final Neo4jOperations template = new Neo4jTemplate(graph, transactionManager);
        template.exec(new GraphCallback.WithoutResult() {
            @Override
            public void doWithGraphWithoutResult(GraphDatabase graph) throws Exception {
                Node node = graph.createNode(map("name", "Test", "size", 100), null);
                refNode.createRelationshipTo(node, HAS);

                final Relationship toTestNode = refNode.getSingleRelationship(HAS, Direction.OUTGOING);
                final Node nodeByRelationship = toTestNode.getEndNode();
                assertEquals("Test", nodeByRelationship.getProperty("name"));
                assertEquals(100, nodeByRelationship.getProperty("size"));
            }
        });
        template.exec(new GraphCallback.WithoutResult() {
            public void doWithGraphWithoutResult(GraphDatabase graph) throws Exception {
                final Relationship toTestNode = refNode.getSingleRelationship(HAS, Direction.OUTGOING);
                final Node nodeByRelationship = toTestNode.getEndNode();
                assertEquals("Test", nodeByRelationship.getProperty("name"));
                assertEquals(100, nodeByRelationship.getProperty("size"));
View Full Code Here

Examples of org.springframework.data.neo4j.support.Neo4jTemplate

        });
    }

    @Test
    public void testRollback() {
        final Neo4jOperations template = new Neo4jTemplate(graph, transactionManager);
        try {
        template.exec(new GraphCallback.WithoutResult() {
            @Override
            public void doWithGraphWithoutResult(GraphDatabase graph) throws Exception {
                Node node = refNode;
                node.setProperty("test", "test");
                assertEquals("test", node.getProperty("test"));
                throw new RuntimeException();
            }
        });
        } catch(RuntimeException ignore) {}
        template.exec(new GraphCallback.WithoutResult() {
            public void doWithGraphWithoutResult(final GraphDatabase graph) throws Exception {
                assertFalse(refNode.hasProperty("test"));
            }
        });
    }
View Full Code Here

Examples of org.springframework.data.neo4j.support.Neo4jTemplate

    @Override
    @Before
    public void setUp() throws Exception {
        super.setUp();
        refNode = new Neo4jTemplate(graph, transactionManager).exec(new GraphCallback<Node>() {
            public Node doWithGraph(GraphDatabase graph) throws Exception {
                return graph.createNode(map(), null);
            }
        });
View Full Code Here

Examples of org.springframework.data.neo4j.support.Neo4jTemplate

    }

    @Test(expected = DataAccessException.class)
    @Ignore
    public void shouldConvertMissingTransactionExceptionToDataAccessException() {
        Neo4jTemplate template = new Neo4jTemplate(graphDatabase, null);
        template.exec(new GraphCallback.WithoutResult() {
            @Override
            public void doWithGraphWithoutResult(GraphDatabase graph) throws Exception {
                graph.createNode(null, null);
            }
        });
View Full Code Here

Examples of org.springframework.data.neo4j.support.Neo4jTemplate

        });
    }

    @Test(expected = DataAccessException.class)
    public void shouldConvertNotFoundExceptionToDataAccessException() {
        Neo4jTemplate template = new Neo4jTemplate(graphDatabase, neo4jTransactionManager);
        template.exec(new GraphCallback.WithoutResult() {
            @Override
            public void doWithGraphWithoutResult(GraphDatabase graph) throws Exception {
                graph.getNodeById(Long.MAX_VALUE);
            }
        });
View Full Code Here

Examples of org.springframework.data.neo4j.support.Neo4jTemplate

    public void setUp() throws Exception
    {
        conversionService = createConversionService();
        graph = createGraphDatabase();
        transactionManager = createTransactionManager();
        template = new Neo4jTemplate(graph, transactionManager);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.