ImageFSM { @OnTransit public void onImageError(@FromState ImageEvent from, @Event ImageErrorEvent event) { Image image = event.getImage(); LOG.info("Changing image {} ({}) status to error", image.getName(), image.getId()); image.setState(ImageState.ERROR); imagesAware.saveImage(image); if (!(from instanceof ImageErrorEvent) && !(from instanceof ImageNotAvailableEvent)) { LOG.info("Sending letter about image {} ({}) error", image.getName(), image.getId()); String message = getMailMessage(imageEventToState(from), image); mailSender.sendLetter(message); } } @Autowired  ImageFSM(OperationProcessor operationProcessor, ImagesAware imagesAware, CloudConfigurationProvider cloudConfigurationProvider, MailSender mailSender); @BeforeTransit void beforeTransit(@Event ImageEvent imageEvent); @OnTransit void onImageQueued(@Event ImageQueuedEvent event); @OnTransit void onImageSaving(@Event ImageSavingEvent event); @OnTransit void onImageSaved(@Event ImageSavedEvent event); @OnTransit void onImageDeleting(@Event ImageDeletingEvent event); @OnTransit void onImageError(@FromState ImageEvent from, @Event ImageErrorEvent event); @OnException void onUnsupportedOperationException(UnsupportedOperationException e);  }
@Test public void testOnImageError() { testOnImageSyncEvent(ImageErrorEvent.class, ERROR); }