use of com.sequenceiq.redbeams.domain.stack.Network in project cloudbreak by hortonworks.
the class DBStackToDatabaseStackConverterTest method testConversionAzureWithMultipleResourceGroups.
@Test
public void testConversionAzureWithMultipleResourceGroups() {
Network network = new Network();
network.setAttributes(new Json(NETWORK_ATTRIBUTES));
dbStack.setNetwork(network);
dbStack.setCloudPlatform(CLOUD_PLATFORM);
dbStack.setParameters(new HashMap<>());
DatabaseServer server = new DatabaseServer();
server.setDatabaseVendor(DatabaseVendor.POSTGRES);
server.setAttributes(new Json(DATABASE_SERVER_ATTRIBUTES));
dbStack.setDatabaseServer(server);
dbStack.setTags(new Json(STACK_TAGS));
dbStack.setTemplate("template");
DetailedEnvironmentResponse environmentResponse = new DetailedEnvironmentResponse();
environmentResponse.setCloudPlatform(CLOUD_PLATFORM);
environmentResponse.setAzure(AzureEnvironmentParameters.builder().withAzureResourceGroup(AzureResourceGroup.builder().withResourceGroupUsage(ResourceGroupUsage.MULTIPLE).build()).build());
when(environmentService.getByCrn(anyString())).thenReturn(environmentResponse);
DatabaseStack convertedStack = underTest.convert(dbStack);
Map<String, Object> parameters = convertedStack.getDatabaseServer().getParameters();
assertThat(parameters.containsKey(RESOURCE_GROUP_NAME_PARAMETER)).isFalse();
assertThat(parameters.containsKey(RESOURCE_GROUP_USAGE_PARAMETER)).isFalse();
assertThat(parameters.size()).isEqualTo(2);
}
use of com.sequenceiq.redbeams.domain.stack.Network in project cloudbreak by hortonworks.
the class DBStackToDatabaseStackConverterTest method testConversionAzureWithAzureEncryptionResourcesPresentAndSingleResourceGroup.
@Test
public void testConversionAzureWithAzureEncryptionResourcesPresentAndSingleResourceGroup() {
Network network = new Network();
network.setAttributes(new Json(NETWORK_ATTRIBUTES));
dbStack.setNetwork(network);
dbStack.setCloudPlatform(CLOUD_PLATFORM);
dbStack.setParameters(new HashMap<>());
DatabaseServer server = new DatabaseServer();
server.setDatabaseVendor(DatabaseVendor.POSTGRES);
server.setAttributes(new Json(DATABASE_SERVER_ATTRIBUTES));
dbStack.setDatabaseServer(server);
dbStack.setTags(new Json(STACK_TAGS));
dbStack.setTemplate("template");
DetailedEnvironmentResponse environmentResponse = new DetailedEnvironmentResponse();
environmentResponse.setCloudPlatform(CLOUD_PLATFORM);
environmentResponse.setAzure(AzureEnvironmentParameters.builder().withAzureResourceGroup(AzureResourceGroup.builder().withResourceGroupUsage(ResourceGroupUsage.SINGLE).withName(RESOURCE_GROUP).build()).withResourceEncryptionParameters(AzureResourceEncryptionParameters.builder().withEncryptionKeyUrl(KEY_URL).withEncryptionKeyResourceGroupName(RESOURCE_GROUP).build()).build());
when(environmentService.getByCrn(anyString())).thenReturn(environmentResponse);
DatabaseStack convertedStack = underTest.convert(dbStack);
Map<String, Object> parameters = convertedStack.getDatabaseServer().getParameters();
assertThat(parameters.get(RESOURCE_GROUP_NAME_PARAMETER).toString()).isEqualTo(RESOURCE_GROUP);
assertThat(parameters.get(RESOURCE_GROUP_USAGE_PARAMETER).toString()).isEqualTo(ResourceGroupUsage.SINGLE.name());
assertThat(parameters.get(ENCRYPTION_KEY_URL).toString()).isEqualTo(KEY_URL);
assertThat(parameters.get(ENCRYPTION_KEY_RESOURCE_GROUP_NAME).toString()).isEqualTo(RESOURCE_GROUP);
assertThat(parameters.size()).isEqualTo(6);
}
use of com.sequenceiq.redbeams.domain.stack.Network in project cloudbreak by hortonworks.
the class DBStackToDatabaseStackConverterTest method testConversionGcpWithGcpEncryptionResourcesPresent.
@Test
public void testConversionGcpWithGcpEncryptionResourcesPresent() {
Network network = new Network();
network.setAttributes(new Json(NETWORK_ATTRIBUTES));
dbStack.setNetwork(network);
dbStack.setCloudPlatform("GCP");
dbStack.setParameters(new HashMap<>());
DatabaseServer server = new DatabaseServer();
server.setDatabaseVendor(DatabaseVendor.POSTGRES);
server.setAttributes(new Json(DATABASE_SERVER_ATTRIBUTES));
dbStack.setDatabaseServer(server);
dbStack.setTags(new Json(STACK_TAGS));
dbStack.setTemplate("template");
DetailedEnvironmentResponse environmentResponse = new DetailedEnvironmentResponse();
environmentResponse.setCloudPlatform("GCP");
environmentResponse.setGcp(GcpEnvironmentParameters.builder().withResourceEncryptionParameters(GcpResourceEncryptionParameters.builder().withEncryptionKey("value").build()).build());
when(environmentService.getByCrn(anyString())).thenReturn(environmentResponse);
DatabaseStack convertedStack = underTest.convert(dbStack);
Map<String, Object> parameters = convertedStack.getDatabaseServer().getParameters();
assertThat(parameters.get("key").toString()).isEqualTo("value");
assertThat(parameters.size()).isEqualTo(3);
}
use of com.sequenceiq.redbeams.domain.stack.Network in project cloudbreak by hortonworks.
the class DBStackToDatabaseStackConverterTest method testConversionAwsWithAwsEncryptionResourcesPresent.
@Test
public void testConversionAwsWithAwsEncryptionResourcesPresent() {
Network network = new Network();
network.setAttributes(new Json(NETWORK_ATTRIBUTES));
dbStack.setNetwork(network);
dbStack.setCloudPlatform("AWS");
dbStack.setParameters(new HashMap<>());
DatabaseServer server = new DatabaseServer();
server.setDatabaseVendor(DatabaseVendor.POSTGRES);
server.setAttributes(new Json(DATABASE_SERVER_ATTRIBUTES));
dbStack.setDatabaseServer(server);
dbStack.setTags(new Json(STACK_TAGS));
dbStack.setTemplate("template");
DetailedEnvironmentResponse environmentResponse = new DetailedEnvironmentResponse();
environmentResponse.setCloudPlatform("AWS");
environmentResponse.setAws(AwsEnvironmentParameters.builder().withAwsDiskEncryptionParameters(AwsDiskEncryptionParameters.builder().withEncryptionKeyArn("value").build()).build());
when(environmentService.getByCrn(anyString())).thenReturn(environmentResponse);
DatabaseStack convertedStack = underTest.convert(dbStack);
Map<String, Object> parameters = convertedStack.getDatabaseServer().getParameters();
assertThat(parameters.get("key").toString()).isEqualTo("value");
assertThat(parameters.size()).isEqualTo(3);
}
use of com.sequenceiq.redbeams.domain.stack.Network in project cloudbreak by hortonworks.
the class DBStackToDatabaseStackConverterTest method testConversionAzureWithSingleResourceGroups.
@Test
public void testConversionAzureWithSingleResourceGroups() {
Network network = new Network();
network.setAttributes(new Json(NETWORK_ATTRIBUTES));
dbStack.setNetwork(network);
dbStack.setCloudPlatform(CLOUD_PLATFORM);
dbStack.setParameters(new HashMap<>());
DatabaseServer server = new DatabaseServer();
server.setDatabaseVendor(DatabaseVendor.POSTGRES);
server.setAttributes(new Json(DATABASE_SERVER_ATTRIBUTES));
dbStack.setDatabaseServer(server);
dbStack.setTags(new Json(STACK_TAGS));
dbStack.setTemplate("template");
DetailedEnvironmentResponse environmentResponse = new DetailedEnvironmentResponse();
environmentResponse.setCloudPlatform(CLOUD_PLATFORM);
environmentResponse.setAzure(AzureEnvironmentParameters.builder().withAzureResourceGroup(AzureResourceGroup.builder().withResourceGroupUsage(ResourceGroupUsage.SINGLE).withName(RESOURCE_GROUP).build()).build());
when(environmentService.getByCrn(anyString())).thenReturn(environmentResponse);
DatabaseStack convertedStack = underTest.convert(dbStack);
Map<String, Object> parameters = convertedStack.getDatabaseServer().getParameters();
assertThat(parameters.get(RESOURCE_GROUP_NAME_PARAMETER).toString()).isEqualTo(RESOURCE_GROUP);
assertThat(parameters.get(RESOURCE_GROUP_USAGE_PARAMETER).toString()).isEqualTo(ResourceGroupUsage.SINGLE.name());
assertThat(parameters.size()).isEqualTo(4);
}
Aggregations