Skip to content

Commit

Permalink
- Fix rules to meet drools-ansible
Browse files Browse the repository at this point in the history
- Revert back to IdentityObjectStore
  • Loading branch information
tkobayas committed Jun 26, 2023
1 parent 27ebb66 commit 1b5d5e6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 32 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@

import org.drools.core.ClockType;
import org.drools.core.common.DefaultEventHandle;
import org.drools.core.common.EqualityObjectStore;
import org.drools.core.common.IdentityObjectStore;
import org.drools.core.common.InternalFactHandle;
import org.drools.core.common.InternalWorkingMemory;
import org.drools.core.common.InternalWorkingMemoryEntryPoint;
import org.drools.core.common.Storage;

public class SimpleSerializationReliableObjectStore extends EqualityObjectStore implements SimpleReliableObjectStore {
public class SimpleSerializationReliableObjectStore extends IdentityObjectStore implements SimpleReliableObjectStore {

protected final transient Storage<Long, StoredObject> storage;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
import static org.drools.model.PatternDSL.rule;
import static org.drools.model.PrototypeDSL.protoPattern;
import static org.drools.model.PrototypeDSL.variable;
import static org.drools.model.PrototypeExpression.prototypeField;
import static org.drools.model.PrototypeExpression.thisPrototype;
import static org.drools.modelcompiler.facttemplate.FactFactory.createMapBasedEvent;
import static org.drools.reliability.infinispan.util.PrototypeUtils.DEFAULT_PROTOTYPE_NAME;
import static org.drools.reliability.infinispan.util.PrototypeUtils.SYNTHETIC_PROTOTYPE_NAME;
Expand All @@ -70,6 +72,7 @@ private Model ruleModel() {
PrototypeVariable controlVar1 = variable(controlPrototype, "c1");
PrototypeVariable controlVar2 = variable(controlPrototype, "c2");
PrototypeVariable controlVar3 = variable(controlPrototype, "c3");
PrototypeVariable eventVar = variable(getPrototype(DEFAULT_PROTOTYPE_NAME), "e");
Variable<Long> resultCount = declarationOf( Long.class, "count" );
Global<List> global = globalOf(List.class, "defaultpkg", "results");

Expand Down Expand Up @@ -199,9 +202,10 @@ private Model ruleModel() {
.build(
protoPattern(controlVar1).expr( "rulename", Index.ConstraintType.EQUAL, endTag ),
protoPattern(controlVar2).expr(p -> ((String)p.get("rulename")).startsWith(rulePrefix)),
on(controlVar1, controlVar2).execute((drools, c1, c2) -> {
drools.delete(c2.get("event"));
drools.delete(c2);
protoPattern(eventVar).expr( thisPrototype(), Index.ConstraintType.EQUAL, controlVar2, prototypeField("event") ),
on(controlVar2, eventVar).execute((drools, c, e) -> {
drools.delete(e);
drools.delete(c);
})
)
);
Expand All @@ -215,8 +219,9 @@ private Model ruleModel() {
.expr( "rulename", Index.ConstraintType.EQUAL, endTag )
.expr( after(0, timeAmount.getTimeUnit(), timeAmount.getAmount(), timeAmount.getTimeUnit()), controlVar1 ) ),
protoPattern(controlVar3).expr(p -> ((String)p.get("rulename")).startsWith(rulePrefix)),
on(controlVar1, controlVar3).execute((drools, c1, c3) -> {
drools.delete(c3.get("event"));
protoPattern(eventVar).expr( thisPrototype(), Index.ConstraintType.EQUAL, controlVar3, prototypeField("event") ),
on(controlVar1, controlVar3, eventVar).execute((drools, c1, c3, e) -> {
drools.delete(e);
drools.delete(c3);
drools.delete(c1);
})
Expand Down Expand Up @@ -261,6 +266,9 @@ void insertFailoverExpireFire_shouldFire(PersistedSessionOption.PersistenceStrat

assertThat(getResults()).as("after 5 minutes window. the main rule is fired")
.hasSize(1);

assertThat(getFactHandles()).as("All events should be cleaned up")
.isEmpty();
}

@ParameterizedTest
Expand All @@ -287,5 +295,8 @@ void insertExpireFailoverFire_shouldFire(PersistedSessionOption.PersistenceStrat

assertThat(getResults()).as("after 5 minutes window. the main rule is fired")
.hasSize(1);

assertThat(getFactHandles()).as("All events should be cleaned up")
.isEmpty();
}
}

0 comments on commit 1b5d5e6

Please sign in to comment.