use of org.wso2.ballerinalang.compiler.packaging.Patten in project ballerina by ballerina-lang.
the class JarIntegrationTest method balInsideJar.
@Test
public void balInsideJar() throws IOException {
Patten balPatten = new Patten(path("very"), Patten.WILDCARD_SOURCE);
JarRepo repo = new JarRepo(tempJar.toUri());
Converter<Path> subject = repo.getConverterInstance();
List<PackageSourceEntry> sources = balPatten.convertToSources(subject, null).collect(Collectors.toList());
Assert.assertEquals(sources.size(), 1);
Assert.assertEquals(sources.get(0).getCode(), BAL_CONTENT);
}
use of org.wso2.ballerinalang.compiler.packaging.Patten in project ballerina by ballerina-lang.
the class PathConverterIntegrationTest method testWildcard.
@Test
public void testWildcard() {
Patten patten = new Patten(WILDCARD_DIR, path("deep"), WILDCARD_DIR, path("dir.bal", "tempFile.bal"));
PathConverter subject = new PathConverter(tempDirectory);
Stream<Path> pathStream = patten.convert(subject);
List<Path> paths = pathStream.collect(Collectors.toList());
Assert.assertEquals(paths.size(), 1);
Assert.assertEquals(paths.get(0).toString(), tempFile.toString());
}
use of org.wso2.ballerinalang.compiler.packaging.Patten in project ballerina by ballerina-lang.
the class PattenTest method testSiblingWildcard.
@Test
public void testSiblingWildcard() {
Patten subject = new Patten(path("first", "second"), Patten.WILDCARD_DIR);
Patten result = subject.sibling(path("third"));
Assert.assertEquals("$/first/second/third", result.toString());
}
use of org.wso2.ballerinalang.compiler.packaging.Patten in project ballerina by ballerina-lang.
the class PattenTest method testReductionAndExpansion.
@Test
public void testReductionAndExpansion() {
Converter<String> mock = mockResolver("my-dir", (a, b) -> a + " > " + b, s -> Stream.of(s + " > cache1", s + " > cache2", s + " > cache3"), q -> Stream.of(q + " > dir1 > x.bal", q + " > y.bal", q + " > dir2 > dir3 > f.bal"));
Patten subject = new Patten(path("hello"), Patten.WILDCARD_DIR, path("world"), Patten.WILDCARD_SOURCE);
List<String> strings = subject.convert(mock).collect(Collectors.toList());
Assert.assertEquals(strings, Arrays.asList("my-dir > hello > cache1 > world > dir1 > x.bal", "my-dir > hello > cache1 > world > y.bal", "my-dir > hello > cache1 > world > dir2 > dir3 > f.bal", "my-dir > hello > cache2 > world > dir1 > x.bal", "my-dir > hello > cache2 > world > y.bal", "my-dir > hello > cache2 > world > dir2 > dir3 > f.bal", "my-dir > hello > cache3 > world > dir1 > x.bal", "my-dir > hello > cache3 > world > y.bal", "my-dir > hello > cache3 > world > dir2 > dir3 > f.bal"));
}
use of org.wso2.ballerinalang.compiler.packaging.Patten in project ballerina by ballerina-lang.
the class PattenTest method testDirExpansion.
@Test
public void testDirExpansion() {
Converter<String> mock = mockResolver("root-dir", null, s -> Stream.of(s + " > cache1", s + " > cache2", s + " > cache3"), null);
Patten subject = new Patten(Patten.WILDCARD_DIR);
List<String> strings = subject.convert(mock).collect(Collectors.toList());
Assert.assertEquals(strings, Arrays.asList("root-dir > cache1", "root-dir > cache2", "root-dir > cache3"));
}
Aggregations