### Question:
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);  }### Answer:
@Test public void sendsSagaStartedEvent() { sagaStartAnnotationProcessor.preIntercept(null, null, 0, null, 0); TxEvent event = messages.get(0); assertThat(event.globalTxId(), is(globalTxId)); assertThat(event.localTxId(), is(globalTxId)); assertThat(event.parentTxId(), is(nullValue())); assertThat(event.compensationMethod().isEmpty(), is(true)); assertThat(event.type(), is(EventType.SagaStartedEvent)); assertThat(event.payloads().length, is(0)); }
@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")); } }