@Test public void shouldGetSellerCredentials() throws Exception { when(System.getenv("PSL_EMAIL")).thenReturn("email"); when(System.getenv("PSL_TOKEN")).thenReturn("token"); Credential expectedCredential = Credential.sellerCredential("email", "token"); Credential credential = provider.getCredential(); assertEquals(expectedCredential, credential); }
@Override public Credential getCredential() { LOGGER.info("Lendo credenciais"); final Credential credential; if (System.getenv("PSL_EMAIL") != null && System.getenv("PSL_TOKEN") != null) { credential = Credential.sellerCredential(System.getenv("PSL_EMAIL").trim(), System.getenv("PSL_TOKEN").trim()); } else if (System.getenv("PSL_APP_ID") != null && System.getenv("PSL_APP_KEY") != null) { credential = Credential.applicationCredential(System.getenv("PSL_APP_ID").trim(), System.getenv("PSL_APP_KEY").trim()); } else { throw new IllegalArgumentException("Seller credential and Application credential not found"); } LOGGER.info("Credenciais lidas"); return credential; }
SystemEnvVariableCredentialProvider implements CredentialProvider { @Override public Credential getCredential() { LOGGER.info("Lendo credenciais"); final Credential credential; if (System.getenv("PSL_EMAIL") != null && System.getenv("PSL_TOKEN") != null) { credential = Credential.sellerCredential(System.getenv("PSL_EMAIL").trim(), System.getenv("PSL_TOKEN").trim()); } else if (System.getenv("PSL_APP_ID") != null && System.getenv("PSL_APP_KEY") != null) { credential = Credential.applicationCredential(System.getenv("PSL_APP_ID").trim(), System.getenv("PSL_APP_KEY").trim()); } else { throw new IllegalArgumentException("Seller credential and Application credential not found"); } LOGGER.info("Credenciais lidas"); return credential; } }
SystemEnvVariableCredentialProvider implements CredentialProvider { @Override public Credential getCredential() { LOGGER.info("Lendo credenciais"); final Credential credential; if (System.getenv("PSL_EMAIL") != null && System.getenv("PSL_TOKEN") != null) { credential = Credential.sellerCredential(System.getenv("PSL_EMAIL").trim(), System.getenv("PSL_TOKEN").trim()); } else if (System.getenv("PSL_APP_ID") != null && System.getenv("PSL_APP_KEY") != null) { credential = Credential.applicationCredential(System.getenv("PSL_APP_ID").trim(), System.getenv("PSL_APP_KEY").trim()); } else { throw new IllegalArgumentException("Seller credential and Application credential not found"); } LOGGER.info("Credenciais lidas"); return credential; } SystemEnvVariableCredentialProvider(); }
SystemEnvVariableCredentialProvider implements CredentialProvider { @Override public Credential getCredential() { LOGGER.info("Lendo credenciais"); final Credential credential; if (System.getenv("PSL_EMAIL") != null && System.getenv("PSL_TOKEN") != null) { credential = Credential.sellerCredential(System.getenv("PSL_EMAIL").trim(), System.getenv("PSL_TOKEN").trim()); } else if (System.getenv("PSL_APP_ID") != null && System.getenv("PSL_APP_KEY") != null) { credential = Credential.applicationCredential(System.getenv("PSL_APP_ID").trim(), System.getenv("PSL_APP_KEY").trim()); } else { throw new IllegalArgumentException("Seller credential and Application credential not found"); } LOGGER.info("Credenciais lidas"); return credential; } SystemEnvVariableCredentialProvider(); @Override Credential getCredential(); }
SystemEnvVariableCredentialProvider implements CredentialProvider { @Override public Credential getCredential() { LOGGER.info("Lendo credenciais"); final Credential credential; if (System.getenv("PSL_EMAIL") != null && System.getenv("PSL_TOKEN") != null) { credential = Credential.sellerCredential(System.getenv("PSL_EMAIL").trim(), System.getenv("PSL_TOKEN").trim()); } else if (System.getenv("PSL_APP_ID") != null && System.getenv("PSL_APP_KEY") != null) { credential = Credential.applicationCredential(System.getenv("PSL_APP_ID").trim(), System.getenv("PSL_APP_KEY").trim()); } else { throw new IllegalArgumentException("Seller credential and Application credential not found"); } LOGGER.info("Credenciais lidas"); return credential; } SystemEnvVariableCredentialProvider(); @Override Credential getCredential();  }