@Test
    void methodChaining() {
        final Set<String> excludedClasses = ImmutableSet.of(
                "AbstractCircuitBreakerMappingBuilder",
                "AbstractCuratorFrameworkBuilder",
                "AbstractDnsResolverBuilder",
                "AbstractDynamicEndpointGroupBuilder",
                "AbstractHeadersSanitizerBuilder",
                "AbstractHealthCheckedEndpointGroupBuilder",
                "AbstractRuleBuilder",
                "AbstractRuleWithContentBuilder",
                "AnnotatedServiceBindingBuilder",
                "ChainedCorsPolicyBuilder",
                "CircuitBreakerMappingBuilder",
                "CircuitBreakerRuleBuilder",
                "CircuitBreakerRuleWithContentBuilder",
                "ClientTlsConfigBuilder",
                "ConsulEndpointGroupBuilder",
                "ContextPathAnnotatedServiceConfigSetters",
                "ContextPathDecoratingBindingBuilder",
                "ContextPathServiceBindingBuilder",
                "ContextPathServicesBuilder",
                "CorsPolicyBuilder",
                "DecoratingServiceBindingBuilder",
                "DnsAddressEndpointGroupBuilder",
                "DnsEndpointGroupBuilder",
                "DnsResolverGroupBuilder",
                "DnsServiceEndpointGroupBuilder",
                "DnsTextEndpointGroupBuilder",
                "DynamicEndpointGroupBuilder",
                "DynamicEndpointGroupSetters",
                "EurekaEndpointGroupBuilder",
                "HealthCheckedEndpointGroupBuilder",
                "InputStreamStreamMessageBuilder",
                "JsonHeadersSanitizerBuilder",
                "JsonLogFormatterBuilder",
                "KubernetesEndpointGroupBuilder",
                "PathStreamMessageBuilder",
                "RampingUpLoadBalancerBuilder",
                "Resilience4jCircuitBreakerMappingBuilder",
                "RetryRuleBuilder",
                "RetryRuleWithContentBuilder",
                "ServerBuilder",
                "ServerTlsConfigBuilder",
                "ServiceBindingBuilder",
                "TextHeadersSanitizerBuilder",
                "TextLogFormatterBuilder",
                "VirtualHostAnnotatedServiceBindingBuilder",
                "VirtualHostBuilder",
                "VirtualHostContextPathDecoratingBindingBuilder",
                "VirtualHostContextPathServiceBindingBuilder",
                "VirtualHostContextPathServicesBuilder",
                "VirtualHostDecoratingServiceBindingBuilder",
                "VirtualHostServiceBindingBuilder",
                "WeightRampingUpStrategyBuilder",
                "ZooKeeperEndpointGroupBuilder",
                "ZooKeeperUpdatingListenerBuilder");
        final String packageName = "com.linecorp.armeria";
        findAllClasses(packageName).stream()
                                   .map(ReflectionUtils::forName)
                                   .filter(clazz -> clazz.getSimpleName().endsWith("Builder") &&
                                                    Modifier.isFinal(clazz.getModifiers()) &&
                                                    Modifier.isPublic(clazz.getModifiers()))
                                   .filter(clazz -> !excludedClasses.contains(clazz.getSimpleName()))
                                   .forEach(clazz -> {
                                       final List<Method> methods = overriddenMethods(clazz);
                                       for (Method m : methods) {
                                           assertThatNoException().isThrownBy(
                                                   () -> clazz.getDeclaredMethod(m.getName(),
                                                                                 m.getParameterTypes()));
                                           final Method overriddenMethod;
                                           try {
                                               overriddenMethod =
                                                       clazz.getDeclaredMethod(m.getName(),
                                                                               m.getParameterTypes());
                                           } catch (NoSuchMethodException e) {
                                               throw new RuntimeException(e);
                                           }
                                           assertThat(overriddenMethod.getReturnType())
                                                   .describedAs("Method name: " + m)
                                                   .isSameAs(clazz);
                                       }
                                   });
    }
Makes sure most builder overrides all overridden methods with the correct return type.
it/builders/src/test/java/com/linecorp/armeria/OverriddenBuilderMethodsReturnTypeTest.java