### Question:
ArchiveFactory { public Archive create(PhantomJsResolverOptions options) { return create(options.getVersion(), options.getBaseUrl()); } @Inject  ArchiveFactory(OperatingSystemFactory operatingSystemFactory); Archive create(PhantomJsResolverOptions options); Archive create(String version, String baseUrl); Archive create(String version);  }### Answer:
@Test public void testBuildWindowsPhantomJSArchive() { when(operatingSystem.getName()).thenReturn("win"); Archive archive = builder.create("1.9.0"); assertThat(archive.getArchiveName()).isEqualTo("phantomjs-1.9.0-windows.zip"); }
@Test public void testBuildMacOSXPhantomJSArchive() { when(operatingSystem.getName()).thenReturn("mac"); Archive archive = builder.create("1.9.0"); assertThat(archive.getArchiveName()).isEqualTo("phantomjs-1.9.0-macosx.zip"); }
@Test public void testBuildMacOSX250PhantomJSArchive() { when(operatingSystem.getName()).thenReturn("mac"); Archive archive = builder.create("2.5.0-beta"); assertThat(archive.getArchiveName()).isEqualTo("phantomjs-2.5.0-beta-macos.zip"); }
@Test public void testBuildLinuxPhantomJSArchive() { when(operatingSystem.getName()).thenReturn("linux"); when(operatingSystem.getArchitecture()).thenReturn("i686"); Archive archive = builder.create("1.9.0"); assertThat(archive.getArchiveName()).isEqualTo("phantomjs-1.9.0-linux-i686.tar.bz2"); }
@Test public void testBuildLinuxPhantomJSArchiveX64() { when(operatingSystem.getName()).thenReturn("linux"); when(operatingSystem.getArchitecture()).thenReturn("x86_64"); Archive archive = builder.create("1.9.2"); assertThat(archive.getArchiveName()).isEqualTo("phantomjs-1.9.2-linux-x86_64.tar.bz2"); }
@Test public void testBuildPhantomJSArchiveWithCustomBaseUrl() { when(options.getVersion()).thenReturn("1.9.0"); when(options.getBaseUrl()).thenReturn("http: when(operatingSystem.getName()).thenReturn("mac"); Archive archive = builder.create(options); assertThat(archive.getArchiveName()).isEqualTo("phantomjs-1.9.0-macosx.zip"); assertThat(archive.getUrl()).isEqualTo("http: }
@Test public void testBuildInvalidPlatform() { when(operatingSystem.getName()).thenReturn("invalid"); assertThatThrownBy(() -> builder.create("")) .isInstanceOf(UnsupportedPlatformException.class); }