Search in sources :

Example 6 with ResourceProvider

use of org.drools.core.common.ResourceProvider in project drools by kiegroup.

the class MemoryKieModuleResourceProviderTest method testGetResourceForFolderWithOnlySubFolders.

@Test
public void testGetResourceForFolderWithOnlySubFolders() throws Exception {
    MemoryFileSystem mfs = new MemoryFileSystem();
    mfs.createFolder(new MemoryFolder(mfs, "src/main/java"));
    mfs.createFolder(new MemoryFolder(mfs, "src/main/java/org"));
    mfs.createFolder(new MemoryFolder(mfs, "src/main/java/com"));
    MemoryKieModule mkm = new MemoryKieModule(releaseId, kieModuleModel, mfs);
    ResourceProvider resourceProvider = mkm.createResourceProvider();
    String folderContents = IOUtils.toString(resourceProvider.getResource("src/main/java").openStream());
    Assertions.assertThat(folderContents).hasLineCount(2).contains("com", "org");
}
Also used : MemoryFileSystem(org.drools.compiler.compiler.io.memory.MemoryFileSystem) ResourceProvider(org.drools.core.common.ResourceProvider) MemoryFolder(org.drools.compiler.compiler.io.memory.MemoryFolder) Test(org.junit.Test)

Example 7 with ResourceProvider

use of org.drools.core.common.ResourceProvider in project drools by kiegroup.

the class MemoryKieModuleResourceProviderTest method testGetResourceForEmptyFolder.

@Test
public void testGetResourceForEmptyFolder() throws Exception {
    MemoryFileSystem mfs = new MemoryFileSystem();
    mfs.createFolder(new MemoryFolder(mfs, "src/main/java"));
    MemoryKieModule mkm = new MemoryKieModule(releaseId, kieModuleModel, mfs);
    ResourceProvider resourceProvider = mkm.createResourceProvider();
    String folderContents = IOUtils.toString(resourceProvider.getResource("src/main/java").openStream());
    Assertions.assertThat(folderContents).isEmpty();
}
Also used : MemoryFileSystem(org.drools.compiler.compiler.io.memory.MemoryFileSystem) ResourceProvider(org.drools.core.common.ResourceProvider) MemoryFolder(org.drools.compiler.compiler.io.memory.MemoryFolder) Test(org.junit.Test)

Aggregations

ResourceProvider (org.drools.core.common.ResourceProvider)7 MemoryFileSystem (org.drools.compiler.compiler.io.memory.MemoryFileSystem)6 Test (org.junit.Test)6 MemoryFolder (org.drools.compiler.compiler.io.memory.MemoryFolder)4 MemoryFile (org.drools.compiler.compiler.io.memory.MemoryFile)3 Field (java.lang.reflect.Field)1 KieRepository (org.kie.api.builder.KieRepository)1 KieBaseModel (org.kie.api.builder.model.KieBaseModel)1