@Test public void shouldGetCredentialsFromSysEnv() throws Exception { PagSeguroEnv expectedEnv = PagSeguroEnv.SANDBOX; when(jvmEnvVariableEnvironmentProvider.getEnvironment()) .thenThrow(new IllegalArgumentException()); when(systemPropEnvironmentProvider.getEnvironment()).thenThrow(new IllegalArgumentException()); when(systemEnvVariableEnvironmentProvider.getEnvironment()).thenReturn(expectedEnv); PagSeguroEnv env = providerChain.getEnvironment(); assertEquals(expectedEnv, env); InOrder inOrder = inOrder(jvmEnvVariableEnvironmentProvider, systemPropEnvironmentProvider, systemEnvVariableEnvironmentProvider); inOrder.verify(jvmEnvVariableEnvironmentProvider, times(1)).getEnvironment(); inOrder.verify(systemPropEnvironmentProvider, times(1)).getEnvironment(); inOrder.verify(systemEnvVariableEnvironmentProvider, times(1)).getEnvironment(); inOrder.verifyNoMoreInteractions(); }
public PagSeguroEnv getEnvironment() { LOGGER.info("Iniciando leitura das configuracoes de ambiente"); for (EnvironmentProvider environmentProvider : environmentProviders) { try { return environmentProvider.getEnvironment(); } catch (Exception e) { } } throw new PagSeguroLibException(new RuntimeException("Can not create PagSeguro Environment " + "from providers")); }
DefaultEnvironmentProviderChain { public PagSeguroEnv getEnvironment() { LOGGER.info("Iniciando leitura das configuracoes de ambiente"); for (EnvironmentProvider environmentProvider : environmentProviders) { try { return environmentProvider.getEnvironment(); } catch (Exception e) { } } throw new PagSeguroLibException(new RuntimeException("Can not create PagSeguro Environment " + "from providers")); } }
DefaultEnvironmentProviderChain { public PagSeguroEnv getEnvironment() { LOGGER.info("Iniciando leitura das configuracoes de ambiente"); for (EnvironmentProvider environmentProvider : environmentProviders) { try { return environmentProvider.getEnvironment(); } catch (Exception e) { } } throw new PagSeguroLibException(new RuntimeException("Can not create PagSeguro Environment " + "from providers")); } DefaultEnvironmentProviderChain(); }
DefaultEnvironmentProviderChain { public PagSeguroEnv getEnvironment() { LOGGER.info("Iniciando leitura das configuracoes de ambiente"); for (EnvironmentProvider environmentProvider : environmentProviders) { try { return environmentProvider.getEnvironment(); } catch (Exception e) { } } throw new PagSeguroLibException(new RuntimeException("Can not create PagSeguro Environment " + "from providers")); } DefaultEnvironmentProviderChain(); PagSeguroEnv getEnvironment(); }
DefaultEnvironmentProviderChain { public PagSeguroEnv getEnvironment() { LOGGER.info("Iniciando leitura das configuracoes de ambiente"); for (EnvironmentProvider environmentProvider : environmentProviders) { try { return environmentProvider.getEnvironment(); } catch (Exception e) { } } throw new PagSeguroLibException(new RuntimeException("Can not create PagSeguro Environment " + "from providers")); } DefaultEnvironmentProviderChain(); PagSeguroEnv getEnvironment();  }