SlotSizeCounter implements Runnable { private int countSlots(Iterable<IResourceAggregate> slots, final IResourceAggregate slotSize) { Function<IResourceAggregate, Integer> counter = machineSlack -> ResourceAggregates.divide(machineSlack, slotSize); int sum = 0; for (int slotCount : FluentIterable.from(slots).transform(counter)) { sum += slotCount; } return sum; } @VisibleForTesting  SlotSizeCounter(
      final Map<String, IResourceAggregate> slotSizes,
      MachineResourceProvider machineResourceProvider,
      CachedCounters cachedCounters); @Inject  SlotSizeCounter(MachineResourceProvider machineResourceProvider, CachedCounters cachedCounters); @Override void run();  }
@Test public void testCountSlots() { expectStatExport(); expectGetSlots( new MachineResource(SMALL, false, false), new MachineResource(SMALL, false, false), new MachineResource(LARGE, false, false), new MachineResource(LARGE, false, true), new MachineResource(LARGE, true, true), new MachineResource(ResourceAggregates.scale(LARGE, 4), false, false), new MachineResource(IResourceAggregate.build(new ResourceAggregate(1, 1, 1)), false, false), new MachineResource(SMALL, true, false), new MachineResource(SMALL, true, false), new MachineResource(ResourceAggregates.scale(SMALL, 2), true, false)); control.replay(); slotCounter.run(); assertEquals(22, smallCounter.get()); assertEquals(4, smallDedicatedCounter.get()); assertEquals(4, smallRevocableCounter.get()); assertEquals(4, smallDedicatedRevocableCounter.get()); assertEquals(5, largeCounter.get()); assertEquals(0, largeDedicatedCounter.get()); assertEquals(1, largeRevocableCounter.get()); assertEquals(1, largeDedicatedRevocableCounter.get()); }