|
12 | 12 | import com.fasterxml.jackson.databind.ObjectMapper; |
13 | 13 | import com.google.common.collect.ImmutableMap; |
14 | 14 | import feign.httpclient.ApacheHttpClient; |
| 15 | +import io.ipdata.client.error.IpdataException; |
15 | 16 | import io.ipdata.client.error.RateLimitException; |
16 | 17 | import io.ipdata.client.model.AsnModel; |
17 | 18 | import io.ipdata.client.model.Currency; |
@@ -143,17 +144,70 @@ public void testBulkResponse() { |
143 | 144 | } |
144 | 145 |
|
145 | 146 | @SneakyThrows |
146 | | - @Test(expected = RateLimitException.class) |
| 147 | + @Test(expected = IpdataException.class) |
147 | 148 | public void testError() { |
148 | 149 | URL url = new URL("https://api.ipdata.co"); |
149 | 150 | IpdataService serviceWithInvalidKey = Ipdata.builder().url(url) |
150 | 151 | .key("THIS_IS_AN_INVALID_KEY") |
| 152 | + .withDefaultCache() |
151 | 153 | .feignClient(new ApacheHttpClient(HttpClientBuilder.create() |
152 | 154 | .setSSLHostnameVerifier(new NoopHostnameVerifier()).setConnectionTimeToLive(10, TimeUnit.SECONDS) |
153 | 155 | .build())).get(); |
154 | 156 | serviceWithInvalidKey.ipdata("8.8.8.8"); |
155 | 157 | } |
156 | 158 |
|
| 159 | + @SneakyThrows |
| 160 | + @Test(expected = IpdataException.class) |
| 161 | + public void testAsnError() { |
| 162 | + URL url = new URL("https://api.ipdata.co"); |
| 163 | + IpdataService serviceWithInvalidKey = Ipdata.builder().url(url) |
| 164 | + .key("THIS_IS_AN_INVALID_KEY") |
| 165 | + .withDefaultCache() |
| 166 | + .feignClient(new ApacheHttpClient(HttpClientBuilder.create() |
| 167 | + .setSSLHostnameVerifier(new NoopHostnameVerifier()).setConnectionTimeToLive(10, TimeUnit.SECONDS) |
| 168 | + .build())).get(); |
| 169 | + serviceWithInvalidKey.asn("8.8.8.8"); |
| 170 | + } |
| 171 | + |
| 172 | + @SneakyThrows |
| 173 | + @Test(expected = IpdataException.class) |
| 174 | + public void testThreatError() { |
| 175 | + URL url = new URL("https://api.ipdata.co"); |
| 176 | + IpdataService serviceWithInvalidKey = Ipdata.builder().url(url) |
| 177 | + .key("THIS_IS_AN_INVALID_KEY") |
| 178 | + .withDefaultCache() |
| 179 | + .feignClient(new ApacheHttpClient(HttpClientBuilder.create() |
| 180 | + .setSSLHostnameVerifier(new NoopHostnameVerifier()).setConnectionTimeToLive(10, TimeUnit.SECONDS) |
| 181 | + .build())).get(); |
| 182 | + serviceWithInvalidKey.threat("8.8.8.8"); |
| 183 | + } |
| 184 | + |
| 185 | + @SneakyThrows |
| 186 | + @Test(expected = IpdataException.class) |
| 187 | + public void testTimeZoneError() { |
| 188 | + URL url = new URL("https://api.ipdata.co"); |
| 189 | + IpdataService serviceWithInvalidKey = Ipdata.builder().url(url) |
| 190 | + .key("THIS_IS_AN_INVALID_KEY") |
| 191 | + .withDefaultCache() |
| 192 | + .feignClient(new ApacheHttpClient(HttpClientBuilder.create() |
| 193 | + .setSSLHostnameVerifier(new NoopHostnameVerifier()).setConnectionTimeToLive(10, TimeUnit.SECONDS) |
| 194 | + .build())).get(); |
| 195 | + serviceWithInvalidKey.timeZone("8.8.8.8"); |
| 196 | + } |
| 197 | + |
| 198 | + @SneakyThrows |
| 199 | + @Test(expected = IpdataException.class) |
| 200 | + public void testCurrencyError() { |
| 201 | + URL url = new URL("https://api.ipdata.co"); |
| 202 | + IpdataService serviceWithInvalidKey = Ipdata.builder().url(url) |
| 203 | + .key("THIS_IS_AN_INVALID_KEY") |
| 204 | + .withDefaultCache() |
| 205 | + .feignClient(new ApacheHttpClient(HttpClientBuilder.create() |
| 206 | + .setSSLHostnameVerifier(new NoopHostnameVerifier()).setConnectionTimeToLive(10, TimeUnit.SECONDS) |
| 207 | + .build())).get(); |
| 208 | + serviceWithInvalidKey.currency("8.8.8.8"); |
| 209 | + } |
| 210 | + |
157 | 211 | @Parameters |
158 | 212 | public static Iterable<IpdataService> data() { |
159 | 213 | init(); |
|
0 commit comments