Shows exception handling isn't required to coerce 404 to null or empty
()
| 64 | |
| 65 | /** Shows exception handling isn't required to coerce 404 to null or empty */ |
| 66 | @Test |
| 67 | void dismiss404() { |
| 68 | server.enqueue(new MockResponse().setResponseCode(404)); |
| 69 | server.enqueue(new MockResponse().setResponseCode(404)); |
| 70 | server.enqueue(new MockResponse().setResponseCode(404)); |
| 71 | server.enqueue(new MockResponse().setResponseCode(404)); |
| 72 | server.enqueue(new MockResponse().setResponseCode(404)); |
| 73 | server.enqueue(new MockResponse().setResponseCode(400)); |
| 74 | |
| 75 | String url = "http://localhost:" + server.getPort(); |
| 76 | TestInterface api = Feign.builder().dismiss404().target(TestInterface.class, url); |
| 77 | |
| 78 | assertThat(api.getQueues("/")).isEmpty(); // empty, not null! |
| 79 | assertThat(api.decodedLazyPost().hasNext()).isFalse(); // empty, not null! |
| 80 | assertThat(api.optionalContent()).isEmpty(); // empty, not null! |
| 81 | assertThat(api.streamPost()).isEmpty(); // empty, not null! |
| 82 | assertThat(api.decodedPost()).isNull(); // null, not empty! |
| 83 | |
| 84 | try { // ensure other 400 codes are not impacted. |
| 85 | api.decodedPost(); |
| 86 | failBecauseExceptionWasNotThrown(FeignException.class); |
| 87 | } catch (FeignException e) { |
| 88 | assertThat(e.status()).isEqualTo(400); |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | /** Shows exception handling isn't required to coerce 204 to null or empty */ |
| 93 | @Test |
no test coverage detected