use of org.kie.api.definition.type.FactType in project drools by kiegroup.
the class UserDefinedFunctionsTest method testFunctions5.
@Test
public void testFunctions5() throws Exception {
setKSession(getModelSession(source3, VERBOSE));
setKbase(getKSession().getKieBase());
FactType userAge5 = getKbase().getFactType(packageName, "UserAge5");
getKSession().getEntryPoint("in_Age").insert(10);
getKSession().fireAllRules();
checkFirstDataFieldOfTypeStatus(userAge5, true, false, null, 45.5);
checkGeneratedRules();
}
use of org.kie.api.definition.type.FactType in project drools by kiegroup.
the class UserDefinedFunctionsTest method testFunctions4.
@Test
public void testFunctions4() throws Exception {
setKSession(getModelSession(source3, VERBOSE));
setKbase(getKSession().getKieBase());
FactType userAge4 = getKbase().getFactType(packageName, "UserAge4");
getKSession().getEntryPoint("in_Age").insert(10);
getKSession().fireAllRules();
checkFirstDataFieldOfTypeStatus(userAge4, true, false, null, 24);
checkGeneratedRules();
}
use of org.kie.api.definition.type.FactType in project drools by kiegroup.
the class UserDefinedFunctionsTest method testFunctions0Overwrite.
@Test
public void testFunctions0Overwrite() throws Exception {
setKSession(getModelSession(source0, VERBOSE));
setKbase(getKSession().getKieBase());
FactType userAge1 = getKbase().getFactType(packageName, "UserAge");
getKSession().getEntryPoint("in_Age").insert(8.4);
getKSession().fireAllRules();
getKSession().getEntryPoint("in_Age").insert(2.2);
getKSession().fireAllRules();
System.out.println(reportWMObjects(getKSession()));
checkFirstDataFieldOfTypeStatus(userAge1, true, false, null, 22.0);
checkGeneratedRules();
}
use of org.kie.api.definition.type.FactType in project drools by kiegroup.
the class ScorecardsKModuleTest method testScorecardFromKModule2.
@Test
public void testScorecardFromKModule2() throws Exception {
KieServices ks = KieServices.Factory.get();
KieContainer kContainer = ks.getKieClasspathContainer();
KieBase kBase = kContainer.getKieBase("namedkiesession");
assertNotNull(kBase);
KieSession kSession = kContainer.newKieSession("ksession1");
assertNotNull(kSession);
FactType scorecardType = kBase.getFactType("org.drools.scorecards.example", "SampleScore");
assertNotNull(scorecardType);
Object scorecard = scorecardType.newInstance();
assertNotNull(scorecard);
scorecardType.set(scorecard, "age", 10);
kSession.insert(scorecard);
kSession.fireAllRules();
kSession.dispose();
// occupation = 5, age = 25, validLicence -1
assertEquals(29.0, scorecardType.get(scorecard, "scorecard__calculatedScore"));
}
use of org.kie.api.definition.type.FactType in project drools by kiegroup.
the class ScorecardsKModuleTest method testScorecardFromKBase2.
@Test
public void testScorecardFromKBase2() throws Exception {
KieServices ks = KieServices.Factory.get();
KieContainer kContainer = ks.getKieClasspathContainer();
KieBase kBase = kContainer.getKieBase("kbase2");
assertNotNull(kBase);
KieSession kSession = kContainer.newKieSession("ksession2");
assertNotNull(kSession);
FactType scorecardType = kBase.getFactType("org.drools.scorecards.example", "SampleScore");
assertNotNull(scorecardType);
Object scorecard = scorecardType.newInstance();
assertNotNull(scorecard);
scorecardType.set(scorecard, "age", 50);
scorecardType.set(scorecard, "validLicense", true);
scorecardType.set(scorecard, "occupation", "PROGRAMMER");
// occupation
kSession.insert(scorecard);
kSession.fireAllRules();
kSession.dispose();
// age = 25, validLicence 0, occupation=5
assertEquals(30.0, scorecardType.get(scorecard, "scorecard__calculatedScore"));
}
Aggregations