@Test public void testGenerateUserAgent_utilitiesRegistered_includeUtilitiesFalse() { when(adsLibConfiguration.isIncludeAdsUtilitiesInUserAgent()).thenReturn(false); adsUtilityRegistry.addUtility(AdsUtility.PRODUCT_PARTITION_TREE); String actualUserAgent = userAgentProvider.getUserAgent(); assertNull("User agent should be null if include utilities is false", actualUserAgent); assertTrue("User agent provider should clear utilities", adsUtilityRegistry.popRegisteredUtilities().isEmpty()); }
@Override public String getUserAgent() { Set<AdsUtility> adsUtilities = adsUtilityRegistry.popRegisteredUtilities(); if (!adsLibConfiguration.isIncludeAdsUtilitiesInUserAgent() || adsUtilities.isEmpty()) { return null; } return Joiner.on(", ").skipNulls().join( Sets.newTreeSet(Collections2.transform(adsUtilities, ADS_UTILITY_FUNCTION))); }
AdsUtilitiesUserAgentProvider implements UserAgentProvider { @Override public String getUserAgent() { Set<AdsUtility> adsUtilities = adsUtilityRegistry.popRegisteredUtilities(); if (!adsLibConfiguration.isIncludeAdsUtilitiesInUserAgent() || adsUtilities.isEmpty()) { return null; } return Joiner.on(", ").skipNulls().join( Sets.newTreeSet(Collections2.transform(adsUtilities, ADS_UTILITY_FUNCTION))); } }
AdsUtilitiesUserAgentProvider implements UserAgentProvider { @Override public String getUserAgent() { Set<AdsUtility> adsUtilities = adsUtilityRegistry.popRegisteredUtilities(); if (!adsLibConfiguration.isIncludeAdsUtilitiesInUserAgent() || adsUtilities.isEmpty()) { return null; } return Joiner.on(", ").skipNulls().join( Sets.newTreeSet(Collections2.transform(adsUtilities, ADS_UTILITY_FUNCTION))); } @Inject  AdsUtilitiesUserAgentProvider(
      AdsUtilityRegistry adsUtilityRegistry, AdsLibConfiguration adsLibConfiguration); }
AdsUtilitiesUserAgentProvider implements UserAgentProvider { @Override public String getUserAgent() { Set<AdsUtility> adsUtilities = adsUtilityRegistry.popRegisteredUtilities(); if (!adsLibConfiguration.isIncludeAdsUtilitiesInUserAgent() || adsUtilities.isEmpty()) { return null; } return Joiner.on(", ").skipNulls().join( Sets.newTreeSet(Collections2.transform(adsUtilities, ADS_UTILITY_FUNCTION))); } @Inject  AdsUtilitiesUserAgentProvider(
      AdsUtilityRegistry adsUtilityRegistry, AdsLibConfiguration adsLibConfiguration); @Override String getUserAgent(); }
AdsUtilitiesUserAgentProvider implements UserAgentProvider { @Override public String getUserAgent() { Set<AdsUtility> adsUtilities = adsUtilityRegistry.popRegisteredUtilities(); if (!adsLibConfiguration.isIncludeAdsUtilitiesInUserAgent() || adsUtilities.isEmpty()) { return null; } return Joiner.on(", ").skipNulls().join( Sets.newTreeSet(Collections2.transform(adsUtilities, ADS_UTILITY_FUNCTION))); } @Inject  AdsUtilitiesUserAgentProvider(
      AdsUtilityRegistry adsUtilityRegistry, AdsLibConfiguration adsLibConfiguration); @Override String getUserAgent();  }