@Test void editByNameParametersNotExisted() { String dynamotable = "dynamotable"; ParametersDto parameters = ParametersDto.builder() .withAccountId(ACCOUNT_ID) .withAwsParameters(AwsParametersDto.builder() .withDynamoDbTableName(dynamotable) .build()) .build(); EnvironmentEditDto environmentDto = EnvironmentEditDto.builder() .withAccountId(ACCOUNT_ID) .withParameters(parameters) .build(); Environment environment = new Environment(); environment.setAccountId(ACCOUNT_ID); BaseParameters baseParameters = new AwsParameters(); when(environmentService .findByNameAndAccountIdAndArchivedIsFalse(eq(ENVIRONMENT_NAME), eq(ACCOUNT_ID))).thenReturn(Optional.of(environment)); when(parametersService.saveParameters(environment, parameters)).thenReturn(baseParameters); environmentModificationServiceUnderTest.editByName(ENVIRONMENT_NAME, environmentDto); verify(parametersService).saveParameters(environment, parameters); assertEquals(baseParameters, environment.getParameters()); }
public EnvironmentDto editByName(String environmentName, EnvironmentEditDto editDto) { Environment env = environmentService .findByNameAndAccountIdAndArchivedIsFalse(environmentName, editDto.getAccountId()) .orElseThrow(() -> new NotFoundException(String.format("No environment found with name '%s'", environmentName))); return edit(editDto, env); }
EnvironmentModificationService { public EnvironmentDto editByName(String environmentName, EnvironmentEditDto editDto) { Environment env = environmentService .findByNameAndAccountIdAndArchivedIsFalse(environmentName, editDto.getAccountId()) .orElseThrow(() -> new NotFoundException(String.format("No environment found with name '%s'", environmentName))); return edit(editDto, env); } }
EnvironmentModificationService { public EnvironmentDto editByName(String environmentName, EnvironmentEditDto editDto) { Environment env = environmentService .findByNameAndAccountIdAndArchivedIsFalse(environmentName, editDto.getAccountId()) .orElseThrow(() -> new NotFoundException(String.format("No environment found with name '%s'", environmentName))); return edit(editDto, env); } EnvironmentModificationService(EnvironmentDtoConverter environmentDtoConverter, EnvironmentService environmentService,
            CredentialService credentialService, NetworkService networkService, AuthenticationDtoConverter authenticationDtoConverter,
            ParametersService parametersService, EnvironmentFlowValidatorService environmentFlowValidatorService,
            EnvironmentResourceService environmentResourceService); }
EnvironmentModificationService { public EnvironmentDto editByName(String environmentName, EnvironmentEditDto editDto) { Environment env = environmentService .findByNameAndAccountIdAndArchivedIsFalse(environmentName, editDto.getAccountId()) .orElseThrow(() -> new NotFoundException(String.format("No environment found with name '%s'", environmentName))); return edit(editDto, env); } 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 editByName(String environmentName, EnvironmentEditDto editDto) { Environment env = environmentService .findByNameAndAccountIdAndArchivedIsFalse(environmentName, editDto.getAccountId()) .orElseThrow(() -> new NotFoundException(String.format("No environment found with name '%s'", environmentName))); return edit(editDto, env); } 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);  }