@Test void externalDatabaseCreationFinishedAction() { CreateExternalDatabaseResult createExternalDatabaseResultPayload = new CreateExternalDatabaseResult(STACK_ID, EXTERNAL_DATABASE_WAIT_SUCCESS_EVENT.event(), STACK_NAME, STACK_CRN); when(stateContext.getMessageHeader(MessageFactory.HEADERS.DATA.name())).thenReturn(createExternalDatabaseResultPayload); Action<?, ?> action = configureAction(underTest::externalDatabaseCreationFinishedAction); action.execute(stateContext); verifyNoMoreInteractions(stackUpdaterService); verify(eventBus).notify(selectorArgumentCaptor.capture(), eventArgumentCaptor.capture()); verify(reactorEventFactory).createEvent(headersArgumentCaptor.capture(), payloadArgumentCaptor.capture()); verify(metricService).incrementMetricCounter(MetricType.EXTERNAL_DATABASE_CREATION_SUCCESSFUL, STACK); assertThat(selectorArgumentCaptor.getValue()).isEqualTo("EXTERNAL_DATABASE_CREATION_FINISHED_EVENT"); Object capturedPayload = payloadArgumentCaptor.getValue(); assertThat(capturedPayload).isInstanceOf(StackEvent.class); StackEvent stackEvent = (StackEvent) capturedPayload; assertThat(stackEvent.getResourceId()).isEqualTo(STACK_ID); }
@Bean(name = "EXTERNAL_DATABASE_CREATION_FINISHED_STATE") public Action<?, ?> externalDatabaseCreationFinishedAction() { return new AbstractExternalDatabaseCreationAction<>(CreateExternalDatabaseResult.class) { @Override protected void doExecute(ExternalDatabaseContext context, CreateExternalDatabaseResult payload, Map<Object, Object> variables) { getMetricService().incrementMetricCounter(MetricType.EXTERNAL_DATABASE_CREATION_SUCCESSFUL, context.getStack()); sendEvent(context); } @Override protected Selectable createRequest(ExternalDatabaseContext context) { return new StackEvent(ExternalDatabaseCreationEvent.EXTERNAL_DATABASE_CREATION_FINISHED_EVENT.event(), context.getStack().getId()); } }; }
ExternalDatabaseCreationActions { @Bean(name = "EXTERNAL_DATABASE_CREATION_FINISHED_STATE") public Action<?, ?> externalDatabaseCreationFinishedAction() { return new AbstractExternalDatabaseCreationAction<>(CreateExternalDatabaseResult.class) { @Override protected void doExecute(ExternalDatabaseContext context, CreateExternalDatabaseResult payload, Map<Object, Object> variables) { getMetricService().incrementMetricCounter(MetricType.EXTERNAL_DATABASE_CREATION_SUCCESSFUL, context.getStack()); sendEvent(context); } @Override protected Selectable createRequest(ExternalDatabaseContext context) { return new StackEvent(ExternalDatabaseCreationEvent.EXTERNAL_DATABASE_CREATION_FINISHED_EVENT.event(), context.getStack().getId()); } }; } }
ExternalDatabaseCreationActions { @Bean(name = "EXTERNAL_DATABASE_CREATION_FINISHED_STATE") public Action<?, ?> externalDatabaseCreationFinishedAction() { return new AbstractExternalDatabaseCreationAction<>(CreateExternalDatabaseResult.class) { @Override protected void doExecute(ExternalDatabaseContext context, CreateExternalDatabaseResult payload, Map<Object, Object> variables) { getMetricService().incrementMetricCounter(MetricType.EXTERNAL_DATABASE_CREATION_SUCCESSFUL, context.getStack()); sendEvent(context); } @Override protected Selectable createRequest(ExternalDatabaseContext context) { return new StackEvent(ExternalDatabaseCreationEvent.EXTERNAL_DATABASE_CREATION_FINISHED_EVENT.event(), context.getStack().getId()); } }; }  }
ExternalDatabaseCreationActions { @Bean(name = "EXTERNAL_DATABASE_CREATION_FINISHED_STATE") public Action<?, ?> externalDatabaseCreationFinishedAction() { return new AbstractExternalDatabaseCreationAction<>(CreateExternalDatabaseResult.class) { @Override protected void doExecute(ExternalDatabaseContext context, CreateExternalDatabaseResult payload, Map<Object, Object> variables) { getMetricService().incrementMetricCounter(MetricType.EXTERNAL_DATABASE_CREATION_SUCCESSFUL, context.getStack()); sendEvent(context); } @Override protected Selectable createRequest(ExternalDatabaseContext context) { return new StackEvent(ExternalDatabaseCreationEvent.EXTERNAL_DATABASE_CREATION_FINISHED_EVENT.event(), context.getStack().getId()); } }; }  @Bean(name = "WAIT_FOR_EXTERNAL_DATABASE_STATE") Action<?, ?> externalDatabaseCreation(); @Bean(name = "EXTERNAL_DATABASE_CREATION_FINISHED_STATE") Action<?, ?> externalDatabaseCreationFinishedAction(); @Bean(name = "EXTERNAL_DATABASE_CREATION_FAILED_STATE") Action<?, ?> externalDatabaseCreationFailureAction(); }
ExternalDatabaseCreationActions { @Bean(name = "EXTERNAL_DATABASE_CREATION_FINISHED_STATE") public Action<?, ?> externalDatabaseCreationFinishedAction() { return new AbstractExternalDatabaseCreationAction<>(CreateExternalDatabaseResult.class) { @Override protected void doExecute(ExternalDatabaseContext context, CreateExternalDatabaseResult payload, Map<Object, Object> variables) { getMetricService().incrementMetricCounter(MetricType.EXTERNAL_DATABASE_CREATION_SUCCESSFUL, context.getStack()); sendEvent(context); } @Override protected Selectable createRequest(ExternalDatabaseContext context) { return new StackEvent(ExternalDatabaseCreationEvent.EXTERNAL_DATABASE_CREATION_FINISHED_EVENT.event(), context.getStack().getId()); } }; }  @Bean(name = "WAIT_FOR_EXTERNAL_DATABASE_STATE") Action<?, ?> externalDatabaseCreation(); @Bean(name = "EXTERNAL_DATABASE_CREATION_FINISHED_STATE") Action<?, ?> externalDatabaseCreationFinishedAction(); @Bean(name = "EXTERNAL_DATABASE_CREATION_FAILED_STATE") Action<?, ?> externalDatabaseCreationFailureAction();  }