### Question:
StackImageUpdateActions { @Bean(name = "SET_IMAGE_STATE") public AbstractStackImageUpdateAction<?> setImageAction() { return new AbstractStackImageUpdateAction<>(StackEvent.class) { @Override protected void doExecute(StackContext context, StackEvent payload, Map<Object, Object> variables) { CloudStack cloudStack = getCloudStackConverter().convert(context.getStack()); Collection<Resource> resources = getResourceService().getAllByStackId(context.getStack().getId()); List<CloudResource> cloudResources = resources.stream().map(resource -> getResourceToCloudResourceConverter().convert(resource)).collect(Collectors.toList()); UpdateImageRequest<Selectable> request = new UpdateImageRequest<>(context.getCloudContext(), context.getCloudCredential(), cloudStack, cloudResources); sendEvent(context, request); } }; }  @Bean(name = "CHECK_IMAGE_VERSIONS_STATE") AbstractStackImageUpdateAction<?> checkImageVersion(); @Bean(name = "CHECK_PACKAGE_VERSIONS_STATE") AbstractStackImageUpdateAction<?> checkPackageVersions(); @Bean(name = "UPDATE_IMAGE_STATE") AbstractStackImageUpdateAction<?> updateImage(); @Bean(name = "IMAGE_PREPARE_STATE") AbstractStackImageUpdateAction<?> prepareImageAction(); @Bean(name = "SET_IMAGE_STATE") AbstractStackImageUpdateAction<?> setImageAction(); @Bean(name = "STACK_IMAGE_UPDATE_FINISHED") AbstractStackImageUpdateAction<?> finishAction(); @Bean(name = "STACK_IMAGE_UPDATE_FAILED_STATE") AbstractStackFailureAction<StackImageUpdateState, StackImageUpdateEvent> handleImageUpdateFailure();  }### Answer:
@Test public void setImageAction() { FlowEvent flowEvent = Mockito.mock(FlowEvent.class); when(stateContext.getEvent()).thenReturn(flowEvent); when(flowEvent.name()).thenReturn(EVENT_NAME); Stack stack = new Stack(); StackEvent payload = new StackEvent(StackImageUpdateEvent.UPDATE_IMAGE_FINESHED_EVENT.event(), 1L); when(stateContext.getMessageHeader(HEADERS.DATA.name())).thenReturn(payload); when(state.getId()).thenReturn(StackImageUpdateState.SET_IMAGE_STATE); when(resourceService.getAllByStackId(anyLong())) .thenReturn(Collections.singletonList(new Resource(ResourceType.CLOUDFORMATION_STACK, "cf", stack))); when(resourceToCloudResourceConverter.convert(any(Resource.class))) .thenReturn(CloudResource.builder().type(ResourceType.CLOUDFORMATION_STACK).name("cfresource").build()); setImageAction.execute(stateContext); verify(eventBus, times(1)).notify(eq(CloudPlatformRequest.selector(UpdateImageRequest.class)), any(Event.class)); }