ResourceCounter { public Metric computeQuotaAllocationTotals() throws StorageException { return storage.read(storeProvider -> { Metric allocation = new Metric(); for (IResourceAggregate quota : storeProvider.getQuotaStore().fetchQuotas().values()) { allocation.accumulate(quota); } return allocation; }); } @Inject  ResourceCounter(Storage storage); List<GlobalMetric> computeConsumptionTotals(); Metric computeQuotaAllocationTotals(); Map<K, Metric> computeAggregates(
      Query.Builder query,
      Predicate<ITaskConfig> filter,
      Function<ITaskConfig, K> keyFunction);  }
@Test public void testComputeQuotaAllocationTotals() { storage.write((NoResult.Quiet) storeProvider -> { storeProvider.getQuotaStore() .saveQuota("a", IResourceAggregate.build(new ResourceAggregate(1, 1, 1))); storeProvider.getQuotaStore() .saveQuota("b", IResourceAggregate.build(new ResourceAggregate(2, 3, 4))); }); assertEquals(new Metric(3, 4, 5), resourceCounter.computeQuotaAllocationTotals()); }