@Test(description = "Test if module exist in the project") public void testIsModuleExists() { Project project = context.get(Project.PROJECT_KEY); Names names = Names.getInstance(context); PackageID expectedPackageId = new PackageID(names.fromString("abc"), names.fromString("fruits"), names.fromString("0.0.1")); Assert.assertTrue(project.isModuleExists(expectedPackageId)); PackageID invalidName = new PackageID(names.fromString("abc"), names.fromString("invalid"), names.fromString("0.0.1")); Assert.assertFalse(project.isModuleExists(invalidName)); PackageID invalidOrg = new PackageID(names.fromString("invalid"), names.fromString("fruits"), names.fromString("0.0.1")); Assert.assertFalse(project.isModuleExists(invalidOrg)); PackageID invalidVersion = new PackageID(names.fromString("abc"), names.fromString("fruits"), names.fromString("0.1.1")); Assert.assertFalse(project.isModuleExists(invalidVersion)); }
@Override public boolean isModuleExists(PackageID moduleId) { if (this.sourceDirectory.getSourcePackageNames().contains(moduleId.name.value) && this.manifest.getProject().getOrgName().equals(moduleId.orgName.value) && this.manifest.getProject().getVersion().equals(moduleId.version.value)) { return true; } else { return false; } }
SourceDirectoryManager implements Project { @Override public boolean isModuleExists(PackageID moduleId) { if (this.sourceDirectory.getSourcePackageNames().contains(moduleId.name.value) && this.manifest.getProject().getOrgName().equals(moduleId.orgName.value) && this.manifest.getProject().getVersion().equals(moduleId.version.value)) { return true; } else { return false; } } }
SourceDirectoryManager implements Project { @Override public boolean isModuleExists(PackageID moduleId) { if (this.sourceDirectory.getSourcePackageNames().contains(moduleId.name.value) && this.manifest.getProject().getOrgName().equals(moduleId.orgName.value) && this.manifest.getProject().getVersion().equals(moduleId.version.value)) { return true; } else { return false; } } private  SourceDirectoryManager(CompilerContext context); }
SourceDirectoryManager implements Project { @Override public boolean isModuleExists(PackageID moduleId) { if (this.sourceDirectory.getSourcePackageNames().contains(moduleId.name.value) && this.manifest.getProject().getOrgName().equals(moduleId.orgName.value) && this.manifest.getProject().getVersion().equals(moduleId.version.value)) { return true; } else { return false; } } private  SourceDirectoryManager(CompilerContext context); static SourceDirectoryManager getInstance(CompilerContext context); Stream<PackageID> listSourceFilesAndPackages(); PackageID getPackageID(String sourcePackage); SourceDirectory getSourceDirectory(); @Override boolean isModuleExists(PackageID moduleId); @Override Path getBaloPath(PackageID moduleId); }
SourceDirectoryManager implements Project { @Override public boolean isModuleExists(PackageID moduleId) { if (this.sourceDirectory.getSourcePackageNames().contains(moduleId.name.value) && this.manifest.getProject().getOrgName().equals(moduleId.orgName.value) && this.manifest.getProject().getVersion().equals(moduleId.version.value)) { return true; } else { return false; } } private  SourceDirectoryManager(CompilerContext context); static SourceDirectoryManager getInstance(CompilerContext context); Stream<PackageID> listSourceFilesAndPackages(); PackageID getPackageID(String sourcePackage); SourceDirectory getSourceDirectory(); @Override boolean isModuleExists(PackageID moduleId); @Override Path getBaloPath(PackageID moduleId);  }