@Override
    public <T> Invoker<T> join(Directory<T> directory, boolean buildFilterChain) throws RpcException {
        if (buildFilterChain) {
            return buildClusterInterceptors(doJoin(directory));
        } else {
            return doJoin(directory);
        }
    }
@Test
    void testBuildClusterInvokerChain() {

        Map<String, String> parameters = new HashMap<>();
        parameters.put(INTERFACE_KEY, DemoService.class.getName());
        parameters.put("registry", "zookeeper");
        parameters.put(REFERENCE_FILTER_KEY, "demo");
        ServiceConfigURL url = new ServiceConfigURL(
                "registry", "127.0.0.1", 2181, "org.apache.dubbo.registry.RegistryService", parameters);
        URL consumerUrl = new ServiceConfigURL("dubbo", "127.0.0.1", 20881, DemoService.class.getName(), parameters);
        consumerUrl = consumerUrl.setScopeModel(ApplicationModel.defaultModel().getInternalModule());
        Directory<?> directory = mock(Directory.class);
        when(directory.getUrl()).thenReturn(url);
        when(directory.getConsumerUrl()).thenReturn(consumerUrl);
        DemoCluster demoCluster = new DemoCluster();
        Invoker<?> invoker = demoCluster.join(directory, true);
        Assertions.assertTrue(invoker instanceof AbstractCluster.ClusterFilterInvoker);
        Assertions.assertTrue(
                ((AbstractCluster.ClusterFilterInvoker<?>) invoker).getFilterInvoker()
                        instanceof FilterChainBuilder.ClusterCallbackRegistrationInvoker);
    }