private static void assertHeaders(ActionRequest<?> request, Map<String, String> headers) { if (headers.size() == 0) { assertThat(request.getHeaders() == null || request.getHeaders().size() == 0, equalTo(true)); } else { assertThat(request.getHeaders(), notNullValue()); assertThat(request.getHeaders().size(), equalTo(headers.size())); for (String key : request.getHeaders()) { assertThat(headers.get(key), equalTo(request.getHeader(key))); } } }
private static void assertContext(ActionRequest<?> request, Map<String, String> context) { if (context.size() == 0) { assertThat(request.isContextEmpty(), is(true)); } else { ImmutableOpenMap map = request.getContext(); assertThat(map, notNullValue()); assertThat(map.size(), equalTo(context.size())); for (Object key : map.keys()) { assertThat(context.get(key), equalTo(request.getFromContext(key))); } } }
private static void putContext(ActionRequest<?> request, Map<String, String> context) { for (Map.Entry<String, String> header : context.entrySet()) { request.putInContext(header.getKey(), header.getValue()); } }
private static void putHeaders(ActionRequest<?> request, Map<String, String> headers) { for (Map.Entry<String, String> header : headers.entrySet()) { request.putHeader(header.getKey(), header.getValue()); } }