### Question:
SagaConsumerHandler implements Handler { @Override public void handle(Invocation invocation, AsyncResponse asyncResponse) throws Exception { if (omegaContext != null && omegaContext.globalTxId() != null) { invocation.getContext().put(GLOBAL_TX_ID_KEY, omegaContext.globalTxId()); invocation.getContext().put(LOCAL_TX_ID_KEY, omegaContext.localTxId()); LOG.debug("Added {} {} and {} {} to request header", GLOBAL_TX_ID_KEY, omegaContext.globalTxId(), LOCAL_TX_ID_KEY, omegaContext.localTxId()); } else { LOG.info("Cannot inject transaction ID, as the OmegaContext is null or cannot get the globalTxId."); } invocation.next(asyncResponse); } SagaConsumerHandler();  SagaConsumerHandler(OmegaContext omegaContext); @Override void handle(Invocation invocation, AsyncResponse asyncResponse);  }### Answer:
@Test public void keepHeaderUnchangedIfContextAbsent() throws Exception { Map<String, String> context = new HashMap<>(); when(invocation.getContext()).thenReturn(context); handler.handle(invocation, asyncResponse); assertThat(invocation.getContext().isEmpty(), is(true)); }
@Test public void interceptTransactionIdInHeaderIfContextPresent() throws Exception { omegaContext.setGlobalTxId(globalTxId); omegaContext.setLocalTxId(localTxId); Map<String, String> context = new HashMap<>(); when(invocation.getContext()).thenReturn(context); handler.handle(invocation, asyncResponse); assertThat(invocation.getContext().get(OmegaContext.GLOBAL_TX_ID_KEY), is(globalTxId)); assertThat(invocation.getContext().get(OmegaContext.LOCAL_TX_ID_KEY), is(localTxId)); }