public List<RuleSet> findRuleSets() { RuleSetQuery ruleSetQuery = new RuleSetQuery(); ruleSetQuery.filterByRuleType(RuleType.SAFETY_SIGNALLING_RULES); ruleSetQuery.filterByStatus(RuleSet.STATUS_ENABLED); ruleSetQuery.filterByStudyId(1); return (List<RuleSet>) caaersRulesEngineService.getRuleSetDao().search(ruleSetQuery); }
private void setupRules() throws Exception { InputStream in = RuleUtil.getResouceAsStream("safety_signalling_rules_study_1A.xml"); String xml = RuleUtil.getFileContext(in); System.out.println(xml); File f = File.createTempFile("r_" + System.currentTimeMillis(), "sae.xml"); System.out.println(f.getAbsolutePath()); FileWriter fw = new FileWriter(f); IOUtils.write(xml, fw); IOUtils.closeQuietly(fw); assertTrue(f.exists()); assertTrue(findRuleSets().isEmpty()); caaersRulesEngineService.importRules(f.getAbsolutePath()); f.delete(); List<RuleSet> ruleSets = findRuleSets(); assertFalse(ruleSets.isEmpty()); RuleSet rs = ruleSets.get(0); assertTrue(rs.isEnabled()); }