@Test void getCredentialFromRequest() { Credential value = new Credential(); when(credentialService.getByNameForAccountId(eq(ENVIRONMENT_NAME), eq(ACCOUNT_ID), any())).thenReturn(value); assertEquals(value, environmentResourceServiceUnderTest.getCredentialFromRequest(request, ACCOUNT_ID)); }
public Credential getCredentialFromRequest(CredentialAwareEnvRequest request, String accountId) { Credential credential; if (StringUtils.isNotEmpty(request.getCredentialName())) { try { credential = credentialService.getByNameForAccountId(request.getCredentialName(), accountId, ENVIRONMENT); } catch (NotFoundException e) { throw new BadRequestException(String.format("No credential found with name [%s] in the workspace.", request.getCredentialName()), e); } } else { throw new BadRequestException("No credential has been specified in request for environment creation."); } return credential; }
EnvironmentResourceService { public Credential getCredentialFromRequest(CredentialAwareEnvRequest request, String accountId) { Credential credential; if (StringUtils.isNotEmpty(request.getCredentialName())) { try { credential = credentialService.getByNameForAccountId(request.getCredentialName(), accountId, ENVIRONMENT); } catch (NotFoundException e) { throw new BadRequestException(String.format("No credential found with name [%s] in the workspace.", request.getCredentialName()), e); } } else { throw new BadRequestException("No credential has been specified in request for environment creation."); } return credential; } }
EnvironmentResourceService { public Credential getCredentialFromRequest(CredentialAwareEnvRequest request, String accountId) { Credential credential; if (StringUtils.isNotEmpty(request.getCredentialName())) { try { credential = credentialService.getByNameForAccountId(request.getCredentialName(), accountId, ENVIRONMENT); } catch (NotFoundException e) { throw new BadRequestException(String.format("No credential found with name [%s] in the workspace.", request.getCredentialName()), e); } } else { throw new BadRequestException("No credential has been specified in request for environment creation."); } return credential; } EnvironmentResourceService(CredentialService credentialService, NetworkService networkService, CloudPlatformConnectors cloudPlatformConnectors,
            CredentialToCloudCredentialConverter credentialToCloudCredentialConverter, Clock clock, ProxyConfigService proxyConfigService); }
EnvironmentResourceService { public Credential getCredentialFromRequest(CredentialAwareEnvRequest request, String accountId) { Credential credential; if (StringUtils.isNotEmpty(request.getCredentialName())) { try { credential = credentialService.getByNameForAccountId(request.getCredentialName(), accountId, ENVIRONMENT); } catch (NotFoundException e) { throw new BadRequestException(String.format("No credential found with name [%s] in the workspace.", request.getCredentialName()), e); } } else { throw new BadRequestException("No credential has been specified in request for environment creation."); } return credential; } EnvironmentResourceService(CredentialService credentialService, NetworkService networkService, CloudPlatformConnectors cloudPlatformConnectors,
            CredentialToCloudCredentialConverter credentialToCloudCredentialConverter, Clock clock, ProxyConfigService proxyConfigService); Credential getCredentialFromRequest(CredentialAwareEnvRequest request, String accountId); Optional<ProxyConfig> getProxyConfig(String proxyConfigName, String accountId); boolean createAndUpdateSshKey(Environment environment); Optional<PublicKeyConnector> getPublicKeyConnector(String cloudPlatform); BaseNetwork createAndSetNetwork(Environment environment, NetworkDto networkDto, String accountId, Map<String, CloudSubnet> subnetMetas); void deletePublicKey(Environment environment); void deletePublicKey(Environment environment, String publicKeyId); boolean isPublicKeyIdExists(Environment environment, String publicKeyId); }
EnvironmentResourceService { public Credential getCredentialFromRequest(CredentialAwareEnvRequest request, String accountId) { Credential credential; if (StringUtils.isNotEmpty(request.getCredentialName())) { try { credential = credentialService.getByNameForAccountId(request.getCredentialName(), accountId, ENVIRONMENT); } catch (NotFoundException e) { throw new BadRequestException(String.format("No credential found with name [%s] in the workspace.", request.getCredentialName()), e); } } else { throw new BadRequestException("No credential has been specified in request for environment creation."); } return credential; } EnvironmentResourceService(CredentialService credentialService, NetworkService networkService, CloudPlatformConnectors cloudPlatformConnectors,
            CredentialToCloudCredentialConverter credentialToCloudCredentialConverter, Clock clock, ProxyConfigService proxyConfigService); Credential getCredentialFromRequest(CredentialAwareEnvRequest request, String accountId); Optional<ProxyConfig> getProxyConfig(String proxyConfigName, String accountId); boolean createAndUpdateSshKey(Environment environment); Optional<PublicKeyConnector> getPublicKeyConnector(String cloudPlatform); BaseNetwork createAndSetNetwork(Environment environment, NetworkDto networkDto, String accountId, Map<String, CloudSubnet> subnetMetas); void deletePublicKey(Environment environment); void deletePublicKey(Environment environment, String publicKeyId); boolean isPublicKeyIdExists(Environment environment, String publicKeyId);  }