@Test public void testAvailableProviders() throws IOException { File googleADC = temporaryFolder.newFile(); ConfigurationService config = new ConfigurationService("clientSubscriptionKey", googleADC.getAbsolutePath(), "{\"type\": \"service_account\"," + "\"auth_uri\": \"https: "ms", "enableDev"); assertThat( config.availableProviders(GoogleCredential.ABSENT, "", false)) .isEmpty(); assertThat(config.availableProviders(config.googleDefaultCredential(), "", false)).containsExactly(BackendID.GOOGLE); assertThat(config.availableProviders(config.googleDefaultCredential(), "msKey", false)).containsExactlyInAnyOrder(BackendID.GOOGLE, BackendID.MS); assertThat(config.availableProviders(GoogleCredential.ABSENT, "msKey", false)).containsExactly(BackendID.MS); assertThat(config.availableProviders(GoogleCredential.ABSENT, "msKey", true)).containsExactlyInAnyOrder(BackendID.MS, BackendID.DEV); assertThat(config.availableProviders(config.googleDefaultCredential(), "msKey", true)).containsExactlyInAnyOrder(BackendID.GOOGLE, BackendID.MS, BackendID.DEV); assertThat(config.availableProviders(config.googleDefaultCredential(), "msKey", false)).containsExactlyInAnyOrder(BackendID.GOOGLE, BackendID.MS); }
@Produces @BackEndProviders protected Set<BackendID> availableProviders( @Credentials(BackendID.GOOGLE) GoogleCredential googleCredential, @Credentials(BackendID.MS) String msCredential, @DevMode boolean isDevMode) { Set<BackendID> providers = Sets.newHashSet(); if (googleCredential.exists()) { providers.add(BackendID.GOOGLE); } if (!isBlank(msCredential)) { providers.add(BackendID.MS); } if (isDevMode) { providers.add(BackendID.DEV); } return providers; }
ConfigurationService { @Produces @BackEndProviders protected Set<BackendID> availableProviders( @Credentials(BackendID.GOOGLE) GoogleCredential googleCredential, @Credentials(BackendID.MS) String msCredential, @DevMode boolean isDevMode) { Set<BackendID> providers = Sets.newHashSet(); if (googleCredential.exists()) { providers.add(BackendID.GOOGLE); } if (!isBlank(msCredential)) { providers.add(BackendID.MS); } if (isDevMode) { providers.add(BackendID.DEV); } return providers; } }
ConfigurationService { @Produces @BackEndProviders protected Set<BackendID> availableProviders( @Credentials(BackendID.GOOGLE) GoogleCredential googleCredential, @Credentials(BackendID.MS) String msCredential, @DevMode boolean isDevMode) { Set<BackendID> providers = Sets.newHashSet(); if (googleCredential.exists()) { providers.add(BackendID.GOOGLE); } if (!isBlank(msCredential)) { providers.add(BackendID.MS); } if (isDevMode) { providers.add(BackendID.DEV); } return providers; } @SuppressWarnings("unused")  ConfigurationService(); @Inject  ConfigurationService(
            @EnvVariable(AZURE_KEY) String msAPIKey,
            @EnvVariable(GOOGLE_ADC) String googleADC,
            @EnvVariable(GOOGLE_CREDENTIAL_CONTENT) String googleADCContent,
            @EnvVariable(DEFAULT_PROVIDER) String defaultProvider,
            @EnvVariable(DEV_BACKEND) String enableDevBackend); }
ConfigurationService { @Produces @BackEndProviders protected Set<BackendID> availableProviders( @Credentials(BackendID.GOOGLE) GoogleCredential googleCredential, @Credentials(BackendID.MS) String msCredential, @DevMode boolean isDevMode) { Set<BackendID> providers = Sets.newHashSet(); if (googleCredential.exists()) { providers.add(BackendID.GOOGLE); } if (!isBlank(msCredential)) { providers.add(BackendID.MS); } if (isDevMode) { providers.add(BackendID.DEV); } return providers; } @SuppressWarnings("unused")  ConfigurationService(); @Inject  ConfigurationService(
            @EnvVariable(AZURE_KEY) String msAPIKey,
            @EnvVariable(GOOGLE_ADC) String googleADC,
            @EnvVariable(GOOGLE_CREDENTIAL_CONTENT) String googleADCContent,
            @EnvVariable(DEFAULT_PROVIDER) String defaultProvider,
            @EnvVariable(DEV_BACKEND) String enableDevBackend); void init(@Observes @Initialized(ApplicationScoped.class) Object init); String getVersion(); String getBuildDate(); @Produces @DevMode boolean isDevMode(); }
ConfigurationService { @Produces @BackEndProviders protected Set<BackendID> availableProviders( @Credentials(BackendID.GOOGLE) GoogleCredential googleCredential, @Credentials(BackendID.MS) String msCredential, @DevMode boolean isDevMode) { Set<BackendID> providers = Sets.newHashSet(); if (googleCredential.exists()) { providers.add(BackendID.GOOGLE); } if (!isBlank(msCredential)) { providers.add(BackendID.MS); } if (isDevMode) { providers.add(BackendID.DEV); } return providers; } @SuppressWarnings("unused")  ConfigurationService(); @Inject  ConfigurationService(
            @EnvVariable(AZURE_KEY) String msAPIKey,
            @EnvVariable(GOOGLE_ADC) String googleADC,
            @EnvVariable(GOOGLE_CREDENTIAL_CONTENT) String googleADCContent,
            @EnvVariable(DEFAULT_PROVIDER) String defaultProvider,
            @EnvVariable(DEV_BACKEND) String enableDevBackend); void init(@Observes @Initialized(ApplicationScoped.class) Object init); String getVersion(); String getBuildDate(); @Produces @DevMode boolean isDevMode();  }