@Test public void testCreateFlowContext() { when(dbStackService.getById(Long.valueOf(1L))).thenReturn(dbStack); when(credentialService.getCredentialByEnvCrn("myenv")).thenReturn(credential); when(credentialConverter.convert(credential)).thenReturn(cloudCredential); when(databaseStackConverter.convert(dbStack)).thenReturn(databaseStack); RedbeamsContext ctx = underTest.createFlowContext(flowParameters, stateContext, new TestPayload()); assertEquals(dbStack.getId(), ctx.getCloudContext().getId()); assertEquals(dbStack.getName(), ctx.getCloudContext().getName()); assertEquals(Platform.platform(dbStack.getCloudPlatform()), ctx.getCloudContext().getPlatform()); assertEquals(Variant.variant(dbStack.getPlatformVariant()), ctx.getCloudContext().getVariant()); assertEquals(Location.location(Region.region(dbStack.getRegion()), AvailabilityZone.availabilityZone(dbStack.getAvailabilityZone())), ctx.getCloudContext().getLocation()); assertEquals(dbStack.getOwnerCrn().getUserId(), ctx.getCloudContext().getUserId()); assertEquals(dbStack.getOwnerCrn().getAccountId(), ctx.getCloudContext().getAccountId()); assertEquals(cloudCredential, ctx.getCloudCredential()); assertEquals(databaseStack, ctx.getDatabaseStack()); }
@Override protected RedbeamsContext createFlowContext(FlowParameters flowParameters, StateContext<RedbeamsProvisionState, RedbeamsProvisionEvent> stateContext, P payload) { DBStack dbStack = dbStackService.getById(payload.getResourceId()); MDCBuilder.buildMdcContext(dbStack); Location location = location(region(dbStack.getRegion()), availabilityZone(dbStack.getAvailabilityZone())); String accountId = dbStack.getOwnerCrn().getAccountId(); CloudContext cloudContext = new CloudContext(dbStack.getId(), dbStack.getName(), dbStack.getCloudPlatform(), dbStack.getPlatformVariant(), location, dbStack.getOwnerCrn().getUserId(), dbStack.getUserName(), accountId); Credential credential = credentialService.getCredentialByEnvCrn(dbStack.getEnvironmentId()); CloudCredential cloudCredential = credentialConverter.convert(credential); DatabaseStack databaseStack = databaseStackConverter.convert(dbStack); return new RedbeamsContext(flowParameters, cloudContext, cloudCredential, databaseStack, dbStack); }
AbstractRedbeamsProvisionAction extends AbstractAction<RedbeamsProvisionState, RedbeamsProvisionEvent, RedbeamsContext, P> { @Override protected RedbeamsContext createFlowContext(FlowParameters flowParameters, StateContext<RedbeamsProvisionState, RedbeamsProvisionEvent> stateContext, P payload) { DBStack dbStack = dbStackService.getById(payload.getResourceId()); MDCBuilder.buildMdcContext(dbStack); Location location = location(region(dbStack.getRegion()), availabilityZone(dbStack.getAvailabilityZone())); String accountId = dbStack.getOwnerCrn().getAccountId(); CloudContext cloudContext = new CloudContext(dbStack.getId(), dbStack.getName(), dbStack.getCloudPlatform(), dbStack.getPlatformVariant(), location, dbStack.getOwnerCrn().getUserId(), dbStack.getUserName(), accountId); Credential credential = credentialService.getCredentialByEnvCrn(dbStack.getEnvironmentId()); CloudCredential cloudCredential = credentialConverter.convert(credential); DatabaseStack databaseStack = databaseStackConverter.convert(dbStack); return new RedbeamsContext(flowParameters, cloudContext, cloudCredential, databaseStack, dbStack); } }
AbstractRedbeamsProvisionAction extends AbstractAction<RedbeamsProvisionState, RedbeamsProvisionEvent, RedbeamsContext, P> { @Override protected RedbeamsContext createFlowContext(FlowParameters flowParameters, StateContext<RedbeamsProvisionState, RedbeamsProvisionEvent> stateContext, P payload) { DBStack dbStack = dbStackService.getById(payload.getResourceId()); MDCBuilder.buildMdcContext(dbStack); Location location = location(region(dbStack.getRegion()), availabilityZone(dbStack.getAvailabilityZone())); String accountId = dbStack.getOwnerCrn().getAccountId(); CloudContext cloudContext = new CloudContext(dbStack.getId(), dbStack.getName(), dbStack.getCloudPlatform(), dbStack.getPlatformVariant(), location, dbStack.getOwnerCrn().getUserId(), dbStack.getUserName(), accountId); Credential credential = credentialService.getCredentialByEnvCrn(dbStack.getEnvironmentId()); CloudCredential cloudCredential = credentialConverter.convert(credential); DatabaseStack databaseStack = databaseStackConverter.convert(dbStack); return new RedbeamsContext(flowParameters, cloudContext, cloudCredential, databaseStack, dbStack); } protected  AbstractRedbeamsProvisionAction(Class<P> payloadClass); }
AbstractRedbeamsProvisionAction extends AbstractAction<RedbeamsProvisionState, RedbeamsProvisionEvent, RedbeamsContext, P> { @Override protected RedbeamsContext createFlowContext(FlowParameters flowParameters, StateContext<RedbeamsProvisionState, RedbeamsProvisionEvent> stateContext, P payload) { DBStack dbStack = dbStackService.getById(payload.getResourceId()); MDCBuilder.buildMdcContext(dbStack); Location location = location(region(dbStack.getRegion()), availabilityZone(dbStack.getAvailabilityZone())); String accountId = dbStack.getOwnerCrn().getAccountId(); CloudContext cloudContext = new CloudContext(dbStack.getId(), dbStack.getName(), dbStack.getCloudPlatform(), dbStack.getPlatformVariant(), location, dbStack.getOwnerCrn().getUserId(), dbStack.getUserName(), accountId); Credential credential = credentialService.getCredentialByEnvCrn(dbStack.getEnvironmentId()); CloudCredential cloudCredential = credentialConverter.convert(credential); DatabaseStack databaseStack = databaseStackConverter.convert(dbStack); return new RedbeamsContext(flowParameters, cloudContext, cloudCredential, databaseStack, dbStack); } protected  AbstractRedbeamsProvisionAction(Class<P> payloadClass); @PostConstruct void init(); }
AbstractRedbeamsProvisionAction extends AbstractAction<RedbeamsProvisionState, RedbeamsProvisionEvent, RedbeamsContext, P> { @Override protected RedbeamsContext createFlowContext(FlowParameters flowParameters, StateContext<RedbeamsProvisionState, RedbeamsProvisionEvent> stateContext, P payload) { DBStack dbStack = dbStackService.getById(payload.getResourceId()); MDCBuilder.buildMdcContext(dbStack); Location location = location(region(dbStack.getRegion()), availabilityZone(dbStack.getAvailabilityZone())); String accountId = dbStack.getOwnerCrn().getAccountId(); CloudContext cloudContext = new CloudContext(dbStack.getId(), dbStack.getName(), dbStack.getCloudPlatform(), dbStack.getPlatformVariant(), location, dbStack.getOwnerCrn().getUserId(), dbStack.getUserName(), accountId); Credential credential = credentialService.getCredentialByEnvCrn(dbStack.getEnvironmentId()); CloudCredential cloudCredential = credentialConverter.convert(credential); DatabaseStack databaseStack = databaseStackConverter.convert(dbStack); return new RedbeamsContext(flowParameters, cloudContext, cloudCredential, databaseStack, dbStack); } protected  AbstractRedbeamsProvisionAction(Class<P> payloadClass); @PostConstruct void init();  }