MotechProxyManager { @Transactional public synchronized void rebuildProxyChain() { LOGGER.info("Rebuilding proxy chain"); updateSecurityChain(securityRulesDAO.getRules()); LOGGER.info("Rebuilt proxy chain"); }  @Transactional synchronized void rebuildProxyChain(); @Transactional void initializeProxyChain(); @Transactional MotechSecurityConfiguration getDefaultSecurityConfiguration(); FilterChainProxy getFilterChainProxy(); @Autowired void setProxy(FilterChainProxy proxy); @Autowired void setSecurityRuleBuilder(SecurityRuleBuilder securityRuleBuilder); @Autowired void setSecurityRulesDAO(MotechSecurityRulesDao securityRulesDAO);  }
@Test public void shouldOrderRulesByPriority() { List<MotechURLSecurityRule> rules = new ArrayList<>(); rules.add(buildRule("priority-3", 3)); rules.add(buildRule("catchall", 0)); rules.add(buildRule("priority-1", 1)); when(allSecurityRules.getRules()).thenReturn(rules); motechProxyManager.rebuildProxyChain(); InOrder inOrder = inOrder(securityRuleBuilder); inOrder.verify(securityRuleBuilder).buildSecurityChain(argThat(ruleMatcher("priority-3")), eq(GET)); inOrder.verify(securityRuleBuilder).buildSecurityChain(argThat(ruleMatcher("priority-1")), eq(GET)); inOrder.verify(securityRuleBuilder).buildSecurityChain(argThat(ruleMatcher("catchall")), eq(GET)); }