### Question:
TraceeClientInterceptor extends AbstractTraceeInterceptor implements ClientInterceptor { @Override public boolean handleRequest(MessageContext messageContext) { serializeContextToSoapHeader(messageContext.getRequest(), OutgoingRequest); return true; } TraceeClientInterceptor();  TraceeClientInterceptor(final String profile);  TraceeClientInterceptor(final TraceeBackend backend, final String profile); @Override boolean handleRequest(MessageContext messageContext); @Override boolean handleResponse(MessageContext messageContext); @Override boolean handleFault(MessageContext messageContext); @Override void afterCompletion(MessageContext messageContext, Exception ex);  }### Answer:
@Test public void doNotAddTpicHeaderIfBackendIsEmpty() throws Exception { unit.handleRequest(messageContext); verify(((SoapMessage) messageContext.getResponse()).getSoapHeader(), never()).addHeaderElement(eq(SOAP_HEADER_QNAME)); }
@Test public void catchJaxbExceptionUponRenderingAndReturnWithoutException() throws Exception { backend.put("our key", "is our value"); when(((SoapMessage) messageContext.getRequest()).getSoapHeader()).thenReturn(mock(SoapHeader.class)); unit.handleRequest(messageContext); verify(((SoapMessage) messageContext.getRequest()).getSoapHeader()).getResult(); }
@Test public void renderTpicContextToRequest() throws Exception { backend.put("our key", "is our value"); final StringWriter writer = new StringWriter(); final SoapHeader soapHeader = mock(SoapHeader.class); when(((SoapMessage) messageContext.getRequest()).getSoapHeader()).thenReturn(soapHeader); when(soapHeader.getResult()).thenReturn(new StreamResult(writer)); unit.handleRequest(messageContext); assertThat(writer.toString(), containsString("<entry key=\"our key\">is our value</entry>")); }
@Test public void skipProcessingWithWrongMessageTypeOnRequest() { when(messageContext.getRequest()).thenReturn(mock(WebServiceMessage.class)); unit.handleRequest(messageContext); assertThat(backend.isEmpty(), is(true)); }