Skip to content

Commit 8b22bd1

Browse files
committed
GH-2526 - Extend test case.
1 parent cdc02cf commit 8b22bd1

File tree

1 file changed

+45
-2
lines changed
  • src/test/java/org/springframework/data/neo4j/integration/issues/gh2526

1 file changed

+45
-2
lines changed

src/test/java/org/springframework/data/neo4j/integration/issues/gh2526/GH2526IT.java

+45-2
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@
5656
import java.util.Set;
5757

5858
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;
5961

6062
/**
6163
* 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
8183

8284
@Test
8385
void relationshipWillGetFoundInResultOfMultilevelInheritance(@Autowired BaseNodeRepository repository) {
84-
Projection m = repository.findByNodeId("acc1", Projection.class);
86+
MeasurementProjection m = repository.findByNodeId("acc1", MeasurementProjection.class);
8587
assertThat(m).isNotNull();
8688
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")));
8791
}
8892

89-
interface Projection {
93+
interface BaseNodeFieldsProjection{
9094
String getNodeId();
95+
}
96+
97+
98+
interface MeasurementProjection extends BaseNodeFieldsProjection {
9199
Set<DataPoint> getDataPoints();
100+
Set<VariableProjection> getVariables();
92101
}
93102

103+
interface VariableProjection {
104+
BaseNodeFieldsProjection getMeasurement();
105+
String getVariable();
106+
}
107+
108+
94109
/**
95110
* Defining most concrete entity
96111
*/
@@ -155,6 +170,34 @@ public static class MeasurementMeta extends BaseNodeEntity {
155170

156171
@Relationship(type = "IS_MEASURED_BY", direction = Relationship.Direction.INCOMING)
157172
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+
}
158201
}
159202

160203
/**

0 commit comments

Comments
 (0)