### Question:
NodeManager { public void installIfNotInstalled() throws IOException { try { factory.getNodeAndNPMInstaller(proxy()) .install(mojo.getNodeVersion(), mojo.getNPMVersion(), mojo.getNodeDistributionRootUrl(), mojo.getNpmRegistryRootUrl() + "/npm/-/"); if (!getNodeExecutable().isFile()) { throw new IOException("Node installation failed - " + getNodeExecutable().getAbsolutePath() + " does not exist"); } } catch (InstallationException e) { throw new IOException(e); } } NodeManager(AbstractWisdomMojo mojo);  NodeManager(Log log, File nodeDirectory, AbstractWisdomMojo mojo); FrontendPluginFactory factory(); FrontendPluginFactory factoryForNPMInstallation(); void installIfNotInstalled(); ProxyConfig proxy(); File getNodeExecutable(); File getNodeModulesDirectory(); File getWorkDir();  }### Answer:
@Test @Category(LongRun.class) public void testInstallationOfCoffeeScript() throws IOException, ParseException { manager.installIfNotInstalled(); AbstractWisdomMojo mojo = mock(AbstractWisdomMojo.class); when(mojo.getLog()).thenReturn(log); when(mojo.getNodeManager()).thenReturn(manager); NPM npm = NPM.npm(mojo, "coffee-script", CoffeeScriptCompilerMojo.COFFEESCRIPT_VERSION); assertThat(npm).isNotNull(); assertThat(npm.findExecutable("coffee")).isFile(); }
@Test @Category(LongRun.class) public void testReinstallation() throws IOException, ParseException { manager.installIfNotInstalled(); AbstractWisdomMojo mojo = mock(AbstractWisdomMojo.class); when(mojo.getLog()).thenReturn(log); when(mojo.getNodeManager()).thenReturn(manager); NPM npm = NPM.npm(mojo, "coffee-script", CoffeeScriptCompilerMojo.COFFEESCRIPT_VERSION); assertThat(npm).isNotNull(); assertThat(npm.findExecutable("coffee")).isFile(); NPM npm2 = NPM.npm(mojo, "coffee-script", CoffeeScriptCompilerMojo.COFFEESCRIPT_VERSION); assertThat(npm).isEqualTo(npm2); assertThat(npm.hashCode()).isEqualTo(npm2.hashCode()); }
@Test @Category(LongRun.class) public void testExecution() throws IOException, ParseException, MojoExecutionException { manager.installIfNotInstalled(); AbstractWisdomMojo mojo = mock(AbstractWisdomMojo.class); when(mojo.getLog()).thenReturn(log); when(mojo.getNodeManager()).thenReturn(manager); NPM npm = NPM.npm(mojo, "coffee-script", CoffeeScriptCompilerMojo.COFFEESCRIPT_VERSION); File input = new File("target/test-classes/coffee/test.coffee"); File output = new File("target/test/coffee"); output.mkdirs(); int exit = npm.execute("coffee", "--compile", "--map", "--output", output.getAbsolutePath(), input.getAbsolutePath()); assertThat(exit).isEqualTo(0); assertThat(new File(output, "test.js")).isFile(); assertThat(new File(output, "test.js.map")).isFile(); }
@Test @Category(LongRun.class) public void testSkipPostInstall() throws IOException, ParseException, MojoExecutionException { manager.installIfNotInstalled(); AbstractWisdomMojo mojo = mock(AbstractWisdomMojo.class); when(mojo.getLog()).thenReturn(log); when(mojo.getNodeManager()).thenReturn(manager); NPM npm = NPM.npm(mojo, "optipng-bin", "1.0.0", "--ignore-scripts"); assertThat(npm).isNotNull(); }