use of org.kie.internal.builder.ScoreCardConfiguration in project drools by kiegroup.
the class ScorecardProviderTest method testKnowledgeBaseWithExection.
@Test
public void testKnowledgeBaseWithExection() throws Exception {
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
ScoreCardConfiguration scconf = KnowledgeBuilderFactory.newScoreCardConfiguration();
scconf.setWorksheetName("scorecards");
kbuilder.add(ResourceFactory.newUrlResource(ScorecardProviderTest.class.getResource("/scoremodel_c.xls")), ResourceType.SCARD, scconf);
assertFalse(kbuilder.hasErrors());
InternalKnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
assertNotNull(kbase);
kbase.addPackages(kbuilder.getKnowledgePackages());
// NEW WORKING MEMORY
KieSession session = kbase.newKieSession();
FactType scorecardType = kbase.getFactType("org.drools.scorecards.example", "SampleScore");
assertNotNull(scorecardType);
Object scorecard = scorecardType.newInstance();
assertNotNull(scorecard);
scorecardType.set(scorecard, "age", 10);
session.insert(scorecard);
session.fireAllRules();
session.dispose();
// occupation = 5, age = 25, validLicence -1
assertEquals(29.0, scorecardType.get(scorecard, "scorecard__calculatedScore"));
}
Aggregations