Skip to content

Commit ccfb1ff

Browse files
authored
build(deps): bump com.networknt:json-schema-validator (#273)
Bumps [com.networknt:json-schema-validator](https://github.com/networknt/json-schema-validator) from 1.4.3 to 1.5.8. in v1.5.1, enumeration error messages changed to include double-quoted values. this change version bumps and fixes expected error messages to match the new format.
1 parent 0277f4e commit ccfb1ff

5 files changed

+74
-7
lines changed

core/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<dependency>
1818
<groupId>com.networknt</groupId>
1919
<artifactId>json-schema-validator</artifactId>
20-
<version>1.4.3</version>
20+
<version>1.5.8</version>
2121
</dependency>
2222
<dependency>
2323
<groupId>org.apache.beam</groupId>

core/src/test/java/org/neo4j/importer/v1/ImportSpecificationDeserializerActionTest.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,17 @@
2121

2222
import java.io.StringReader;
2323
import org.junit.jupiter.api.Test;
24+
import org.neo4j.importer.v1.actions.ActionStage;
2425
import org.neo4j.importer.v1.validation.InvalidSpecificationException;
2526
import org.neo4j.importer.v1.validation.UndeserializableActionException;
2627

2728
// This exercises the compliance of various import spec payloads with the JSON schema
2829
// The class focuses on (lack of) compliance of the action side of the spec.
2930
public class ImportSpecificationDeserializerActionTest {
3031

32+
private static final String ENUM_ARRAY_ACTION_STAGE =
33+
ImportSpecificationDeserializerEnumUtil.enumToJsonString(ActionStage.class);
34+
3135
@Test
3236
void fails_if_actions_are_wrongly_typed() {
3337
assertThatThrownBy(() -> deserialize(new StringReader(
@@ -267,7 +271,8 @@ void fails_if_action_stage_is_unsupported() {
267271
.hasMessageContainingAll(
268272
"1 error(s)",
269273
"0 warning(s)",
270-
"$.actions[0].stage: does not have a value in the enumeration [start, post_sources, pre_nodes, post_nodes, pre_relationships, post_relationships, pre_queries, post_queries, end]");
274+
"$.actions[0].stage: does not have a value in the enumeration",
275+
ENUM_ARRAY_ACTION_STAGE);
271276
}
272277

273278
@Test
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright (c) "Neo4j"
3+
* Neo4j Sweden AB [https://neo4j.com]
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package org.neo4j.importer.v1;
18+
19+
import java.util.Arrays;
20+
import java.util.stream.Collectors;
21+
22+
/**
23+
* Utility class for serializing enums to JSON-like string formats to keep tests DRY.
24+
* The class is a singleton and cannot be instantiated.
25+
*/
26+
public final class ImportSpecificationDeserializerEnumUtil {
27+
28+
private ImportSpecificationDeserializerEnumUtil() {
29+
/* singleton */
30+
}
31+
32+
public static <E extends Enum<E>> String enumToJsonString(Class<E> enumType) {
33+
return Arrays.stream(enumType.getEnumConstants())
34+
.map((E e) -> "\"" + e.name().toLowerCase() + "\"")
35+
.collect(Collectors.joining(", ", "[", "]"));
36+
}
37+
}

core/src/test/java/org/neo4j/importer/v1/ImportSpecificationDeserializerNodeTargetTest.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,18 @@
2222

2323
import java.io.StringReader;
2424
import org.junit.Test;
25+
import org.neo4j.importer.v1.targets.PropertyType;
26+
import org.neo4j.importer.v1.targets.WriteMode;
2527
import org.neo4j.importer.v1.validation.InvalidSpecificationException;
2628

2729
public class ImportSpecificationDeserializerNodeTargetTest {
2830

31+
private static final String ENUM_ARRAY_PROPERTY_TYPE =
32+
ImportSpecificationDeserializerEnumUtil.enumToJsonString(PropertyType.class);
33+
34+
private static final String ENUM_ARRAY_WRITE_MODE =
35+
ImportSpecificationDeserializerEnumUtil.enumToJsonString(WriteMode.class);
36+
2937
@Test
3038
public void fails_if_node_target_active_attribute_has_wrong_type() {
3139
assertThatThrownBy(() -> deserialize(new StringReader(
@@ -242,7 +250,8 @@ public void fails_if_node_target_write_mode_has_wrong_value() {
242250
.hasMessageContainingAll(
243251
"1 error(s)",
244252
"0 warning(s)",
245-
"$.targets.nodes[0].write_mode: does not have a value in the enumeration [create, merge]");
253+
"$.targets.nodes[0].write_mode: does not have a value in the enumeration",
254+
ENUM_ARRAY_WRITE_MODE);
246255
}
247256

248257
@Test
@@ -846,7 +855,8 @@ public void fails_if_node_target_property_mappings_target_property_type_is_unsup
846855
.hasMessageContainingAll(
847856
"1 error(s)",
848857
"0 warning(s)",
849-
"$.targets.nodes[0].properties[0].target_property_type: does not have a value in the enumeration [boolean, boolean_array, byte_array, date, date_array, duration, duration_array, float, float_array, integer, integer_array, local_datetime, local_datetime_array, local_time, local_time_array, point, point_array, string, string_array, zoned_datetime, zoned_datetime_array, zoned_time, zoned_time_array]");
858+
"$.targets.nodes[0].properties[0].target_property_type: does not have a value in the enumeration",
859+
ENUM_ARRAY_PROPERTY_TYPE);
850860
}
851861

852862
@Test

core/src/test/java/org/neo4j/importer/v1/ImportSpecificationDeserializerRelationshipTargetTest.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,23 @@
2323

2424
import java.io.StringReader;
2525
import org.junit.Test;
26+
import org.neo4j.importer.v1.targets.NodeMatchMode;
27+
import org.neo4j.importer.v1.targets.PropertyType;
28+
import org.neo4j.importer.v1.targets.WriteMode;
2629
import org.neo4j.importer.v1.validation.InvalidSpecificationException;
2730
import org.neo4j.importer.v1.validation.SpecificationException;
2831

2932
public class ImportSpecificationDeserializerRelationshipTargetTest {
3033

34+
private static final String ENUM_ARRAY_NODE_MATCH_MODE =
35+
ImportSpecificationDeserializerEnumUtil.enumToJsonString(NodeMatchMode.class);
36+
37+
private static final String ENUM_ARRAY_PROPERTY_TYPE =
38+
ImportSpecificationDeserializerEnumUtil.enumToJsonString(PropertyType.class);
39+
40+
private static final String ENUM_ARRAY_WRITE_MODE =
41+
ImportSpecificationDeserializerEnumUtil.enumToJsonString(WriteMode.class);
42+
3143
@Test
3244
public void deserializes_full_start_and_end_node_references() throws SpecificationException {
3345
var specification = deserialize(
@@ -422,7 +434,8 @@ public void fails_if_relationship_target_write_mode_has_wrong_value() {
422434
.hasMessageContainingAll(
423435
"1 error(s)",
424436
"0 warning(s)",
425-
"$.targets.relationships[0].write_mode: does not have a value in the enumeration [create, merge]");
437+
"$.targets.relationships[0].write_mode: does not have a value in the enumeration",
438+
ENUM_ARRAY_WRITE_MODE);
426439
}
427440

428441
@Test
@@ -508,7 +521,8 @@ public void fails_if_relationship_target_node_match_mode_has_wrong_value() {
508521
.hasMessageContainingAll(
509522
"1 error(s)",
510523
"0 warning(s)",
511-
"$.targets.relationships[0].node_match_mode: does not have a value in the enumeration [match, merge]");
524+
"$.targets.relationships[0].node_match_mode: does not have a value in the enumeration",
525+
ENUM_ARRAY_NODE_MATCH_MODE);
512526
}
513527

514528
@Test
@@ -2731,7 +2745,8 @@ public void fails_if_relationship_target_property_mappings_target_property_type_
27312745
.hasMessageContainingAll(
27322746
"1 error(s)",
27332747
"0 warning(s)",
2734-
"$.targets.relationships[0].properties[0].target_property_type: does not have a value in the enumeration [boolean, boolean_array, byte_array, date, date_array, duration, duration_array, float, float_array, integer, integer_array, local_datetime, local_datetime_array, local_time, local_time_array, point, point_array, string, string_array, zoned_datetime, zoned_datetime_array, zoned_time, zoned_time_array]");
2748+
"$.targets.relationships[0].properties[0].target_property_type: does not have a value in the enumeration",
2749+
ENUM_ARRAY_PROPERTY_TYPE);
27352750
}
27362751

27372752
@Test

0 commit comments

Comments
 (0)