16
16
17
17
package org .springframework .restdocs .payload ;
18
18
19
- import java .io .IOException ;
20
19
import java .util .Arrays ;
21
20
import java .util .List ;
22
21
@@ -39,64 +38,62 @@ public class JsonContentHandlerTests {
39
38
public ExpectedException thrown = ExpectedException .none ();
40
39
41
40
@ Test
42
- public void typeForFieldWithNullValueMustMatch () throws IOException {
41
+ public void typeForFieldWithNullValueMustMatch () {
43
42
this .thrown .expect (FieldTypesDoNotMatchException .class );
44
43
new JsonContentHandler ("{\" a\" : null}" .getBytes ())
45
44
.determineFieldType (new FieldDescriptor ("a" ).type (JsonFieldType .STRING ));
46
45
}
47
46
48
47
@ Test
49
- public void typeForFieldWithNotNullAndThenNullValueMustMatch () throws IOException {
48
+ public void typeForFieldWithNotNullAndThenNullValueMustMatch () {
50
49
this .thrown .expect (FieldTypesDoNotMatchException .class );
51
50
new JsonContentHandler ("{\" a\" :[{\" id\" :1},{\" id\" :null}]}" .getBytes ())
52
51
.determineFieldType (
53
52
new FieldDescriptor ("a[].id" ).type (JsonFieldType .STRING ));
54
53
}
55
54
56
55
@ Test
57
- public void typeForFieldWithNullAndThenNotNullValueMustMatch () throws IOException {
56
+ public void typeForFieldWithNullAndThenNotNullValueMustMatch () {
58
57
this .thrown .expect (FieldTypesDoNotMatchException .class );
59
58
new JsonContentHandler ("{\" a\" :[{\" id\" :null},{\" id\" :1}]}" .getBytes ())
60
59
.determineFieldType (
61
60
new FieldDescriptor ("a.[].id" ).type (JsonFieldType .STRING ));
62
61
}
63
62
64
63
@ Test
65
- public void typeForOptionalFieldWithNumberAndThenNullValueIsNumber ()
66
- throws IOException {
64
+ public void typeForOptionalFieldWithNumberAndThenNullValueIsNumber () {
67
65
Object fieldType = new JsonContentHandler (
68
66
"{\" a\" :[{\" id\" :1},{\" id\" :null}]}\" " .getBytes ())
69
67
.determineFieldType (new FieldDescriptor ("a[].id" ).optional ());
70
68
assertThat ((JsonFieldType ) fieldType , is (equalTo (JsonFieldType .NUMBER )));
71
69
}
72
70
73
71
@ Test
74
- public void typeForOptionalFieldWithNullAndThenNumberIsNumber () throws IOException {
72
+ public void typeForOptionalFieldWithNullAndThenNumberIsNumber () {
75
73
Object fieldType = new JsonContentHandler (
76
74
"{\" a\" :[{\" id\" :null},{\" id\" :1}]}" .getBytes ())
77
75
.determineFieldType (new FieldDescriptor ("a[].id" ).optional ());
78
76
assertThat ((JsonFieldType ) fieldType , is (equalTo (JsonFieldType .NUMBER )));
79
77
}
80
78
81
79
@ Test
82
- public void typeForFieldWithNumberAndThenNullValueIsVaries () throws IOException {
80
+ public void typeForFieldWithNumberAndThenNullValueIsVaries () {
83
81
Object fieldType = new JsonContentHandler (
84
82
"{\" a\" :[{\" id\" :1},{\" id\" :null}]}\" " .getBytes ())
85
83
.determineFieldType (new FieldDescriptor ("a[].id" ));
86
84
assertThat ((JsonFieldType ) fieldType , is (equalTo (JsonFieldType .VARIES )));
87
85
}
88
86
89
87
@ Test
90
- public void typeForFieldWithNullAndThenNumberIsVaries () throws IOException {
88
+ public void typeForFieldWithNullAndThenNumberIsVaries () {
91
89
Object fieldType = new JsonContentHandler (
92
90
"{\" a\" :[{\" id\" :null},{\" id\" :1}]}" .getBytes ())
93
91
.determineFieldType (new FieldDescriptor ("a[].id" ));
94
92
assertThat ((JsonFieldType ) fieldType , is (equalTo (JsonFieldType .VARIES )));
95
93
}
96
94
97
95
@ Test
98
- public void typeForOptionalFieldWithNullValueCanBeProvidedExplicitly ()
99
- throws IOException {
96
+ public void typeForOptionalFieldWithNullValueCanBeProvidedExplicitly () {
100
97
Object fieldType = new JsonContentHandler ("{\" a\" : null}" .getBytes ())
101
98
.determineFieldType (
102
99
new FieldDescriptor ("a" ).type (JsonFieldType .STRING ).optional ());
0 commit comments