StorageUtils { public static boolean usesEphemeral(Storage storage) { if (storage != null) { if (isEphemeral(storage)) { return true; } if (Storage.TYPE_JBOD.equals(storage.getType()) && storage instanceof JbodStorage) { JbodStorage jbodStorage = (JbodStorage) storage; return jbodStorage.getVolumes().stream().anyMatch(StorageUtils::isEphemeral); } } return false; }  static double parseMemory(String memory, String units); static long parseMemory(Quantity size); static long parseMemory(String size); static boolean usesEphemeral(Storage storage);  }
@Test public void testEphemeralStorage() { Storage notEphemeral = new PersistentClaimStorageBuilder().build(); Storage isEphemeral = new EphemeralStorageBuilder().build(); Storage includesEphemeral = new JbodStorageBuilder().withVolumes( new EphemeralStorageBuilder().withId(1).build(), new EphemeralStorageBuilder().withId(2).build()) .build(); assertThat(StorageUtils.usesEphemeral(notEphemeral), is(false)); assertThat(StorageUtils.usesEphemeral(isEphemeral), is(true)); assertThat(StorageUtils.usesEphemeral(includesEphemeral), is(true)); }