public static StrimziPodSet createPodSet(
            String name,
            String namespace,
            Labels labels,
            OwnerReference ownerReference,
            ResourceTemplate template,
            int replicas,
            Map<String, String> annotations,
            Labels selectorLabels,
            Function<Integer, Pod> podCreator
    )  {
        List<Map<String, Object>> pods = new ArrayList<>(replicas);

        for (int i = 0; i < replicas; i++)  {
            Pod pod = podCreator.apply(i);
            pods.add(PodSetUtils.podToMap(pod));
        }

        return new StrimziPodSetBuilder()
                .withNewMetadata()
                    .withName(name)
                    .withLabels(labels.withAdditionalLabels(TemplateUtils.labels(template)).toMap())
                    .withNamespace(namespace)
                    .withAnnotations(Util.mergeLabelsOrAnnotations(annotations, TemplateUtils.annotations(template)))
                    .withOwnerReferences(ownerReference)
                .endMetadata()
                .withNewSpec()
                    .withSelector(new LabelSelectorBuilder().withMatchLabels(selectorLabels.toMap()).build())
                    .withPods(pods)
                .endSpec()
                .build();
    }
@Test
    public void testCreateStrimziPodSetFromNodeReferencesWithNullTemplate()  {
        List<String> podNames = new ArrayList<>();

        StrimziPodSet sps = WorkloadUtils.createPodSet(
                NAME,
                NAMESPACE,
                LABELS,
                OWNER_REFERENCE,
                null,
                NODES,
                Map.of("extra", "annotations"),
                LABELS.strimziSelectorLabels(),
                n -> {
                    podNames.add(n.podName());
                    return new PodBuilder()
                            .withNewMetadata()
                                .withName(n.podName())
                            .endMetadata()
                            .build();
                }
        );

        assertThat(sps.getMetadata().getName(), is(NAME));
        assertThat(sps.getMetadata().getNamespace(), is(NAMESPACE));
        assertThat(sps.getMetadata().getOwnerReferences(), is(List.of(OWNER_REFERENCE)));
        assertThat(sps.getMetadata().getLabels(), is(LABELS.toMap()));
        assertThat(sps.getMetadata().getAnnotations(), is(Map.of("extra", "annotations")));

        assertThat(sps.getSpec().getSelector().getMatchLabels().size(), is(3));
        assertThat(sps.getSpec().getSelector().getMatchLabels().get(Labels.STRIMZI_CLUSTER_LABEL), is("my-cluster"));
        assertThat(sps.getSpec().getSelector().getMatchLabels().get(Labels.STRIMZI_NAME_LABEL), is("my-workload"));
        assertThat(sps.getSpec().getSelector().getMatchLabels().get(Labels.STRIMZI_KIND_LABEL), is("my-kind"));

        // Test generating pods from the PodCreator method
        assertThat(podNames.size(), is(3));
        assertThat(podNames, hasItems("my-cluster-nodes-10", "my-cluster-nodes-11", "my-cluster-nodes-12"));
        assertThat(sps.getSpec().getPods().size(), is(3));
        assertThat(sps.getSpec().getPods().stream().map(pod -> PodSetUtils.mapToPod(pod).getMetadata().getName()).toList(), hasItems("my-cluster-nodes-10", "my-cluster-nodes-11", "my-cluster-nodes-12"));
    }