15
15
*/
16
16
package org .springframework .data .neo4j .integration .issues .gh2526 ;
17
17
18
+ import static org .assertj .core .api .Assertions .*;
19
+ import static org .assertj .core .api .InstanceOfAssertFactories .*;
20
+
18
21
import java .util .Set ;
19
22
20
23
import org .junit .jupiter .api .BeforeEach ;
35
38
import org .springframework .transaction .PlatformTransactionManager ;
36
39
import org .springframework .transaction .annotation .EnableTransactionManagement ;
37
40
38
- import static org .assertj .core .api .Assertions .assertThat ;
39
-
41
+ /**
42
+ * @author Andreas Berger
43
+ */
40
44
@ Neo4jIntegrationTest
41
- public class GH2526 {
45
+ public class GH2526IT {
42
46
43
47
protected static Neo4jExtension .Neo4jConnectionSupport neo4jConnectionSupport ;
44
48
@@ -47,27 +51,28 @@ void setupData(@Autowired Driver driver, @Autowired BookmarkCapture bookmarkCapt
47
51
48
52
try (Session session = driver .session ()) {
49
53
session .run ("MATCH (n) DETACH DELETE n" ).consume ();
50
- session .run (
51
- "CREATE (o1:Measurand {measurandId: 'o1'})" +
52
- "CREATE (acc1:AccountingMeasurementMeta:BaseNodeEntity {nodeId: 'acc1'})" +
53
- "CREATE (o1)-[:IS_MEASURED_BY{ manual: true }]->(acc1)"
54
- ).consume ();
54
+ session .run ("CREATE (o1:Measurand {measurandId: 'o1'})"
55
+ + "CREATE (acc1:AccountingMeasurementMeta:BaseNodeEntity {nodeId: 'acc1'})"
56
+ + "CREATE (o1)-[:IS_MEASURED_BY{ manual: true }]->(acc1)" ).consume ();
55
57
bookmarkCapture .seedWith (session .lastBookmark ());
56
58
}
57
59
}
58
60
59
61
@ Test
60
- void test (@ Autowired BaseNodeRepository repository ) {
62
+ // GH-2526
63
+ void testRichRelationWithInheritance (@ Autowired BaseNodeRepository repository ) {
61
64
Projection m = repository .findByNodeId ("acc1" , Projection .class );
62
65
assertThat (m ).isNotNull ();
66
+ assertThat (m ).extracting (Projection ::getDataPoints , collection (DataPoint .class ))
67
+ .extracting (DataPoint ::isManual , DataPoint ::getMeasurand ).contains (tuple (true , new Measurand ("o1" )));
63
68
}
64
69
65
70
interface Projection {
66
71
String getNodeId ();
72
+
67
73
Set <DataPoint > getDataPoints ();
68
74
}
69
75
70
-
71
76
@ Configuration
72
77
@ EnableTransactionManagement
73
78
@ EnableNeo4jRepositories
@@ -79,13 +84,11 @@ public BookmarkCapture bookmarkCapture() {
79
84
}
80
85
81
86
@ Override
82
- public PlatformTransactionManager transactionManager (
83
- Driver driver , DatabaseSelectionProvider databaseNameProvider )
84
- {
87
+ public PlatformTransactionManager transactionManager (Driver driver ,
88
+ DatabaseSelectionProvider databaseNameProvider ) {
85
89
86
90
BookmarkCapture bookmarkCapture = bookmarkCapture ();
87
- return new Neo4jTransactionManager (driver , databaseNameProvider ,
88
- Neo4jBookmarkManager .create (bookmarkCapture ));
91
+ return new Neo4jTransactionManager (driver , databaseNameProvider , Neo4jBookmarkManager .create (bookmarkCapture ));
89
92
}
90
93
91
94
@ Bean
0 commit comments