private List<Object> getTargetInstancesByRules(String targetName, List<Object> instances, String path,
            Map<String, List<String>> header) {
        RouterConfiguration configuration = ConfigCache.getLabel(RouterConstant.SPRING_CACHE_NAME);
        if (RouterConfiguration.isInValid(configuration, RouterConstant.FLOW_MATCH_KIND)) {
            return instances;
        }
        List<Rule> rules = FlowRuleUtils.getFlowRules(configuration, targetName, path, AppCache.INSTANCE.getAppName());
        if (CollectionUtils.isEmpty(rules)) {
            return instances;
        }
        Optional<Rule> ruleOptional = getRule(rules, header);
        if (ruleOptional.isPresent()) {
            return RuleStrategyHandler.INSTANCE.getFlowMatchInstances(targetName, instances, ruleOptional.get());
        }
        return RuleStrategyHandler.INSTANCE
                .getMismatchInstances(targetName, instances, RuleUtils.getTags(rules), true);
    }
@Test
    public void testGetTargetInstancesByRules() {
        RuleInitializationUtils.initFlowMatchRule();
        List<Object> instances = new ArrayList<>();
        ServiceInstance instance1 = TestDefaultServiceInstance.getTestDefaultServiceInstance("1.0.0");
        instances.add(instance1);
        ServiceInstance instance2 = TestDefaultServiceInstance.getTestDefaultServiceInstance("1.0.1");
        instances.add(instance2);
        Map<String, List<String>> header = new HashMap<>();
        header.put("bar", Collections.singletonList("bar1"));
        List<Object> targetInstances = flowRouteHandler.handle("foo", instances,
                new RequestData(header, null, null));
        Assert.assertEquals(1, targetInstances.size());
        Assert.assertEquals(instance2, targetInstances.get(0));
        ConfigCache.getLabel(RouterConstant.SPRING_CACHE_NAME).resetRouteRule(Collections.emptyMap());
    }