@Test public void shouldGetCredentialsFromSysProp() throws Exception { Credential expectedCredential = Credential.sellerCredential("email", "token"); when(jvmEnvVariableCredentialProvider.getCredential()) .thenThrow(new IllegalArgumentException()); when(systemPropCredentialProvider.getCredential()).thenReturn(expectedCredential); Credential credential = providerChain.getCredential(); assertEquals(expectedCredential, credential); InOrder inOrder = inOrder(jvmEnvVariableCredentialProvider, systemPropCredentialProvider, systemEnvVariableCredentialProvider); inOrder.verify(jvmEnvVariableCredentialProvider, times(1)).getCredential(); inOrder.verify(systemPropCredentialProvider, times(1)).getCredential(); inOrder.verify(systemEnvVariableCredentialProvider, times(0)).getCredential(); inOrder.verifyNoMoreInteractions(); }
public Credential getCredential() { LOGGER.info("Iniciando leitura das credenciais"); for (CredentialProvider credentialProvider : credentialProviders) { try { return credentialProvider.getCredential(); } catch (Exception e) { } } throw new PagSeguroLibException(new RuntimeException("Can not create Credentials " + "from providers")); }
DefaultCredentialProviderChain { public Credential getCredential() { LOGGER.info("Iniciando leitura das credenciais"); for (CredentialProvider credentialProvider : credentialProviders) { try { return credentialProvider.getCredential(); } catch (Exception e) { } } throw new PagSeguroLibException(new RuntimeException("Can not create Credentials " + "from providers")); } }
DefaultCredentialProviderChain { public Credential getCredential() { LOGGER.info("Iniciando leitura das credenciais"); for (CredentialProvider credentialProvider : credentialProviders) { try { return credentialProvider.getCredential(); } catch (Exception e) { } } throw new PagSeguroLibException(new RuntimeException("Can not create Credentials " + "from providers")); } DefaultCredentialProviderChain(); }
DefaultCredentialProviderChain { public Credential getCredential() { LOGGER.info("Iniciando leitura das credenciais"); for (CredentialProvider credentialProvider : credentialProviders) { try { return credentialProvider.getCredential(); } catch (Exception e) { } } throw new PagSeguroLibException(new RuntimeException("Can not create Credentials " + "from providers")); } DefaultCredentialProviderChain(); Credential getCredential(); }
DefaultCredentialProviderChain { public Credential getCredential() { LOGGER.info("Iniciando leitura das credenciais"); for (CredentialProvider credentialProvider : credentialProviders) { try { return credentialProvider.getCredential(); } catch (Exception e) { } } throw new PagSeguroLibException(new RuntimeException("Can not create Credentials " + "from providers")); } DefaultCredentialProviderChain(); Credential getCredential();  }