|
2 | 2 |
|
3 | 3 | import static org.junit.Assert.assertFalse; |
4 | 4 | import static org.junit.Assert.assertNotNull; |
| 5 | +import static org.junit.Assert.assertThrows; |
5 | 6 | import static org.junit.Assert.assertTrue; |
6 | | -import static org.junit.Assert.fail; |
7 | 7 | import static org.mockito.ArgumentMatchers.any; |
8 | 8 | import static org.mockito.Mockito.mock; |
9 | 9 | import static org.mockito.Mockito.when; |
10 | 10 |
|
11 | | -import java.io.IOException; |
12 | | -import java.util.ArrayList; |
13 | | -import java.util.Arrays; |
14 | 11 | import java.util.HashSet; |
15 | | -import java.util.List; |
16 | 12 | import java.util.concurrent.ThreadLocalRandom; |
17 | 13 |
|
18 | 14 | import com.google.gson.JsonParser; |
|
28 | 24 | import org.mockito.stubbing.Answer; |
29 | 25 |
|
30 | 26 | import okhttp3.Call; |
31 | | -import okhttp3.Callback; |
32 | 27 | import okhttp3.MediaType; |
33 | 28 | import okhttp3.OkHttpClient; |
34 | 29 | import okhttp3.Protocol; |
@@ -115,34 +110,26 @@ public String answer(InvocationOnMock invocation) throws Throwable { |
115 | 110 | } |
116 | 111 | }); |
117 | 112 |
|
118 | | - try { |
| 113 | + assertThrows("the number of steps cannot exceed 20", IllegalArgumentException.class, () -> { |
119 | 114 | new MSBatchRequestContent(null, null, null, null, null, null, null, null, null, null, null, null, null, |
120 | 115 | null, null, null, null, null, null, null, null, null); |
121 | | - fail("the number of steps cannot exceed 20"); |
122 | | - } catch (IllegalArgumentException ex) { |
123 | | - } |
| 116 | + }); |
124 | 117 |
|
125 | 118 | new MSBatchRequestContent(mockStep, null); // addind a null step doesn't throw |
126 | | - try { |
| 119 | + assertThrows("should throw argument exception", IllegalArgumentException.class, () -> { |
127 | 120 | new MSBatchRequestContent().addBatchRequestStep(null); |
128 | | - fail("should throw argument exception"); |
129 | | - } catch (IllegalArgumentException ex) { |
130 | | - } |
131 | | - try { |
| 121 | + }); |
| 122 | + assertThrows("should throw argument exception", IllegalArgumentException.class, () -> { |
132 | 123 | new MSBatchRequestContent().addBatchRequestStep((Request) null); |
133 | | - fail("should throw argument exception"); |
134 | | - } catch (IllegalArgumentException ex) { |
135 | | - } |
| 124 | + }); |
136 | 125 |
|
137 | | - try { |
| 126 | + assertThrows("the number of steps cannot exceed 20", IllegalArgumentException.class, () -> { |
138 | 127 | final MSBatchRequestContent batchContent = new MSBatchRequestContent(); |
139 | 128 | for (int i = 0; i < MSBatchRequestContent.MAX_NUMBER_OF_REQUESTS; i++) { |
140 | 129 | assertNotNull(batchContent.addBatchRequestStep(mock(Request.class))); |
141 | 130 | } |
142 | 131 | batchContent.addBatchRequestStep(mock(Request.class)); |
143 | | - fail("the number of steps cannot exceed 20"); |
144 | | - } catch (IllegalArgumentException ex) { |
145 | | - } |
| 132 | + }); |
146 | 133 | { |
147 | 134 | final MSBatchRequestContent batchContent = new MSBatchRequestContent(); |
148 | 135 | reservedIds.clear(); |
|
0 commit comments