use of org.drools.core.common.DefaultFactHandle in project drools by kiegroup.
the class InsertObjectInEntryPointCommand method execute.
public FactHandle execute(Context context) {
KieSession ksession = ((RegistryContext) context).lookup(KieSession.class);
EntryPoint ep = ksession.getEntryPoint(entryPoint);
FactHandle factHandle = ep.insert(object);
DefaultFactHandle disconnectedHandle = ((DefaultFactHandle) factHandle).clone();
disconnectedHandle.disconnect();
if (outIdentifier != null) {
if (this.returnObject) {
((RegistryContext) context).lookup(ExecutionResultImpl.class).setResult(this.outIdentifier, object);
}
((RegistryContext) context).lookup(ExecutionResultImpl.class).getFactHandles().put(this.outIdentifier, disconnectedHandle);
}
return disconnectedHandle;
}
use of org.drools.core.common.DefaultFactHandle in project drools by kiegroup.
the class FactHandleTest method testHashCode.
@Test
public void testHashCode() {
final DefaultFactHandle f0 = new DefaultFactHandle(234, "cheese");
assertEquals("cheese".hashCode(), f0.getObjectHashCode());
assertEquals(234, f0.hashCode());
}
use of org.drools.core.common.DefaultFactHandle in project drools by kiegroup.
the class FactHandleTest method testFactHandleImpllong.
/*
* Class under test for void FactHandleImpl(long)
*/
@Test
public void testFactHandleImpllong() {
final DefaultFactHandle f0 = new DefaultFactHandle(134, "cheese");
assertEquals(134, f0.getId());
assertEquals(134, f0.getRecency());
}
use of org.drools.core.common.DefaultFactHandle in project drools by kiegroup.
the class ProtobufOutputMarshallerTest method testOrderFacts.
@Test
public void testOrderFacts() throws Exception {
List<InternalFactHandle> list = new ArrayList<InternalFactHandle>();
List<Integer> ids = Arrays.asList(0, 1, 2, 3, 4, 5, 6, 30, 31, 32, -2147483640, 7, 8, 9, 10, 11, 12, 13, 14, 15, 28, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27);
for (Integer i : ids) {
list.add(new DefaultFactHandle(i.intValue(), i));
}
InternalFactHandle first = ProtobufOutputMarshaller.orderFacts(list)[0];
assertEquals(-2147483640, first.getId());
}
use of org.drools.core.common.DefaultFactHandle in project drools by kiegroup.
the class RemoveRuleTest method testRuleRemovalWithJoinedRootPattern.
@Test
public void testRuleRemovalWithJoinedRootPattern() {
String str = "";
str += "package org.drools.compiler \n";
str += "import " + Person.class.getCanonicalName() + ";\n";
str += "import " + Cheese.class.getCanonicalName() + ";\n";
str += "rule rule1 \n";
str += "when \n";
str += " String() \n";
str += " Person() \n";
str += "then \n";
str += "end \n";
str += "rule rule2 \n";
str += "when \n";
str += " String() \n";
str += " Cheese() \n";
str += "then \n";
str += "end \n";
final KieServices kieServices = KieServices.get();
final ReleaseId releaseId = kieServices.newReleaseId("org.kie", "test-remove-rule-with-joined-root-pattern", "1.0");
KieUtil.getKieModuleFromDrls(releaseId, kieBaseTestConfiguration, str);
final KieContainer kieContainer = kieServices.newKieContainer(releaseId);
final KieBase kbase = kieContainer.getKieBase();
final KieSession ksession = kbase.newKieSession();
final DefaultFactHandle handle = (DefaultFactHandle) ksession.insert("hello");
ksession.fireAllRules();
LeftTuple leftTuple = handle.getFirstLeftTuple();
assertNotNull(leftTuple);
assertNotNull(leftTuple.getPeer());
kbase.removeRule("org.drools.compiler", "rule2");
leftTuple = handle.getFirstLeftTuple();
assertNotNull(leftTuple);
assertNull(leftTuple.getHandleNext());
}
Aggregations