use of com.sequenceiq.common.api.telemetry.response.TelemetryResponse in project cloudbreak by hortonworks.
the class EnvironmentResponseConverterTest method testDtoToSimpleResponse.
@ParameterizedTest
@EnumSource(value = CloudPlatform.class, names = { "AWS", "AZURE" })
void testDtoToSimpleResponse(CloudPlatform cloudPlatform) {
EnvironmentDto environmentDto = createEnvironmentDto(cloudPlatform);
CredentialViewResponse credentialResponse = mock(CredentialViewResponse.class);
FreeIpaResponse freeIpaResponse = mock(FreeIpaResponse.class);
CompactRegionResponse compactRegionResponse = mock(CompactRegionResponse.class);
TelemetryResponse telemetryResponse = mock(TelemetryResponse.class);
ProxyViewResponse proxyResponse = mock(ProxyViewResponse.class);
EnvironmentNetworkResponse environmentNetworkResponse = mock(EnvironmentNetworkResponse.class);
when(credentialViewConverter.convertResponse(environmentDto.getCredential())).thenReturn(credentialResponse);
when(freeIpaConverter.convert(environmentDto.getFreeIpaCreation())).thenReturn(freeIpaResponse);
when(regionConverter.convertRegions(environmentDto.getRegions())).thenReturn(compactRegionResponse);
when(telemetryApiConverter.convert(environmentDto.getTelemetry())).thenReturn(telemetryResponse);
when(proxyConfigToProxyResponseConverter.convertToView(environmentDto.getProxyConfig())).thenReturn(proxyResponse);
when(networkDtoToResponseConverter.convert(environmentDto.getNetwork(), environmentDto.getExperimentalFeatures().getTunnel(), false)).thenReturn(environmentNetworkResponse);
SimpleEnvironmentResponse actual = underTest.dtoToSimpleResponse(environmentDto, true, true);
assertEquals(environmentDto.getResourceCrn(), actual.getCrn());
assertEquals(environmentDto.getName(), actual.getName());
assertEquals(environmentDto.getOriginalName(), actual.getOriginalName());
assertEquals(environmentDto.getDescription(), actual.getDescription());
assertEquals(environmentDto.getCloudPlatform(), actual.getCloudPlatform());
assertEquals(credentialResponse, actual.getCredential());
assertEquals(environmentDto.getStatus().getResponseStatus(), actual.getEnvironmentStatus());
assertEquals(environmentDto.getCreator(), actual.getCreator());
assertLocation(environmentDto.getLocation(), actual.getLocation());
assertTrue(actual.getCreateFreeIpa());
assertEquals(freeIpaResponse, actual.getFreeIpa());
assertEquals(environmentDto.getStatusReason(), actual.getStatusReason());
assertEquals(environmentDto.getCreated(), actual.getCreated());
assertEquals(environmentDto.getExperimentalFeatures().getTunnel(), actual.getTunnel());
assertEquals(environmentDto.getExperimentalFeatures().getCcmV2TlsType(), actual.getCcmV2TlsType());
assertEquals(environmentDto.getAdminGroupName(), actual.getAdminGroupName());
assertEquals(environmentDto.getTags().getUserDefinedTags(), actual.getTags().getUserDefined());
assertEquals(environmentDto.getTags().getDefaultTags(), actual.getTags().getDefaults());
assertEquals(telemetryResponse, actual.getTelemetry());
assertEquals(compactRegionResponse, actual.getRegions());
assertParameters(environmentDto, actual, cloudPlatform);
assertEquals(environmentDto.getParentEnvironmentName(), actual.getParentEnvironmentName());
assertEquals(proxyResponse, actual.getProxyConfig());
assertEquals(environmentNetworkResponse, actual.getNetwork());
verify(credentialViewConverter).convertResponse(environmentDto.getCredential());
verify(freeIpaConverter).convert(environmentDto.getFreeIpaCreation());
verify(regionConverter).convertRegions(environmentDto.getRegions());
verify(telemetryApiConverter).convert(environmentDto.getTelemetry());
verify(proxyConfigToProxyResponseConverter).convertToView(environmentDto.getProxyConfig());
verify(networkDtoToResponseConverter).convert(environmentDto.getNetwork(), environmentDto.getExperimentalFeatures().getTunnel(), false);
}
use of com.sequenceiq.common.api.telemetry.response.TelemetryResponse in project cloudbreak by hortonworks.
the class TelemetryApiConverterTest method testConvertToResponse.
@Test
public void testConvertToResponse() {
// GIVEN
EnvironmentLogging logging = new EnvironmentLogging();
S3CloudStorageParameters s3Params = new S3CloudStorageParameters();
s3Params.setInstanceProfile(INSTANCE_PROFILE_VALUE);
logging.setS3(s3Params);
EnvironmentTelemetry telemetry = new EnvironmentTelemetry();
telemetry.setLogging(logging);
// WHEN
TelemetryResponse result = underTest.convert(telemetry);
// THEN
assertEquals(INSTANCE_PROFILE_VALUE, result.getLogging().getS3().getInstanceProfile());
assertNull(result.getWorkloadAnalytics());
}
use of com.sequenceiq.common.api.telemetry.response.TelemetryResponse in project cloudbreak by hortonworks.
the class TelemetryApiConverter method convert.
public TelemetryResponse convert(EnvironmentTelemetry telemetry) {
TelemetryResponse response = null;
if (telemetry != null) {
response = new TelemetryResponse();
response.setLogging(createLoggingResponseFromSource(telemetry.getLogging()));
response.setMonitoring(createMonitoringResponseFromSource(telemetry.getMonitoring()));
response.setWorkloadAnalytics(createWorkloadAnalyticsResponseFromSource(telemetry.getWorkloadAnalytics()));
response.setFluentAttributes(telemetry.getFluentAttributes());
response.setFeatures(createFeaturesResponseFromSource(telemetry.getFeatures()));
response.setFluentAttributes(telemetry.getFluentAttributes());
}
return response;
}
use of com.sequenceiq.common.api.telemetry.response.TelemetryResponse in project cloudbreak by hortonworks.
the class CloudStorageDecoratorTest method testConvertWhenCloudStorageLocationsIsNullAndEnvironmentHasTelemetryWithLogging.
@Test
void testConvertWhenCloudStorageLocationsIsNullAndEnvironmentHasTelemetryWithLogging() {
DetailedEnvironmentResponse environment = new DetailedEnvironmentResponse();
TelemetryResponse telemetry = new TelemetryResponse();
telemetry.setLogging(new LoggingResponse());
environment.setTelemetry(telemetry);
CloudStorageRequest result = underTest.decorate(BLUEPRINT_NAME, CLUSTER_NAME, null, environment);
assertNotNull(result);
assertTrue(result.getIdentities().stream().anyMatch(id -> CloudIdentityType.LOG.equals(id.getType())));
}
use of com.sequenceiq.common.api.telemetry.response.TelemetryResponse in project cloudbreak by hortonworks.
the class CloudStorageDecorator method decorate.
public CloudStorageRequest decorate(String blueprintName, String clusterName, CloudStorageRequest request, DetailedEnvironmentResponse environment) {
if (environment != null) {
if (request == null) {
request = new CloudStorageRequest();
}
TelemetryResponse telemetry = environment.getTelemetry();
if (telemetry != null && telemetry.getLogging() != null) {
LoggingResponse logging = telemetry.getLogging();
StorageIdentityBase identity = new StorageIdentityBase();
identity.setType(CloudIdentityType.LOG);
identity.setS3(logging.getS3());
identity.setAdlsGen2(logging.getAdlsGen2());
identity.setGcs(logging.getGcs());
List<StorageIdentityBase> identities = request.getIdentities();
if (identities == null) {
identities = new ArrayList<>();
}
boolean logConfiguredInRequest = false;
for (StorageIdentityBase identityBase : identities) {
if (CloudIdentityType.LOG.equals(identityBase.getType())) {
logConfiguredInRequest = true;
}
}
if (!logConfiguredInRequest) {
identities.add(identity);
}
request.setIdentities(identities);
}
List<SdxClusterResponse> datalakes = sdxClientService.getByEnvironmentCrn(environment.getCrn());
updateCloudStorageLocations(blueprintName, clusterName, request, datalakes);
updateDynamoDBTable(request, environment);
}
return request;
}
Aggregations