### Question:
CssAnalyzerBundle implements Bundle { @Override public void deploy(Path deployLocation) { this.deployLocation = deployLocation; PROFILER.startDebug("Deploying bundle"); LOG.debug("Deploying css-bundle into {}", deployLocation); InputStream bundle = getClass().getResourceAsStream(bundleLocation); if (bundle == null) { throw new IllegalStateException("css-bundle not found in " + bundleLocation); } try { LOG.debug("Deploying css-bundle to {}", deployLocation.toAbsolutePath()); Zip.extract(bundle, deployLocation); startServerScript = deployLocation.resolve(DEFAULT_STARTUP_SCRIPT).toAbsolutePath().toString(); } catch (Exception e) { throw new IllegalStateException("Failed to deploy css-bundle (with classpath '" + bundleLocation + "')", e); } PROFILER.stopDebug(); } CssAnalyzerBundle(); @VisibleForTesting  CssAnalyzerBundle(String bundleLocation); @Override void deploy(Path deployLocation); @Override String startServerScript(); @Override String resolve(String relativePath);  }### Answer:
@Test public void missing_bundle() throws Exception { Bundle bundle = new CssAnalyzerBundle("/bundle/invalid-bundle-path.zip"); assertThatThrownBy(() -> bundle.deploy(tempFolder.newDir().toPath())) .isInstanceOf(IllegalStateException.class) .hasMessage("css-bundle not found in /bundle/invalid-bundle-path.zip"); }
@Test public void invalid_bundle_zip() throws Exception { Bundle bundle = new CssAnalyzerBundle("/bundle/invalid-zip-file.zip"); assertThatThrownBy(() -> bundle.deploy(tempFolder.newDir().toPath())) .isInstanceOf(IllegalStateException.class) .hasMessage("Failed to deploy css-bundle (with classpath '/bundle/invalid-zip-file.zip')"); }
@Test public void should_not_fail_when_deployed_twice() throws Exception { Bundle bundle = new CssAnalyzerBundle("/bundle/test-css-bundle.zip"); Path deployLocation = tempFolder.newDir().toPath(); assertThatCode(() -> { bundle.deploy(deployLocation); bundle.deploy(deployLocation); }).doesNotThrowAnyException(); }