diff --git a/spring-data-neo4j-examples/hello-worlds-aspects/.gitignore b/spring-data-neo4j-examples/hello-worlds-aspects/.gitignore
new file mode 100644
index 000000000..f092f6270
--- /dev/null
+++ b/spring-data-neo4j-examples/hello-worlds-aspects/.gitignore
@@ -0,0 +1,11 @@
+lib
+.ivy
+.gradle
+target
+*.ipr
+*.iml
+*.iws
+.classpath
+.project
+.settings
+
diff --git a/spring-data-neo4j-examples/hello-worlds-aspects/README.md b/spring-data-neo4j-examples/hello-worlds-aspects/README.md
new file mode 100644
index 000000000..bc35e2083
--- /dev/null
+++ b/spring-data-neo4j-examples/hello-worlds-aspects/README.md
@@ -0,0 +1,12 @@
+Hello Worlds (Using Advanced Mode - AspectJ)
+============
+
+A simple Spring Data Neo4j example with just enough code to do something that works using aspectj.
+
+See https://github.com/SpringSource/spring-data-neo4j/blob/master/spring-data-neo4j-examples/hello-worlds-aspects/src/test/java/org/springframework/data/neo4j/examples/hellograph/GalaxyServiceTest.java for example code.
+
+Build and Run
+-------------
+
+`mvn clean test`
+
diff --git a/spring-data-neo4j-examples/hello-worlds-aspects/build.gradle b/spring-data-neo4j-examples/hello-worlds-aspects/build.gradle
new file mode 100644
index 000000000..32fd113d4
--- /dev/null
+++ b/spring-data-neo4j-examples/hello-worlds-aspects/build.gradle
@@ -0,0 +1,24 @@
+sourceCompatibility = 1.7
+targetCompatibility = 1.7
+
+apply plugin: 'idea'
+apply plugin: 'eclipse'
+
+
+springVersion = "3.2.8.RELEASE"
+springDataNeo4jVersion = "3.0.2-SNAPSHOT"
+
+configurations {
+ runtime
+ testCompile
+}
+repositories {
+ mavenCentral()
+ mavenLocal()
+ mavenRepo urls: "http://maven.springframework.org/release"
+}
+
+
+dependencies{
+ testCompile group:"junit", name: "junit", version: "4.11"
+}
diff --git a/spring-data-neo4j-examples/hello-worlds-aspects/build.xml b/spring-data-neo4j-examples/hello-worlds-aspects/build.xml
new file mode 100644
index 000000000..d31a84be8
--- /dev/null
+++ b/spring-data-neo4j-examples/hello-worlds-aspects/build.xml
@@ -0,0 +1,61 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/spring-data-neo4j-examples/hello-worlds-aspects/pom.xml b/spring-data-neo4j-examples/hello-worlds-aspects/pom.xml
new file mode 100644
index 000000000..46273a44b
--- /dev/null
+++ b/spring-data-neo4j-examples/hello-worlds-aspects/pom.xml
@@ -0,0 +1,206 @@
+
+ 4.0.0
+
+ org.springframework.data.examples
+ spring-data-neo4j-hello-worlds-aspects
+ 3.0.2.BUILD-SNAPSHOT
+ jar
+
+ Spring Data Neo4j hello-worlds
+
+
+ UTF-8
+ 3.2.8.RELEASE
+ 1.7.4
+ 1.7.5
+ ${project.version}
+ 2.0.1
+ 4.11
+ 1.2.17
+ 4.2.0.Final
+ 1.0.0.Final
+
+
+
+
+ spring-maven-release
+ Spring Maven Release Repository
+ http://maven.springframework.org/release
+
+
+ spring-maven-snapshot
+ Spring Maven Snapshot Repository
+
+ true
+
+ http://maven.springframework.org/snapshot
+
+
+ spring-maven-milestone
+ Spring Maven Milestone Repository
+ http://maven.springframework.org/milestone
+
+
+ neo4j-release-repository
+ Neo4j Maven 2 release repository
+ http://m2.neo4j.org/releases
+
+ true
+
+
+ false
+
+
+
+ neo4j-snapshot-repository
+ Neo4j Maven 2 snapshot repository
+ http://m2.neo4j.org/snapshots
+
+ true
+
+
+ false
+
+
+
+
+
+
+ spring-maven-release
+ Spring Maven Release Repository
+ http://maven.springframework.org/release
+
+
+ spring-maven-milestone
+ Spring Maven Milestone Repository
+ http://maven.springframework.org/milestone
+
+
+
+
+
+
+ org.springframework.data
+ spring-data-neo4j-aspects
+ ${spring-data-neo4j.version}
+
+
+
+
+ org.hibernate
+ hibernate-validator
+ ${hibernate-validator.version}
+
+
+
+ org.hibernate.javax.persistence
+ hibernate-jpa-2.0-api
+ ${hibernate-jpa.version}
+ true
+ compile
+
+
+
+
+ org.slf4j
+ slf4j-api
+ ${slf4j.version}
+
+
+ org.slf4j
+ slf4j-log4j12
+ ${slf4j.version}
+
+
+ log4j
+ log4j
+ ${log4j.version}
+
+
+
+
+ org.springframework
+ spring-test
+ ${spring.version}
+ test
+
+
+ org.neo4j
+ neo4j-kernel
+ ${neo4j.version}
+ test-jar
+ test
+
+
+ junit
+ junit
+ ${junit.version}
+ test
+
+
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.1
+
+ 1.7
+ 1.7
+
+
+
+
+
+
+ org.codehaus.mojo
+ aspectj-maven-plugin
+ 1.4
+
+ true
+
+
+ org.springframework
+ spring-aspects
+
+
+ org.springframework.data
+ spring-data-neo4j-aspects
+
+
+ 1.7
+ 1.7
+
+
+
+
+ compile
+ test-compile
+
+
+
+
+
+ org.aspectj
+ aspectjrt
+ ${aspectj.version}
+
+
+ org.aspectj
+ aspectjtools
+ ${aspectj.version}
+
+
+
+
+
+
+
+
diff --git a/spring-data-neo4j-examples/hello-worlds-aspects/settings/install-ivy.xml b/spring-data-neo4j-examples/hello-worlds-aspects/settings/install-ivy.xml
new file mode 100644
index 000000000..314d20d9a
--- /dev/null
+++ b/spring-data-neo4j-examples/hello-worlds-aspects/settings/install-ivy.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/spring-data-neo4j-examples/hello-worlds-aspects/settings/ivy.xml b/spring-data-neo4j-examples/hello-worlds-aspects/settings/ivy.xml
new file mode 100644
index 000000000..0866b3cbe
--- /dev/null
+++ b/spring-data-neo4j-examples/hello-worlds-aspects/settings/ivy.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/spring-data-neo4j-examples/hello-worlds-aspects/settings/ivysettings.xml b/spring-data-neo4j-examples/hello-worlds-aspects/settings/ivysettings.xml
new file mode 100644
index 000000000..704bb0fbc
--- /dev/null
+++ b/spring-data-neo4j-examples/hello-worlds-aspects/settings/ivysettings.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/spring-data-neo4j-examples/hello-worlds-aspects/settings/path.xml b/spring-data-neo4j-examples/hello-worlds-aspects/settings/path.xml
new file mode 100644
index 000000000..3d49c706b
--- /dev/null
+++ b/spring-data-neo4j-examples/hello-worlds-aspects/settings/path.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/spring-data-neo4j-examples/hello-worlds-aspects/src/main/java/org/springframework/data/neo4j/examples/hellograph/GalaxyService.java b/spring-data-neo4j-examples/hello-worlds-aspects/src/main/java/org/springframework/data/neo4j/examples/hellograph/GalaxyService.java
new file mode 100644
index 000000000..144230968
--- /dev/null
+++ b/spring-data-neo4j-examples/hello-worlds-aspects/src/main/java/org/springframework/data/neo4j/examples/hellograph/GalaxyService.java
@@ -0,0 +1,79 @@
+package org.springframework.data.neo4j.examples.hellograph;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.neo4j.aspects.core.NodeBacked;
+import org.springframework.stereotype.Service;
+
+@Service
+public class GalaxyService {
+
+ @Autowired
+ private WorldRepository worldRepository;
+
+ public long getNumberOfWorlds() {
+ return worldRepository.count();
+ }
+
+ public World createWorld(String name, int moons) {
+ // The lin below is just as valid within you code (it assumes)
+ // the aspectj compilcation has occured, however the cast to
+ // the NodeBacked class is being used here as its helpful to
+ // IDE's which struggle with aspectj stuff
+ //
+ // return new World(name, moons).persist();
+
+ World world = new World(name, moons);
+ ((NodeBacked)world).persist();
+ return world;
+ }
+
+ public Iterable getAllWorlds() {
+ return worldRepository.findAll();
+ }
+
+ public World findWorldById(Long id) {
+ return worldRepository.findOne(id);
+ }
+
+ public World findWorldByName(String name) {
+ return worldRepository.findBySchemaPropertyValue("name", name);
+ }
+
+ // This is using the legacy index
+ public Iterable findAllByNumberOfMoons(int numberOfMoons) {
+ return worldRepository.findAllByPropertyValue("moons", numberOfMoons);
+ }
+
+ public Collection makeSomeWorlds() {
+ Collection worlds = new ArrayList();
+
+ // Solar worlds
+ worlds.add(createWorld("Mercury", 0));
+ worlds.add(createWorld("Venus", 0));
+
+ World earth = createWorld("Earth", 1);
+ World mars = createWorld("Mars", 2);
+ mars.addRocketRouteTo(earth);
+ worldRepository.save(mars);
+ worlds.add(earth);
+ worlds.add(mars);
+
+ worlds.add(createWorld("Jupiter", 63));
+ worlds.add(createWorld("Saturn", 62));
+ worlds.add(createWorld("Uranus", 27));
+ worlds.add(createWorld("Neptune", 13));
+
+ // Norse worlds
+ worlds.add(createWorld("Alfheimr", 0));
+ worlds.add(createWorld("Midgard", 1));
+ worlds.add(createWorld("Muspellheim", 2));
+ worlds.add(createWorld("Asgard", 63));
+ worlds.add(createWorld("Hel", 62));
+
+ return worlds;
+ }
+
+}
diff --git a/spring-data-neo4j-examples/hello-worlds-aspects/src/main/java/org/springframework/data/neo4j/examples/hellograph/World.java b/spring-data-neo4j-examples/hello-worlds-aspects/src/main/java/org/springframework/data/neo4j/examples/hellograph/World.java
new file mode 100644
index 000000000..a3bd618be
--- /dev/null
+++ b/spring-data-neo4j-examples/hello-worlds-aspects/src/main/java/org/springframework/data/neo4j/examples/hellograph/World.java
@@ -0,0 +1,77 @@
+package org.springframework.data.neo4j.examples.hellograph;
+
+import org.neo4j.graphdb.Direction;
+import org.springframework.data.neo4j.annotation.Fetch;
+import org.springframework.data.neo4j.annotation.GraphId;
+import org.springframework.data.neo4j.annotation.Indexed;
+import org.springframework.data.neo4j.annotation.NodeEntity;
+import org.springframework.data.neo4j.annotation.RelatedTo;
+import org.springframework.data.neo4j.support.index.IndexType;
+
+import java.util.Set;
+
+@NodeEntity
+public class World {
+ private final static String REACHABLE_BY_ROCKET = "REACHABLE_BY_ROCKET";
+
+ @GraphId
+ private Long id;
+
+ @Indexed
+ private String name;
+
+ @Indexed(indexType = IndexType.SIMPLE)
+ private int moons;
+
+ @Fetch
+ @RelatedTo(type = REACHABLE_BY_ROCKET, direction = Direction.BOTH)
+ private Set reachableByRocket;
+
+ public World(String name, int moons) {
+ this.name = name;
+ this.moons = moons;
+ }
+
+ public World() {
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public int getMoons() {
+ return moons;
+ }
+
+ public void addRocketRouteTo(World otherWorld) {
+ reachableByRocket.add(otherWorld);
+ }
+
+ public boolean canBeReachedFrom(World otherWorld) {
+ return reachableByRocket.contains(otherWorld);
+ }
+
+ @Override
+ public int hashCode() {
+ return (id == null) ? 0 : id.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null) return false;
+ if (getClass() != obj.getClass()) return false;
+ World other = (World) obj;
+ if (id == null) return other.id == null;
+ return id.equals(other.id);
+ }
+
+ @Override
+ public String toString() {
+ return String.format("World{name='%s', moons=%d}", name, moons);
+ }
+}
diff --git a/spring-data-neo4j-examples/hello-worlds-aspects/src/main/java/org/springframework/data/neo4j/examples/hellograph/WorldRepository.java b/spring-data-neo4j-examples/hello-worlds-aspects/src/main/java/org/springframework/data/neo4j/examples/hellograph/WorldRepository.java
new file mode 100644
index 000000000..350acbf34
--- /dev/null
+++ b/spring-data-neo4j-examples/hello-worlds-aspects/src/main/java/org/springframework/data/neo4j/examples/hellograph/WorldRepository.java
@@ -0,0 +1,5 @@
+package org.springframework.data.neo4j.examples.hellograph;
+
+import org.springframework.data.neo4j.repository.GraphRepository;
+
+public interface WorldRepository extends GraphRepository {}
diff --git a/spring-data-neo4j-examples/hello-worlds-aspects/src/main/resources/log4j.properties b/spring-data-neo4j-examples/hello-worlds-aspects/src/main/resources/log4j.properties
new file mode 100644
index 000000000..beb86feab
--- /dev/null
+++ b/spring-data-neo4j-examples/hello-worlds-aspects/src/main/resources/log4j.properties
@@ -0,0 +1,7 @@
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+
+# Print the date in ISO 8601 format
+log4j.appender.stdout.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
+
+log4j.rootLogger=ERROR, stdout
diff --git a/spring-data-neo4j-examples/hello-worlds/src/main/resources/spring/aspects/helloWorldContext.xml b/spring-data-neo4j-examples/hello-worlds-aspects/src/main/resources/spring/helloWorldContext.xml
similarity index 90%
rename from spring-data-neo4j-examples/hello-worlds/src/main/resources/spring/aspects/helloWorldContext.xml
rename to spring-data-neo4j-examples/hello-worlds-aspects/src/main/resources/spring/helloWorldContext.xml
index 622bbbc6f..57abf0fd3 100644
--- a/spring-data-neo4j-examples/hello-worlds/src/main/resources/spring/aspects/helloWorldContext.xml
+++ b/spring-data-neo4j-examples/hello-worlds-aspects/src/main/resources/spring/helloWorldContext.xml
@@ -18,7 +18,7 @@
-
+
diff --git a/spring-data-neo4j-examples/hello-worlds/src/test/java/org/springframework/data/neo4j/examples/hellograph/GalaxyServiceTests.java b/spring-data-neo4j-examples/hello-worlds-aspects/src/test/java/org/springframework/data/neo4j/examples/hellograph/GalaxyServiceTest.java
similarity index 97%
rename from spring-data-neo4j-examples/hello-worlds/src/test/java/org/springframework/data/neo4j/examples/hellograph/GalaxyServiceTests.java
rename to spring-data-neo4j-examples/hello-worlds-aspects/src/test/java/org/springframework/data/neo4j/examples/hellograph/GalaxyServiceTest.java
index 99c7edfeb..8e4ad0cc3 100644
--- a/spring-data-neo4j-examples/hello-worlds/src/test/java/org/springframework/data/neo4j/examples/hellograph/GalaxyServiceTests.java
+++ b/spring-data-neo4j-examples/hello-worlds-aspects/src/test/java/org/springframework/data/neo4j/examples/hellograph/GalaxyServiceTest.java
@@ -1,12 +1,5 @@
package org.springframework.data.neo4j.examples.hellograph;
-import static org.hamcrest.CoreMatchers.anyOf;
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.*;
-import static org.junit.internal.matchers.StringContains.containsString;
-
-import java.util.Collection;
-
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
@@ -18,10 +11,17 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.transaction.BeforeTransaction;
import org.springframework.transaction.annotation.Transactional;
+import java.util.Collection;
+
+import static org.hamcrest.CoreMatchers.anyOf;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.*;
+
@ContextConfiguration(locations = "classpath:/spring/helloWorldContext.xml")
@RunWith(SpringJUnit4ClassRunner.class)
@Transactional
-public class GalaxyServiceTests {
+public class GalaxyServiceTest {
@Autowired
private GalaxyService galaxyService;
diff --git a/spring-data-neo4j-examples/hello-worlds/build.gradle b/spring-data-neo4j-examples/hello-worlds/build.gradle
index 7b2c1ccd5..9e59e3f81 100644
--- a/spring-data-neo4j-examples/hello-worlds/build.gradle
+++ b/spring-data-neo4j-examples/hello-worlds/build.gradle
@@ -1,12 +1,12 @@
-sourceCompatibility = 1.6
-targetCompatibility = 1.6
+sourceCompatibility = 1.7
+targetCompatibility = 1.7
apply plugin: 'idea'
apply plugin: 'eclipse'
-springVersion = "3.0.7.RELEASE"
-springDataNeo4jVersion = "2.0.0.RELEASE"
+springVersion = "3.2.8.RELEASE"
+springDataNeo4jVersion = "3.0.2-SNAPSHOT"
configurations {
runtime
@@ -20,5 +20,5 @@ repositories {
dependencies{
- testCompile group:"junit", name: "junit", version: "4.8"
+ testCompile group:"junit", name: "junit", version: "4.11"
}
diff --git a/spring-data-neo4j-examples/hello-worlds/build.xml b/spring-data-neo4j-examples/hello-worlds/build.xml
index c975fc6cf..d31a84be8 100644
--- a/spring-data-neo4j-examples/hello-worlds/build.xml
+++ b/spring-data-neo4j-examples/hello-worlds/build.xml
@@ -27,7 +27,7 @@
-
+
@@ -36,7 +36,7 @@
-
+
diff --git a/spring-data-neo4j-examples/hello-worlds/pom.xml b/spring-data-neo4j-examples/hello-worlds/pom.xml
index 533b2f50b..60cb23c54 100644
--- a/spring-data-neo4j-examples/hello-worlds/pom.xml
+++ b/spring-data-neo4j-examples/hello-worlds/pom.xml
@@ -4,17 +4,20 @@
org.springframework.data.examples
spring-data-neo4j-hello-worlds
- 2.2.0.BUILD-SNAPSHOT
+ 3.0.2.BUILD-SNAPSHOT
jar
Spring Data Neo4j hello-worlds
UTF-8
- 3.0.7.RELEASE
- 1.6.12
- 1.6.1
+ 3.2.8.RELEASE
+ 1.7.5
${project.version}
+ 2.0.1
+ 4.11
+ 1.2.17
+ 4.2.0.Final
@@ -74,41 +77,59 @@
-
- junit
- junit
- 4.8.1
- test
-
-
- org.springframework
- spring-test
- ${spring.version}
- test
-
-
- commons-logging
- commons-logging
-
-
-
-
- cglib
- cglib-nodep
- 2.2
-
+
- org.hibernate.javax.persistence
- hibernate-jpa-2.0-api
- 1.0.0.Final
- true
- compile
-
-
- javax.validation
- validation-api
- 1.0.0.GA
+ org.springframework.data
+ spring-data-neo4j
+ ${spring-data-neo4j.version}
+
+
+ org.hibernate
+ hibernate-validator
+ ${hibernate-validator.version}
+
+
+
+
+ org.slf4j
+ slf4j-api
+ ${slf4j.version}
+
+
+ org.slf4j
+ slf4j-log4j12
+ ${slf4j.version}
+
+
+ log4j
+ log4j
+ ${log4j.version}
+
+
+
+
+ org.springframework
+ spring-test
+ ${spring.version}
+ test
+
+
+ org.neo4j
+ neo4j-kernel
+ ${neo4j.version}
+ test-jar
+ test
+
+
+ junit
+ junit
+ ${junit.version}
+ test
+
+
@@ -119,196 +140,14 @@
org.apache.maven.plugins
maven-compiler-plugin
- 2.1
+ 3.1
1.7
1.7
-
-
- org.apache.maven.plugins
- maven-idea-plugin
- 2.2
-
- true
- true
-
-
-
-
-
-
- org.codehaus.mojo
- exec-maven-plugin
- 1.2
-
-
-
- exec
-
-
-
-
- org.springframework.data.neo4j.examples.hellograph.App
-
-
-
-
- maven-assembly-plugin
-
- hello-worlds-${project.version}
- false
- false
-
-
- org.springframework.data.neo4j.examples.hellograph.App
-
-
-
- jar-with-dependencies
-
-
-
-
- make-assembly
- package
-
- single
-
-
-
-
-
- maven-resources-plugin
-
-
- initialize
-
- resources
-
-
-
-
-
-
-
- plain
-
-
- org.springframework.data
- spring-data-neo4j
- ${spring-data-neo4j.version}
-
-
-
-
-
-
- ${project.basedir}/src/main/resources/spring/plain
- ${project.build.directory}/classes/spring
- true
-
- helloWorldContext.xml
-
-
-
-
-
-
- aspects
-
- true
-
-
-
-
- org.springframework.data
- spring-data-neo4j-aspects
- ${spring-data-neo4j.version}
-
-
-
-
-
-
-
- org.codehaus.mojo
- aspectj-maven-plugin
- 1.2
-
- true
-
-
- org.springframework
- spring-aspects
-
-
- org.springframework.data
- spring-data-neo4j-aspects
-
-
- 1.7
- 1.7
-
-
-
-
- compile
- test-compile
-
-
-
-
-
- org.aspectj
- aspectjrt
- ${aspectj.version}
-
-
- org.aspectj
- aspectjtools
- ${aspectj.version}
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-eclipse-plugin
- 2.8
-
-
- 1.5
-
- org.eclipse.ajdt.ui.ajnature
- org.eclipse.jdt.core.javanature
- org.springframework.ide.eclipse.core.springnature
-
-
-
-
-
-
- ${project.basedir}/src/main/resources/spring/aspects
- ${project.build.directory}/classes/spring
- true
-
- helloWorldContext.xml
-
-
-
-
-
-
diff --git a/spring-data-neo4j-examples/hello-worlds/settings/ivy.xml b/spring-data-neo4j-examples/hello-worlds/settings/ivy.xml
index 49894f178..0c5b95124 100644
--- a/spring-data-neo4j-examples/hello-worlds/settings/ivy.xml
+++ b/spring-data-neo4j-examples/hello-worlds/settings/ivy.xml
@@ -1,12 +1,12 @@
-
+
-
-
+
+
diff --git a/spring-data-neo4j-examples/hello-worlds/src/main/java/org/springframework/data/neo4j/examples/hellograph/GalaxyService.java b/spring-data-neo4j-examples/hello-worlds/src/main/java/org/springframework/data/neo4j/examples/hellograph/GalaxyService.java
index 41f9cf7e3..93188c501 100644
--- a/spring-data-neo4j-examples/hello-worlds/src/main/java/org/springframework/data/neo4j/examples/hellograph/GalaxyService.java
+++ b/spring-data-neo4j-examples/hello-worlds/src/main/java/org/springframework/data/neo4j/examples/hellograph/GalaxyService.java
@@ -29,9 +29,10 @@ public class GalaxyService {
}
public World findWorldByName(String name) {
- return worldRepository.findByPropertyValue("name", name);
+ return worldRepository.findBySchemaPropertyValue("name", name);
}
-
+
+ // This is using the legacy index
public Iterable findAllByNumberOfMoons(int numberOfMoons) {
return worldRepository.findAllByPropertyValue("moons", numberOfMoons);
}
diff --git a/spring-data-neo4j-examples/hello-worlds/src/main/java/org/springframework/data/neo4j/examples/hellograph/World.java b/spring-data-neo4j-examples/hello-worlds/src/main/java/org/springframework/data/neo4j/examples/hellograph/World.java
index a4554a2c9..a3bd618be 100644
--- a/spring-data-neo4j-examples/hello-worlds/src/main/java/org/springframework/data/neo4j/examples/hellograph/World.java
+++ b/spring-data-neo4j-examples/hello-worlds/src/main/java/org/springframework/data/neo4j/examples/hellograph/World.java
@@ -6,6 +6,8 @@ import org.springframework.data.neo4j.annotation.GraphId;
import org.springframework.data.neo4j.annotation.Indexed;
import org.springframework.data.neo4j.annotation.NodeEntity;
import org.springframework.data.neo4j.annotation.RelatedTo;
+import org.springframework.data.neo4j.support.index.IndexType;
+
import java.util.Set;
@NodeEntity
@@ -18,7 +20,7 @@ public class World {
@Indexed
private String name;
- @Indexed(indexName = "moon-index")
+ @Indexed(indexType = IndexType.SIMPLE)
private int moons;
@Fetch
diff --git a/spring-data-neo4j-examples/hello-worlds/src/main/resources/spring/plain/helloWorldContext.xml b/spring-data-neo4j-examples/hello-worlds/src/main/resources/spring/helloWorldContext.xml
similarity index 90%
rename from spring-data-neo4j-examples/hello-worlds/src/main/resources/spring/plain/helloWorldContext.xml
rename to spring-data-neo4j-examples/hello-worlds/src/main/resources/spring/helloWorldContext.xml
index 9805b0c22..256f491b7 100644
--- a/spring-data-neo4j-examples/hello-worlds/src/main/resources/spring/plain/helloWorldContext.xml
+++ b/spring-data-neo4j-examples/hello-worlds/src/main/resources/spring/helloWorldContext.xml
@@ -18,7 +18,7 @@
-
+
diff --git a/spring-data-neo4j-examples/hello-worlds/src/test/java/org/springframework/data/neo4j/examples/hellograph/GalaxyServiceTest.java b/spring-data-neo4j-examples/hello-worlds/src/test/java/org/springframework/data/neo4j/examples/hellograph/GalaxyServiceTest.java
new file mode 100644
index 000000000..8e4ad0cc3
--- /dev/null
+++ b/spring-data-neo4j-examples/hello-worlds/src/test/java/org/springframework/data/neo4j/examples/hellograph/GalaxyServiceTest.java
@@ -0,0 +1,119 @@
+package org.springframework.data.neo4j.examples.hellograph;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.neo4j.support.Neo4jTemplate;
+import org.springframework.data.neo4j.support.node.Neo4jHelper;
+import org.springframework.test.annotation.Rollback;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.transaction.BeforeTransaction;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.Collection;
+
+import static org.hamcrest.CoreMatchers.anyOf;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.*;
+
+@ContextConfiguration(locations = "classpath:/spring/helloWorldContext.xml")
+@RunWith(SpringJUnit4ClassRunner.class)
+@Transactional
+public class GalaxyServiceTest {
+
+ @Autowired
+ private GalaxyService galaxyService;
+
+ @Autowired
+ private Neo4jTemplate template;
+
+ @Rollback(false)
+ @BeforeTransaction
+ public void cleanUpGraph() {
+ Neo4jHelper.cleanDb(template);
+ }
+
+ @Test
+ public void shouldAllowDirectWorldCreation() {
+ assertEquals(0, galaxyService.getNumberOfWorlds());
+ World myWorld = galaxyService.createWorld("mine", 0);
+ assertEquals(1, galaxyService.getNumberOfWorlds());
+
+ Iterable foundWorlds = galaxyService.getAllWorlds();
+ World mine = foundWorlds.iterator().next();
+ assertEquals(myWorld.getName(), mine.getName());
+ }
+
+ @Test
+ public void shouldHaveCorrectNumberOfWorlds() {
+ galaxyService.makeSomeWorlds();
+ assertEquals(13, galaxyService.getNumberOfWorlds());
+ }
+
+ @Test
+ public void shouldFindWorldsById() {
+ galaxyService.makeSomeWorlds();
+
+ for(World world : galaxyService.getAllWorlds()) {
+ World foundWorld = galaxyService.findWorldById(world.getId());
+ assertNotNull(foundWorld);
+ }
+ }
+
+ @Test
+ public void shouldFindWorldsByName() {
+ galaxyService.makeSomeWorlds();
+
+ for(World world : galaxyService.getAllWorlds()) {
+ World foundWorld = galaxyService.findWorldByName(world.getName());
+ assertNotNull(foundWorld);
+ }
+ }
+
+ @Test
+ public void shouldReachMarsFromEarth() {
+ galaxyService.makeSomeWorlds();
+
+ World earth = galaxyService.findWorldByName("Earth");
+ World mars = galaxyService.findWorldByName("Mars");
+
+ assertTrue(mars.canBeReachedFrom(earth));
+ assertTrue(earth.canBeReachedFrom(mars));
+ }
+
+ @Test
+ public void shouldFindAllWorlds() {
+ Collection madeWorlds = galaxyService.makeSomeWorlds();
+ Iterable foundWorlds = galaxyService.getAllWorlds();
+
+ int countOfFoundWorlds = 0;
+ for(World foundWorld : foundWorlds) {
+ assertTrue(madeWorlds.contains(foundWorld));
+ countOfFoundWorlds++;
+ }
+
+ assertEquals(madeWorlds.size(), countOfFoundWorlds);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void shouldFindWorldsWith1Moon() {
+ galaxyService.makeSomeWorlds();
+
+ for(World worldWithOneMoon : galaxyService.findAllByNumberOfMoons(1)) {
+ assertThat(
+ worldWithOneMoon.getName(),
+ is(anyOf(containsString("Earth"), containsString("Midgard"))));
+ }
+ }
+
+ @Test
+ public void shouldNotFindKrypton() {
+ galaxyService.makeSomeWorlds();
+ World krypton = galaxyService.findWorldByName("Krypton");
+ assertNull(krypton);
+ }
+
+}