Skip to content

Commit 86b16c1

Browse files
FlorentinDs1ck
authored andcommitted
Fix test usages
1 parent e9dc7c7 commit 86b16c1

File tree

15 files changed

+173
-215
lines changed

15 files changed

+173
-215
lines changed

core/src/test/java/org/neo4j/gds/api/schema/GraphSchemaIntegrationTest.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import org.neo4j.gds.NodeLabel;
2828
import org.neo4j.gds.NodeProjection;
2929
import org.neo4j.gds.PropertyMapping;
30-
import org.neo4j.gds.PropertyMappings;
3130
import org.neo4j.gds.RelationshipProjection;
3231
import org.neo4j.gds.RelationshipType;
3332
import org.neo4j.gds.StoreLoaderBuilder;
@@ -37,7 +36,6 @@
3736
import org.neo4j.gds.api.nodeproperties.ValueType;
3837
import org.neo4j.gds.core.Aggregation;
3938

40-
import java.util.List;
4139
import java.util.stream.Stream;
4240

4341
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -62,10 +60,10 @@ void computesCorrectNodeSchema(PropertySchema expectedSchema, PropertyMapping pr
6260
Graph graph = new StoreLoaderBuilder()
6361
.databaseService(db)
6462
.addNodeProjection(
65-
NodeProjection.of(
66-
"Node",
67-
PropertyMappings.of(List.of(propertyMapping))
68-
)
63+
NodeProjection.builder()
64+
.label("Node")
65+
.addProperty(propertyMapping)
66+
.build()
6967
)
7068
.build()
7169
.graph();
@@ -81,7 +79,7 @@ void computesCorrectRelationshipSchema(RelationshipPropertySchema expectedSchema
8179
.addRelationshipProjection(
8280
RelationshipProjection.builder()
8381
.type("REL")
84-
.properties(PropertyMappings.of(List.of(propertyMapping)))
82+
.addProperties(propertyMapping)
8583
.build()
8684
)
8785
.build()

core/src/test/java/org/neo4j/gds/config/GraphProjectFromCypherConfigTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
import org.junit.jupiter.params.provider.Arguments;
2525
import org.junit.jupiter.params.provider.MethodSource;
2626
import org.neo4j.gds.AbstractProjections;
27+
import org.neo4j.gds.ImmutableNodeProjections;
2728
import org.neo4j.gds.ImmutableRelationshipProjections;
28-
import org.neo4j.gds.NodeProjections;
2929
import org.neo4j.gds.core.CypherMapWrapper;
3030

3131
import java.util.Map;
@@ -71,9 +71,9 @@ void omitCypherParametersFromToMap() {
7171

7272
static Stream<Arguments> invalidKeys() {
7373
return Stream.of(
74-
Arguments.of(GraphProjectFromStoreConfig.NODE_PROJECTION_KEY, NodeProjections.of()),
74+
Arguments.of(GraphProjectFromStoreConfig.NODE_PROJECTION_KEY, ImmutableNodeProjections.of()),
7575
Arguments.of(GraphProjectFromStoreConfig.RELATIONSHIP_PROJECTION_KEY, ImmutableRelationshipProjections.of()),
76-
Arguments.of(GraphProjectFromStoreConfig.NODE_PROPERTIES_KEY, NodeProjections.of())
76+
Arguments.of(GraphProjectFromStoreConfig.NODE_PROPERTIES_KEY, ImmutableNodeProjections.of())
7777
);
7878
}
7979

core/src/test/java/org/neo4j/gds/config/GraphProjectFromStoreConfigTest.java

Lines changed: 41 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@
2525
import org.neo4j.gds.NodeProjection;
2626
import org.neo4j.gds.NodeProjections;
2727
import org.neo4j.gds.Orientation;
28+
import org.neo4j.gds.PropertyMapping;
2829
import org.neo4j.gds.PropertyMappings;
2930
import org.neo4j.gds.RelationshipProjection;
3031
import org.neo4j.gds.RelationshipProjections;
3132
import org.neo4j.gds.RelationshipType;
3233
import org.neo4j.gds.api.DefaultValue;
3334
import org.neo4j.gds.core.Aggregation;
3435

35-
import java.util.Collections;
3636
import java.util.Set;
3737

3838
import static org.hamcrest.MatcherAssert.assertThat;
@@ -46,14 +46,18 @@ class GraphProjectFromStoreConfigTest {
4646

4747
@Test
4848
void testThrowOnOverlappingNodeProperties() {
49-
PropertyMappings propertyMappings = PropertyMappings.builder()
50-
.addMapping("duplicate", "foo", DefaultValue.of(0.0), Aggregation.NONE)
51-
.build();
52-
53-
NodeProjections nodeProjections = NodeProjections.create(Collections.singletonMap(
54-
NodeLabel.of("A"), NodeProjection.of("A", propertyMappings)
49+
PropertyMappings propertyMappings = PropertyMappings.of(PropertyMapping.of(
50+
"duplicate",
51+
"foo",
52+
DefaultValue.of(0.0),
53+
Aggregation.NONE
5554
));
5655

56+
var nodeProjections = NodeProjections.single(
57+
NodeLabel.of("A"),
58+
NodeProjection.builder().label("A").properties(propertyMappings).build()
59+
);
60+
5761
IllegalArgumentException ex = assertThrows(IllegalArgumentException.class, () ->
5862
ImmutableGraphProjectFromStoreConfig.builder()
5963
.graphName("graph")
@@ -68,9 +72,12 @@ void testThrowOnOverlappingNodeProperties() {
6872

6973
@Test
7074
void testThrowOnOverlappingRelProperties() {
71-
PropertyMappings propertyMappings = PropertyMappings.builder()
72-
.addMapping("duplicate", "foo", DefaultValue.of(0.0), Aggregation.NONE)
73-
.build();
75+
var propertyMappings = PropertyMappings.of(PropertyMapping.of(
76+
"duplicate",
77+
"foo",
78+
DefaultValue.of(0.0),
79+
Aggregation.NONE
80+
));
7481

7582
RelationshipProjections relProjections = ImmutableRelationshipProjections.single(
7683
RelationshipType.of("A"),
@@ -95,18 +102,26 @@ void testThrowOnOverlappingRelProperties() {
95102

96103
@Test
97104
void testMergingOfNodePropertiesAndProjections() {
98-
PropertyMappings propertyMappings1 = PropertyMappings.builder()
99-
.addMapping("foo", "foo", DefaultValue.of(0.0), Aggregation.NONE)
100-
.build();
101-
102-
PropertyMappings propertyMappings2 = PropertyMappings.builder()
103-
.addMapping("bar", "foo", DefaultValue.of(0.0), Aggregation.NONE)
104-
.build();
105+
var propertyMappings1 = PropertyMappings.of(PropertyMapping.of(
106+
"foo",
107+
"foo",
108+
DefaultValue.of(0.0),
109+
Aggregation.NONE
110+
)
111+
);
105112

106-
NodeProjections nodeProjections = NodeProjections.create(Collections.singletonMap(
107-
NodeLabel.of("A"), NodeProjection.of("A", propertyMappings2)
113+
var propertyMappings2 = PropertyMappings.of(PropertyMapping.of(
114+
"bar",
115+
"foo",
116+
DefaultValue.of(0.0),
117+
Aggregation.NONE
108118
));
109119

120+
var nodeProjections = NodeProjections.single(
121+
NodeLabel.of("A"),
122+
NodeProjection.builder().label("A").properties(propertyMappings2).build()
123+
);
124+
110125
GraphProjectFromStoreConfig graphProjectConfig = ImmutableGraphProjectFromStoreConfig.builder()
111126
.graphName("graph")
112127
.relationshipProjections(RelationshipProjections.ALL)
@@ -122,13 +137,14 @@ void testMergingOfNodePropertiesAndProjections() {
122137

123138
@Test
124139
void testMergingOfRelationshipPropertiesAndProjections() {
125-
PropertyMappings propertyMappings1 = PropertyMappings.builder()
126-
.addMapping("foo", "foo", DefaultValue.of(0.0), Aggregation.NONE)
127-
.build();
140+
var propertyMappings1 = PropertyMappings.of(PropertyMapping.of("foo", "foo", DefaultValue.of(0.0), Aggregation.NONE));
128141

129-
PropertyMappings propertyMappings2 = PropertyMappings.builder()
130-
.addMapping("bar", "foo", DefaultValue.of(0.0), Aggregation.NONE)
131-
.build();
142+
var propertyMappings2 = PropertyMappings.of(PropertyMapping.of(
143+
"bar",
144+
"foo",
145+
DefaultValue.of(0.0),
146+
Aggregation.NONE
147+
));
132148

133149
RelationshipProjections relProjections = ImmutableRelationshipProjections.single(
134150
RelationshipType.of("A"),

core/src/test/java/org/neo4j/gds/core/GraphLoaderMultipleRelTypesAndPropertiesTest.java

Lines changed: 14 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import org.neo4j.gds.NodeLabel;
3030
import org.neo4j.gds.NodeProjection;
3131
import org.neo4j.gds.PropertyMapping;
32-
import org.neo4j.gds.PropertyMappings;
3332
import org.neo4j.gds.RelationshipProjection;
3433
import org.neo4j.gds.RelationshipType;
3534
import org.neo4j.gds.StoreLoaderBuilder;
@@ -89,25 +88,14 @@ void setup() {
8988
@Test
9089
void nodeProjectionsWithExclusiveProperties() {
9190
GraphStore graphStore = new StoreLoaderBuilder()
92-
.putNodeProjectionsWithIdentifier(
93-
"N1",
94-
NodeProjection.of(
95-
"Node1",
96-
PropertyMappings.builder().addMapping(PropertyMapping.of("prop1", 0.0D)).build()
97-
)
98-
).putNodeProjectionsWithIdentifier(
99-
"N2",
100-
NodeProjection.of(
101-
"Node1",
102-
PropertyMappings.of()
103-
)
104-
).putNodeProjectionsWithIdentifier(
105-
"N3",
106-
NodeProjection.of(
107-
"Node2",
108-
PropertyMappings.builder().addMapping(PropertyMapping.of("prop2", 1.0D)).build()
109-
)
110-
).graphName("myGraph")
91+
.putNodeProjectionsWithIdentifier("N1",
92+
NodeProjection.builder().label("Node1").addProperty(PropertyMapping.of("prop1", 0.0D)).build()
93+
)
94+
.putNodeProjectionsWithIdentifier("N2", NodeProjection.of("Node1"))
95+
.putNodeProjectionsWithIdentifier("N3",
96+
NodeProjection.builder().label("Node2").addProperty(PropertyMapping.of("prop2", 1.0D)).build()
97+
)
98+
.graphName("myGraph")
11199
.databaseService(db)
112100
.build()
113101
.graphStore();
@@ -134,19 +122,14 @@ void nodeProjectionsWithAndWithoutLabel() {
134122
GraphStore graphStore = new StoreLoaderBuilder()
135123
.putNodeProjectionsWithIdentifier(
136124
allIdentifier.name(),
137-
NodeProjection.of(
138-
"*",
139-
PropertyMappings.builder()
140-
.addMapping(PropertyMapping.of("prop1", 42.0D))
141-
.addMapping(PropertyMapping.of("prop2", 8.0D))
142-
.build()
143-
)
125+
NodeProjection
126+
.builder()
127+
.label("*")
128+
.addProperties(PropertyMapping.of("prop1", 42.0D), PropertyMapping.of("prop2", 8.0D))
129+
.build()
144130
).putNodeProjectionsWithIdentifier(
145131
node2Identifier.name(),
146-
NodeProjection.of(
147-
"Node2",
148-
PropertyMappings.builder().addMapping(PropertyMapping.of("prop2", 8.0D)).build()
149-
)
132+
NodeProjection.builder().label("Node2").addProperty(PropertyMapping.of("prop2", 8.0D)).build()
150133
).graphName("myGraph")
151134
.databaseService(db)
152135
.build()

core/src/test/java/org/neo4j/gds/core/loading/GraphStoreTest.java

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -279,18 +279,18 @@ void nodeOnlyGraph() {
279279
private static List<NodeProjection> nodeProjections() {
280280
NodeProjection aMapping = NodeProjection.builder()
281281
.label("A")
282-
.properties(PropertyMappings.of(Arrays.asList(
282+
.addProperties(
283283
PropertyMapping.of("nodeProperty", -1D),
284284
PropertyMapping.of("a", -1D)
285-
)))
285+
)
286286
.build();
287287

288288
NodeProjection bMapping = NodeProjection.builder()
289289
.label("B")
290-
.properties(PropertyMappings.of(Arrays.asList(
290+
.addProperties(
291291
PropertyMapping.of("nodeProperty", -1D),
292292
PropertyMapping.of("b", -1D)
293-
)))
293+
)
294294
.build();
295295

296296
return Arrays.asList(aMapping, bMapping);
@@ -302,32 +302,24 @@ private static List<RelationshipProjection> relationshipProjections() {
302302
.type("T1")
303303
.orientation(Orientation.NATURAL)
304304
.aggregation(Aggregation.NONE)
305-
.properties(
306-
PropertyMappings.builder()
307-
.addMapping("property1", "property1", DefaultValue.of(42D), Aggregation.NONE)
308-
.addMapping("property2", "property2", DefaultValue.of(1337D), Aggregation.NONE)
309-
.build()
305+
.addProperties(
306+
PropertyMapping.of("property1", "property1", DefaultValue.of(42D), Aggregation.NONE),
307+
PropertyMapping.of("property2", "property2", DefaultValue.of(1337D), Aggregation.NONE)
310308
).build();
311309

312310
RelationshipProjection t2Mapping = RelationshipProjection.builder()
313311
.type("T2")
314312
.orientation(Orientation.NATURAL)
315313
.aggregation(Aggregation.NONE)
316-
.properties(
317-
PropertyMappings.builder()
318-
.addMapping("property1", "property1", DefaultValue.of(42D), Aggregation.NONE)
319-
.build()
320-
).build();
314+
.addProperty(PropertyMapping.of("property1", "property1", DefaultValue.of(42D), Aggregation.NONE))
315+
.build();
321316

322317
RelationshipProjection t3Mapping = RelationshipProjection.builder()
323318
.type("T3")
324319
.orientation(Orientation.NATURAL)
325320
.aggregation(Aggregation.NONE)
326-
.properties(
327-
PropertyMappings.builder()
328-
.addMapping("property2", "property2", DefaultValue.of(42D), Aggregation.NONE)
329-
.build()
330-
).build();
321+
.addProperty(PropertyMapping.of("property2", "property2", DefaultValue.of(42D), Aggregation.NONE))
322+
.build();
331323

332324
return Arrays.asList(t1Mapping, t2Mapping, t3Mapping);
333325
}

cypher/cypher-test/src/test/java/org/neo4j/gds/storageengine/InMemoryNodeCursorTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import org.junit.jupiter.api.Test;
2323
import org.neo4j.gds.NodeProjection;
2424
import org.neo4j.gds.PropertyMapping;
25-
import org.neo4j.gds.PropertyMappings;
2625
import org.neo4j.gds.StoreLoaderBuilder;
2726
import org.neo4j.gds.api.GraphStore;
2827
import org.neo4j.gds.compat.AbstractInMemoryNodeCursor;
@@ -53,8 +52,8 @@ protected void onSetup() {
5352
protected GraphStore graphStore() {
5453
return new StoreLoaderBuilder()
5554
.databaseService(db)
56-
.addNodeProjection(NodeProjection.of("A", PropertyMappings.of(PropertyMapping.of("prop1"))))
57-
.addNodeProjection(NodeProjection.of("B", PropertyMappings.of(PropertyMapping.of("prop2"))))
55+
.addNodeProjection(NodeProjection.builder().label("A").addProperty(PropertyMapping.of("prop1")).build())
56+
.addNodeProjection(NodeProjection.builder().label("B").addProperty(PropertyMapping.of("prop2")).build())
5857
.build()
5958
.graphStore();
6059
}

cypher/cypher-test/src/test/java/org/neo4j/internal/recordstorage/InMemoryStorageEngineTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import org.neo4j.gds.NodeProjection;
2424
import org.neo4j.gds.Orientation;
2525
import org.neo4j.gds.PropertyMapping;
26-
import org.neo4j.gds.PropertyMappings;
2726
import org.neo4j.gds.RelationshipProjection;
2827
import org.neo4j.gds.StoreLoaderBuilder;
2928
import org.neo4j.gds.api.GraphStore;
@@ -45,8 +44,8 @@ class InMemoryStorageEngineTest extends CypherTest {
4544
protected GraphStore graphStore() {
4645
return new StoreLoaderBuilder()
4746
.databaseService(db)
48-
.addNodeProjection(NodeProjection.of("A", PropertyMappings.of(PropertyMapping.of("prop1"))))
49-
.addNodeProjection(NodeProjection.of("B", PropertyMappings.of(PropertyMapping.of("prop2"))))
47+
.addNodeProjection(NodeProjection.builder().label("A").addProperty(PropertyMapping.of("prop1")).build())
48+
.addNodeProjection(NodeProjection.builder().label("B").addProperty(PropertyMapping.of("prop2")).build())
5049
.addRelationshipProjection(RelationshipProjection.of("REL", Orientation.NATURAL))
5150
.build()
5251
.graphStore();

0 commit comments

Comments
 (0)