SlotSizeCounter implements Runnable { @Override public void run() { Iterable<MachineResource> slots = machineResourceProvider.get(); slotSizes.entrySet().stream().forEach(e -> updateStats(e.getKey(), slots, e.getValue())); } @VisibleForTesting  SlotSizeCounter(
      final Map<String, IResourceAggregate> slotSizes,
      MachineResourceProvider machineResourceProvider,
      CachedCounters cachedCounters); @Inject  SlotSizeCounter(MachineResourceProvider machineResourceProvider, CachedCounters cachedCounters); @Override void run();  }
@Test public void testNoOffers() { expectStatExport(); expectGetSlots(); control.replay(); slotCounter.run(); assertEquals(0, smallCounter.get()); assertEquals(0, smallDedicatedCounter.get()); assertEquals(0, smallRevocableCounter.get()); assertEquals(0, smallDedicatedRevocableCounter.get()); assertEquals(0, largeCounter.get()); assertEquals(0, largeDedicatedCounter.get()); assertEquals(0, largeRevocableCounter.get()); assertEquals(0, largeDedicatedRevocableCounter.get()); }
@Test public void testTinyOffers() { expectStatExport(); expectGetSlots(new MachineResource( IResourceAggregate.build(new ResourceAggregate(0.1, 1, 1)), false, false)); control.replay(); slotCounter.run(); assertEquals(0, smallCounter.get()); assertEquals(0, smallDedicatedCounter.get()); assertEquals(0, smallRevocableCounter.get()); assertEquals(0, smallDedicatedRevocableCounter.get()); assertEquals(0, largeCounter.get()); assertEquals(0, largeDedicatedCounter.get()); assertEquals(0, largeRevocableCounter.get()); assertEquals(0, largeDedicatedRevocableCounter.get()); }
@Test public void testStarvedResourceVector() { expectStatExport(); expectGetSlots( new MachineResource( IResourceAggregate.build(new ResourceAggregate(1000, 16384, 1)), false, false)); control.replay(); slotCounter.run(); assertEquals(0, smallCounter.get()); assertEquals(0, smallDedicatedCounter.get()); assertEquals(0, smallRevocableCounter.get()); assertEquals(0, smallDedicatedRevocableCounter.get()); assertEquals(0, largeCounter.get()); assertEquals(0, largeDedicatedCounter.get()); assertEquals(0, largeRevocableCounter.get()); assertEquals(0, largeDedicatedRevocableCounter.get()); }