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

Method setup

mock/src/test/java/feign/mock/MockClientTest.java:96–145  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

94 private MockClient mockClient;
95
96 @BeforeEach
97 void setup() throws IOException {
98 try (InputStream input = getClass().getResourceAsStream("/fixtures/contributors.json")) {
99 byte[] data = toByteArray(input);
100 RequestKey postContributorKey =
101 RequestKey.builder(HttpMethod.POST, "/repos/netflix/feign/contributors")
102 .charset(UTF_8)
103 .headers(
104 RequestHeaders.builder()
105 .add("Content-Length", "55")
106 .add("Content-Type", "application/json")
107 .build())
108 .body("{\"login\":\"velo_at_github\",\"type\":\"preposterous hacker\"}")
109 .build();
110 mockClient = new MockClient();
111 github =
112 Feign.builder()
113 .decoder(new AssertionDecoder(new GsonDecoder()))
114 .client(
115 mockClient
116 .ok(HttpMethod.GET, "/repos/netflix/feign/contributors", data)
117 .ok(HttpMethod.GET, "/repos/netflix/feign/contributors?client_id=55")
118 .ok(
119 HttpMethod.GET,
120 "/repos/netflix/feign/contributors?client_id=7 7",
121 new ByteArrayInputStream(data))
122 .ok(postContributorKey, "{\"login\":\"velo\",\"contributions\":0}")
123 .noContent(HttpMethod.PATCH, "/repos/velo/feign-mock/contributors")
124 .add(
125 HttpMethod.GET,
126 "/repos/netflix/feign/contributors?client_id=1234567890",
127 HttpURLConnection.HTTP_NOT_FOUND)
128 .add(
129 HttpMethod.GET,
130 "/repos/netflix/feign/contributors?client_id=123456789",
131 HttpURLConnection.HTTP_INTERNAL_ERROR,
132 new ByteArrayInputStream(data))
133 .add(
134 HttpMethod.GET,
135 "/repos/netflix/feign/contributors?client_id=123456789",
136 HttpURLConnection.HTTP_INTERNAL_ERROR,
137 "")
138 .add(
139 HttpMethod.GET,
140 "/repos/netflix/feign/contributors?client_id=123456789",
141 HttpURLConnection.HTTP_INTERNAL_ERROR,
142 data))
143 .target(new MockTarget<>(GitHub.class));
144 }
145 }
146
147 @Test
148 void hitMock() {

Callers

nothing calls this directly

Calls 14

builderMethod · 0.95
builderMethod · 0.95
builderMethod · 0.95
okMethod · 0.80
bodyMethod · 0.65
headersMethod · 0.65
decoderMethod · 0.65
noContentMethod · 0.65
toByteArrayMethod · 0.45
buildMethod · 0.45
charsetMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected