Search in sources :

Example 1 with CaseAssignment

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

the class ProcessContextTest method testProcessContextGetAssignment.

@Test
public void testProcessContextGetAssignment() {
    KieBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
    KieSession ksession = kbase.newKieSession();
    assertNotNull(ksession);
    CaseInformation caseInfo = new CaseInformation();
    caseInfo.assign("owner", new OrganizationalEntity() {

        @Override
        public String getId() {
            return "testUser";
        }

        @Override
        public void writeExternal(ObjectOutput out) throws IOException {
        }

        @Override
        public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
        }
    });
    ksession.insert(caseInfo);
    ProcessContext processContext = new ProcessContext(ksession);
    CaseAssignment caseAssignment = processContext.getCaseAssignment();
    assertNotNull(caseAssignment);
    Collection<OrganizationalEntity> forRole = caseAssignment.getAssignments("owner");
    assertNotNull(forRole);
    assertEquals(1, forRole.size());
}
Also used : OrganizationalEntity(org.kie.api.task.model.OrganizationalEntity) ObjectOutput(java.io.ObjectOutput) IOException(java.io.IOException) CaseAssignment(org.kie.api.runtime.process.CaseAssignment) KieBase(org.kie.api.KieBase) KieSession(org.kie.api.runtime.KieSession) ObjectInput(java.io.ObjectInput) Test(org.junit.Test)

Example 2 with CaseAssignment

use of org.kie.api.runtime.process.CaseAssignment 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 CaseAssignment (org.kie.api.runtime.process.CaseAssignment)2 IOException (java.io.IOException)1 ObjectInput (java.io.ObjectInput)1 ObjectOutput (java.io.ObjectOutput)1 CaseData (org.kie.api.runtime.process.CaseData)1 OrganizationalEntity (org.kie.api.task.model.OrganizationalEntity)1