@Test(description = "Test if the generated source are runnable.", enabled = false) public void testGeneratedSourceContent() throws IOException { Manifest manifest = new Manifest(); manifest.setName("wso2"); manifest.setVersion("1.0.0"); SrcFile packageFile = new SrcFile("wso2_abc", FileType.SERVICE); SrcFile mainFile = new SrcFile("main_runner", FileType.MAIN); List<SrcFile> srcFiles = new ArrayList<>(); srcFiles.add(packageFile); srcFiles.add(mainFile); List<PackageMdFile> packageMdFiles = new ArrayList<>(); PackageMdFile packageMdFileForService = new PackageMdFile("wso2_abc", FileType.SERVICE); PackageMdFile packageMdFileForMain = new PackageMdFile("main_runner", FileType.MAIN); packageMdFiles.add(packageMdFileForService); packageMdFiles.add(packageMdFileForMain); InitHandler.initialize(tmpDir, manifest, srcFiles, packageMdFiles); Path tomlFile = tmpDir.resolve("Ballerina.toml"); byte[] tomlFileBytes = Files.readAllBytes(tomlFile); String tomlFileContents = new String(tomlFileBytes, Charset.defaultCharset()); Assert.assertTrue(tomlFileContents.contains("[project]"), "Project header missing in Ballerina.toml"); Assert.assertTrue(tomlFileContents.contains("org-name = \"" + manifest.getName() + "\""), "Org-Name missing in Ballerina.toml"); Assert.assertTrue(tomlFileContents.contains("version = \"" + manifest.getVersion() + "\""), "Version missing in Ballerina.toml"); Path servicesBalFile = tmpDir.resolve(packageFile.getName()).resolve("services.bal"); Path mainBalFile = tmpDir.resolve(mainFile.getName()); Assert.assertTrue(Files.exists(servicesBalFile), "Package not generated."); Assert.assertTrue(Files.exists(mainBalFile), "Main file not generated."); CompileResult serviceFileCompileResult = BCompileUtil.compile(servicesBalFile.getParent().toString()); Assert.assertFalse(serviceFileCompileResult.getDiagnostics().length > 0, "Errors found in the generated service files."); CompileResult mainFileCompileResult = BCompileUtil.compile(mainBalFile.toString()); Assert.assertFalse(mainFileCompileResult.getDiagnostics().length > 0, "Errors found in the generated service files."); }
public static void initialize(Path projectPath, Manifest manifest, List<SrcFile> srcFiles, List<PackageMdFile> packageMdFile) throws IOException { createBallerinaToml(projectPath, manifest); createBallerinaCacheFile(projectPath); createPackageMd(projectPath, packageMdFile); createSrcFolder(projectPath, srcFiles); String ignoreFileContent = "target/\n"; createIgnoreFiles(projectPath, ignoreFileContent); }
InitHandler { public static void initialize(Path projectPath, Manifest manifest, List<SrcFile> srcFiles, List<PackageMdFile> packageMdFile) throws IOException { createBallerinaToml(projectPath, manifest); createBallerinaCacheFile(projectPath); createPackageMd(projectPath, packageMdFile); createSrcFolder(projectPath, srcFiles); String ignoreFileContent = "target/\n"; createIgnoreFiles(projectPath, ignoreFileContent); } }
InitHandler { public static void initialize(Path projectPath, Manifest manifest, List<SrcFile> srcFiles, List<PackageMdFile> packageMdFile) throws IOException { createBallerinaToml(projectPath, manifest); createBallerinaCacheFile(projectPath); createPackageMd(projectPath, packageMdFile); createSrcFolder(projectPath, srcFiles); String ignoreFileContent = "target/\n"; createIgnoreFiles(projectPath, ignoreFileContent); }  }
InitHandler { public static void initialize(Path projectPath, Manifest manifest, List<SrcFile> srcFiles, List<PackageMdFile> packageMdFile) throws IOException { createBallerinaToml(projectPath, manifest); createBallerinaCacheFile(projectPath); createPackageMd(projectPath, packageMdFile); createSrcFolder(projectPath, srcFiles); String ignoreFileContent = "target/\n"; createIgnoreFiles(projectPath, ignoreFileContent); }  static void initialize(Path projectPath, Manifest manifest, List<SrcFile> srcFiles,
                                  List<PackageMdFile> packageMdFile); }
InitHandler { public static void initialize(Path projectPath, Manifest manifest, List<SrcFile> srcFiles, List<PackageMdFile> packageMdFile) throws IOException { createBallerinaToml(projectPath, manifest); createBallerinaCacheFile(projectPath); createPackageMd(projectPath, packageMdFile); createSrcFolder(projectPath, srcFiles); String ignoreFileContent = "target/\n"; createIgnoreFiles(projectPath, ignoreFileContent); }  static void initialize(Path projectPath, Manifest manifest, List<SrcFile> srcFiles,
                                  List<PackageMdFile> packageMdFile);  }