MCPcopy Index your code
hub / github.com/OpenFeign/feign / dismiss404

Method dismiss404

core/src/test/java/feign/FeignBuilderTest.java:66–90  ·  view source on GitHub ↗

Shows exception handling isn't required to coerce 404 to null or empty

()

Source from the content-addressed store, hash-verified

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

Callers 1

simple404OptionalTestMethod · 0.45

Calls 11

builderMethod · 0.95
getQueuesMethod · 0.95
decodedLazyPostMethod · 0.95
optionalContentMethod · 0.95
streamPostMethod · 0.95
decodedPostMethod · 0.95
isEmptyMethod · 0.80
targetMethod · 0.45
assertThatMethod · 0.45
hasNextMethod · 0.45
statusMethod · 0.45

Tested by

no test coverage detected