@Test public void getUserAgent_returnsStringIncludingGamesSDKVersions_whenGamesSDKVersionRegistrarReturnsVersions() { String[] expectedUserAgent = {"bar/2", "buzz/2", "fizz/1", "foo/1"}; HashSet<LibraryVersion> gamesLibraryVersions = new HashSet<>(); gamesLibraryVersions.add(LibraryVersion.create("fizz", "1")); gamesLibraryVersions.add(LibraryVersion.create("buzz", "2")); when(globalLibraryVersionRegistrar.getRegisteredVersions()).thenReturn(gamesLibraryVersions); userAgentPublisher = new DefaultUserAgentPublisher(libraryVersions, globalLibraryVersionRegistrar); String[] actualUserAgent = userAgentPublisher.getUserAgent().split(" "); Arrays.sort(actualUserAgent); assertThat(actualUserAgent).isEqualTo(expectedUserAgent); }
@Override public String getUserAgent() { if (gamesSDKRegistrar.getRegisteredVersions().isEmpty()) { return javaSDKVersionUserAgent; } return javaSDKVersionUserAgent + ' ' + toUserAgent(gamesSDKRegistrar.getRegisteredVersions()); }
DefaultUserAgentPublisher implements UserAgentPublisher { @Override public String getUserAgent() { if (gamesSDKRegistrar.getRegisteredVersions().isEmpty()) { return javaSDKVersionUserAgent; } return javaSDKVersionUserAgent + ' ' + toUserAgent(gamesSDKRegistrar.getRegisteredVersions()); } }
DefaultUserAgentPublisher implements UserAgentPublisher { @Override public String getUserAgent() { if (gamesSDKRegistrar.getRegisteredVersions().isEmpty()) { return javaSDKVersionUserAgent; } return javaSDKVersionUserAgent + ' ' + toUserAgent(gamesSDKRegistrar.getRegisteredVersions()); } DefaultUserAgentPublisher(
      Set<LibraryVersion> libraryVersions, GlobalLibraryVersionRegistrar gamesSDKRegistrar); }
DefaultUserAgentPublisher implements UserAgentPublisher { @Override public String getUserAgent() { if (gamesSDKRegistrar.getRegisteredVersions().isEmpty()) { return javaSDKVersionUserAgent; } return javaSDKVersionUserAgent + ' ' + toUserAgent(gamesSDKRegistrar.getRegisteredVersions()); } DefaultUserAgentPublisher(
      Set<LibraryVersion> libraryVersions, GlobalLibraryVersionRegistrar gamesSDKRegistrar); @Override String getUserAgent(); static Component<UserAgentPublisher> component(); }
DefaultUserAgentPublisher implements UserAgentPublisher { @Override public String getUserAgent() { if (gamesSDKRegistrar.getRegisteredVersions().isEmpty()) { return javaSDKVersionUserAgent; } return javaSDKVersionUserAgent + ' ' + toUserAgent(gamesSDKRegistrar.getRegisteredVersions()); } DefaultUserAgentPublisher(
      Set<LibraryVersion> libraryVersions, GlobalLibraryVersionRegistrar gamesSDKRegistrar); @Override String getUserAgent(); static Component<UserAgentPublisher> component();  }