()
| 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() { |
nothing calls this directly
no test coverage detected