### Question:
StopDatabaseServerFailedAction extends AbstractRedbeamsStopAction<RedbeamsFailureEvent> { @Override protected RedbeamsStopContext createFlowContext( FlowParameters flowParameters, StateContext<RedbeamsStopState, RedbeamsStopEvent> stateContext, RedbeamsFailureEvent payload) { Flow flow = getFlow(flowParameters.getFlowId()); flow.setFlowFailed(payload.getException()); return super.createFlowContext(flowParameters, stateContext, payload); } StopDatabaseServerFailedAction();   }### Answer:
@Test public void shouldCreateFlowContext() { when(flowParameters.getFlowId()).thenReturn(FLOW_ID); when(runningFlows.get(FLOW_ID)).thenReturn(flow); when(payload.getException()).thenReturn(exception); when(payload.getResourceId()).thenReturn(RESOURCE_ID); when(dbStackService.getById(RESOURCE_ID)).thenReturn(dbStack); when(dbStack.getOwnerCrn()).thenReturn(ownerCrn); when(dbStack.getId()).thenReturn(DB_STACK_ID); when(dbStack.getName()).thenReturn(DB_STACK_NAME); when(dbStack.getCloudPlatform()).thenReturn(DB_STACK_CLOUD_PLATFORM); when(dbStack.getPlatformVariant()).thenReturn(DB_STACK_PLATFORM_VARIANT); when(dbStack.getRegion()).thenReturn(DB_STACK_REGION); when(dbStack.getAvailabilityZone()).thenReturn(DB_STACK_AZ); when(dbStack.getEnvironmentId()).thenReturn(DB_STACK_ENV_ID); when(ownerCrn.getUserId()).thenReturn(USER_NAME); when(ownerCrn.getAccountId()).thenReturn(ACCOUNT_ID); when(credentialService.getCredentialByEnvCrn(DB_STACK_ENV_ID)).thenReturn(credential); when(credentialConverter.convert(credential)).thenReturn(cloudCredential); when(databaseStackConverter.convert(dbStack)).thenReturn(databaseStack); RedbeamsStopContext redbeamsStopContext = victim.createFlowContext(flowParameters, stateContext, payload); verify(flow).setFlowFailed(exception); assertEquals(flowParameters, redbeamsStopContext.getFlowParameters()); assertEquals(DB_STACK_ID, redbeamsStopContext.getCloudContext().getId()); assertEquals(DB_STACK_NAME, redbeamsStopContext.getCloudContext().getName()); assertEquals(DB_STACK_CLOUD_PLATFORM, redbeamsStopContext.getCloudContext().getPlatform().value()); assertEquals(DB_STACK_PLATFORM_VARIANT, redbeamsStopContext.getCloudContext().getVariant().value()); assertEquals(DB_STACK_REGION, redbeamsStopContext.getCloudContext().getLocation().getRegion().value()); assertEquals(DB_STACK_AZ, redbeamsStopContext.getCloudContext().getLocation().getAvailabilityZone().value()); assertEquals(USER_NAME, redbeamsStopContext.getCloudContext().getUserId()); assertEquals(ACCOUNT_ID, redbeamsStopContext.getCloudContext().getAccountId()); assertEquals(flowParameters, redbeamsStopContext.getFlowParameters()); assertEquals(cloudCredential, redbeamsStopContext.getCloudCredential()); assertEquals(databaseStack, redbeamsStopContext.getDatabaseStack()); }