@Test void testConvertWhenCloudStorageLocationsIsEmptyAndEnvironmentHasTelemetryWithLogging() { 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()))); assertTrue(result.getLocations().isEmpty()); }
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; }
CloudStorageDecorator { 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; } }
CloudStorageDecorator { 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; }  }
CloudStorageDecorator { 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; }  CloudStorageRequest decorate(String blueprintName,
        String clusterName,
        CloudStorageRequest request,
        DetailedEnvironmentResponse environment); void updateDynamoDBTable(CloudStorageRequest request, DetailedEnvironmentResponse environment); CloudStorageRequest updateCloudStorageLocations(String blueprintName, String clusterName,
        CloudStorageRequest request, List<SdxClusterResponse> datalakes); boolean storageLocationsNotDefined(CloudStorageRequest request); }
CloudStorageDecorator { 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; }  CloudStorageRequest decorate(String blueprintName,
        String clusterName,
        CloudStorageRequest request,
        DetailedEnvironmentResponse environment); void updateDynamoDBTable(CloudStorageRequest request, DetailedEnvironmentResponse environment); CloudStorageRequest updateCloudStorageLocations(String blueprintName, String clusterName,
        CloudStorageRequest request, List<SdxClusterResponse> datalakes); boolean storageLocationsNotDefined(CloudStorageRequest request);  }