### Question:
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);  }### Answer:
@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()); }
@Test public void testAzureCredential() { CredentialResponse credentialResponse = new CredentialResponse(); credentialResponse.setCrn(CRN); credentialResponse.setName(NAME); credentialResponse.setAttributes(secretResponse); AzureCredentialResponseParameters azureResponse = new AzureCredentialResponseParameters(); azureResponse.setSubscriptionId(SUBSCRIPTION_ID); credentialResponse.setAzure(azureResponse); 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()); assertTrue(credential.getAzure().isPresent()); assertEquals(SUBSCRIPTION_ID, credential.getAzure().get().getSubscriptionId()); }