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

Method decode204

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

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

()

Source from the content-addressed store, hash-verified

91
92 /** Shows exception handling isn't required to coerce 204 to null or empty */
93 @Test
94 void decode204() {
95 server.enqueue(new MockResponse().setResponseCode(204));
96 server.enqueue(new MockResponse().setResponseCode(204));
97 server.enqueue(new MockResponse().setResponseCode(204));
98 server.enqueue(new MockResponse().setResponseCode(204));
99 server.enqueue(new MockResponse().setResponseCode(204));
100 server.enqueue(new MockResponse().setResponseCode(400));
101
102 String url = "http://localhost:" + server.getPort();
103 TestInterface api = Feign.builder().target(TestInterface.class, url);
104
105 assertThat(api.getQueues("/")).isEmpty(); // empty, not null!
106 assertThat(api.decodedLazyPost().hasNext()).isFalse(); // empty, not null!
107 assertThat(api.optionalContent()).isEmpty(); // empty, not null!
108 assertThat(api.streamPost()).isEmpty(); // empty, not null!
109 assertThat(api.decodedPost()).isNull(); // null, not empty!
110
111 try { // ensure other 400 codes are not impacted.
112 api.decodedPost();
113 failBecauseExceptionWasNotThrown(FeignException.class);
114 } catch (FeignException e) {
115 assertThat(e.status()).isEqualTo(400);
116 }
117 }
118
119 @Test
120 void noFollowRedirect() {

Callers

nothing calls this directly

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