### Question:
TransactionClientHttpRequestInterceptor implements ClientHttpRequestInterceptor { @Override public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException { if (omegaContext != null && omegaContext.globalTxId() != null) { request.getHeaders().add(GLOBAL_TX_ID_KEY, omegaContext.globalTxId()); request.getHeaders().add(LOCAL_TX_ID_KEY, omegaContext.localTxId()); request.getHeaders().add(GLOBAL_TX_CATEGORY_KEY, omegaContext.category()); LOG.debug("Added {} {} and {} {} to request header", GLOBAL_TX_ID_KEY, omegaContext.globalTxId(), LOCAL_TX_ID_KEY, omegaContext.localTxId(), GLOBAL_TX_CATEGORY_KEY, omegaContext.category()); } return execution.execute(request, body); } TransactionClientHttpRequestInterceptor(OmegaContext omegaContext); @Override ClientHttpResponse intercept(HttpRequest request, byte[] body,
      ClientHttpRequestExecution execution);  }### Answer:
@Test public void keepHeaderUnchangedIfContextAbsent() throws IOException { when(request.getHeaders()).thenReturn(new HttpHeaders()); when(execution.execute(request, null)).thenReturn(response); clientHttpRequestInterceptor.intercept(request, null, execution); assertThat(request.getHeaders().isEmpty(), is(true)); }
@Test public void interceptTransactionIdInHeaderIfContextPresent() throws IOException { omegaContext.setGlobalTxId(globalTxId); omegaContext.setLocalTxId(localTxId); HttpHeaders headers = new HttpHeaders(); when(request.getHeaders()).thenReturn(headers); when(execution.execute(request, null)).thenReturn(response); clientHttpRequestInterceptor.intercept(request, null, execution); assertThat(request.getHeaders().get(OmegaContext.GLOBAL_TX_ID_KEY), contains(globalTxId)); assertThat(request.getHeaders().get(OmegaContext.LOCAL_TX_ID_KEY), contains(localTxId)); }