Search in sources :

Example 1 with FileSystemResource

use of org.drools.core.io.impl.FileSystemResource in project drools by kiegroup.

the class ChangesetUndoTest method testCompilationUndoAfterGoodResults.

@Test
public void testCompilationUndoAfterGoodResults() {
    KnowledgeBuilder knowledgeBuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
    knowledgeBuilder.add(new FileSystemResource(resources[1]), ResourceType.DRL);
    knowledgeBuilder.add(new FileSystemResource(resources[4]), ResourceType.CHANGE_SET);
    assertTrue(knowledgeBuilder.hasErrors());
    knowledgeBuilder.undo();
    assertFalse(knowledgeBuilder.hasErrors());
    for (KiePackage kp : knowledgeBuilder.getKnowledgePackages()) {
        if ("org.drools.test1".equals(kp.getName())) {
            assertEquals(1, kp.getRules().size());
            assertEquals(1, kp.getFactTypes().size());
        } else {
            assertTrue(kp.getRules().isEmpty());
            assertTrue(kp.getFactTypes().isEmpty());
        }
    }
    ;
}
Also used : KnowledgeBuilder(org.kie.internal.builder.KnowledgeBuilder) KiePackage(org.kie.api.definition.KiePackage) FileSystemResource(org.drools.core.io.impl.FileSystemResource) Test(org.junit.Test)

Example 2 with FileSystemResource

use of org.drools.core.io.impl.FileSystemResource in project drools by kiegroup.

the class ChangesetUndoTest method testCompilationUndo.

@Test
public void testCompilationUndo() {
    KnowledgeBuilder knowledgeBuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
    knowledgeBuilder.add(new FileSystemResource(resources[0]), ResourceType.CHANGE_SET);
    assertTrue(knowledgeBuilder.hasErrors());
    knowledgeBuilder.undo();
    assertFalse(knowledgeBuilder.hasErrors());
    for (KiePackage kp : knowledgeBuilder.getKnowledgePackages()) {
        assertTrue(kp.getRules().isEmpty());
        assertTrue(kp.getFactTypes().isEmpty());
    }
    ;
}
Also used : KnowledgeBuilder(org.kie.internal.builder.KnowledgeBuilder) KiePackage(org.kie.api.definition.KiePackage) FileSystemResource(org.drools.core.io.impl.FileSystemResource) Test(org.junit.Test)

Aggregations

FileSystemResource (org.drools.core.io.impl.FileSystemResource)2 Test (org.junit.Test)2 KiePackage (org.kie.api.definition.KiePackage)2 KnowledgeBuilder (org.kie.internal.builder.KnowledgeBuilder)2