Search in sources :

Example 56 with Resource

use of org.kie.api.io.Resource in project drools by kiegroup.

the class DecisionTableTest method testLockOnActive.

@Test
public void testLockOnActive() {
    final Resource decisionTable = ResourceUtil.getDecisionTableResourceFromClasspath("agenda-group.csv", getClass(), DecisionTableInputType.CSV);
    final KieBase kbase = KieBaseUtil.getKieBaseFromResources(kieBaseTestConfiguration, decisionTable);
    final KieSession ksession = kbase.newKieSession();
    final OrderListener listener = new OrderListener();
    ksession.addEventListener(listener);
    ksession.insert("lockOnActive");
    ksession.fireAllRules();
    Assertions.assertThat(listener.size()).isEqualTo(3);
    final String[] expected = { "a", "a2", "a3" };
    for (int i = 0; i < listener.size(); i++) {
        Assertions.assertThat(listener.get(i)).isEqualTo(expected[i]);
    }
}
Also used : KieBase(org.kie.api.KieBase) Resource(org.kie.api.io.Resource) OrderListener(org.drools.testcoverage.common.listener.OrderListener) KieSession(org.kie.api.runtime.KieSession) Test(org.junit.Test)

Example 57 with Resource

use of org.kie.api.io.Resource in project drools by kiegroup.

the class DecisionTableTest method testSimpleXLS.

@Test
public void testSimpleXLS() {
    final Resource decisionTable = ResourceUtil.getDecisionTableResourceFromClasspath("sample.xls", getClass(), DecisionTableInputType.XLS);
    testSimpleDecisionTable(decisionTable);
}
Also used : Resource(org.kie.api.io.Resource) Test(org.junit.Test)

Example 58 with Resource

use of org.kie.api.io.Resource in project drools by kiegroup.

the class MultipleSheetsLoadingTest method buildResources.

private KieBuilder buildResources() {
    final Resource resourceXlsFirst = this.createResourceWithConfig(WORKSHEET_1_NAME);
    final Resource resourceXlsSecond = this.createResourceWithConfig(WORKSHEET_2_NAME);
    return KieUtil.getKieBuilderFromResources(kieBaseTestConfiguration, false, resourceXlsFirst, resourceXlsSecond);
}
Also used : Resource(org.kie.api.io.Resource)

Example 59 with Resource

use of org.kie.api.io.Resource in project drools by kiegroup.

the class NonStringCompareTest method build.

private KieBuilder build(final String replacement) {
    final String drl = String.format(genericDrl, replacement);
    final Resource resource = KieServices.Factory.get().getResources().newReaderResource(new StringReader(drl));
    resource.setTargetPath(TestConstants.DRL_TEST_TARGET_PATH);
    return KieUtil.getKieBuilderFromResources(kieBaseTestConfiguration, false, resource);
}
Also used : Resource(org.kie.api.io.Resource) StringReader(java.io.StringReader)

Example 60 with Resource

use of org.kie.api.io.Resource in project drools by kiegroup.

the class POJOAnnotationMergeTest method testPositionFromPOJOIgnored.

/**
 * Tests adding metadata in DRL to the metadata already declared in a POJO.
 */
@Test
public void testPositionFromPOJOIgnored() {
    final Resource resource = KieServices.Factory.get().getResources().newReaderResource(new StringReader(DRL));
    resource.setTargetPath(TestConstants.DRL_TEST_TARGET_PATH);
    KieUtil.getKieBuilderFromResources(kieBaseTestConfiguration, true, resource);
}
Also used : Resource(org.kie.api.io.Resource) StringReader(java.io.StringReader) Test(org.junit.Test)

Aggregations

Resource (org.kie.api.io.Resource)162 Test (org.junit.Test)100 KieSession (org.kie.api.runtime.KieSession)50 KieServices (org.kie.api.KieServices)43 KieBase (org.kie.api.KieBase)42 ArrayList (java.util.ArrayList)30 KieContainer (org.kie.api.runtime.KieContainer)27 StringReader (java.io.StringReader)23 ReleaseId (org.kie.api.builder.ReleaseId)23 KieBuilder (org.kie.api.builder.KieBuilder)20 KieModule (org.kie.api.builder.KieModule)20 KieFileSystem (org.kie.api.builder.KieFileSystem)19 ClassPathResource (org.drools.core.io.impl.ClassPathResource)18 InternalKieModule (org.drools.compiler.kie.builder.impl.InternalKieModule)17 FactType (org.kie.api.definition.type.FactType)17 KnowledgeBuilder (org.kie.internal.builder.KnowledgeBuilder)16 InternalKnowledgeBase (org.drools.core.impl.InternalKnowledgeBase)14 ByteArrayResource (org.drools.core.io.impl.ByteArrayResource)14 IOException (java.io.IOException)13 PMMLResource (org.drools.compiler.compiler.PMMLResource)11