@SuppressWarnings("unchecked") @Test void getStorageQuotaShouldCalculateCurrentQuotaWhenUnlimited() throws Exception { when(mockedMaxQuotaManager.getMaxStorage(any(Map.class))).thenReturn(Optional.of(QuotaSizeLimit.unlimited())); when(mockedCurrentQuotaManager.getCurrentStorage(quotaRoot)).thenAnswer(any -> Mono.fromCallable(() -> QuotaSizeUsage.size(36L))); assertThat(testee.getStorageQuota(quotaRoot)).isEqualTo( Quota.<QuotaSizeLimit, QuotaSizeUsage>builder().used(QuotaSizeUsage.size(36)).computedLimit(QuotaSizeLimit.unlimited()).build()); }
@Override public Quota<QuotaSizeLimit, QuotaSizeUsage> getStorageQuota(QuotaRoot quotaRoot) throws MailboxException { Map<Scope, QuotaSizeLimit> maxStorageDetails = maxQuotaManager.listMaxStorageDetails(quotaRoot); return Quota.<QuotaSizeLimit, QuotaSizeUsage>builder() .used(Mono.from(currentQuotaManager.getCurrentStorage(quotaRoot)).block()) .computedLimit(maxQuotaManager.getMaxStorage(maxStorageDetails).orElse(QuotaSizeLimit.unlimited())) .limitsByScope(maxStorageDetails) .build(); }
StoreQuotaManager implements QuotaManager { @Override public Quota<QuotaSizeLimit, QuotaSizeUsage> getStorageQuota(QuotaRoot quotaRoot) throws MailboxException { Map<Scope, QuotaSizeLimit> maxStorageDetails = maxQuotaManager.listMaxStorageDetails(quotaRoot); return Quota.<QuotaSizeLimit, QuotaSizeUsage>builder() .used(Mono.from(currentQuotaManager.getCurrentStorage(quotaRoot)).block()) .computedLimit(maxQuotaManager.getMaxStorage(maxStorageDetails).orElse(QuotaSizeLimit.unlimited())) .limitsByScope(maxStorageDetails) .build(); } }
StoreQuotaManager implements QuotaManager { @Override public Quota<QuotaSizeLimit, QuotaSizeUsage> getStorageQuota(QuotaRoot quotaRoot) throws MailboxException { Map<Scope, QuotaSizeLimit> maxStorageDetails = maxQuotaManager.listMaxStorageDetails(quotaRoot); return Quota.<QuotaSizeLimit, QuotaSizeUsage>builder() .used(Mono.from(currentQuotaManager.getCurrentStorage(quotaRoot)).block()) .computedLimit(maxQuotaManager.getMaxStorage(maxStorageDetails).orElse(QuotaSizeLimit.unlimited())) .limitsByScope(maxStorageDetails) .build(); } @Inject  StoreQuotaManager(CurrentQuotaManager currentQuotaManager, MaxQuotaManager maxQuotaManager); }
StoreQuotaManager implements QuotaManager { @Override public Quota<QuotaSizeLimit, QuotaSizeUsage> getStorageQuota(QuotaRoot quotaRoot) throws MailboxException { Map<Scope, QuotaSizeLimit> maxStorageDetails = maxQuotaManager.listMaxStorageDetails(quotaRoot); return Quota.<QuotaSizeLimit, QuotaSizeUsage>builder() .used(Mono.from(currentQuotaManager.getCurrentStorage(quotaRoot)).block()) .computedLimit(maxQuotaManager.getMaxStorage(maxStorageDetails).orElse(QuotaSizeLimit.unlimited())) .limitsByScope(maxStorageDetails) .build(); } @Inject  StoreQuotaManager(CurrentQuotaManager currentQuotaManager, MaxQuotaManager maxQuotaManager); @Override Quota<QuotaCountLimit, QuotaCountUsage> getMessageQuota(QuotaRoot quotaRoot); @Override Quota<QuotaSizeLimit, QuotaSizeUsage> getStorageQuota(QuotaRoot quotaRoot); }
StoreQuotaManager implements QuotaManager { @Override public Quota<QuotaSizeLimit, QuotaSizeUsage> getStorageQuota(QuotaRoot quotaRoot) throws MailboxException { Map<Scope, QuotaSizeLimit> maxStorageDetails = maxQuotaManager.listMaxStorageDetails(quotaRoot); return Quota.<QuotaSizeLimit, QuotaSizeUsage>builder() .used(Mono.from(currentQuotaManager.getCurrentStorage(quotaRoot)).block()) .computedLimit(maxQuotaManager.getMaxStorage(maxStorageDetails).orElse(QuotaSizeLimit.unlimited())) .limitsByScope(maxStorageDetails) .build(); } @Inject  StoreQuotaManager(CurrentQuotaManager currentQuotaManager, MaxQuotaManager maxQuotaManager); @Override Quota<QuotaCountLimit, QuotaCountUsage> getMessageQuota(QuotaRoot quotaRoot); @Override Quota<QuotaSizeLimit, QuotaSizeUsage> getStorageQuota(QuotaRoot quotaRoot);  }