use of com.sequenceiq.environment.environment.dto.telemetry.EnvironmentFeatures in project cloudbreak by hortonworks.
the class EnvironmentModificationServiceTest method testChangeTelemetryFeaturesByEnvironmentName.
@Test
public void testChangeTelemetryFeaturesByEnvironmentName() {
String accountId = "myAccountId";
String envName = "myEnvName";
EnvironmentFeatures featuresInput = new EnvironmentFeatures();
featuresInput.addClusterLogsCollection(true);
Environment environment = new Environment();
environment.setTelemetry(new EnvironmentTelemetry());
when(environmentService.findByNameAndAccountIdAndArchivedIsFalse(envName, accountId)).thenReturn(Optional.of(environment));
when(environmentService.save(environment)).thenReturn(environment);
when(environmentDtoConverter.environmentToDto(environment)).thenReturn(new EnvironmentDto());
environmentModificationServiceUnderTest.changeTelemetryFeaturesByEnvironmentName(accountId, envName, featuresInput);
verify(environmentService).save(any());
assertTrue(environment.getTelemetry().getFeatures().getClusterLogsCollection().isEnabled());
}
use of com.sequenceiq.environment.environment.dto.telemetry.EnvironmentFeatures in project cloudbreak by hortonworks.
the class TelemetryApiConverterTest method testConvertToRequestWithFeatures.
@Test
public void testConvertToRequestWithFeatures() {
// GIVEN
EnvironmentLogging logging = new EnvironmentLogging();
S3CloudStorageParameters s3Params = new S3CloudStorageParameters();
s3Params.setInstanceProfile(INSTANCE_PROFILE_VALUE);
logging.setS3(s3Params);
EnvironmentFeatures features = new EnvironmentFeatures();
features.addClusterLogsCollection(false);
features.addMonitoring(true);
EnvironmentTelemetry telemetry = new EnvironmentTelemetry();
telemetry.setLogging(logging);
telemetry.setFeatures(features);
// WHEN
TelemetryRequest result = underTest.convertToRequest(telemetry);
// THEN
assertNotNull(result.getFeatures());
assertFalse(result.getFeatures().getClusterLogsCollection().isEnabled());
assertTrue(result.getFeatures().getMonitoring().isEnabled());
assertEquals(INSTANCE_PROFILE_VALUE, result.getLogging().getS3().getInstanceProfile());
}
use of com.sequenceiq.environment.environment.dto.telemetry.EnvironmentFeatures in project cloudbreak by hortonworks.
the class EnvironmentController method changeTelemetryFeaturesByEnvironmentCrn.
@Override
@CheckPermissionByResourceCrn(action = AuthorizationResourceAction.EDIT_ENVIRONMENT)
public DetailedEnvironmentResponse changeTelemetryFeaturesByEnvironmentCrn(@ValidCrn(resource = CrnResourceDescriptor.ENVIRONMENT) @ResourceCrn String crn, @Valid FeaturesRequest request) {
String accountId = ThreadBasedUserCrnProvider.getAccountId();
EnvironmentFeatures features = environmentApiConverter.convertToEnvironmentTelemetryFeatures(request);
EnvironmentDto result = environmentModificationService.changeTelemetryFeaturesByEnvironmentCrn(accountId, crn, features);
return environmentResponseConverter.dtoToDetailedResponse(result);
}
use of com.sequenceiq.environment.environment.dto.telemetry.EnvironmentFeatures in project cloudbreak by hortonworks.
the class TelemetryApiConverter method createEnvironmentFeaturesFromRequest.
private EnvironmentFeatures createEnvironmentFeaturesFromRequest(FeaturesRequest featuresRequest, Features accountFeatures, String accountId) {
EnvironmentFeatures features = null;
boolean cdpSaas = entitlementService.isCdpSaasEnabled(accountId);
if (featuresRequest != null) {
features = new EnvironmentFeatures();
if (useSharedAltusCredential) {
features.addUseSharedAltusredential(true);
}
setClusterLogsCollectionFromAccountAndRequest(featuresRequest, accountFeatures, features);
setMonitoringFromAccountAndRequest(featuresRequest, accountFeatures, features, cdpSaas);
setCloudStorageLoggingFromAccountAndRequest(featuresRequest, accountFeatures, features);
if (accountFeatures.getWorkloadAnalytics() != null) {
features.setWorkloadAnalytics(accountFeatures.getWorkloadAnalytics());
}
if (featuresRequest.getWorkloadAnalytics() != null) {
features.setWorkloadAnalytics(featuresRequest.getWorkloadAnalytics());
}
}
return features;
}
use of com.sequenceiq.environment.environment.dto.telemetry.EnvironmentFeatures in project cloudbreak by hortonworks.
the class EnvironmentModificationServiceTest method testChangeTelemetryFeaturesByEnvironmentCrn.
@Test
public void testChangeTelemetryFeaturesByEnvironmentCrn() {
String accountId = "myAccountId";
String envCrn = "myEnvCrn";
EnvironmentFeatures featuresInput = new EnvironmentFeatures();
featuresInput.addCloudStorageLogging(false);
featuresInput.addClusterLogsCollection(true);
Environment environment = new Environment();
environment.setTelemetry(new EnvironmentTelemetry());
when(environmentService.findByResourceCrnAndAccountIdAndArchivedIsFalse(envCrn, accountId)).thenReturn(Optional.of(environment));
when(environmentService.save(environment)).thenReturn(environment);
when(environmentDtoConverter.environmentToDto(environment)).thenReturn(new EnvironmentDto());
environmentModificationServiceUnderTest.changeTelemetryFeaturesByEnvironmentCrn(accountId, envCrn, featuresInput);
verify(environmentService).save(any());
assertFalse(environment.getTelemetry().getFeatures().getCloudStorageLogging().isEnabled());
assertTrue(environment.getTelemetry().getFeatures().getClusterLogsCollection().isEnabled());
}
Aggregations