56
56
import java .util .Set ;
57
57
58
58
import static org .assertj .core .api .Assertions .assertThat ;
59
+ import static org .assertj .core .api .Assertions .tuple ;
60
+ import static org .assertj .core .api .InstanceOfAssertFactories .collection ;
59
61
60
62
/**
61
63
* Test setup for GH-2526: Query creation of and picking the correct named relationship out of the result.
@@ -81,16 +83,29 @@ void setupData(@Autowired Driver driver, @Autowired BookmarkCapture bookmarkCapt
81
83
82
84
@ Test
83
85
void relationshipWillGetFoundInResultOfMultilevelInheritance (@ Autowired BaseNodeRepository repository ) {
84
- Projection m = repository .findByNodeId ("acc1" , Projection .class );
86
+ MeasurementProjection m = repository .findByNodeId ("acc1" , MeasurementProjection .class );
85
87
assertThat (m ).isNotNull ();
86
88
assertThat (m .getDataPoints ()).isNotEmpty ();
89
+ assertThat (m ).extracting (MeasurementProjection ::getDataPoints , collection (DataPoint .class ))
90
+ .extracting (DataPoint ::isManual , DataPoint ::getMeasurand ).contains (tuple (true , new Measurand ("o1" )));
87
91
}
88
92
89
- interface Projection {
93
+ interface BaseNodeFieldsProjection {
90
94
String getNodeId ();
95
+ }
96
+
97
+
98
+ interface MeasurementProjection extends BaseNodeFieldsProjection {
91
99
Set <DataPoint > getDataPoints ();
100
+ Set <VariableProjection > getVariables ();
92
101
}
93
102
103
+ interface VariableProjection {
104
+ BaseNodeFieldsProjection getMeasurement ();
105
+ String getVariable ();
106
+ }
107
+
108
+
94
109
/**
95
110
* Defining most concrete entity
96
111
*/
@@ -155,6 +170,34 @@ public static class MeasurementMeta extends BaseNodeEntity {
155
170
156
171
@ Relationship (type = "IS_MEASURED_BY" , direction = Relationship .Direction .INCOMING )
157
172
private Set <DataPoint > dataPoints ;
173
+
174
+ @ Relationship (type = "USES" , direction = Relationship .Direction .OUTGOING )
175
+ private Set <Variable > variables ;
176
+ }
177
+
178
+ @ RelationshipProperties
179
+ @ Value
180
+ @ With
181
+ @ AllArgsConstructor
182
+ @ EqualsAndHashCode
183
+ @ Immutable
184
+ public static class Variable {
185
+ @ RelationshipId
186
+ Long id ;
187
+
188
+ @ TargetNode
189
+ MeasurementMeta measurement ;
190
+
191
+ String variable ;
192
+
193
+ public static Variable create (MeasurementMeta measurement , String variable ) {
194
+ return new Variable (null , measurement , variable );
195
+ }
196
+
197
+ @ Override
198
+ public String toString () {
199
+ return variable + ": " + measurement .getNodeId ();
200
+ }
158
201
}
159
202
160
203
/**
0 commit comments