@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 testGetTargetInstancesByTagRulesWithPolicySceneFive() {
        RuleInitializationUtils.initAZTagMatchTriggerThresholdMinAllInstancesPolicyRule();
        // Scenario 1: The proportion of az1 instances/ALL instances is greater than the triggerThreshold
        List<Object> instances = new ArrayList<>();
        ServiceInstance instance1 = TestDefaultServiceInstance.getTestDefaultServiceInstance("1.0.0", "az1");
        ServiceInstance instance2 = TestDefaultServiceInstance.getTestDefaultServiceInstance("1.0.0", "az2");
        ServiceInstance instance3 = TestDefaultServiceInstance.getTestDefaultServiceInstance("1.0.1", "az1");
        instances.add(instance1);
        instances.add(instance2);
        instances.add(instance3);
        Map<String, String> metadata = new HashMap<>();
        metadata.put("zone", "az1");
        AppCache.INSTANCE.setMetadata(metadata);
        List<Object> targetInstances = tagRouteHandler.handle("foo", instances,
                new RequestData(null, null, null));
        Assert.assertEquals(2, targetInstances.size());

        // Scenario 2: The proportion of az1 instances/ALL instances is less than the triggerThreshold
        List<Object> instances2 = new ArrayList<>();
        ServiceInstance instance4 = TestDefaultServiceInstance.getTestDefaultServiceInstance("1.0.0", "az1");
        ServiceInstance instance5 = TestDefaultServiceInstance.getTestDefaultServiceInstance("1.0.0", "az2");
        ServiceInstance instance6 = TestDefaultServiceInstance.getTestDefaultServiceInstance("1.0.1", "az2");
        instances2.add(instance4);
        instances2.add(instance5);
        instances2.add(instance6);
        targetInstances = tagRouteHandler.handle("foo", instances2,
                new RequestData(null, null, null));
        Assert.assertEquals(1, targetInstances.size());

        // There is no match on all instances returned
        List<Object> instances3 = new ArrayList<>();
        ServiceInstance instance7 = TestDefaultServiceInstance.getTestDefaultServiceInstance("1.0.0", "az3");
        ServiceInstance instance8 = TestDefaultServiceInstance.getTestDefaultServiceInstance("1.0.0", "az2");
        ServiceInstance instance9 = TestDefaultServiceInstance.getTestDefaultServiceInstance("1.0.1", "az2");
        instances3.add(instance7);
        instances3.add(instance8);
        instances3.add(instance9);
        targetInstances = tagRouteHandler.handle("foo", instances3,
                new RequestData(null, null, null));
        Assert.assertEquals(3, targetInstances.size());

        ConfigCache.getLabel(RouterConstant.SPRING_CACHE_NAME).resetRouteRule(Collections.emptyMap());
    }