@Test public void test() throws Exception { TestRulesBundle rulesBundle = new TestRulesBundle("/test-bundle.tgz"); RulesBundles rulesBundles = new RulesBundles(new TestRulesBundle[]{rulesBundle}, tempFolder); List<Path> paths = rulesBundles.deploy(); assertThat(paths).hasSize(1); assertThat(paths.get(0)).exists(); assertThat(paths.get(0).resolve("bin/server")).hasContent("#!/usr/bin/env node\n\n"); }
public List<Path> deploy() { List<Path> unpackedBundles = new ArrayList<>(); bundles.forEach(bundle -> { Path target = tempFolder.newDir().toPath(); try { LOG.info("Deploying custom rules bundle {} to {}", bundle, target); BundleUtils.extractFromClasspath(bundle.openStream(), target); Path deployedBundle = target.resolve("package").toAbsolutePath(); if (!Files.exists(deployedBundle)) { throw new IllegalStateException("Failed to deploy bundle " + bundle + ". Didn't find 'package' dir."); } unpackedBundles.add(deployedBundle); } catch (IOException e) { LOG.error("Failed to extract bundle " + bundle, e); } }); return unpackedBundles; }
RulesBundles { public List<Path> deploy() { List<Path> unpackedBundles = new ArrayList<>(); bundles.forEach(bundle -> { Path target = tempFolder.newDir().toPath(); try { LOG.info("Deploying custom rules bundle {} to {}", bundle, target); BundleUtils.extractFromClasspath(bundle.openStream(), target); Path deployedBundle = target.resolve("package").toAbsolutePath(); if (!Files.exists(deployedBundle)) { throw new IllegalStateException("Failed to deploy bundle " + bundle + ". Didn't find 'package' dir."); } unpackedBundles.add(deployedBundle); } catch (IOException e) { LOG.error("Failed to extract bundle " + bundle, e); } }); return unpackedBundles; } }
RulesBundles { public List<Path> deploy() { List<Path> unpackedBundles = new ArrayList<>(); bundles.forEach(bundle -> { Path target = tempFolder.newDir().toPath(); try { LOG.info("Deploying custom rules bundle {} to {}", bundle, target); BundleUtils.extractFromClasspath(bundle.openStream(), target); Path deployedBundle = target.resolve("package").toAbsolutePath(); if (!Files.exists(deployedBundle)) { throw new IllegalStateException("Failed to deploy bundle " + bundle + ". Didn't find 'package' dir."); } unpackedBundles.add(deployedBundle); } catch (IOException e) { LOG.error("Failed to extract bundle " + bundle, e); } }); return unpackedBundles; } RulesBundles(TempFolder tempFolder);  RulesBundles(RulesBundle[] rulesBundles, TempFolder tempFolder); }
RulesBundles { public List<Path> deploy() { List<Path> unpackedBundles = new ArrayList<>(); bundles.forEach(bundle -> { Path target = tempFolder.newDir().toPath(); try { LOG.info("Deploying custom rules bundle {} to {}", bundle, target); BundleUtils.extractFromClasspath(bundle.openStream(), target); Path deployedBundle = target.resolve("package").toAbsolutePath(); if (!Files.exists(deployedBundle)) { throw new IllegalStateException("Failed to deploy bundle " + bundle + ". Didn't find 'package' dir."); } unpackedBundles.add(deployedBundle); } catch (IOException e) { LOG.error("Failed to extract bundle " + bundle, e); } }); return unpackedBundles; } RulesBundles(TempFolder tempFolder);  RulesBundles(RulesBundle[] rulesBundles, TempFolder tempFolder); List<Path> deploy(); }
RulesBundles { public List<Path> deploy() { List<Path> unpackedBundles = new ArrayList<>(); bundles.forEach(bundle -> { Path target = tempFolder.newDir().toPath(); try { LOG.info("Deploying custom rules bundle {} to {}", bundle, target); BundleUtils.extractFromClasspath(bundle.openStream(), target); Path deployedBundle = target.resolve("package").toAbsolutePath(); if (!Files.exists(deployedBundle)) { throw new IllegalStateException("Failed to deploy bundle " + bundle + ". Didn't find 'package' dir."); } unpackedBundles.add(deployedBundle); } catch (IOException e) { LOG.error("Failed to extract bundle " + bundle, e); } }); return unpackedBundles; } RulesBundles(TempFolder tempFolder);  RulesBundles(RulesBundle[] rulesBundles, TempFolder tempFolder); List<Path> deploy();  }