Search in sources :

Example 1 with Patten

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);
}
Also used : Path(java.nio.file.Path) PackageSourceEntry(org.ballerinalang.repository.PackageSourceEntry) Patten(org.wso2.ballerinalang.compiler.packaging.Patten) JarRepo(org.wso2.ballerinalang.compiler.packaging.repo.JarRepo) Test(org.testng.annotations.Test)

Example 2 with Patten

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());
}
Also used : Path(java.nio.file.Path) PathConverter(org.wso2.ballerinalang.compiler.packaging.converters.PathConverter) Patten(org.wso2.ballerinalang.compiler.packaging.Patten) Test(org.testng.annotations.Test)

Example 3 with Patten

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());
}
Also used : Patten(org.wso2.ballerinalang.compiler.packaging.Patten) Test(org.testng.annotations.Test)

Example 4 with Patten

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"));
}
Also used : Patten(org.wso2.ballerinalang.compiler.packaging.Patten) Test(org.testng.annotations.Test)

Example 5 with Patten

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"));
}
Also used : Patten(org.wso2.ballerinalang.compiler.packaging.Patten) Test(org.testng.annotations.Test)

Aggregations

Patten (org.wso2.ballerinalang.compiler.packaging.Patten)20 Test (org.testng.annotations.Test)16 PackageID (org.ballerinalang.model.elements.PackageID)6 Path (java.nio.file.Path)5 URI (java.net.URI)3 ProjectSourceRepo (org.wso2.ballerinalang.compiler.packaging.repo.ProjectSourceRepo)3 Repo (org.wso2.ballerinalang.compiler.packaging.repo.Repo)3 BLangCompilerException (org.ballerinalang.compiler.BLangCompilerException)2 PackageSourceEntry (org.ballerinalang.repository.PackageSourceEntry)2 Converter (org.wso2.ballerinalang.compiler.packaging.converters.Converter)2 PathConverter (org.wso2.ballerinalang.compiler.packaging.converters.PathConverter)2 CacheRepo (org.wso2.ballerinalang.compiler.packaging.repo.CacheRepo)2 HomeRepo (org.wso2.ballerinalang.compiler.packaging.repo.HomeRepo)2 ObjRepo (org.wso2.ballerinalang.compiler.packaging.repo.ObjRepo)2 RemoteRepo (org.wso2.ballerinalang.compiler.packaging.repo.RemoteRepo)2 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 MissingResourceException (java.util.MissingResourceException)1 URIConverter (org.wso2.ballerinalang.compiler.packaging.converters.URIConverter)1 JarRepo (org.wso2.ballerinalang.compiler.packaging.repo.JarRepo)1