Skip to content

Commit

Permalink
Enhanced testSalienceIntegerAndLoadOrder for better memory management…
Browse files Browse the repository at this point in the history
… and type safety (apache#6042)

Co-authored-by: Rashmesh Radhakrishnan <rashmeshradhakrishnan@Rashmeshs-Mac-Studio.local>
  • Loading branch information
2 people authored and rgdoliveira committed Aug 26, 2024
1 parent b5c09a3 commit 673eae0
Showing 1 changed file with 17 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,26 @@ public static Collection<Object[]> getParameters() {
@Test(timeout = 10000)
public void testSalienceIntegerAndLoadOrder() throws Exception {
KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(this.getClass(), kieBaseTestConfiguration, "test_salienceIntegerRule.drl");
KieSession ksession = kbase.newKieSession();
final List list = new ArrayList();
ksession.setGlobal( "list", list );
KieSession ksession = null;
try {
ksession = kbase.newKieSession();
final List<String> list = new ArrayList<>();
ksession.setGlobal("list", list);

final PersonInterface person = new Person( "Edson", "cheese" );
ksession.insert( person );
final PersonInterface person = new Person("Edson", "cheese");
ksession.insert(person);

ksession.fireAllRules();
ksession.fireAllRules();

assertThat(list.size()).as("Three rules should have been fired").isEqualTo(3);
assertThat(list.get(0)).as("Rule 4 should have been fired first").isEqualTo("Rule 4");
assertThat(list.get(1)).as("Rule 2 should have been fired second").isEqualTo("Rule 2");
assertThat(list.get(2)).as("Rule 3 should have been fired third").isEqualTo("Rule 3");
assertThat(list.size()).as("Three rules should have been fired").isEqualTo(3);
assertThat(list.get(0)).as("Rule 4 should have been fired first").isEqualTo("Rule 4");
assertThat(list.get(1)).as("Rule 2 should have been fired second").isEqualTo("Rule 2");
assertThat(list.get(2)).as("Rule 3 should have been fired third").isEqualTo("Rule 3");
} finally {
if (ksession != null) {
ksession.dispose();
}
}
}

@Test
Expand Down

0 comments on commit 673eae0

Please sign in to comment.