ModelUtils { public static List<Toleration> tolerations(String tolerations, List<Toleration> tolerationList, String templateTolerations, PodTemplate podTemplate) { List<Toleration> tolerationsListLocal; if (podTemplate != null && podTemplate.getTolerations() != null) { if (tolerationList != null) { log.warn("Tolerations given on both {} and {}; latter takes precedence", tolerations, templateTolerations); } tolerationsListLocal = podTemplate.getTolerations(); } else { tolerationsListLocal = tolerationList; } removeEmptyValuesFromTolerations(tolerationsListLocal); return tolerationsListLocal; } 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 testEmptyTolerations() { Toleration t1 = new TolerationBuilder() .withValue("") .withEffect("NoExecute") .build(); Toleration t2 = new TolerationBuilder() .withValue(null) .withEffect("NoExecute") .build(); PodTemplate pt1 = new PodTemplate(); pt1.setTolerations(singletonList(t1)); PodTemplate pt2 = new PodTemplate(); pt2.setTolerations(singletonList(t2)); assertThat(ModelUtils.tolerations("tolerations", null, "template.tolerations", pt1), is(ModelUtils.tolerations("tolerations", null, "template.tolerations", pt2))); }