Java Code Examples for org.kie.api.runtime.KieContainer#getKieSessionModel()

The following examples show how to use org.kie.api.runtime.KieContainer#getKieSessionModel() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KieContainerTest.java    From kogito-runtimes with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetDefaultKieSessionModelEmptyKmodule() {
    KieServices kieServices = KieServices.Factory.get();
    String drl = "package org.drools.test\n" +
            "rule R1 when\n" +
            "   $m : Object()\n" +
            "then\n" +
            "end\n";
    Resource resource = kieServices.getResources().newReaderResource( new StringReader( drl), "UTF-8" );
    resource.setTargetPath("org/drools/test/rules.drl");
    String kmodule = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
            "<kmodule xmlns=\"http://www.drools.org/xsd/kmodule\">\n" +
            "</kmodule>";

    // Create an in-memory jar for version 1.0.0
    ReleaseId releaseId = kieServices.newReleaseId("org.kie", "test-testGetDefaultKieSessionModelEmptyKmodule", "1.0.0");
    createAndDeployJar(kieServices, kmodule, releaseId, resource);

    KieContainer kieContainer = kieServices.newKieContainer(releaseId);

    KieSessionModel sessionModel = kieContainer.getKieSessionModel(null);
    assertNotNull(sessionModel);
}
 
Example 2
Source File: KieContainerTest.java    From kogito-runtimes with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetDefaultKieSessionModel() {
    KieServices kieServices = KieServices.Factory.get();
    String drl = "package org.drools.test\n" +
            "rule R1 when\n" +
            "   $m : Object()\n" +
            "then\n" +
            "end\n";
    Resource resource = kieServices.getResources().newReaderResource( new StringReader( drl), "UTF-8" );
    resource.setTargetPath("org/drools/test/rules.drl");
    String kmodule = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
            "<kmodule xmlns=\"http://www.drools.org/xsd/kmodule\">\n" +
            "  <kbase name=\"testKbase\" packages=\"org.drools.test\">\n" +
            "    <ksession name=\"testKsession\" default=\"true\"/>\n" +
            "  </kbase>\n" +
            "</kmodule>";

    // Create an in-memory jar for version 1.0.0
    ReleaseId releaseId = kieServices.newReleaseId("org.kie", "test-testGetDefaultKieSessionModel", "1.0.0");
    createAndDeployJar(kieServices, kmodule, releaseId, resource);

    KieContainer kieContainer = kieServices.newKieContainer(releaseId);

    KieSessionModel sessionModel = kieContainer.getKieSessionModel(null);
    assertNotNull(sessionModel);
    assertEquals("testKsession", sessionModel.getName());
}