WebsterMojo extends AbstractMojo { @Override public final void execute() throws MojoFailureException { WebsterPlan.Builder builder = new WebsterPlan.Builder(); builder.withArchiveRoot(websterArchiveRoot.getAbsoluteFile()); suppressOakLogging(System::setProperty); if (websterTargets == null || websterTargets.isEmpty()) { getLog().info("No websterTargets configuration found in plugin configuration. skipping webster execution."); return; } addTargets(builder, JsonTargetFactory::fromJsonHintMap); WebsterPlan.FixtureProvider fixtureProvider = getFixtureProvider(); if (fixtureProvider == null) { getLog().info("No source Oak repository provided. skipping webster execution."); return; } builder.withFixtureProvider(fixtureProvider); executeWebsterPlan(builder); }  @Override final void execute(); static final String PARAM_REPOSITORY_HOME; static final String PARAM_OAK_RUN_ARGS; static final String PARAM_TMPDIR; }
@Test public void testExecute_noTargets() throws Exception { final File testOutDir = new File(testOutBaseDir, "testExecute_noTargets"); FileUtils.deleteDirectory(testOutDir); final File projectRoot = new File(testOutDir, "content-package"); FileUtils.copyDirectory(new File(srcDir, "content-package"), projectRoot); WebsterMojo mojo = newMojo(); mojo.websterArchiveRoot = new File(projectRoot, "src/main/resources"); mojo.execute(); Optional<MockMojoLog.MockMojoLogEntry> logEntry = logFor(mojo).last(); assertTrue("log is not empty", logEntry.isPresent()); assertTrue("log starts with 'No websterTargets", logEntry.get().message.startsWith("No websterTargets")); }
@Test public void testExecute_noFixture() throws Exception { final File testOutDir = new File(testOutBaseDir, "testExecute_noFixture"); FileUtils.deleteDirectory(testOutDir); final File projectRoot = new File(testOutDir, "content-package"); FileUtils.copyDirectory(new File(srcDir, "content-package"), projectRoot); WebsterMojo mojo = newMojo(); mojo.baseDir = projectRoot; mojo.websterArchiveRoot = new File(projectRoot, "src/main/resources"); mojo.websterTargets = obj().key("nodetypes", obj()).key("privileges", obj()).get(); mojo.execute(); Optional<MockMojoLog.MockMojoLogEntry> logEntry = logFor(mojo).last(); assertTrue("log is not empty", logEntry.isPresent()); assertTrue("log starts with 'No source Oak", logEntry.get().message.startsWith("No source Oak")); }
@Test public void testExecute() throws Exception { final File testOutDir = new File(testOutBaseDir, "testExecute"); FileUtils.deleteDirectory(testOutDir); final File projectRoot = new File(testOutDir, "content-package"); FileUtils.copyDirectory(new File(srcDir, "content-package"), projectRoot); WebsterMojo mojo = newMojo(); final File archiveRoot = new File(projectRoot, "src/main/content"); final File tempDir = new File(testOutDir, "webster-tmp"); mojo.baseDir = projectRoot; mojo.websterTempDirectory = tempDir; mojo.websterArchiveRoot = archiveRoot; mojo.websterTargets = obj().key("nodetypes", obj()).key("privileges", obj()).get(); mojo.websterOakRunArgs = "memory"; mojo.execute(); assertTrue("expect nodetypes", new File(archiveRoot, "META-INF/vault/nodetypes.cnd").exists()); assertTrue("expect privileges", new File(archiveRoot, "META-INF/vault/privileges.xml").exists()); }