@@ -51,7 +51,7 @@ public String formatName() {
51
51
@ Test
52
52
public void test () {
53
53
SchemaLoader schemaLoader = SchemaLoader .builder ()
54
- .schemaJson (loader . readObj ( "customformat-schema.json" ))
54
+ .schemaJson (baseSchemaJson ( ))
55
55
.addFormatValidator ("evenlength" , new EvenCharNumValidator ())
56
56
.build ();
57
57
try {
@@ -63,26 +63,33 @@ public void test() {
63
63
64
64
@ Test
65
65
public void nameOverride () {
66
- JSONObject rawSchemaJson = loader . readObj ( "customformat-schema.json" );
66
+ JSONObject rawSchemaJson = baseSchemaJson ( );
67
67
JSONObject idPropSchema = (JSONObject ) rawSchemaJson .query ("/properties/id" );
68
68
idPropSchema .put ("format" , "somethingelse" );
69
69
SchemaLoader schemaLoader = SchemaLoader .builder ()
70
70
.schemaJson (rawSchemaJson )
71
71
.addFormatValidator ("somethingelse" , new EvenCharNumValidator ())
72
72
.build ();
73
- Object actual = new JSONObject (schemaLoader .load ().build ().toString ())
74
- .query ("/properties/id/format" );
73
+ Object actual = fetchFormatValueFromOutputJson (schemaLoader );
75
74
assertEquals ("somethingelse" , actual );
76
75
}
77
76
77
+ private Object fetchFormatValueFromOutputJson (SchemaLoader schemaLoader ) {
78
+ return new JSONObject (schemaLoader .load ().build ().toString ())
79
+ .query ("/properties/id/format" );
80
+ }
81
+
82
+ private JSONObject baseSchemaJson () {
83
+ return loader .readObj ("customformat-schema.json" );
84
+ }
85
+
78
86
@ Test
79
87
public void formatValidatorWithoutExplicitName () {
80
88
SchemaLoader schemaLoader = SchemaLoader .builder ()
81
- .schemaJson (loader . readObj ( "customformat-schema.json" ))
89
+ .schemaJson (baseSchemaJson ( ))
82
90
.addFormatValidator (new EvenCharNumValidator ())
83
91
.build ();
84
- Object actual = new JSONObject (schemaLoader .load ().build ().toString ())
85
- .query ("/properties/id/format" );
92
+ Object actual = fetchFormatValueFromOutputJson (schemaLoader );
86
93
assertEquals ("evenlength" , actual );
87
94
}
88
95
0 commit comments