@Test public void testChangeTelemetryFeaturesByEnvironmentCrn() { String accountId = "myAccountId"; String envCrn = "myEnvCrn"; EnvironmentFeatures featuresInput = new EnvironmentFeatures(); 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()); assertTrue(environment.getTelemetry().getFeatures().getClusterLogsCollection().isEnabled()); }
public EnvironmentDto changeTelemetryFeaturesByEnvironmentCrn(String accountId, String crn, EnvironmentFeatures features) { Environment environment = environmentService .findByResourceCrnAndAccountIdAndArchivedIsFalse(crn, accountId) .orElseThrow(() -> new NotFoundException(String.format("No environment found with CRN '%s'", crn))); return changeTelemetryFeatures(features, environment); }
EnvironmentModificationService { public EnvironmentDto changeTelemetryFeaturesByEnvironmentCrn(String accountId, String crn, EnvironmentFeatures features) { Environment environment = environmentService .findByResourceCrnAndAccountIdAndArchivedIsFalse(crn, accountId) .orElseThrow(() -> new NotFoundException(String.format("No environment found with CRN '%s'", crn))); return changeTelemetryFeatures(features, environment); } }
EnvironmentModificationService { public EnvironmentDto changeTelemetryFeaturesByEnvironmentCrn(String accountId, String crn, EnvironmentFeatures features) { Environment environment = environmentService .findByResourceCrnAndAccountIdAndArchivedIsFalse(crn, accountId) .orElseThrow(() -> new NotFoundException(String.format("No environment found with CRN '%s'", crn))); return changeTelemetryFeatures(features, environment); } EnvironmentModificationService(EnvironmentDtoConverter environmentDtoConverter, EnvironmentService environmentService,
            CredentialService credentialService, NetworkService networkService, AuthenticationDtoConverter authenticationDtoConverter,
            ParametersService parametersService, EnvironmentFlowValidatorService environmentFlowValidatorService,
            EnvironmentResourceService environmentResourceService); }
EnvironmentModificationService { public EnvironmentDto changeTelemetryFeaturesByEnvironmentCrn(String accountId, String crn, EnvironmentFeatures features) { Environment environment = environmentService .findByResourceCrnAndAccountIdAndArchivedIsFalse(crn, accountId) .orElseThrow(() -> new NotFoundException(String.format("No environment found with CRN '%s'", crn))); return changeTelemetryFeatures(features, environment); } EnvironmentModificationService(EnvironmentDtoConverter environmentDtoConverter, EnvironmentService environmentService,
            CredentialService credentialService, NetworkService networkService, AuthenticationDtoConverter authenticationDtoConverter,
            ParametersService parametersService, EnvironmentFlowValidatorService environmentFlowValidatorService,
            EnvironmentResourceService environmentResourceService); EnvironmentDto editByName(String environmentName, EnvironmentEditDto editDto); EnvironmentDto editByCrn(String crn, EnvironmentEditDto editDto); EnvironmentDto changeCredentialByEnvironmentName(String accountId, String environmentName, EnvironmentChangeCredentialDto dto); EnvironmentDto changeCredentialByEnvironmentCrn(String accountId, String crn, EnvironmentChangeCredentialDto dto); EnvironmentDto changeTelemetryFeaturesByEnvironmentName(String accountId, String environmentName,
            EnvironmentFeatures features); EnvironmentDto changeTelemetryFeaturesByEnvironmentCrn(String accountId, String crn,
            EnvironmentFeatures features); }
EnvironmentModificationService { public EnvironmentDto changeTelemetryFeaturesByEnvironmentCrn(String accountId, String crn, EnvironmentFeatures features) { Environment environment = environmentService .findByResourceCrnAndAccountIdAndArchivedIsFalse(crn, accountId) .orElseThrow(() -> new NotFoundException(String.format("No environment found with CRN '%s'", crn))); return changeTelemetryFeatures(features, environment); } EnvironmentModificationService(EnvironmentDtoConverter environmentDtoConverter, EnvironmentService environmentService,
            CredentialService credentialService, NetworkService networkService, AuthenticationDtoConverter authenticationDtoConverter,
            ParametersService parametersService, EnvironmentFlowValidatorService environmentFlowValidatorService,
            EnvironmentResourceService environmentResourceService); EnvironmentDto editByName(String environmentName, EnvironmentEditDto editDto); EnvironmentDto editByCrn(String crn, EnvironmentEditDto editDto); EnvironmentDto changeCredentialByEnvironmentName(String accountId, String environmentName, EnvironmentChangeCredentialDto dto); EnvironmentDto changeCredentialByEnvironmentCrn(String accountId, String crn, EnvironmentChangeCredentialDto dto); EnvironmentDto changeTelemetryFeaturesByEnvironmentName(String accountId, String environmentName,
            EnvironmentFeatures features); EnvironmentDto changeTelemetryFeaturesByEnvironmentCrn(String accountId, String crn,
            EnvironmentFeatures features);  }