|
19 | 19 |
|
20 | 20 | import com.fasterxml.jackson.databind.JsonNode;
|
21 | 21 | import com.fasterxml.jackson.databind.ObjectMapper;
|
| 22 | +import com.fasterxml.jackson.databind.exc.MismatchedInputException; |
22 | 23 | import com.fasterxml.jackson.databind.node.JsonNodeFactory;
|
23 | 24 | import io.cloudevents.CloudEvent;
|
24 | 25 | import io.cloudevents.SpecVersion;
|
25 | 26 | import io.cloudevents.core.builder.CloudEventBuilder;
|
26 | 27 | import io.cloudevents.core.provider.EventFormatProvider;
|
| 28 | +import io.cloudevents.rw.CloudEventRWException; |
| 29 | +import org.junit.jupiter.api.Test; |
27 | 30 | import org.junit.jupiter.params.ParameterizedTest;
|
28 | 31 | import org.junit.jupiter.params.provider.Arguments;
|
29 | 32 | import org.junit.jupiter.params.provider.MethodSource;
|
|
38 | 41 |
|
39 | 42 | import static io.cloudevents.core.test.Data.*;
|
40 | 43 | import static org.assertj.core.api.Assertions.assertThat;
|
| 44 | +import static org.assertj.core.api.Assertions.assertThatCode; |
41 | 45 |
|
42 | 46 | class JsonFormatTest {
|
43 | 47 |
|
@@ -109,6 +113,13 @@ void eventRoundTrip(CloudEvent input) {
|
109 | 113 | assertThat(output).isEqualTo(normalizeToJsonValueIfNeeded(input));
|
110 | 114 | }
|
111 | 115 |
|
| 116 | + @Test |
| 117 | + void throwExpectedOnInvalidSpecversion() { |
| 118 | + assertThatCode(() -> getFormat().deserialize(("{\"specversion\":\"9000.1\"}").getBytes(StandardCharsets.UTF_8))) |
| 119 | + .hasCauseInstanceOf(MismatchedInputException.class) |
| 120 | + .hasMessageContaining(CloudEventRWException.newInvalidSpecVersion("9000.1").getMessage()); |
| 121 | + } |
| 122 | + |
112 | 123 | public static Stream<Arguments> serializeTestArgumentsDefault() {
|
113 | 124 | return Stream.of(
|
114 | 125 | Arguments.of(V03_MIN, "v03/min.json"),
|
|
0 commit comments