StorageDiff extends AbstractResourceDiff { public boolean shrinkSize() { return shrinkSize; } StorageDiff(Storage current, Storage desired, int currentReplicas, int desiredReplicas); private  StorageDiff(Storage current, Storage desired, int currentReplicas, int desiredReplicas, String volumeDesc); @Override boolean isEmpty(); boolean changesType(); boolean shrinkSize();  }
@Test public void testSizeChanges() { Storage persistent = new PersistentClaimStorageBuilder().withStorageClass("gp2-ssd").withDeleteClaim(false).withId(0).withSize("100Gi").build(); Storage persistent2 = new PersistentClaimStorageBuilder().withStorageClass("gp2-ssd").withDeleteClaim(false).withId(0).withSize("1000Gi").build(); Storage persistent3 = new PersistentClaimStorageBuilder().withStorageClass("gp2-ssd").withDeleteClaim(false).withId(0).withSize("10Gi").build(); assertThat(new StorageDiff(persistent, persistent, 3, 3).shrinkSize(), is(false)); assertThat(new StorageDiff(persistent, persistent2, 3, 3).shrinkSize(), is(false)); assertThat(new StorageDiff(persistent, persistent3, 3, 3).shrinkSize(), is(true)); }
@Test public void testSizeChangesInJbod() { Storage jbod = new JbodStorageBuilder().withVolumes( new PersistentClaimStorageBuilder().withStorageClass("gp2-ssd").withDeleteClaim(false).withId(0).withSize("1000Gi").build(), new PersistentClaimStorageBuilder().withStorageClass("gp2-ssd").withDeleteClaim(true).withId(1).withSize("1000Gi").build()) .build(); Storage jbod2 = new JbodStorageBuilder().withVolumes( new PersistentClaimStorageBuilder().withStorageClass("gp2-ssd").withDeleteClaim(false).withId(0).withSize("5000Gi").build(), new PersistentClaimStorageBuilder().withStorageClass("gp2-ssd").withDeleteClaim(true).withId(1).withSize("1000Gi").build()) .build(); Storage jbod3 = new JbodStorageBuilder().withVolumes( new PersistentClaimStorageBuilder().withStorageClass("gp2-ssd").withDeleteClaim(false).withId(0).withSize("1000Gi").build(), new PersistentClaimStorageBuilder().withStorageClass("gp2-ssd").withDeleteClaim(true).withId(1).withSize("500Gi").build()) .build(); assertThat(new StorageDiff(jbod, jbod, 3, 3).shrinkSize(), is(false)); assertThat(new StorageDiff(jbod, jbod2, 3, 3).shrinkSize(), is(false)); assertThat(new StorageDiff(jbod, jbod3, 3, 3).shrinkSize(), is(true)); }