use of org.drools.compiler.Precondition in project drools by kiegroup.
the class DynamicRulesTest method testRemovePackage.
@Test(timeout = 10000)
public void testRemovePackage() throws Exception {
Collection<KiePackage> kpkgs = SerializationHelper.serializeObject(loadKnowledgePackages("test_RemovePackage.drl"));
final String packageName = kpkgs.iterator().next().getName();
InternalKnowledgeBase kbase = (InternalKnowledgeBase) loadKnowledgeBase();
kbase.addPackages(kpkgs);
kbase = SerializationHelper.serializeObject(kbase);
KieSession session = createKnowledgeSession(kbase);
session.insert(new Precondition("genericcode", "genericvalue"));
session.fireAllRules();
InternalKnowledgeBase ruleBaseWM = (InternalKnowledgeBase) session.getKieBase();
ruleBaseWM.removeKiePackage(packageName);
kpkgs = SerializationHelper.serializeObject(loadKnowledgePackages("test_RemovePackage.drl"));
ruleBaseWM.addPackages(kpkgs);
ruleBaseWM = SerializationHelper.serializeObject(ruleBaseWM);
session = SerializationHelper.getSerialisedStatefulKnowledgeSession(session, true);
session.fireAllRules();
ruleBaseWM.removeKiePackage(packageName);
ruleBaseWM.addPackages(SerializationHelper.serializeObject(kpkgs));
ruleBaseWM.removeKiePackage(packageName);
ruleBaseWM.addPackages(SerializationHelper.serializeObject(kpkgs));
}
Aggregations