Here's the code:
public final class APIClient {
private static Identity identity = createIdentity();
private static Identity createIdentity() {
CredentialsProvider provider = new CredentialsProvider(API_USER);
Credentials creds = provider.getCredentials();
identity = new Identity();
identity.setAttribute(Identity.ACCESS_KEY, creds.getAccessKeyId());
identity.setAttribute(Identity.SECRET_KEY, creds.getSecretKey());
return identity;
}
}
How can I mock a CredentialsProvider
when unit test:
@Test
public void testCreateAPIClient() {
// mock a CredentialsProvider
client = new APIClient();
Assert.assertNotNull(client);
}
Thanks in advance!
Aucun commentaire:
Enregistrer un commentaire