use of org.wso2.ballerinalang.compiler.packaging.Patten in project ballerina by ballerina-lang.
the class PattenTest method testBalExpansion.
@Test
public void testBalExpansion() {
Converter<String> mock = mockResolver("project-dir", null, null, s -> Stream.of(s + " > dir1 > x.bal", s + " > y.bal", s + " > dir2 > dir3 > f.bal"));
Patten subject = new Patten(Patten.WILDCARD_SOURCE);
List<String> strings = subject.convert(mock).collect(Collectors.toList());
Assert.assertEquals(strings, Arrays.asList("project-dir > dir1 > x.bal", "project-dir > y.bal", "project-dir > dir2 > dir3 > f.bal"));
}
use of org.wso2.ballerinalang.compiler.packaging.Patten in project ballerina by ballerina-lang.
the class PattenTest method testSiblingPath.
@Test
public void testSiblingPath() {
Patten subject = new Patten(path("first", "second", "third-a"));
Patten result = subject.sibling(path("third-b"));
Assert.assertEquals("$/first/second/third-b", result.toString());
}
use of org.wso2.ballerinalang.compiler.packaging.Patten in project ballerina by ballerina-lang.
the class PattenTest method testLazy.
/**
* Disabled because it fails in JVM 8
* See: https://bugs.openjdk.java.net/browse/JDK-8075939
*/
@Test(enabled = false)
public void testLazy() {
Converter<String> mock = mockResolver("root-dir", null, s -> Stream.concat(Stream.of("", ""), Stream.generate(() -> {
Assert.fail("method called. Hence not lazy.");
return "";
})), null);
Patten subject = new Patten(Patten.WILDCARD_DIR);
List<String> strings = subject.convert(mock).limit(1).collect(Collectors.toList());
Assert.assertTrue(strings.isEmpty());
}
use of org.wso2.ballerinalang.compiler.packaging.Patten in project ballerina by ballerina-lang.
the class RepoTest method testProjectObjRepo.
@Test
public void testProjectObjRepo() {
PackageID pkg = newPackageID("my_org", "my.pkg", "1.2.3");
ObjRepo subject = new ObjRepo((PathConverter) null);
Patten patten = subject.calculate(pkg);
Assert.assertEquals(patten.toString(), "$/repo/my_org/my.pkg/1.2.3/obj/my.pkg.balo");
}
use of org.wso2.ballerinalang.compiler.packaging.Patten in project ballerina by ballerina-lang.
the class RepoTest method testSystemOrgIsReserved.
@Test
public void testSystemOrgIsReserved() {
PackageID pkg = newPackageID("ballerina", "any.pkg", "10.2.3");
Repo subject = new NonSysRepo<String>(null) {
@Override
public Patten calculateNonSysPkg(PackageID pkg) {
Assert.fail("Tried to calculate path for system packages");
return null;
}
};
Patten patten = subject.calculate(pkg);
Assert.assertEquals(patten, Patten.NULL);
}
Aggregations