use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.database.DatabaseResponse in project cloudbreak by hortonworks.
the class ExternalDatabaseToDatabaseResponseConverterTest method convert.
@ParameterizedTest
@EnumSource(DatabaseAvailabilityType.class)
void convert(DatabaseAvailabilityType source) {
String databaseEngineVersion = "13";
DatabaseResponse result = underTest.convert(source, databaseEngineVersion);
assertThat(result.getAvailabilityType()).isEqualTo(source);
assertThat(result.getDatabaseEngineVersion()).isEqualTo(databaseEngineVersion);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.database.DatabaseResponse in project cloudbreak by hortonworks.
the class StackToStackV4ResponseConverterTest method testConvert.
@Test
public void testConvert() throws CloudbreakImageNotFoundException {
Stack source = getSource();
// GIVEN
given(imageService.getImage(source.getId())).willReturn(mock(Image.class));
given(imageToStackImageV4ResponseConverter.convert(any(Image.class))).willReturn(new StackImageV4Response());
given(stackAuthenticationToStackAuthenticationV4ResponseConverter.convert(any(StackAuthentication.class))).willReturn(new StackAuthenticationV4Response());
given(stackToCustomDomainsSettingsV4Response.convert(any())).willReturn(new CustomDomainSettingsV4Response());
given(clusterToClusterV4ResponseConverter.convert(any())).willReturn(new ClusterV4Response());
given(networkToNetworkV4ResponseConverter.convert(any())).willReturn(new NetworkV4Response());
given(workspaceToWorkspaceResourceV4ResponseConverter.convert(any())).willReturn(new WorkspaceResourceV4Response());
given(cloudbreakDetailsToCloudbreakDetailsV4ResponseConverter.convert(any())).willReturn(new CloudbreakDetailsV4Response());
given(stackToPlacementSettingsV4ResponseConverter.convert(any())).willReturn(new PlacementSettingsV4Response());
given(telemetryConverter.convert(any())).willReturn(new TelemetryResponse());
given(instanceGroupToInstanceGroupV4ResponseConverter.convert(any())).willReturn(new InstanceGroupV4Response());
given(databaseAvailabilityTypeToDatabaseResponseConverter.convert(any(), any())).willReturn(new DatabaseResponse());
// WHEN
StackV4Response result = underTest.convert(source);
// THEN
assertAllFieldsNotNull(result, Arrays.asList("gcp", "mock", "openstack", "aws", "yarn", "azure", "environmentName", "credentialName", "credentialCrn", "telemetry", "flowIdentifier", "loadBalancers"));
verify(restRequestThreadLocalService).setWorkspace(source.getWorkspace());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.database.DatabaseResponse in project cloudbreak by hortonworks.
the class StackToStackV4ResponseConverterTest method testConvertWithoutCluster.
@Test
public void testConvertWithoutCluster() throws CloudbreakImageNotFoundException {
Stack source = getSource();
// GIVEN
getSource().setCluster(null);
given(imageService.getImage(source.getId())).willReturn(mock(Image.class));
given(imageToStackImageV4ResponseConverter.convert(any())).willReturn(new StackImageV4Response());
given(stackToCustomDomainsSettingsV4Response.convert(any())).willReturn(new CustomDomainSettingsV4Response());
given(stackAuthenticationToStackAuthenticationV4ResponseConverter.convert(any())).willReturn(new StackAuthenticationV4Response());
given(networkToNetworkV4ResponseConverter.convert(any())).willReturn(new NetworkV4Response());
given(workspaceToWorkspaceResourceV4ResponseConverter.convert(any())).willReturn(new WorkspaceResourceV4Response());
given(cloudbreakDetailsToCloudbreakDetailsV4ResponseConverter.convert(any())).willReturn(new CloudbreakDetailsV4Response());
given(stackToPlacementSettingsV4ResponseConverter.convert(any())).willReturn(new PlacementSettingsV4Response());
given(telemetryConverter.convert(any())).willReturn(new TelemetryResponse());
given(instanceGroupToInstanceGroupV4ResponseConverter.convert(any())).willReturn(new InstanceGroupV4Response());
given(databaseAvailabilityTypeToDatabaseResponseConverter.convert(any(), any())).willReturn(new DatabaseResponse());
// WHEN
StackV4Response result = underTest.convert(source);
// THEN
assertAllFieldsNotNull(result, Arrays.asList("cluster", "gcp", "mock", "openstack", "aws", "yarn", "azure", "telemetry", "environmentName", "credentialName", "credentialCrn", "telemetry", "flowIdentifier", "loadBalancers"));
assertNull(result.getCluster());
verify(restRequestThreadLocalService).setWorkspace(source.getWorkspace());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.database.DatabaseResponse in project cloudbreak by hortonworks.
the class StackToStackV4ResponseConverterTest method testConvertWithLoadBalancers.
@Test
public void testConvertWithLoadBalancers() throws CloudbreakImageNotFoundException {
Set<LoadBalancer> loadBalancers = Set.of(new LoadBalancer());
Stack source = getSource();
// GIVEN
given(imageService.getImage(source.getId())).willReturn(mock(Image.class));
given(imageToStackImageV4ResponseConverter.convert(any())).willReturn(new StackImageV4Response());
given(stackToCustomDomainsSettingsV4Response.convert(any())).willReturn(new CustomDomainSettingsV4Response());
given(stackAuthenticationToStackAuthenticationV4ResponseConverter.convert(any())).willReturn(new StackAuthenticationV4Response());
given(networkToNetworkV4ResponseConverter.convert(any())).willReturn(new NetworkV4Response());
given(workspaceToWorkspaceResourceV4ResponseConverter.convert(any())).willReturn(new WorkspaceResourceV4Response());
given(cloudbreakDetailsToCloudbreakDetailsV4ResponseConverter.convert(any())).willReturn(new CloudbreakDetailsV4Response());
given(stackToPlacementSettingsV4ResponseConverter.convert(any())).willReturn(new PlacementSettingsV4Response());
given(telemetryConverter.convert(any())).willReturn(new TelemetryResponse());
given(instanceGroupToInstanceGroupV4ResponseConverter.convert(any())).willReturn(new InstanceGroupV4Response());
given(databaseAvailabilityTypeToDatabaseResponseConverter.convert(any(), any())).willReturn(new DatabaseResponse());
given(loadBalancerService.findByStackId(any())).willReturn(loadBalancers);
// WHEN
source.setLoadBalancers(loadBalancers);
StackV4Response result = underTest.convert(source);
// THEN
assertNotNull(result.getLoadBalancers());
assertTrue(result.isEnableLoadBalancer());
verify(restRequestThreadLocalService).setWorkspace(source.getWorkspace());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.database.DatabaseResponse in project cloudbreak by hortonworks.
the class ExternalDatabaseToDatabaseResponseConverter method convert.
public DatabaseResponse convert(DatabaseAvailabilityType availabilityType, String externalDatabaseEngineVersion) {
if (allNull(availabilityType, externalDatabaseEngineVersion)) {
return null;
} else {
DatabaseResponse response = new DatabaseResponse();
response.setAvailabilityType(availabilityType);
response.setDatabaseEngineVersion(externalDatabaseEngineVersion);
return response;
}
}
Aggregations