ModelUtils { public static void parsePodDisruptionBudgetTemplate(AbstractModel model, PodDisruptionBudgetTemplate pdb) { if (pdb != null) { if (pdb.getMetadata() != null) { model.templatePodDisruptionBudgetLabels = pdb.getMetadata().getLabels(); model.templatePodDisruptionBudgetAnnotations = pdb.getMetadata().getAnnotations(); } model.templatePodDisruptionBudgetMaxUnavailable = pdb.getMaxUnavailable(); } } private  ModelUtils(); static int getCertificateValidity(CertificateAuthority certificateAuthority); static int getRenewalDays(CertificateAuthority certificateAuthority); static String formatTimestamp(Date date); static String defaultResourceLabels(String cluster); static Map<String, String> getContainerEnv(StatefulSet sts, String containerName); static Secret buildSecret(ClusterCa clusterCa, Secret secret, String namespace, String secretName,
            String commonName, String keyCertName, Labels labels, OwnerReference ownerReference, boolean isMaintenanceTimeWindowsSatisfied); static Secret createSecret(String name, String namespace, Labels labels, OwnerReference ownerReference, Map<String, String> data); static void parsePodDisruptionBudgetTemplate(AbstractModel model, PodDisruptionBudgetTemplate pdb); static void parsePodTemplate(AbstractModel model, PodTemplate pod); static boolean containsPersistentStorage(Storage storage); static Storage decodeStorageFromJson(String json); static String encodeStorageToJson(Storage storage); static Map<String, String> getCustomLabelsOrAnnotations(String envVarName); static boolean doExistingCertificatesDiffer(Secret current, Secret desired); static List<T> asListOrEmptyList(List<T> list); static String getJavaSystemPropertiesToString(List<SystemProperty> javaSystemProperties); static List<String> getLinesWithoutCommentsAndEmptyLines(String config); static void removeEmptyValuesFromTolerations(List<Toleration> tolerations); static List<Toleration> tolerations(String tolerations, List<Toleration> tolerationList, String templateTolerations, PodTemplate podTemplate); static AffinityBuilder populateAffinityBuilderWithRackLabelSelector(AffinityBuilder builder, Affinity userAffinity, String topologyKey); static final String TLS_SIDECAR_LOG_LEVEL; }
@Test public void testParsePodDisruptionBudgetTemplate() { Kafka kafka = new KafkaBuilder() .withNewMetadata() .withName("my-cluster") .withNamespace("my-namespace") .endMetadata() .build(); PodDisruptionBudgetTemplate template = new PodDisruptionBudgetTemplateBuilder() .withNewMetadata() .withAnnotations(Collections.singletonMap("annoKey", "annoValue")) .withLabels(Collections.singletonMap("labelKey", "labelValue")) .endMetadata() .withMaxUnavailable(2) .build(); Model model = new Model(kafka); ModelUtils.parsePodDisruptionBudgetTemplate(model, template); assertThat(model.templatePodDisruptionBudgetLabels, is(Collections.singletonMap("labelKey", "labelValue"))); assertThat(model.templatePodDisruptionBudgetAnnotations, is(Collections.singletonMap("annoKey", "annoValue"))); assertThat(model.templatePodDisruptionBudgetMaxUnavailable, is(2)); }
@Test public void testParseNullPodDisruptionBudgetTemplate() { Kafka kafka = new KafkaBuilder() .withNewMetadata() .withName("my-cluster") .withNamespace("my-namespace") .endMetadata() .build(); Model model = new Model(kafka); ModelUtils.parsePodDisruptionBudgetTemplate(model, null); assertThat(model.templatePodDisruptionBudgetLabels, is(nullValue())); assertThat(model.templatePodDisruptionBudgetAnnotations, is(nullValue())); assertThat(model.templatePodDisruptionBudgetMaxUnavailable, is(1)); }