### Question:
SagaProviderHandler implements Handler { @Override public void handle(Invocation invocation, AsyncResponse asyncResponse) throws Exception { if (omegaContext != null) { String globalTxId = invocation.getContext().get(GLOBAL_TX_ID_KEY); if (globalTxId == null) { LOG.debug("no such header: {}", GLOBAL_TX_ID_KEY); } else { omegaContext.setGlobalTxId(globalTxId); omegaContext.setLocalTxId(invocation.getContext().get(LOCAL_TX_ID_KEY)); } } else { LOG.info("Cannot inject transaction ID, as the OmegaContext is null or cannot get the globalTxId."); } invocation.next(asyncResponse); } SagaProviderHandler();  SagaProviderHandler(OmegaContext omegaContext); @Override void handle(Invocation invocation, AsyncResponse asyncResponse);  }### Answer:
@Test public void setUpOmegaContextInTransactionRequest() throws Exception { Map<String, String> context = new HashMap<>(); context.put(GLOBAL_TX_ID_KEY, globalTxId); context.put(LOCAL_TX_ID_KEY, localTxId); when(invocation.getContext()).thenReturn(context); handler.handle(invocation, asyncResponse); assertThat(omegaContext.globalTxId(), is(globalTxId)); assertThat(omegaContext.localTxId(), is(localTxId)); }
@Test public void doNothingInNonTransactionRequest() throws Exception { when(invocation.getContext()).thenReturn(Collections.EMPTY_MAP); handler.handle(invocation, asyncResponse); assertThat(omegaContext.globalTxId(), is(nullValue())); assertThat(omegaContext.localTxId(), is(nullValue())); }