CapacityManager { public boolean acquire() { return acquire(1); } CapacityManager(final int maxCapacity); boolean acquire(); boolean acquire(int capacity); void release(); void release(int capacity); int consumedCapacity(); int availableCapacity();  }
@Test public void acquire() { CapacityManager mgr = new CapacityManager(10); Assert.assertTrue(mgr.acquire()); Assert.assertEquals(mgr.availableCapacity(), 9); Assert.assertEquals(mgr.consumedCapacity(), 1); Assert.assertTrue(mgr.acquire(9)); Assert.assertEquals(mgr.availableCapacity(), 0); Assert.assertEquals(mgr.consumedCapacity(), 10); Assert.assertFalse(mgr.acquire(1)); }