DeployASGroupTask extends Task<ASGroup> { int capacityDuringDeployment(int currentDesiredCapacity, int localDesiredCapacity) { if (localDesiredCapacity > currentDesiredCapacity) return localDesiredCapacity + (currentDesiredCapacity >= 3 ? 3 : currentDesiredCapacity); return currentDesiredCapacity >= 3 ? currentDesiredCapacity + 3 : currentDesiredCapacity * 2; } DeployASGroupTask(ASGroup resource); @Override void execute(Context context);  }
@Test void capacityDuringDeployment() { assertEquals(8, task.capacityDuringDeployment(5, 3), "add 3 more for current cap"); assertEquals(4, task.capacityDuringDeployment(2, 1), "just double the current cap"); assertEquals(6, task.capacityDuringDeployment(3, 3), "just double the current cap"); assertEquals(4, task.capacityDuringDeployment(0, 4), "lift cap to target"); assertEquals(3, task.capacityDuringDeployment(0, 3), "lift cap to target"); assertEquals(2, task.capacityDuringDeployment(0, 2), "lift cap to target"); assertEquals(3, task.capacityDuringDeployment(1, 2), "lift with target"); assertEquals(8, task.capacityDuringDeployment(3, 5), "lift with target"); assertEquals(8, task.capacityDuringDeployment(4, 5), "lift with target"); assertEquals(9, task.capacityDuringDeployment(4, 6), "lift with target"); }