Search in sources :

Example 1 with InternationalAddress

use of org.drools.testcoverage.common.model.InternationalAddress in project drools by kiegroup.

the class OOPathDslTest method dslWithOOPathAndSpecialChars.

/**
 * Shows it's possible to use OOPath including some characters that are significant for both DSL and OOPath.
 */
@Test
public void dslWithOOPathAndSpecialChars() {
    final String dsl = "[when]Person comes from \"{state}\"=person : " + "Person( /address#InternationalAddress[ state == \"{state}\" ] )\n";
    final String drl = "package P\n" + "\n" + "import org.drools.testcoverage.common.model.InternationalAddress\n" + "import org.drools.testcoverage.common.model.Person\n" + "\n" + "rule R\n" + "when\n" + "    Person comes from \"Peaceful State\"\n" + "then\n" + "end";
    KieSession kieSession = new KieHelper().addContent(dsl, ResourceType.DSL).addContent(drl, ResourceType.DSLR).build().newKieSession();
    final Person person = new Person("Bruno", 21);
    person.setAddress(new InternationalAddress("Some Street", 10, "Beautiful City", "Peaceful State"));
    kieSession.insert(person);
    assertThat(kieSession.fireAllRules()).isEqualTo(1);
}
Also used : InternationalAddress(org.drools.testcoverage.common.model.InternationalAddress) KieHelper(org.kie.internal.utils.KieHelper) KieSession(org.kie.api.runtime.KieSession) Person(org.drools.testcoverage.common.model.Person) Test(org.junit.Test)

Example 2 with InternationalAddress

use of org.drools.testcoverage.common.model.InternationalAddress in project drools by kiegroup.

the class OOPathDtablesTest method prepareData.

private Person[] prepareData() {
    final Person bruno = new Person("Bruno", 25);
    bruno.setAddress(new InternationalAddress("Some Street", 10, "Nice City", "Safecountry"));
    final Person robert = new Person("Robert", 17);
    robert.setAddress(new InternationalAddress("Some Street", 12, "Small City", "Riskyland"));
    final Person joe = new Person("Joe", 11);
    joe.setAddress(new InternationalAddress("Some Street", 13, "Big City", "Safecountry"));
    final Person mike = new Person("Mike", 25);
    mike.setAddress(new Address("Some Street", 14, "Local City"));
    return new Person[] { bruno, robert, joe, mike };
}
Also used : InternationalAddress(org.drools.testcoverage.common.model.InternationalAddress) Address(org.drools.testcoverage.common.model.Address) InternationalAddress(org.drools.testcoverage.common.model.InternationalAddress) Person(org.drools.testcoverage.common.model.Person)

Aggregations

InternationalAddress (org.drools.testcoverage.common.model.InternationalAddress)2 Person (org.drools.testcoverage.common.model.Person)2 Address (org.drools.testcoverage.common.model.Address)1 Test (org.junit.Test)1 KieSession (org.kie.api.runtime.KieSession)1 KieHelper (org.kie.internal.utils.KieHelper)1