@Test
public void testRequestWithCustomHeaders() {
// GIVEN a fake url
String remote = "https://fake.kinto.url";
// AND custom headers
Map<String, String> customHeaders = new HashMap<>();
customHeaders.put("Authorization", "Basic supersecurestuff");
customHeaders.put("Warning", "Be careful");
customHeaders.put("Accept", "application/html");
// AND expected headers
Map<String, List<String>> expectedHeaders = new HashMap<>(defaultHeaders);
customHeaders.forEach((k, v) -> expectedHeaders.merge(k, Arrays.asList(v), (a, b) -> a.addAll(b) ? a:a));
// AND a kintoClient
KintoClient kintoClient = new KintoClient(remote, customHeaders);
// AND an ENDPOINTS
ENDPOINTS endpoint = ENDPOINTS.GROUPS;
// WHEN calling request
GetRequest request = kintoClient.request(endpoint);
// THEN the root part is initialized
assertThat(request.getUrl(), is(remote + "/buckets/{bucket}/groups"));
// AND the get http method is used
assertThat(request.getHttpMethod(), is(HttpMethod.GET));
// AND the default headers are set
assertThat(request.getHeaders(), is(expectedHeaders));
}
KintoClientTest.java 文件源码
java
阅读 25
收藏 0
点赞 0
评论 0
项目:kinto-http-java
作者:
评论列表
文章目录