use of org.wso2.ballerinalang.compiler.packaging.Resolution in project ballerina by ballerina-lang.
the class RepoHierarchyTest method testFullOrder.
@Test
public void testFullOrder() {
PackageID nonExisting = newPackageID("bad", "ok.pkg", "5");
ArrayList<Integer> order = new ArrayList<>();
RepoHierarchy subject = createSubject(order);
Resolution resolution = subject.resolve(nonExisting);
Assert.assertEquals(resolution, Resolution.NOT_FOUND);
Assert.assertEquals(order, Arrays.asList(0, 1, 2, 3, 4));
}
use of org.wso2.ballerinalang.compiler.packaging.Resolution in project ballerina by ballerina-lang.
the class RepoHierarchy method resolve.
public Resolution resolve(PackageID pkg) {
log1(pkg);
for (int i = 0; i < repos.length; i++) {
Repo repo = repos[i];
Patten patten = repo.calculate(pkg);
if (patten != Patten.NULL) {
Converter converter = repo.getConverterInstance();
List<PackageSourceEntry> paths = patten.convertToSources(converter, pkg).collect(Collectors.toList());
log2(repo, patten, paths);
if (!paths.isEmpty()) {
return new Resolution(getChildHierarchyForRepo(i), paths);
}
} else {
log3(repo);
}
}
log4();
return Resolution.NOT_FOUND;
}
use of org.wso2.ballerinalang.compiler.packaging.Resolution in project ballerina by ballerina-lang.
the class PackageLoader method loadPackageEntity.
private PackageEntity loadPackageEntity(PackageID pkgId) {
updateVersionFromToml(pkgId);
Resolution resolution = repos.resolve(pkgId);
if (resolution == Resolution.NOT_FOUND) {
return null;
}
return new GenericPackageSource(pkgId, resolution.sources, resolution.resolvedBy);
}
use of org.wso2.ballerinalang.compiler.packaging.Resolution in project ballerina by ballerina-lang.
the class RepoHierarchyTest method testResolvingFromAnIntermediate.
@Test
public void testResolvingFromAnIntermediate() {
RepoHierarchy subject;
Resolution resolution;
// Part 1
PackageID repo1sPkg = newPackageID("good", "i.am", "1");
ArrayList<Integer> order = new ArrayList<>();
subject = createSubject(order);
resolution = subject.resolve(repo1sPkg);
Assert.assertNotEquals(resolution, Resolution.NOT_FOUND);
Assert.assertEquals(order, Arrays.asList(0, 1));
// Part 2
order.clear();
PackageID repo4sPkg = newPackageID("ugly", "ok.pkg", "4");
subject = resolution.resolvedBy;
subject.resolve(repo4sPkg);
Assert.assertNotEquals(resolution, Resolution.NOT_FOUND);
Assert.assertEquals(order, Arrays.asList(1, 2, 3, 4));
}
use of org.wso2.ballerinalang.compiler.packaging.Resolution in project ballerina by ballerina-lang.
the class RepoHierarchyTest method testIdempotence.
@Test
public void testIdempotence() {
RepoHierarchy subject;
Resolution resolution;
// Part 1
PackageID repo0sPkg = newPackageID("easy", "too", "0");
ArrayList<Integer> order = new ArrayList<>();
subject = createSubject(order);
resolution = subject.resolve(repo0sPkg);
Assert.assertNotEquals(resolution, Resolution.NOT_FOUND);
// Part 2
order.clear();
subject = resolution.resolvedBy;
subject.resolve(repo0sPkg);
Assert.assertNotEquals(resolution, Resolution.NOT_FOUND);
}
Aggregations