public static Labels generateDefaultLabels(HasMetadata resource, String strimziComponentName, String strimziComponentType, String managedBy) {
        String customResourceName = resource.getMetadata().getName();

        return Labels.fromResource(resource)
                // Strimzi labels
                .withStrimziKind(resource.getKind())
                .withStrimziName(strimziComponentName)
                .withStrimziCluster(customResourceName)
                .withStrimziComponentType(strimziComponentType)
                // Kubernetes labels
                .withKubernetesName(strimziComponentType)
                .withKubernetesInstance(customResourceName)
                .withKubernetesPartOf(customResourceName)
                .withKubernetesManagedBy(managedBy);
    }
@Test
    public void testGenerateDefaultLabels() {
        String customResourceName = "my-cluster";
        String componentName = "kafka";
        String operatorName  = "my-operator";

        class ResourceWithMetadata implements HasMetadata {

            String kind;
            String apiVersion;
            ObjectMeta metadata;

            public ResourceWithMetadata(String kind, String apiVersion, ObjectMeta metadata) {
                this.kind = kind;
                this.apiVersion = apiVersion;
                this.metadata = metadata;
            }

            public ObjectMeta getMetadata() {
                return metadata;
            }
            public void setMetadata(ObjectMeta metadata) {
                this.metadata = metadata;
            }

            public String getKind() {
                return kind;
            }

            public String getApiVersion() {
                return apiVersion;
            }
            public void setApiVersion(String apiVersion) {
                this.apiVersion = apiVersion;
            }

        }

        Map<String, String> expectedLabels = new HashMap<>();
        expectedLabels.put(Labels.STRIMZI_KIND_LABEL, "MyResource");
        expectedLabels.put(Labels.STRIMZI_NAME_LABEL, customResourceName + "-" + componentName);
        expectedLabels.put(Labels.STRIMZI_COMPONENT_TYPE_LABEL, componentName);
        expectedLabels.put(Labels.STRIMZI_CLUSTER_LABEL, customResourceName);
        expectedLabels.put(Labels.KUBERNETES_NAME_LABEL, componentName);
        expectedLabels.put(Labels.KUBERNETES_INSTANCE_LABEL, customResourceName);
        expectedLabels.put(Labels.KUBERNETES_MANAGED_BY_LABEL, operatorName);
        expectedLabels.put(Labels.KUBERNETES_PART_OF_LABEL, Labels.APPLICATION_NAME + "-" + customResourceName);

        ResourceWithMetadata resource = new ResourceWithMetadata("MyResource", "strimzi.io/v0", new ObjectMetaBuilder().withName(customResourceName).build());

        Labels l = Labels.generateDefaultLabels(resource, customResourceName + "-" + componentName, componentName, operatorName);

        assertThat(l.toMap(), is(expectedLabels));
    }