@Test public void testNonAzureCredential() { CredentialResponse credentialResponse = new CredentialResponse(); credentialResponse.setCrn(CRN); credentialResponse.setName(NAME); credentialResponse.setAttributes(secretResponse); when(credentialEndpoint.getByEnvironmentCrn(ENVIRONMENT_CRN)).thenReturn(credentialResponse); Credential credential = underTest.getCredentialByEnvCrn(ENVIRONMENT_CRN); assertEquals(CRN, credential.getCrn()); assertEquals(NAME, credential.getName()); assertEquals(ATTRIBUTES, credential.getAttributes()); assertFalse(credential.getAzure().isPresent()); }
public Credential getCredentialByEnvCrn(String envCrn) { CredentialResponse credentialResponse = credentialEndpoint.getByEnvironmentCrn(envCrn); SecretResponse secretResponse = credentialResponse.getAttributes(); String attributes = secretService.getByResponse(secretResponse); if (credentialResponse.getAzure() != null) { return new Credential(credentialResponse.getCrn(), credentialResponse.getName(), attributes, new Credential.AzureParameters(credentialResponse.getAzure().getSubscriptionId())); } else { return new Credential(credentialResponse.getCrn(), credentialResponse.getName(), attributes); } }
CredentialService { public Credential getCredentialByEnvCrn(String envCrn) { CredentialResponse credentialResponse = credentialEndpoint.getByEnvironmentCrn(envCrn); SecretResponse secretResponse = credentialResponse.getAttributes(); String attributes = secretService.getByResponse(secretResponse); if (credentialResponse.getAzure() != null) { return new Credential(credentialResponse.getCrn(), credentialResponse.getName(), attributes, new Credential.AzureParameters(credentialResponse.getAzure().getSubscriptionId())); } else { return new Credential(credentialResponse.getCrn(), credentialResponse.getName(), attributes); } } }
CredentialService { public Credential getCredentialByEnvCrn(String envCrn) { CredentialResponse credentialResponse = credentialEndpoint.getByEnvironmentCrn(envCrn); SecretResponse secretResponse = credentialResponse.getAttributes(); String attributes = secretService.getByResponse(secretResponse); if (credentialResponse.getAzure() != null) { return new Credential(credentialResponse.getCrn(), credentialResponse.getName(), attributes, new Credential.AzureParameters(credentialResponse.getAzure().getSubscriptionId())); } else { return new Credential(credentialResponse.getCrn(), credentialResponse.getName(), attributes); } }  }
CredentialService { public Credential getCredentialByEnvCrn(String envCrn) { CredentialResponse credentialResponse = credentialEndpoint.getByEnvironmentCrn(envCrn); SecretResponse secretResponse = credentialResponse.getAttributes(); String attributes = secretService.getByResponse(secretResponse); if (credentialResponse.getAzure() != null) { return new Credential(credentialResponse.getCrn(), credentialResponse.getName(), attributes, new Credential.AzureParameters(credentialResponse.getAzure().getSubscriptionId())); } else { return new Credential(credentialResponse.getCrn(), credentialResponse.getName(), attributes); } }  Credential getCredentialByEnvCrn(String envCrn); }
CredentialService { public Credential getCredentialByEnvCrn(String envCrn) { CredentialResponse credentialResponse = credentialEndpoint.getByEnvironmentCrn(envCrn); SecretResponse secretResponse = credentialResponse.getAttributes(); String attributes = secretService.getByResponse(secretResponse); if (credentialResponse.getAzure() != null) { return new Credential(credentialResponse.getCrn(), credentialResponse.getName(), attributes, new Credential.AzureParameters(credentialResponse.getAzure().getSubscriptionId())); } else { return new Credential(credentialResponse.getCrn(), credentialResponse.getName(), attributes); } }  Credential getCredentialByEnvCrn(String envCrn);  }