@Override
    public List<Object> handle(String targetName, List<Object> instances, RequestData requestData) {
        if (!shouldHandle(instances)) {
            return instances;
        }

        List<Object> result = getTargetInstancesByRules(targetName, instances);
        return super.handle(targetName, result, requestData);
    }
@Test
    public void testGetTargetInstancesByConsumerTagRules() {
        RuleInitializationUtils.initConsumerTagRules();
        List<Object> instances = new ArrayList<>();
        Map<String, String> metadata1 = new HashMap<>();
        metadata1.put("group", "red");
        Map<String, String> metadata2 = new HashMap<>();
        metadata2.put("group", "green");
        ServiceInstance instance1 = new TestDefaultServiceInstance(metadata1);
        instances.add(instance1);
        ServiceInstance instance2 = new TestDefaultServiceInstance(metadata2);
        instances.add(instance2);
        AppCache.INSTANCE.setMetadata(metadata1);
        List<Object> targetInstances = tagRouteHandler.handle("foo", instances,
                new RequestData(null, null, null));
        Assert.assertEquals(1, targetInstances.size());
        Assert.assertEquals(instance1, targetInstances.get(0));
        ConfigCache.getLabel(RouterConstant.SPRING_CACHE_NAME).resetRouteRule(Collections.emptyMap());
    }