SpaceRemainingQuota extends BlobStoreQuotaSupport { @Override public BlobStoreQuotaResult check(final BlobStore blobStore) { checkNotNull(blobStore); long availableSpace = blobStore.getMetrics().getAvailableSpace(); boolean isUnlimited = blobStore.getMetrics().isUnlimited(); long limit = getLimit(blobStore.getBlobStoreConfiguration()); String name = blobStore.getBlobStoreConfiguration().getName(); String msg = format("Blob store %s is limited to having %s available space, and has %s space remaining", name, formatStorage(limit), formatStorage(availableSpace)); return new BlobStoreQuotaResult(!isUnlimited && availableSpace < limit, name, msg); }  @Override void validateConfig(final BlobStoreConfiguration config); @Override BlobStoreQuotaResult check(final BlobStore blobStore); @Override String getDisplayName(); @Override String getId(); static final String ID; }
@Test public void sufficientSpaceRemaining() { when(metrics.isUnlimited()).thenReturn(false); when(metrics.getAvailableSpace()).thenReturn(20L); assertFalse(quota.check(blobStore).isViolation()); }
@Test public void insufficientSpaceRemaining() { when(metrics.isUnlimited()).thenReturn(false); when(metrics.getAvailableSpace()).thenReturn(5L); assertTrue(quota.check(blobStore).isViolation()); }
@Test public void unlimitedSpaceRemaining() { when(metrics.isUnlimited()).thenReturn(true); when(metrics.getAvailableSpace()).thenReturn(5L); assertFalse(quota.check(blobStore).isViolation()); }