2
2
3
3
import static org .junit .jupiter .api .Assertions .assertEquals ;
4
4
import static org .junit .jupiter .api .Assertions .assertThrows ;
5
- import static org .junit .jupiter .api .Assertions .assertTrue ;
6
5
7
6
import com .stripe .BaseStripeTest ;
8
7
import java .io .ByteArrayInputStream ;
14
13
15
14
public class HttpContentTest extends BaseStripeTest {
16
15
@ Test
17
- public void TestBuildFormURLEncodedContentNull () throws IOException {
18
- Throwable exception =
19
- assertThrows (
20
- IllegalArgumentException .class ,
21
- () -> {
22
- HttpContent .buildFormURLEncodedContent (null );
23
- });
24
- assertTrue (exception .getMessage ().contains ("nameValueCollection may not be null" ));
16
+ public void testBuildFormURLEncodedContentNull () throws IOException {
17
+ assertThrows (
18
+ NullPointerException .class ,
19
+ () -> {
20
+ HttpContent .buildFormURLEncodedContent (null );
21
+ });
25
22
}
26
23
27
24
@ Test
28
- public void TestBuildFormURLEncodedContentEmptySourceSuccess () throws IOException {
25
+ public void testBuildFormURLEncodedContentEmptySourceSuccess () throws IOException {
29
26
HttpContent content =
30
27
HttpContent .buildFormURLEncodedContent (new ArrayList <KeyValuePair <String , String >>());
31
28
assertEquals (0 , content .byteArrayContent ().length );
32
29
}
33
30
34
31
@ Test
35
- public void TestBuildFormURLEncodedContentEmptySourceCorrectContentType () throws IOException {
32
+ public void testBuildFormURLEncodedContentEmptySourceCorrectContentType () throws IOException {
36
33
HttpContent content =
37
34
HttpContent .buildFormURLEncodedContent (new ArrayList <KeyValuePair <String , String >>());
38
35
assertEquals ("application/x-www-form-urlencoded;charset=UTF-8" , content .contentType ());
39
36
}
40
37
41
38
@ Test
42
- public void TestBuildFormURLEncodedContentOneEntrySeparatedByEquals () throws IOException {
39
+ public void testBuildFormURLEncodedContentOneEntrySeparatedByEquals () throws IOException {
43
40
List <KeyValuePair <String , String >> data = new ArrayList <KeyValuePair <String , String >>();
44
41
data .add (new KeyValuePair <String , String >("key" , "value" ));
45
42
@@ -49,7 +46,7 @@ public void TestBuildFormURLEncodedContentOneEntrySeparatedByEquals() throws IOE
49
46
}
50
47
51
48
@ Test
52
- public void TestBuildFormURLEncodedContentOneUnicodeEntryEncoded () throws IOException {
49
+ public void testBuildFormURLEncodedContentOneUnicodeEntryEncoded () throws IOException {
53
50
List <KeyValuePair <String , String >> data = new ArrayList <KeyValuePair <String , String >>();
54
51
data .add (new KeyValuePair <String , String >("key" , "valueク" ));
55
52
@@ -60,7 +57,7 @@ public void TestBuildFormURLEncodedContentOneUnicodeEntryEncoded() throws IOExce
60
57
}
61
58
62
59
@ Test
63
- public void TestBuildFormURLEncodedContentTwoEntriesSeparatedByAnd () throws IOException {
60
+ public void testBuildFormURLEncodedContentTwoEntriesSeparatedByAnd () throws IOException {
64
61
List <KeyValuePair <String , String >> data = new ArrayList <KeyValuePair <String , String >>();
65
62
data .add (new KeyValuePair <String , String >("key1" , "value1" ));
66
63
data .add (new KeyValuePair <String , String >("key2" , "value2" ));
@@ -72,7 +69,7 @@ public void TestBuildFormURLEncodedContentTwoEntriesSeparatedByAnd() throws IOEx
72
69
}
73
70
74
71
@ Test
75
- public void TestBuildFormURLEncodedContentWithSpacesEncodedAsPlus () throws IOException {
72
+ public void testBuildFormURLEncodedContentWithSpacesEncodedAsPlus () throws IOException {
76
73
List <KeyValuePair <String , String >> data = new ArrayList <KeyValuePair <String , String >>();
77
74
data .add (new KeyValuePair <String , String >("key 1" , "val%20ue 1" ));
78
75
data .add (new KeyValuePair <String , String >("key 2" , "val%ue 2" ));
@@ -85,7 +82,7 @@ public void TestBuildFormURLEncodedContentWithSpacesEncodedAsPlus() throws IOExc
85
82
}
86
83
87
84
@ Test
88
- public void TestBuildFormURLEncodedContentWithSquareBracketsUnencoded () throws IOException {
85
+ public void testBuildFormURLEncodedContentWithSquareBracketsUnencoded () throws IOException {
89
86
List <KeyValuePair <String , String >> data = new ArrayList <KeyValuePair <String , String >>();
90
87
data .add (new KeyValuePair <String , String >("key[subkey]" , "[#value]" ));
91
88
@@ -96,18 +93,16 @@ public void TestBuildFormURLEncodedContentWithSquareBracketsUnencoded() throws I
96
93
}
97
94
98
95
@ Test
99
- public void TestBuildMultipartFormDataContentNull () throws IOException {
100
- Throwable exception =
101
- assertThrows (
102
- IllegalArgumentException .class ,
103
- () -> {
104
- HttpContent .buildMultipartFormDataContent (null );
105
- });
106
- assertTrue (exception .getMessage ().contains ("nameValueCollection may not be null" ));
96
+ public void testBuildMultipartFormDataContentNull () throws IOException {
97
+ assertThrows (
98
+ NullPointerException .class ,
99
+ () -> {
100
+ HttpContent .buildMultipartFormDataContent (null );
101
+ });
107
102
}
108
103
109
104
@ Test
110
- public void TestBuildMultipartFormDataContentNullEmptySourceCorrectContentType ()
105
+ public void testBuildMultipartFormDataContentNullEmptySourceCorrectContentType ()
111
106
throws IOException {
112
107
HttpContent content =
113
108
HttpContent .buildMultipartFormDataContent (
@@ -116,7 +111,7 @@ public void TestBuildMultipartFormDataContentNullEmptySourceCorrectContentType()
116
111
}
117
112
118
113
@ Test
119
- public void TestBuildMultipartFormDataContentNullEmptySourceSuccess () throws IOException {
114
+ public void testBuildMultipartFormDataContentNullEmptySourceSuccess () throws IOException {
120
115
List <KeyValuePair <String , Object >> data = new ArrayList <KeyValuePair <String , Object >>();
121
116
122
117
HttpContent content = HttpContent .buildMultipartFormDataContent (data , "test-boundary" );
@@ -126,7 +121,7 @@ public void TestBuildMultipartFormDataContentNullEmptySourceSuccess() throws IOE
126
121
}
127
122
128
123
@ Test
129
- public void TestBuildMultipartFormDataContentNullOneStringEntrySuccess () throws IOException {
124
+ public void testBuildMultipartFormDataContentNullOneStringEntrySuccess () throws IOException {
130
125
List <KeyValuePair <String , Object >> data = new ArrayList <KeyValuePair <String , Object >>();
131
126
data .add (new KeyValuePair <String , Object >("key" , "valueク" ));
132
127
@@ -139,7 +134,7 @@ public void TestBuildMultipartFormDataContentNullOneStringEntrySuccess() throws
139
134
}
140
135
141
136
@ Test
142
- public void TestBuildMultipartFormDataContentNullOneStreamEntrySuccess () throws IOException {
137
+ public void testBuildMultipartFormDataContentNullOneStreamEntrySuccess () throws IOException {
143
138
List <KeyValuePair <String , Object >> data = new ArrayList <KeyValuePair <String , Object >>();
144
139
data .add (
145
140
new KeyValuePair <String , Object >(
@@ -155,7 +150,7 @@ public void TestBuildMultipartFormDataContentNullOneStreamEntrySuccess() throws
155
150
}
156
151
157
152
@ Test
158
- public void TestBuildMultipartFormDataContentNullTwoEntriesSuccess () throws IOException {
153
+ public void testBuildMultipartFormDataContentNullTwoEntriesSuccess () throws IOException {
159
154
List <KeyValuePair <String , Object >> data = new ArrayList <KeyValuePair <String , Object >>();
160
155
data .add (
161
156
new KeyValuePair <String , Object >(
0 commit comments