// Get the config file as an InputStream
InputStream is = Main.class.getClassLoader().getResourceAsStream(
"rooliebanking/roolie-config.xml");
// Create RulesEngine instance
RulesEngine rules = new RulesEngine(is);
// Create some rule arguments (aka "Facts") to test for some users
List<BankingRuleArgs> bankingRuleArgsList = createRuleArgsToTest();
// See if rules pass for each BankingRuleArgs created.
for (BankingRuleArgs ruleArgs : bankingRuleArgsList)
{
msg("\n* Evaluating 'userCanWithdrawFunds' rule for " + ruleArgs.getUser());
boolean canWithdrawFunds =
rules.passesRule("userCanWithdrawFunds", ruleArgs);
msg("User can withdraw funds? " + canWithdrawFunds);
if (canWithdrawFunds)
{
withdrawFunds(ruleArgs);
}
else
{
msg(ruleArgs.getUser() + " cannot withdraw $"
+ ruleArgs.getRequestedWithdrawlAmount());
}
msg("\n* Evaluating 'userCanDepositFunds' rule for " + ruleArgs.getUser());
boolean canDepositFunds =
rules.passesRule("userCanDepositFunds", ruleArgs);
msg("User can deposit funds? " + canDepositFunds);
if (canDepositFunds)
{
depositFunds(ruleArgs);