Repository: apache/kafka
File: test-common/test-common-runtime/src/main/java/org/apache/kafka/common/test/junit/ClusterTestExtensions.java (Java)

Code before:
            throw new IllegalStateException("processClusterTests method should provide at least one config");
        }

        return ret;
    }

    private List<TestTemplateInvocationContext> processClusterTestInternal(
        ExtensionContext context,
        ClusterTest clusterTest,
        ClusterTestDefaults defaults
    ) {
        Type[] types = clusterTest.types().length == 0 ? defaults.types() : clusterTest.types();
        Map<String, String> serverProperties = Stream.concat(Arrays.stream(defaults.serverProperties()), Arrays.stream(clusterTest.serverProperties()))
            .filter(e -> e.id() == -1)
            .collect(Collectors.toMap(ClusterConfigProperty::key, ClusterConfigProperty::value, (a, b) -> b));

        Map<Integer, Map<String, String>> perServerProperties = Stream.concat(Arrays.stream(defaults.serverProperties()), Arrays.stream(clusterTest.serverProperties()))
            .filter(e -> e.id() != -1)
            .collect(Collectors.groupingBy(ClusterConfigProperty::id, Collectors.mapping(Function.identity(),
                Collectors.toMap(ClusterConfigProperty::key, ClusterConfigProperty::value, (a, b) -> b))));

        Map<Feature, Short> features = Arrays.stream(clusterTest.features())
            .collect(Collectors.toMap(ClusterFeature::feature, ClusterFeature::version));

        ClusterConfig config = ClusterConfig.builder()
            .setTypes(new HashSet<>(List.of(types)))
            .setBrokers(clusterTest.brokers() == 0 ? defaults.brokers() : clusterTest.brokers())
            .setControllers(clusterTest.controllers() == 0 ? defaults.controllers() : clusterTest.controllers())
            .setDisksPerBroker(clusterTest.disksPerBroker() == 0 ? defaults.disksPerBroker() : clusterTest.disksPerBroker())
            .setAutoStart(clusterTest.autoStart() == AutoStart.DEFAULT ? defaults.autoStart() : clusterTest.autoStart() == AutoStart.YES)
            .setBrokerListenerName(ListenerName.normalised(clusterTest.brokerListener()))
            .setBrokerSecurityProtocol(clusterTest.brokerSecurityProtocol())
            .setControllerListenerName(ListenerName.normalised(clusterTest.controllerListener()))
            .setControllerSecurityProtocol(clusterTest.controllerSecurityProtocol())
            .setServerProperties(serverProperties)
            .setPerServerProperties(perServerProperties)
            .setMetadataVersion(clusterTest.metadataVersion())
            .setTags(List.of(clusterTest.tags()))
            .setFeatures(features)
            .build();

        return Arrays.stream(types)
            .map(type -> invocationContextForClusterType(type, context.getRequiredTestMethod().getName(), config))
            .collect(Collectors.toList());
    }

    private ClusterTestDefaults getClusterTestDefaults(Class<?> testClass) {
        return Optional.ofNullable(testClass.getDeclaredAnnotation(ClusterTestDefaults.class))
            .orElseGet(() -> EmptyClass.class.getDeclaredAnnotation(ClusterTestDefaults.class));
    }


Review comment (suggestion):
```suggestion
            .setTypes(Set.of(types))
```

Code after:
        }

        return ret;
    }

    private List<TestTemplateInvocationContext> processClusterTestInternal(
        ExtensionContext context,
        ClusterTest clusterTest,
        ClusterTestDefaults defaults
    ) {
        Type[] types = clusterTest.types().length == 0 ? defaults.types() : clusterTest.types();
        Map<String, String> serverProperties = Stream.concat(Arrays.stream(defaults.serverProperties()), Arrays.stream(clusterTest.serverProperties()))
            .filter(e -> e.id() == -1)
            .collect(Collectors.toMap(ClusterConfigProperty::key, ClusterConfigProperty::value, (a, b) -> b));

        Map<Integer, Map<String, String>> perServerProperties = Stream.concat(Arrays.stream(defaults.serverProperties()), Arrays.stream(clusterTest.serverProperties()))
            .filter(e -> e.id() != -1)
            .collect(Collectors.groupingBy(ClusterConfigProperty::id, Collectors.mapping(Function.identity(),
                Collectors.toMap(ClusterConfigProperty::key, ClusterConfigProperty::value, (a, b) -> b))));

        Map<Feature, Short> features = Arrays.stream(clusterTest.features())
            .collect(Collectors.toMap(ClusterFeature::feature, ClusterFeature::version));

        ClusterConfig config = ClusterConfig.builder()
            .setTypes(Set.of(types))
            .setBrokers(clusterTest.brokers() == 0 ? defaults.brokers() : clusterTest.brokers())
            .setControllers(clusterTest.controllers() == 0 ? defaults.controllers() : clusterTest.controllers())
            .setDisksPerBroker(clusterTest.disksPerBroker() == 0 ? defaults.disksPerBroker() : clusterTest.disksPerBroker())
            .setAutoStart(clusterTest.autoStart() == AutoStart.DEFAULT ? defaults.autoStart() : clusterTest.autoStart() == AutoStart.YES)
            .setBrokerListenerName(ListenerName.normalised(clusterTest.brokerListener()))
            .setBrokerSecurityProtocol(clusterTest.brokerSecurityProtocol())
            .setControllerListenerName(ListenerName.normalised(clusterTest.controllerListener()))
            .setControllerSecurityProtocol(clusterTest.controllerSecurityProtocol())
            .setServerProperties(serverProperties)
            .setPerServerProperties(perServerProperties)
            .setMetadataVersion(clusterTest.metadataVersion())
            .setTags(List.of(clusterTest.tags()))
            .setFeatures(features)
            .build();

        return Arrays.stream(types)
            .map(type -> invocationContextForClusterType(type, context.getRequiredTestMethod().getName(), config))
            .collect(Collectors.toList());
    }

    private ClusterTestDefaults getClusterTestDefaults(Class<?> testClass) {
        return Optional.ofNullable(testClass.getDeclaredAnnotation(ClusterTestDefaults.class))
            .orElseGet(() -> EmptyClass.class.getDeclaredAnnotation(ClusterTestDefaults.class));
    }

    @ClusterTestDefaults