@Test public void transformInterceptedException() { MessageSender sender = mock(MessageSender.class); SagaStartAnnotationProcessor sagaStartAnnotationProcessor = new SagaStartAnnotationProcessor(context, sender); doThrow(exception).when(sender).send(any(TxEvent.class)); try { sagaStartAnnotationProcessor.preIntercept(null, null, 0, null, 0); expectFailing(TransactionalException.class); } catch (TransactionalException e) { assertThat(e.getMessage(), is("exception")); assertThat(e.getCause(), instanceOf(RuntimeException.class)); assertThat(e.getCause().getMessage(), is("runtime exception")); } }
@Override public AlphaResponse preIntercept(String parentTxId, String compensationMethod, int timeout, String retriesMethod, int retries, Object... message) { try { return sender.send(new SagaStartedEvent(omegaContext.globalTxId(), omegaContext.localTxId(), timeout, omegaContext.category())); } catch (OmegaException e) { throw new TransactionalException(e.getMessage(), e.getCause()); } }
SagaStartAnnotationProcessor implements EventAwareInterceptor { @Override public AlphaResponse preIntercept(String parentTxId, String compensationMethod, int timeout, String retriesMethod, int retries, Object... message) { try { return sender.send(new SagaStartedEvent(omegaContext.globalTxId(), omegaContext.localTxId(), timeout, omegaContext.category())); } catch (OmegaException e) { throw new TransactionalException(e.getMessage(), e.getCause()); } } }
SagaStartAnnotationProcessor implements EventAwareInterceptor { @Override public AlphaResponse preIntercept(String parentTxId, String compensationMethod, int timeout, String retriesMethod, int retries, Object... message) { try { return sender.send(new SagaStartedEvent(omegaContext.globalTxId(), omegaContext.localTxId(), timeout, omegaContext.category())); } catch (OmegaException e) { throw new TransactionalException(e.getMessage(), e.getCause()); } } SagaStartAnnotationProcessor(OmegaContext omegaContext, MessageSender sender); }
SagaStartAnnotationProcessor implements EventAwareInterceptor { @Override public AlphaResponse preIntercept(String parentTxId, String compensationMethod, int timeout, String retriesMethod, int retries, Object... message) { try { return sender.send(new SagaStartedEvent(omegaContext.globalTxId(), omegaContext.localTxId(), timeout, omegaContext.category())); } catch (OmegaException e) { throw new TransactionalException(e.getMessage(), e.getCause()); } } SagaStartAnnotationProcessor(OmegaContext omegaContext, MessageSender sender); @Override AlphaResponse preIntercept(String parentTxId, String compensationMethod, int timeout, String retriesMethod,
      int retries, Object... message); @Override void postIntercept(String parentTxId, String compensationMethod); @Override void onError(String parentTxId, String compensationMethod, Throwable throwable); }
SagaStartAnnotationProcessor implements EventAwareInterceptor { @Override public AlphaResponse preIntercept(String parentTxId, String compensationMethod, int timeout, String retriesMethod, int retries, Object... message) { try { return sender.send(new SagaStartedEvent(omegaContext.globalTxId(), omegaContext.localTxId(), timeout, omegaContext.category())); } catch (OmegaException e) { throw new TransactionalException(e.getMessage(), e.getCause()); } } SagaStartAnnotationProcessor(OmegaContext omegaContext, MessageSender sender); @Override AlphaResponse preIntercept(String parentTxId, String compensationMethod, int timeout, String retriesMethod,
      int retries, Object... message); @Override void postIntercept(String parentTxId, String compensationMethod); @Override void onError(String parentTxId, String compensationMethod, Throwable throwable);  }