From 2a2c3e199680832afe8a10f7d1bb83c318098183 Mon Sep 17 00:00:00 2001 From: Luanne Misquitta Date: Mon, 2 Nov 2015 14:06:00 +0530 Subject: [PATCH] DATAGRAPH-783 - Argument type mismatch (int to Float) with derived finders. --- .../neo4j/examples/galaxy/GalaxyServiceTest.java | 15 +++++++++++++++ .../data/neo4j/examples/galaxy/domain/World.java | 13 ++++++++++++- .../examples/galaxy/repo/WorldRepository.java | 2 ++ .../examples/galaxy/service/GalaxyService.java | 8 ++++++++ 4 files changed, 37 insertions(+), 1 deletion(-) diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/galaxy/GalaxyServiceTest.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/galaxy/GalaxyServiceTest.java index 40cbfba27..96937442e 100644 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/galaxy/GalaxyServiceTest.java +++ b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/galaxy/GalaxyServiceTest.java @@ -289,6 +289,21 @@ public class GalaxyServiceTest { assertEquals(0, count); } + /** + * @see DATAGRAPH-783 + */ + @Test + public void shouldFindWorldWithRadius() { + galaxyService.deleteAll(); + World earth = new World("Earth",1); + earth.setRadius(6371.0f); + galaxyService.create(earth); + + earth = galaxyService.findByName("Earth"); + assertEquals(Float.valueOf(6371.0f),earth.getRadius()); + + } + private String[] getNamesSorted(List worlds) { List names = new ArrayList(); diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/galaxy/domain/World.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/galaxy/domain/World.java index eb15527e1..b03e1c0df 100644 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/galaxy/domain/World.java +++ b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/galaxy/domain/World.java @@ -31,6 +31,10 @@ public class World { private int moons; + private Float radius; + + private Long updated; + public Long getUpdated() { return updated; } @@ -39,7 +43,6 @@ public class World { this.updated = updated; } - private Long updated; private Set reachableByRocket = new HashSet<>(); @@ -89,6 +92,14 @@ public class World { return false; } + public Float getRadius() { + return radius; + } + + public void setRadius(Float radius) { + this.radius = radius; + } + @Override public boolean equals(Object o) { if (this == o) return true; diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/galaxy/repo/WorldRepository.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/galaxy/repo/WorldRepository.java index 9fa72a876..aec68b274 100644 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/galaxy/repo/WorldRepository.java +++ b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/galaxy/repo/WorldRepository.java @@ -31,4 +31,6 @@ public interface WorldRepository extends GraphRepository { @Query("MATCH (n:World) SET n.updated=timestamp()") Result touchAllWorldsWithStatistics(); + World findByName(String name); + } diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/galaxy/service/GalaxyService.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/galaxy/service/GalaxyService.java index 1875c075b..89a6d9cdb 100644 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/galaxy/service/GalaxyService.java +++ b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/galaxy/service/GalaxyService.java @@ -48,6 +48,10 @@ public class GalaxyService { return worldRepository.save(new World(name, moons)); } + public World create(World world) { + return worldRepository.save(world); + } + public Iterable getAllWorlds() { return worldRepository.findAll(); } @@ -176,4 +180,8 @@ public class GalaxyService { public Iterable findAllWorlds(Sort sort, int depth) { return worldRepository.findAll(sort, depth); } + + public World findByName(String name) { + return worldRepository.findByName(name); + } }