public void updateRules(Map<String, List<R>> rulesMap) {
        originalRules = rulesMap;
        Map<Pattern, List<R>> regexRules = new HashMap<>();
        Map<String, List<R>> simpleRules = new HashMap<>();
        for (Map.Entry<String, List<R>> entry : rulesMap.entrySet()) {
            String resource = entry.getKey();
            List<R> rules = entry.getValue();

            List<R> rulesOfSimple = new ArrayList<>();
            List<R> rulesOfRegex = new ArrayList<>();
            for (R rule : rules) {
                if (predicate.test(rule)) {
                    rulesOfRegex.add(rule);
                } else {
                    rulesOfSimple.add(rule);
                }
            }
            if (!rulesOfRegex.isEmpty()) {
                regexRules.put(Pattern.compile(resource), rulesOfRegex);
            }
            if (!rulesOfSimple.isEmpty()) {
                simpleRules.put(resource, rulesOfSimple);
            }
        }
        // rebuild regex cache rules
        setRules(regexRules, simpleRules);
    }
@Test
    public void testUpdateRules() throws Exception {
        // Setup
        final Map<String, List<FlowRule>> rulesMap = generateFlowRules(true);

        // Run the test
        ruleManager.updateRules(rulesMap);

        // Verify the results
        assertEquals(ruleManager.getRules().size(), 2);
        Field regexRules = RuleManager.class.getDeclaredField("regexRules");
        regexRules.setAccessible(true);
        assertEquals(((Map)regexRules.get(ruleManager)).size(), 1);
        Field simpleRules = RuleManager.class.getDeclaredField("simpleRules");
        simpleRules.setAccessible(true);
        assertEquals(((Map)simpleRules.get(ruleManager)).size(), 1);
    }