@Test public void checksStagingEnvironment() throws Exception { String anyAccessToken = "anyAccessToken"; String anyUserAgent = "anyUserAgent"; Logger mockedLogger = mock(Logger.class); CertificateBlacklist mockedBlacklist = mock(CertificateBlacklist.class); TelemetryClientFactory telemetryClientFactory = new TelemetryClientFactory(anyAccessToken, anyUserAgent, mockedLogger, mockedBlacklist); String anyAppInfoHostname = "any.app.info.hostname"; String anyAppInfoAccessToken = "anyAppInfoAccessToken"; Bundle mockedBundle = obtainStagingBundle(anyAppInfoHostname, anyAppInfoAccessToken); Context mockedContext = obtainMockedContext(mockedBundle); TelemetryClient actual = telemetryClientFactory.obtainTelemetryClient(mockedContext); assertEquals(Environment.STAGING, actual.obtainSetting().getEnvironment()); }
TelemetryClient obtainTelemetryClient(Context context) { try { ApplicationInfo appInformation = context.getPackageManager().getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA); if (appInformation != null && appInformation.metaData != null) { EnvironmentChain environmentChain = new EnvironmentChain(); return buildClientFrom(environmentChain.setup().obtainServerInformation(appInformation.metaData), context); } } catch (Exception exception) { logger.error(LOG_TAG, String.format(RETRIEVING_APP_META_DATA_ERROR_MESSAGE, exception.getMessage())); } return buildTelemetryClient(Environment.COM, certificateBlacklist, context); }
TelemetryClientFactory { TelemetryClient obtainTelemetryClient(Context context) { try { ApplicationInfo appInformation = context.getPackageManager().getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA); if (appInformation != null && appInformation.metaData != null) { EnvironmentChain environmentChain = new EnvironmentChain(); return buildClientFrom(environmentChain.setup().obtainServerInformation(appInformation.metaData), context); } } catch (Exception exception) { logger.error(LOG_TAG, String.format(RETRIEVING_APP_META_DATA_ERROR_MESSAGE, exception.getMessage())); } return buildTelemetryClient(Environment.COM, certificateBlacklist, context); } }
TelemetryClientFactory { TelemetryClient obtainTelemetryClient(Context context) { try { ApplicationInfo appInformation = context.getPackageManager().getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA); if (appInformation != null && appInformation.metaData != null) { EnvironmentChain environmentChain = new EnvironmentChain(); return buildClientFrom(environmentChain.setup().obtainServerInformation(appInformation.metaData), context); } } catch (Exception exception) { logger.error(LOG_TAG, String.format(RETRIEVING_APP_META_DATA_ERROR_MESSAGE, exception.getMessage())); } return buildTelemetryClient(Environment.COM, certificateBlacklist, context); } TelemetryClientFactory(String accessToken, String userAgent, Logger logger,
                         CertificateBlacklist certificateBlacklist); }
TelemetryClientFactory { TelemetryClient obtainTelemetryClient(Context context) { try { ApplicationInfo appInformation = context.getPackageManager().getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA); if (appInformation != null && appInformation.metaData != null) { EnvironmentChain environmentChain = new EnvironmentChain(); return buildClientFrom(environmentChain.setup().obtainServerInformation(appInformation.metaData), context); } } catch (Exception exception) { logger.error(LOG_TAG, String.format(RETRIEVING_APP_META_DATA_ERROR_MESSAGE, exception.getMessage())); } return buildTelemetryClient(Environment.COM, certificateBlacklist, context); } TelemetryClientFactory(String accessToken, String userAgent, Logger logger,
                         CertificateBlacklist certificateBlacklist);  }
TelemetryClientFactory { TelemetryClient obtainTelemetryClient(Context context) { try { ApplicationInfo appInformation = context.getPackageManager().getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA); if (appInformation != null && appInformation.metaData != null) { EnvironmentChain environmentChain = new EnvironmentChain(); return buildClientFrom(environmentChain.setup().obtainServerInformation(appInformation.metaData), context); } } catch (Exception exception) { logger.error(LOG_TAG, String.format(RETRIEVING_APP_META_DATA_ERROR_MESSAGE, exception.getMessage())); } return buildTelemetryClient(Environment.COM, certificateBlacklist, context); } TelemetryClientFactory(String accessToken, String userAgent, Logger logger,
                         CertificateBlacklist certificateBlacklist);   }