HeaderUpdateInterceptor implements RequestInterceptor, ResponseInterceptor { @Override public void onRequestReceive(final WilmaHttpRequest request, final ParameterList parameters) { if (parameters != null && !parameters.isEmpty()) { List<Parameter> parameterList = parameters.getAllParameters(); for (Parameter parameter : parameterList) { String name = parameter.getName(); String value = parameter.getValue(); if (REMOVE_HEADER.equals(name.toUpperCase())) { request.addHeaderRemove(value); } else { request.addHeaderUpdate(name, value); } } } }  @Override void onRequestReceive(final WilmaHttpRequest request, final ParameterList parameters); @Override void onResponseReceive(final WilmaHttpResponse response, final ParameterList parameters); static final String REMOVE_HEADER; }
@Test public void testRequestInterceptorMarksHeadersToBeRemoved() { given(parameterMap.isEmpty()).willReturn(false); List<Parameter> parameters = new ArrayList<>(); Parameter p = new Parameter(HeaderUpdateInterceptor.REMOVE_HEADER, "B"); parameters.add(p); given(parameterMap.getAllParameters()).willReturn(parameters); underTest.onRequestReceive(request, parameterMap); verify(request).addHeaderRemove("B"); }
@Test public void testRequestInterceptorMarksHeadersToBeUpdated() { given(parameterMap.isEmpty()).willReturn(false); List<Parameter> parameters = new ArrayList<>(); Parameter p = new Parameter("A", "B"); parameters.add(p); given(parameterMap.getAllParameters()).willReturn(parameters); underTest.onRequestReceive(request, parameterMap); verify(request).addHeaderUpdate("A", "B"); }