77import java .io .IOException ;
88import java .io .InputStream ;
99import java .util .ArrayList ;
10+ import java .util .Collection ;
1011import java .util .List ;
1112import java .util .Map ;
12- import java .util .Set ;
1313import java .util .stream .Collectors ;
1414import java .util .stream .Stream ;
1515import javax .annotation .Nonnull ;
1919import com .fasterxml .jackson .databind .ObjectMapper ;
2020import com .fasterxml .jackson .dataformat .yaml .YAMLFactory ;
2121import com .meterware .simplestub .Memento ;
22- import com .networknt .schema .JsonSchema ;
23- import com .networknt .schema .JsonSchemaFactory ;
24- import com .networknt .schema .SpecVersion ;
25- import com .networknt .schema .ValidationMessage ;
22+ import com .networknt .schema .Error ;
23+ import com .networknt .schema .Schema ;
24+ import com .networknt .schema .SchemaRegistry ;
25+ import com .networknt .schema .dialect . Dialects ;
2626import oracle .kubernetes .json .Feature ;
2727import oracle .kubernetes .operator .tuning .TuningParameters ;
2828import oracle .kubernetes .operator .tuning .TuningParametersStub ;
@@ -62,9 +62,9 @@ void tearDown() {
6262 DOMAIN_V2_SAMPLE_YAML_4 , DOMAIN_V2_SAMPLE_YAML_5 })
6363 void validateSchemaAgainstSamples (String fileName ) throws IOException {
6464 final JsonNode jsonToValidate = convertToJson (fileName );
65- final JsonSchema schema = createJsonSchema (DomainResource .class );
65+ final Schema schema = createJsonSchema (DomainResource .class );
6666
67- Set < ValidationMessage > validationResult = schema .validate (jsonToValidate );
67+ Collection < Error > validationResult = schema .validate (jsonToValidate );
6868 if (!validationResult .isEmpty ()) {
6969 throw new RuntimeException (toExceptionMessage (fileName , validationResult ));
7070 }
@@ -101,7 +101,7 @@ private static class ClassForDisabledFeature {
101101 }
102102
103103 @ Nonnull
104- private String toExceptionMessage (String fileName , Set < ValidationMessage > validationResult ) {
104+ private String toExceptionMessage (String fileName , Collection < Error > validationResult ) {
105105 return Stream .concat (toPrefixStream (fileName ), toFailureStream (validationResult ))
106106 .collect (Collectors .joining (System .lineSeparator ()));
107107 }
@@ -112,12 +112,12 @@ private Stream<String> toPrefixStream(String fileName) {
112112 }
113113
114114 @ Nonnull
115- private Stream <String > toFailureStream (Set < ValidationMessage > validationResult ) {
115+ private Stream <String > toFailureStream (Collection < Error > validationResult ) {
116116 return validationResult .stream ().map (this ::toIndentedString );
117117 }
118118
119119 @ Nonnull
120- private String toIndentedString (ValidationMessage message ) {
120+ private String toIndentedString (Error message ) {
121121 return " " + message ;
122122 }
123123
@@ -126,8 +126,8 @@ private static Map<String, Object> createSchema(Class<?> someClass) {
126126 }
127127
128128 @ SuppressWarnings ("SameParameterValue" )
129- private static JsonSchema createJsonSchema (Class <?> someClass ) throws JsonProcessingException {
130- final JsonSchemaFactory schemaFactory = JsonSchemaFactory . getInstance ( SpecVersion . VersionFlag . V201909 );
129+ private static Schema createJsonSchema (Class <?> someClass ) throws JsonProcessingException {
130+ final SchemaRegistry schemaFactory = SchemaRegistry . withDialect ( Dialects . getDraft201909 () );
131131 final Map <String , Object > schema = createSchema (someClass );
132132 return schemaFactory .getSchema (toJsonInputStream (schema ));
133133 }
0 commit comments