DATAGRAPH-844 - Remove deprecated Neo4j api usage.
This commit is contained in:
@@ -26,7 +26,7 @@
|
||||
|
||||
<properties>
|
||||
<neo4j.version>2.3.2</neo4j.version>
|
||||
<neo4j.ogm.version>2.0.0-M04</neo4j.ogm.version>
|
||||
<neo4j.ogm.version>2.0.0-SNAPSHOT</neo4j.ogm.version>
|
||||
<ogm.properties>ogm-http.properties</ogm.properties>
|
||||
</properties>
|
||||
|
||||
@@ -71,20 +71,6 @@
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.neo4j</groupId>
|
||||
<artifactId>neo4j-kernel</artifactId>
|
||||
<version>${neo4j.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.neo4j.app</groupId>
|
||||
<artifactId>neo4j-server</artifactId>
|
||||
<version>${neo4j.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- this test dependency also brings in all the drivers -->
|
||||
<dependency>
|
||||
<groupId>org.neo4j</groupId>
|
||||
|
||||
@@ -17,7 +17,6 @@ import org.junit.After;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.neo4j.graphdb.GraphDatabaseService;
|
||||
import org.neo4j.graphdb.ResourceIterator;
|
||||
import org.neo4j.graphdb.Result;
|
||||
import org.neo4j.ogm.session.Session;
|
||||
import org.neo4j.ogm.testutil.MultiDriverTestClass;
|
||||
@@ -101,10 +100,11 @@ public class ConversionServiceTest extends MultiDriverTestClass {
|
||||
|
||||
this.pensionRepository.save(pensionToSave);
|
||||
|
||||
ResourceIterator<Number> resourceIterator = graphDatabaseService
|
||||
.execute("MATCH (p:PensionPlan) RETURN p.fundValue AS fv").columnAs("fv");
|
||||
assertTrue("Nothing was saved", resourceIterator.hasNext());
|
||||
assertEquals("The amount wasn't converted and persisted correctly", 1647281, resourceIterator.next().intValue());
|
||||
Result result = graphDatabaseService
|
||||
.execute("MATCH (p:PensionPlan) RETURN p.fundValue AS fv");
|
||||
assertTrue("Nothing was saved", result.hasNext());
|
||||
assertEquals("The amount wasn't converted and persisted correctly", 1647281, result.next().get("fv"));
|
||||
result.close();
|
||||
|
||||
PensionPlan reloadedPension = this.pensionRepository.findOne(pensionToSave.getPensionPlanId());
|
||||
assertEquals("The amount was converted incorrectly", pensionToSave.getFundValue(), reloadedPension.getFundValue());
|
||||
@@ -119,11 +119,11 @@ public class ConversionServiceTest extends MultiDriverTestClass {
|
||||
|
||||
PensionPlan pension = new PensionPlan(new MonetaryAmount(20_000, 00), "Ashes Assets LLP");
|
||||
this.pensionRepository.save(pension);
|
||||
|
||||
ResourceIterator<Integer> resourceIterator = graphDatabaseService
|
||||
.execute("MATCH (p:PensionPlan) RETURN p.fundValue AS fv").columnAs("fv");
|
||||
assertTrue("Nothing was saved", resourceIterator.hasNext());
|
||||
assertEquals("The amount wasn't converted and persisted correctly", 2000000, resourceIterator.next().intValue());
|
||||
Result result = graphDatabaseService
|
||||
.execute("MATCH (p:PensionPlan) RETURN p.fundValue AS fv");
|
||||
assertTrue("Nothing was saved", result.hasNext());
|
||||
assertEquals("The amount wasn't converted and persisted correctly", 2000000, result.next().get("fv"));
|
||||
result.close();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -139,10 +139,11 @@ public class ConversionServiceTest extends MultiDriverTestClass {
|
||||
|
||||
this.javaElementRepository.save(method);
|
||||
|
||||
ResourceIterator<String> resourceIterator = graphDatabaseService
|
||||
.execute("MATCH (e:JavaElement) RETURN e.elementType AS type").columnAs("type");
|
||||
assertTrue("Nothing was saved", resourceIterator.hasNext());
|
||||
assertEquals("The element type wasn't converted and persisted correctly", "METHOD", resourceIterator.next());
|
||||
Result result = graphDatabaseService
|
||||
.execute("MATCH (e:JavaElement) RETURN e.elementType AS type");
|
||||
assertTrue("Nothing was saved", result.hasNext());
|
||||
assertEquals("The element type wasn't converted and persisted correctly", "METHOD", result.next().get("type"));
|
||||
result.close();
|
||||
|
||||
JavaElement loadedObject = this.javaElementRepository.findAll().iterator().next();
|
||||
assertEquals("The element type wasn't loaded and converted correctly", ElementType.METHOD, loadedObject.getElementType());
|
||||
|
||||
@@ -284,7 +284,7 @@ public class DerivedQueryTest extends MultiDriverTestClass {
|
||||
public void shouldFindNodeEntitiesWithNestedRelationshipEntityProperty() {
|
||||
executeUpdate("CREATE (m1:Movie {title:'Speed'}) CREATE (m2:Movie {title:'The Matrix'}) CREATE (m:Movie {title:'Chocolat'})" +
|
||||
" CREATE (u:User {name:'Michal'}) CREATE (u1:User {name:'Vince'}) " +
|
||||
" CREATE (u)-[:RATED {stars:3}]->(m1) CREATE (u)-[:RATED {stars:4}]->(m2) CREATE (u1)-[:RATED {stars:3}]->m");
|
||||
" CREATE (u)-[:RATED {stars:3}]->(m1) CREATE (u)-[:RATED {stars:4}]->(m2) CREATE (u1)-[:RATED {stars:3}]->(m)");
|
||||
|
||||
List<User> users = userRepository.findByRatingsStars(3);
|
||||
assertEquals(2, users.size());
|
||||
@@ -364,7 +364,7 @@ public class DerivedQueryTest extends MultiDriverTestClass {
|
||||
public void shouldFindNodeEntititiesWithRelationshipEntityAndNestedProperty() {
|
||||
executeUpdate("CREATE (m1:Movie {title:'Speed'}) CREATE (m2:Movie {title:'The Matrix'}) CREATE (m:Movie {title:'Chocolat'})" +
|
||||
" CREATE (u:User {name:'Michal'}) CREATE (u1:User {name:'Vince'}) CREATE (g:Genre {name:'Thriller'}) CREATE (u)-[:INTERESTED]->(g) " +
|
||||
" CREATE (u)-[:RATED {stars:3}]->(m1) CREATE (u)-[:RATED {stars:4}]->(m2) CREATE (u1)-[:RATED {stars:3}]->m");
|
||||
" CREATE (u)-[:RATED {stars:3}]->(m1) CREATE (u)-[:RATED {stars:4}]->(m2) CREATE (u1)-[:RATED {stars:3}]->(m)");
|
||||
|
||||
List<User> users = userRepository.findByRatingsStarsAndInterestedName(3,"Thriller");
|
||||
assertEquals(1, users.size());
|
||||
|
||||
@@ -378,7 +378,7 @@ public class Neo4jTemplateTest extends MultiDriverTestClass {
|
||||
assertEquals(1, stats.getLabelsRemoved());
|
||||
assertEquals(1, stats.getPropertiesSet());
|
||||
|
||||
stats = this.template.query("MATCH n-[r]-(m:Movie) delete n,r,m",Collections.EMPTY_MAP).queryStatistics();
|
||||
stats = this.template.query("MATCH (n)-[r]-(m:Movie) delete n,r,m",Collections.EMPTY_MAP).queryStatistics();
|
||||
assertTrue(stats.containsUpdates());
|
||||
assertEquals(2, stats.getNodesDeleted());
|
||||
assertEquals(1, stats.getRelationshipsDeleted());
|
||||
@@ -420,7 +420,7 @@ public class Neo4jTemplateTest extends MultiDriverTestClass {
|
||||
assertEquals(1, stats.getLabelsRemoved());
|
||||
assertEquals(1, stats.getPropertiesSet());
|
||||
|
||||
stats = this.template.query("MATCH n-[r]-(m:Movie) delete n,r,m", Collections.EMPTY_MAP).queryStatistics();
|
||||
stats = this.template.query("MATCH (n)-[r]-(m:Movie) delete n,r,m", Collections.EMPTY_MAP).queryStatistics();
|
||||
assertTrue(stats.containsUpdates());
|
||||
assertEquals(2, stats.getNodesDeleted());
|
||||
assertEquals(1, stats.getRelationshipsDeleted());
|
||||
|
||||
@@ -52,11 +52,11 @@ public class BusinessService {
|
||||
}
|
||||
|
||||
public Iterable<Map<String, Object>> fetch() {
|
||||
return new Neo4jTemplate(session).query("MATCH n RETURN n.name", new HashMap<String, Object>());
|
||||
return new Neo4jTemplate(session).query("MATCH (n) RETURN n.name", new HashMap<String, Object>());
|
||||
}
|
||||
|
||||
public void purge() {
|
||||
new Neo4jTemplate(session).execute("MATCH n DELETE n");
|
||||
new Neo4jTemplate(session).execute("MATCH (n) DELETE n");
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user