use of com.sequenceiq.redbeams.flow.redbeams.common.RedbeamsContext in project cloudbreak by hortonworks.
the class RedbeamsProvisionActions method updateDatabaseServerRegistration.
@Bean(name = "UPDATE_DATABASE_SERVER_REGISTRATION_STATE")
public Action<?, ?> updateDatabaseServerRegistration() {
return new AbstractRedbeamsProvisionAction<>(AllocateDatabaseServerSuccess.class) {
@Override
protected void doExecute(RedbeamsContext context, AllocateDatabaseServerSuccess payload, Map<Object, Object> variables) {
dbStackStatusUpdater.updateStatus(payload.getResourceId(), DetailedDBStackStatus.PROVISIONED);
List<CloudResourceStatus> dbResourcesList = dbResourceService.getAllAsCloudResourceStatus(payload.getResourceId());
sendEvent(context, new UpdateDatabaseServerRegistrationRequest(context.getCloudContext(), context.getCloudCredential(), context.getDatabaseStack(), ResourceLists.transform(dbResourcesList)));
}
};
}
use of com.sequenceiq.redbeams.flow.redbeams.common.RedbeamsContext in project cloudbreak by hortonworks.
the class AbstractRedbeamsTerminationActionTest method testCreateFlowContext.
@Test
public void testCreateFlowContext() {
when(dbStackService.findById(Long.valueOf(1L))).thenReturn(Optional.of(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 RedbeamsEvent(1L));
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().getAccountId(), ctx.getCloudContext().getAccountId());
assertEquals(cloudCredential, ctx.getCloudCredential());
assertEquals(databaseStack, ctx.getDatabaseStack());
}
Aggregations