@Test void testConvertWhenEnvironmentDoesNotHaveTelemetryButCloudStorageLocationsIsNotEmpty() { CloudStorageCdpService eStorageLocationType = CloudStorageCdpService.RANGER_AUDIT; String eStorageLocationValue = "MYBUCKET/CONTAINER"; StorageLocationBase storageLocationBase = new StorageLocationBase(); storageLocationBase.setType(eStorageLocationType); storageLocationBase.setValue(eStorageLocationValue); List<StorageLocationBase> storageLocations = List.of(storageLocationBase); CloudStorageRequest request = new CloudStorageRequest(); request.setLocations(storageLocations); CloudStorageRequest result = underTest.decorate(BLUEPRINT_NAME, CLUSTER_NAME, request, new DetailedEnvironmentResponse()); assertNotNull(result); assertTrue(result.getLocations().stream().anyMatch(loc -> eStorageLocationType.equals(loc.getType()) && eStorageLocationValue.equals(loc.getValue()))); }
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);  }