|
17 | 17 | import io.vertx.openapi.contract.MediaType; |
18 | 18 | import io.vertx.openapi.contract.OpenAPIContractException; |
19 | 19 | import io.vertx.openapi.contract.impl.MediaTypeImpl; |
| 20 | +import java.util.Map; |
20 | 21 | import org.junit.jupiter.api.Test; |
21 | 22 | import org.junit.jupiter.params.ParameterizedTest; |
22 | 23 | import org.junit.jupiter.params.provider.Arguments; |
|
33 | 34 |
|
34 | 35 | class MediaTypeImplTest { |
35 | 36 | private static final String DUMMY_IDENTIFIER = APPLICATION_JSON.toString(); |
| 37 | + private static final String DUMMY_REF = "__dummy_unknown_ref__"; |
| 38 | + private static final String ABS_URI = "__absolute_uri__"; |
| 39 | + private static final String ABS_RECURSIVE_REF = "__absolute_recursive_ref__"; |
| 40 | + private static final String ABS_REF = "__absolute_ref__"; |
| 41 | + private static final String DUMMY_REF_VALUE = "dummy-ref-value"; |
36 | 42 |
|
37 | 43 | private static Stream<Arguments> testGetters() { |
| 44 | + var partialSchemaJson = JsonObject.of("schema", stringSchema().toJson()); |
| 45 | + |
| 46 | + var partialUnknownAnnotation = JsonObject.of(DUMMY_REF, DUMMY_REF_VALUE); |
| 47 | + var partialAbsoluteUri = JsonObject.of(ABS_URI, DUMMY_REF_VALUE); |
| 48 | + var partialAbsoluteRecursiveRef = JsonObject.of(ABS_RECURSIVE_REF, DUMMY_REF_VALUE); |
| 49 | + var partialAbsoluteRef = JsonObject.of(ABS_REF, DUMMY_REF_VALUE); |
| 50 | + var partialMultipleAnnotations = partialAbsoluteUri.copy().mergeIn(partialUnknownAnnotation); |
| 51 | + |
38 | 52 | return Stream.of( |
39 | | - Arguments.of("MediaType model defined", new JsonObject().put("schema", stringSchema().toJson()), List.of("type" |
40 | | - , "$id")), |
41 | | - Arguments.of("No MediaType model defined", EMPTY_JSON_OBJECT, List.of()) |
| 53 | + Arguments.of("MediaType model defined, with no internal annotations", partialSchemaJson, |
| 54 | + List.of("type", "$id")), |
| 55 | + Arguments.of("MediaType model defined, with an unknown internal annotation", partialSchemaJson |
| 56 | + .copy().mergeIn(partialUnknownAnnotation), List.of("type", "$id")), |
| 57 | + Arguments.of("MediaType model defined, with multiple internal annotations", partialSchemaJson |
| 58 | + .copy().mergeIn(partialMultipleAnnotations), List.of("type", "$id")), |
| 59 | + Arguments.of("No MediaType model defined, with an unknown internal annotation", |
| 60 | + partialUnknownAnnotation, List.of()), |
| 61 | + Arguments.of("No MediaType model defined, with absolute_uri internal annotation", |
| 62 | + partialAbsoluteUri, List.of()), |
| 63 | + Arguments.of("No MediaType model defined, with absolute_recursive_ref internal annotation", |
| 64 | + partialAbsoluteRecursiveRef, List.of()), |
| 65 | + Arguments.of("No MediaType model defined, with absolute_ref internal annotation", |
| 66 | + partialAbsoluteRef, List.of()), |
| 67 | + Arguments.of("No MediaType model defined, with multiple internal annotations", |
| 68 | + partialMultipleAnnotations, List.of()), |
| 69 | + Arguments.of("No MediaType model defined, with no internal annotations", |
| 70 | + EMPTY_JSON_OBJECT, List.of()) |
42 | 71 | ); |
43 | 72 | } |
44 | 73 |
|
|
0 commit comments