Search in sources :

Example 1 with CaseData

use of org.kie.api.runtime.process.CaseData in project drools by kiegroup.

the class ProcessContextTest method testProcessContextGetData.

@Test
public void testProcessContextGetData() {
    KieBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
    KieSession ksession = kbase.newKieSession();
    assertNotNull(ksession);
    CaseInformation caseInfo = new CaseInformation();
    caseInfo.add("test", "value");
    ksession.insert(caseInfo);
    ProcessContext processContext = new ProcessContext(ksession);
    CaseData caseData = processContext.getCaseData();
    assertNotNull(caseData);
    Map<String, Object> allData = caseData.getData();
    assertNotNull(allData);
    assertEquals(1, allData.size());
    assertEquals("value", caseData.getData("test"));
}
Also used : CaseData(org.kie.api.runtime.process.CaseData) KieBase(org.kie.api.KieBase) KieSession(org.kie.api.runtime.KieSession) Test(org.junit.Test)

Example 2 with CaseData

use of org.kie.api.runtime.process.CaseData in project drools by kiegroup.

the class ProcessContextTest method testProcessContextGetDataAndAssignmentWithoutInsert.

@Test
public void testProcessContextGetDataAndAssignmentWithoutInsert() {
    KieBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
    KieSession ksession = kbase.newKieSession();
    assertNotNull(ksession);
    ProcessContext processContext = new ProcessContext(ksession);
    CaseData caseData = processContext.getCaseData();
    assertNull(caseData);
    CaseAssignment caseAssignment = processContext.getCaseAssignment();
    assertNull(caseAssignment);
}
Also used : CaseData(org.kie.api.runtime.process.CaseData) KieBase(org.kie.api.KieBase) KieSession(org.kie.api.runtime.KieSession) CaseAssignment(org.kie.api.runtime.process.CaseAssignment) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 KieBase (org.kie.api.KieBase)2 KieSession (org.kie.api.runtime.KieSession)2 CaseData (org.kie.api.runtime.process.CaseData)2 CaseAssignment (org.kie.api.runtime.process.CaseAssignment)1