### Question:
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();  }### Answer:
@Test public void getUserAgent_createsConcatenatedStringOfSdkVersions() { String[] expectedUserAgent = {"bar/2", "foo/1"}; String[] actualUserAgent = userAgentPublisher.getUserAgent().split(" "); Arrays.sort(actualUserAgent); assertThat(actualUserAgent).isEqualTo(expectedUserAgent); }
@Test public void getUserAgent_returnsEmptyString_whenVersionSetIsEmpty() { userAgentPublisher = new DefaultUserAgentPublisher(new HashSet<>(), globalLibraryVersionRegistrar); assertThat(userAgentPublisher.getUserAgent()).isEqualTo(""); }
@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); }