|
16 | 16 | import static com.github.tomakehurst.wiremock.client.WireMock.delete;
|
17 | 17 | import static com.github.tomakehurst.wiremock.client.WireMock.get;
|
18 | 18 | import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
|
19 |
| -import static org.junit.Assert.assertNull; |
20 |
| -import static org.junit.Assert.assertTrue; |
21 |
| -import static org.junit.Assert.fail; |
| 19 | +import static org.junit.Assert.*; |
22 | 20 |
|
23 | 21 | import com.github.tomakehurst.wiremock.junit.WireMockRule;
|
24 | 22 | import com.google.gson.Gson;
|
25 |
| -import com.google.gson.JsonSyntaxException; |
26 | 23 | import io.kubernetes.client.openapi.ApiClient;
|
27 | 24 | import io.kubernetes.client.openapi.ApiException;
|
28 | 25 | import io.kubernetes.client.openapi.models.*;
|
@@ -65,15 +62,12 @@ public void testErrorStatusHandler() throws ApiException {
|
65 | 62 |
|
66 | 63 | @Test
|
67 | 64 | public void testNotDeserializableResponse() {
|
| 65 | + String message = "-foobar"; |
68 | 66 | wireMockRule.stubFor(
|
69 | 67 | get(urlEqualTo("/api/v1/namespaces/default/pods/foo"))
|
70 |
| - .willReturn(aResponse().withStatus(403).withBody("-foobar"))); |
71 |
| - try { |
72 |
| - podClient.get("default", "foo"); |
73 |
| - } catch (RuntimeException e) { |
74 |
| - assertTrue(JsonSyntaxException.class.equals(e.getCause().getClass())); |
75 |
| - return; |
76 |
| - } |
77 |
| - fail("no exception thrown"); |
| 68 | + .willReturn(aResponse().withStatus(403).withBody(message))); |
| 69 | + KubernetesApiResponse response = podClient.get("default", "foo"); |
| 70 | + assertFalse(response.isSuccess()); |
| 71 | + assertEquals(response.getStatus().getMessage(), message); |
78 | 72 | }
|
79 | 73 | }
|
0 commit comments