@Test public void testGenerateLibraryUserAgent() { String nonLibraryUserAgent = "myUserAgent"; when(userAgentProvider1.getUserAgent()).thenReturn("userAgent/1"); when(userAgentProvider2.getUserAgent()).thenReturn("userAgent/2"); assertEquals( "myUserAgent (userAgent/1, userAgent/2)", userAgentCombiner.getUserAgent(nonLibraryUserAgent)); assertEquals( "myUserAgent (userAgent/1, userAgent/2)", userAgentCombiner.getUserAgent(nonLibraryUserAgent)); }
public String getUserAgent(String nonLibraryUserAgent) { StringBuilder agentStringBuilder = new StringBuilder(); agentStringBuilder.append(nonLibraryUserAgent); agentStringBuilder.append(" ("); Joiner.on(", ") .skipNulls() .appendTo( agentStringBuilder, Iterables.transform( userAgentProviders, input -> input == null ? null : input.getUserAgent())); agentStringBuilder.append(')'); return agentStringBuilder.toString(); }
UserAgentCombiner { public String getUserAgent(String nonLibraryUserAgent) { StringBuilder agentStringBuilder = new StringBuilder(); agentStringBuilder.append(nonLibraryUserAgent); agentStringBuilder.append(" ("); Joiner.on(", ") .skipNulls() .appendTo( agentStringBuilder, Iterables.transform( userAgentProviders, input -> input == null ? null : input.getUserAgent())); agentStringBuilder.append(')'); return agentStringBuilder.toString(); } }
UserAgentCombiner { public String getUserAgent(String nonLibraryUserAgent) { StringBuilder agentStringBuilder = new StringBuilder(); agentStringBuilder.append(nonLibraryUserAgent); agentStringBuilder.append(" ("); Joiner.on(", ") .skipNulls() .appendTo( agentStringBuilder, Iterables.transform( userAgentProviders, input -> input == null ? null : input.getUserAgent())); agentStringBuilder.append(')'); return agentStringBuilder.toString(); } @Inject  UserAgentCombiner(ProductUserAgentProvider productUserAgentProvider,
      ProductFrameworkProviderHolder productFrameworkProviderHolder,
      AdsLibraryUserAgentProvider adsLibraryUserAgentProvider,
      FrameworkProviderHolder frameworkProviderHolder,
      RuntimeUserAgentProvider runtimeUserAgentProvider,
      BuildTypeUserAgentProvider buildTypeUserAgentProvider,
      AdsUtilitiesUserAgentProvider adsUtilitiesUserAgentProvider,
      ExtensionProviderHolder extensionProviderHolder); @VisibleForTesting  UserAgentCombiner(
      List<UserAgentProvider> userAgentProviders); }
UserAgentCombiner { public String getUserAgent(String nonLibraryUserAgent) { StringBuilder agentStringBuilder = new StringBuilder(); agentStringBuilder.append(nonLibraryUserAgent); agentStringBuilder.append(" ("); Joiner.on(", ") .skipNulls() .appendTo( agentStringBuilder, Iterables.transform( userAgentProviders, input -> input == null ? null : input.getUserAgent())); agentStringBuilder.append(')'); return agentStringBuilder.toString(); } @Inject  UserAgentCombiner(ProductUserAgentProvider productUserAgentProvider,
      ProductFrameworkProviderHolder productFrameworkProviderHolder,
      AdsLibraryUserAgentProvider adsLibraryUserAgentProvider,
      FrameworkProviderHolder frameworkProviderHolder,
      RuntimeUserAgentProvider runtimeUserAgentProvider,
      BuildTypeUserAgentProvider buildTypeUserAgentProvider,
      AdsUtilitiesUserAgentProvider adsUtilitiesUserAgentProvider,
      ExtensionProviderHolder extensionProviderHolder); @VisibleForTesting  UserAgentCombiner(
      List<UserAgentProvider> userAgentProviders); String getUserAgent(String nonLibraryUserAgent); }
UserAgentCombiner { public String getUserAgent(String nonLibraryUserAgent) { StringBuilder agentStringBuilder = new StringBuilder(); agentStringBuilder.append(nonLibraryUserAgent); agentStringBuilder.append(" ("); Joiner.on(", ") .skipNulls() .appendTo( agentStringBuilder, Iterables.transform( userAgentProviders, input -> input == null ? null : input.getUserAgent())); agentStringBuilder.append(')'); return agentStringBuilder.toString(); } @Inject  UserAgentCombiner(ProductUserAgentProvider productUserAgentProvider,
      ProductFrameworkProviderHolder productFrameworkProviderHolder,
      AdsLibraryUserAgentProvider adsLibraryUserAgentProvider,
      FrameworkProviderHolder frameworkProviderHolder,
      RuntimeUserAgentProvider runtimeUserAgentProvider,
      BuildTypeUserAgentProvider buildTypeUserAgentProvider,
      AdsUtilitiesUserAgentProvider adsUtilitiesUserAgentProvider,
      ExtensionProviderHolder extensionProviderHolder); @VisibleForTesting  UserAgentCombiner(
      List<UserAgentProvider> userAgentProviders); String getUserAgent(String nonLibraryUserAgent);  }