Skip to content

Instantly share code, notes, and snippets.

@baldimir
Created February 18, 2019 12:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save baldimir/e5a6af0221f2f6784802be7529b5e4f7 to your computer and use it in GitHub Desktop.
Save baldimir/e5a6af0221f2f6784802be7529b5e4f7 to your computer and use it in GitHub Desktop.
@Test
public void testEnum() {
final String drl =
"package org.drools.compiler.integrationtests.operators;" +
"import " + Person.class.getCanonicalName() + ";\n" +
"import " + Pet.class.getCanonicalName() + ";\n" +
"rule \"Enum rule\" \n" +
"when \n" +
" $p : Person () \n" +
" $pet : Pet (type == Pet.PetType.DOG) from $p.getPets().values() \n" +
"then \n" +
"end";
final KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("from-test",
kieBaseTestConfiguration,
drl);
final KieSession ksession = kbase.newKieSession();
try {
final Person person = new Person("dog lady");
final Pet pet1 = new Pet(Pet.PetType.DOG, 3);
final Pet pet2 = new Pet(Pet.PetType.DOG, 5);
person.addPet("dog1", pet1);
person.addPet("dog2", pet2);
ksession.insert(person);
assertEquals(2, ksession.fireAllRules());
} finally {
ksession.dispose();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment