@Test(description = "Return module should be equivalence to the expected module") public void testGetPackageID() { PackageID fruits = directoryManager.getPackageID("fruits"); Names names = Names.getInstance(context); PackageID expectedPackageId = new PackageID(names.fromString("abc"), names.fromString("fruits"), names.fromString("0.0.1")); Assert.assertEquals(fruits, expectedPackageId); }
public PackageID getPackageID(String sourcePackage) { List<String> sourceFileNames = this.sourceDirectory.getSourceFileNames(); Name orgName = getOrgName(this.manifest); Name version = new Name(this.manifest.getProject().getVersion()); if (orgName.equals(Names.BUILTIN_ORG)) { return new PackageID(orgName, names.fromString(sourcePackage), version); } if (sourceFileNames.contains(sourcePackage)) { return new PackageID(sourcePackage); } List<String> packageNames = this.sourceDirectory.getSourcePackageNames(); if (packageNames.contains(sourcePackage)) { return new PackageID(orgName, names.fromString(sourcePackage), version); } return null; }
SourceDirectoryManager implements Project { public PackageID getPackageID(String sourcePackage) { List<String> sourceFileNames = this.sourceDirectory.getSourceFileNames(); Name orgName = getOrgName(this.manifest); Name version = new Name(this.manifest.getProject().getVersion()); if (orgName.equals(Names.BUILTIN_ORG)) { return new PackageID(orgName, names.fromString(sourcePackage), version); } if (sourceFileNames.contains(sourcePackage)) { return new PackageID(sourcePackage); } List<String> packageNames = this.sourceDirectory.getSourcePackageNames(); if (packageNames.contains(sourcePackage)) { return new PackageID(orgName, names.fromString(sourcePackage), version); } return null; } }
SourceDirectoryManager implements Project { public PackageID getPackageID(String sourcePackage) { List<String> sourceFileNames = this.sourceDirectory.getSourceFileNames(); Name orgName = getOrgName(this.manifest); Name version = new Name(this.manifest.getProject().getVersion()); if (orgName.equals(Names.BUILTIN_ORG)) { return new PackageID(orgName, names.fromString(sourcePackage), version); } if (sourceFileNames.contains(sourcePackage)) { return new PackageID(sourcePackage); } List<String> packageNames = this.sourceDirectory.getSourcePackageNames(); if (packageNames.contains(sourcePackage)) { return new PackageID(orgName, names.fromString(sourcePackage), version); } return null; } private  SourceDirectoryManager(CompilerContext context); }
SourceDirectoryManager implements Project { public PackageID getPackageID(String sourcePackage) { List<String> sourceFileNames = this.sourceDirectory.getSourceFileNames(); Name orgName = getOrgName(this.manifest); Name version = new Name(this.manifest.getProject().getVersion()); if (orgName.equals(Names.BUILTIN_ORG)) { return new PackageID(orgName, names.fromString(sourcePackage), version); } if (sourceFileNames.contains(sourcePackage)) { return new PackageID(sourcePackage); } List<String> packageNames = this.sourceDirectory.getSourcePackageNames(); if (packageNames.contains(sourcePackage)) { return new PackageID(orgName, names.fromString(sourcePackage), version); } return null; } 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 { public PackageID getPackageID(String sourcePackage) { List<String> sourceFileNames = this.sourceDirectory.getSourceFileNames(); Name orgName = getOrgName(this.manifest); Name version = new Name(this.manifest.getProject().getVersion()); if (orgName.equals(Names.BUILTIN_ORG)) { return new PackageID(orgName, names.fromString(sourcePackage), version); } if (sourceFileNames.contains(sourcePackage)) { return new PackageID(sourcePackage); } List<String> packageNames = this.sourceDirectory.getSourcePackageNames(); if (packageNames.contains(sourcePackage)) { return new PackageID(orgName, names.fromString(sourcePackage), version); } return null; } 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);  }