Skip to content

Commit a3c8afa

Browse files
committed
GH-2138 - Add additional test.
1 parent d9bb2bb commit a3c8afa

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/test/java/org/springframework/data/neo4j/integration/imperative/InheritanceMappingIT.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
import java.util.Collection;
3535
import java.util.Collections;
36+
import java.util.List;
3637

3738
import static org.assertj.core.api.Assertions.assertThat;
3839

@@ -103,6 +104,31 @@ void collectionsShouldHaveCorrectTypes(@Autowired TerritoryRepository repository
103104
);
104105
}
105106

107+
@Test // GH-2138
108+
void resultCollectionShouldHaveCorrectTypes(@Autowired TerritoryRepository repository) {
109+
110+
try (Session session = driver.session()) {
111+
session.run("CREATE (c:Country:BaseTerritory:BaseEntity{nameEn:'country', countryProperty:'baseCountry'}) " +
112+
"CREATE (c)-[:LINK]->(:Country:BaseTerritory:BaseEntity{nameEn:'anotherCountry', countryProperty:'large'}) " +
113+
"CREATE (c)-[:LINK]->(:Continent:BaseTerritory:BaseEntity{nameEn:'continent', continentProperty:'small'}) " +
114+
"CREATE (c)-[:LINK]->(:GenericTerritory:BaseTerritory:BaseEntity{nameEn:'generic'})").consume();
115+
}
116+
117+
List<Inheritance.BaseTerritory> territories = repository.findAll();
118+
119+
Inheritance.Country country1 = new Inheritance.Country("country", "baseCountry");
120+
Inheritance.Country country2 = new Inheritance.Country("anotherCountry", "large");
121+
Inheritance.Continent continent = new Inheritance.Continent("continent", "small");
122+
Inheritance.GenericTerritory genericTerritory = new Inheritance.GenericTerritory("generic");
123+
124+
assertThat(territories).containsExactlyInAnyOrder(
125+
country1,
126+
country2,
127+
continent,
128+
genericTerritory
129+
);
130+
}
131+
106132
@Repository
107133
interface BuildingRepository extends Neo4jRepository<Inheritance.Building, Long> {}
108134

0 commit comments

Comments
 (0)