@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)); }
@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 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 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); }
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); }
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);  }