@Test public void shouldGetApplicationCredentials() throws Exception { provider = new SystemPropCredentialProvider("pagseguro2.properties"); Credential expectedCredential = Credential.applicationCredential("appId", "appKey"); Credential credential = provider.getCredential(); assertEquals(expectedCredential, credential); }
@Override public Credential getCredential() throws Exception { LOGGER.info("Lendo credenciais"); final Credential credential; InputStream inputStream = getClass().getClassLoader().getResourceAsStream(file); Properties properties = new Properties(); properties.load(inputStream); if (properties.getProperty("email") != null && properties.getProperty("token") != null) { credential = Credential.sellerCredential(properties.getProperty("email"), properties.getProperty("token")); } else if (properties.getProperty("appId") != null && properties.getProperty("appKey") != null) { credential = Credential.applicationCredential(properties.getProperty("appId"), properties.getProperty("appKey")); } else { throw new IllegalArgumentException("Seller credential and Application credential not found"); } inputStream.close(); LOGGER.info("Credenciais lidas"); return credential; }
SystemPropCredentialProvider implements CredentialProvider { @Override public Credential getCredential() throws Exception { LOGGER.info("Lendo credenciais"); final Credential credential; InputStream inputStream = getClass().getClassLoader().getResourceAsStream(file); Properties properties = new Properties(); properties.load(inputStream); if (properties.getProperty("email") != null && properties.getProperty("token") != null) { credential = Credential.sellerCredential(properties.getProperty("email"), properties.getProperty("token")); } else if (properties.getProperty("appId") != null && properties.getProperty("appKey") != null) { credential = Credential.applicationCredential(properties.getProperty("appId"), properties.getProperty("appKey")); } else { throw new IllegalArgumentException("Seller credential and Application credential not found"); } inputStream.close(); LOGGER.info("Credenciais lidas"); return credential; } }
SystemPropCredentialProvider implements CredentialProvider { @Override public Credential getCredential() throws Exception { LOGGER.info("Lendo credenciais"); final Credential credential; InputStream inputStream = getClass().getClassLoader().getResourceAsStream(file); Properties properties = new Properties(); properties.load(inputStream); if (properties.getProperty("email") != null && properties.getProperty("token") != null) { credential = Credential.sellerCredential(properties.getProperty("email"), properties.getProperty("token")); } else if (properties.getProperty("appId") != null && properties.getProperty("appKey") != null) { credential = Credential.applicationCredential(properties.getProperty("appId"), properties.getProperty("appKey")); } else { throw new IllegalArgumentException("Seller credential and Application credential not found"); } inputStream.close(); LOGGER.info("Credenciais lidas"); return credential; } SystemPropCredentialProvider(String file); }
SystemPropCredentialProvider implements CredentialProvider { @Override public Credential getCredential() throws Exception { LOGGER.info("Lendo credenciais"); final Credential credential; InputStream inputStream = getClass().getClassLoader().getResourceAsStream(file); Properties properties = new Properties(); properties.load(inputStream); if (properties.getProperty("email") != null && properties.getProperty("token") != null) { credential = Credential.sellerCredential(properties.getProperty("email"), properties.getProperty("token")); } else if (properties.getProperty("appId") != null && properties.getProperty("appKey") != null) { credential = Credential.applicationCredential(properties.getProperty("appId"), properties.getProperty("appKey")); } else { throw new IllegalArgumentException("Seller credential and Application credential not found"); } inputStream.close(); LOGGER.info("Credenciais lidas"); return credential; } SystemPropCredentialProvider(String file); @Override Credential getCredential(); }
SystemPropCredentialProvider implements CredentialProvider { @Override public Credential getCredential() throws Exception { LOGGER.info("Lendo credenciais"); final Credential credential; InputStream inputStream = getClass().getClassLoader().getResourceAsStream(file); Properties properties = new Properties(); properties.load(inputStream); if (properties.getProperty("email") != null && properties.getProperty("token") != null) { credential = Credential.sellerCredential(properties.getProperty("email"), properties.getProperty("token")); } else if (properties.getProperty("appId") != null && properties.getProperty("appKey") != null) { credential = Credential.applicationCredential(properties.getProperty("appId"), properties.getProperty("appKey")); } else { throw new IllegalArgumentException("Seller credential and Application credential not found"); } inputStream.close(); LOGGER.info("Credenciais lidas"); return credential; } SystemPropCredentialProvider(String file); @Override Credential getCredential();  }