TaskGeneratePackageJson extends NodeUpdater { @Override public void execute() { try { modified = false; JsonObject mainContent = getPackageJson(); modified = updateDefaultDependencies(mainContent); if (modified) { writePackageFile(mainContent); } if (flowResourcesFolder != null && !new File(npmFolder, NODE_MODULES + FLOW_NPM_PACKAGE_NAME) .equals(flowResourcesFolder)) { writeResourcesPackageFile(getResourcesPackageJson()); } if (formResourcesFolder != null && !new File(npmFolder, NODE_MODULES + FORM_NPM_PACKAGE_NAME) .equals(formResourcesFolder)) { writeFormResourcesPackageFile(getFormResourcesPackageJson()); } } catch (IOException e) { throw new UncheckedIOException(e); } } TaskGeneratePackageJson(File npmFolder, File generatedPath, File flowResourcesPath); @Override void execute();  }
@Test public void should_witeFlowAndFormResourcesPackageFiles() throws IOException { JsonObject resourcePackageJson = Mockito.mock(JsonObject.class); JsonObject formReSourcePackageJson = Mockito.mock(JsonObject.class); Mockito.doReturn(resourcePackageJson).when(task).getResourcesPackageJson(); Mockito.doReturn(formReSourcePackageJson).when(task).getFormResourcesPackageJson(); task.execute(); verify(task).writeResourcesPackageFile(resourcePackageJson); verify(task).writeFormResourcesPackageFile(formReSourcePackageJson); }