NodeTasks implements FallibleCommand { @Override public void execute() throws ExecutionFailedException { for (FallibleCommand command : commands) { command.execute(); } } private  NodeTasks(Builder builder); @Override void execute();  }
@Test public void should_UseDefaultFolders()throws Exception { Builder builder = new Builder( new DefaultClassFinder(this.getClass().getClassLoader()), new File(userDir)) .enablePackagesUpdate(false) .enableImportsUpdate(true) .runNpmInstall(false) .withEmbeddableWebComponents(false); Assert.assertEquals(new File(userDir, DEFAULT_FRONTEND_DIR).getAbsolutePath(), ((File)getFieldValue(builder, "frontendDirectory")).getAbsolutePath()); Assert.assertEquals(new File(userDir, DEFAULT_GENERATED_DIR).getAbsolutePath(), ((File)getFieldValue(builder, "generatedFolder")).getAbsolutePath()); builder.build().execute(); Assert.assertTrue(new File(userDir, DEFAULT_GENERATED_DIR + IMPORTS_NAME).exists()); }
@Test public void should_BeAbleToCustomizeFolders() throws Exception { System.setProperty(PARAM_FRONTEND_DIR, "my_custom_sources_folder"); System.setProperty(PARAM_GENERATED_DIR, "my/custom/generated/folder"); Builder builder = new Builder( new DefaultClassFinder(this.getClass().getClassLoader()), new File(userDir)) .enablePackagesUpdate(false) .enableImportsUpdate(true) .runNpmInstall(false) .withEmbeddableWebComponents(false); Assert.assertEquals(new File(userDir, "my_custom_sources_folder").getAbsolutePath(), ((File)getFieldValue(builder, "frontendDirectory")).getAbsolutePath()); Assert.assertEquals(new File(userDir, "my/custom/generated/folder").getAbsolutePath(), ((File)getFieldValue(builder, "generatedFolder")).getAbsolutePath()); builder.build().execute(); Assert.assertTrue(new File(userDir, "my/custom/generated/folder/" + IMPORTS_NAME).exists()); }
@Test public void should_SetIsClientBootstrapMode_When_EnableClientSideBootstrapMode() throws ExecutionFailedException, IOException { Builder builder = new Builder( new DefaultClassFinder(this.getClass().getClassLoader()), new File(userDir)) .enablePackagesUpdate(false) .withWebpack(new File(userDir, TARGET + "classes"), WEBPACK_CONFIG, WEBPACK_GENERATED) .enableImportsUpdate(true).runNpmInstall(false) .withEmbeddableWebComponents(false) .useV14Bootstrap(false).withFlowResourcesFolder( new File(userDir, TARGET + "flow-frontend")); builder.build().execute(); String webpackGeneratedContent = Files .lines(new File(userDir, WEBPACK_GENERATED).toPath()) .collect(Collectors.joining("\n")); Assert.assertTrue( "useClientSideIndexFileForBootstrapping should be true", webpackGeneratedContent.contains( "const useClientSideIndexFileForBootstrapping = true;")); }
@Test public void should_Generate_Connect_Files() throws Exception { File src = new File(getClass().getClassLoader().getResource("java").getFile()); File dir = new File(userDir); File json = new File(dir, "api-file.json"); Builder builder = new Builder( new DefaultClassFinder( Collections.singleton(ConnectEndpointsForTesting.class)), dir) .enablePackagesUpdate(false) .enableImportsUpdate(false) .withEmbeddableWebComponents(false) .withConnectJavaSourceFolder(src) .withConnectGeneratedOpenApiJson(json) .withConnectClientTsApiFolder(new File(dir, "api")); builder.build().execute(); Arrays.asList( "target/index.html", "target/index.ts", "api-file.json", "api/connect-client.default.ts", "api/MyEndpoint.ts") .forEach(name -> assertTrue(name + " not created.", new File(dir, name).exists())); }