VolumeUtils { public static Volume createEmptyDirVolume(String name, String sizeLimit) { String validName = getValidVolumeName(name); EmptyDirVolumeSource emptyDirVolumeSource = new EmptyDirVolumeSourceBuilder().build(); if (sizeLimit != null && !sizeLimit.isEmpty()) { emptyDirVolumeSource.setSizeLimit(new Quantity(sizeLimit)); } Volume volume = new VolumeBuilder() .withName(validName) .withEmptyDir(emptyDirVolumeSource) .build(); log.trace("Created emptyDir Volume named '{}' with sizeLimit '{}'", validName, sizeLimit); return volume; }  static Volume createConfigMapVolume(String name, String configMapName); static Volume createSecretVolume(String name, String secretName, Map<String, String> items, boolean isOpenshift); static Volume createSecretVolume(String name, String secretName, boolean isOpenshift); static Volume createEmptyDirVolume(String name, String sizeLimit); static PersistentVolumeClaim createPersistentVolumeClaimTemplate(String name, PersistentClaimStorage storage); static VolumeMount createVolumeMount(String name, String path); static List<Volume> getDataVolumes(Storage storage); static List<PersistentVolumeClaim> getDataPersistentVolumeClaims(Storage storage); static List<VolumeMount> getDataVolumeMountPaths(Storage storage, String mountPath); static String getVolumePrefix(Integer id); static String getValidVolumeName(String originalName);  }
@Test public void testCreateEmptyDirVolumeWithSizeLimit() { Volume volume = VolumeUtils.createEmptyDirVolume("bar", "1Gi"); assertThat(volume.getEmptyDir().getSizeLimit(), is(new Quantity("1", "Gi"))); }
@Test public void testCreateEmptyDirVolumeWithNullSizeLimit() { Volume volume = VolumeUtils.createEmptyDirVolume("bar", null); assertThat(volume.getEmptyDir().getSizeLimit(), is(nullValue())); }
@Test public void testCreateEmptyDirVolumeWithEmptySizeLimit() { Volume volume = VolumeUtils.createEmptyDirVolume("bar", ""); assertThat(volume.getEmptyDir().getSizeLimit(), is(nullValue())); }