QueueCircuitBreakerRulePatternToCircuitMapping { public List<PatternAndCircuitHash> updateRulePatternToCircuitMapping(List<Rule> rules){ List<PatternAndCircuitHash> originalPatternAndCircuitHashes = new ArrayList<>(rulePatternToCircuitMapping); log.debug("clearing rule pattern to circuit mapping values"); rulePatternToCircuitMapping.clear(); log.debug("new rule pattern to circuit mapping values are:"); for (Rule rule : rules) { PatternAndCircuitHash patternAndCircuitHash = getPatternAndCircuitHashFromRule(rule); if(patternAndCircuitHash != null){ log.debug(patternAndCircuitHash.toString()); rulePatternToCircuitMapping.add(patternAndCircuitHash); } else { log.error("rule pattern and circuitHash could not be retrieved from rule " + rule.getUrlPattern()); } } return getRemovedPatternAndCircuitHashes(originalPatternAndCircuitHashes, rulePatternToCircuitMapping); }  List<PatternAndCircuitHash> updateRulePatternToCircuitMapping(List<Rule> rules); PatternAndCircuitHash getCircuitFromRequestUri(String requestUri);  }
@Test public void testGetRemovedPatternAndCircuitHashAfterUpdate(TestContext context){ context.assertNotNull(rules); context.assertNotNull(rulesAfterUpdate); context.assertEquals(3, rules.size()); context.assertEquals(4, rulesAfterUpdate.size()); List<PatternAndCircuitHash> patternAndCircuitHashes = mapping.updateRulePatternToCircuitMapping(rules); context.assertEquals(0, patternAndCircuitHashes.size()); List<PatternAndCircuitHash> patternAndCircuitHashesAfterUpdate = mapping.updateRulePatternToCircuitMapping(rulesAfterUpdate); context.assertEquals(1, patternAndCircuitHashesAfterUpdate.size()); PatternAndCircuitHash removedPatternAndCircuitHash = patternAndCircuitHashesAfterUpdate.get(0); context.assertEquals("/playground/js/(.*)", removedPatternAndCircuitHash.getPattern().pattern()); }