ResourceProvisionerSimple extends ResourceProvisionerAbstract { @Override public boolean deallocateResourceForVm(final Vm vm) { final long amountFreed = deallocateResourceForVmAndSetAllocationMapEntryToZero(vm); getResourceAllocationMap().remove(vm); return amountFreed > 0; } ResourceProvisionerSimple(); protected  ResourceProvisionerSimple(final ResourceManageable resource); @Override boolean allocateResourceForVm(final Vm vm, final long newTotalVmResourceCapacity); @Override boolean allocateResourceForVm(final Vm vm, final double newTotalVmResource); @Override boolean deallocateResourceForVm(final Vm vm); @Override boolean isSuitableForVm(final Vm vm, final long newVmTotalAllocatedResource);  }
@Test public void testDeallocateResourceForVm() { final VmSimple vm1 = createVm(0, HALF_CAPACITY); final VmSimple vm2 = createVm(1, HALF_CAPACITY); assertEquals(0, vm1.getRam().getAllocatedResource()); assertEquals(0, vm2.getRam().getAllocatedResource()); assertTrue(provisioner.isSuitableForVm(vm1, HALF_CAPACITY)); assertTrue(provisioner.allocateResourceForVm(vm1, HALF_CAPACITY)); assertEquals(HALF_CAPACITY, provisioner.getAvailableResource()); provisioner.deallocateResourceForVm(vm1); assertEquals(CAPACITY, provisioner.getAvailableResource()); assertTrue(provisioner.isSuitableForVm(vm1, HALF_CAPACITY)); assertTrue(provisioner.allocateResourceForVm(vm1, HALF_CAPACITY)); assertTrue(provisioner.isSuitableForVm(vm2, HALF_CAPACITY)); assertTrue(provisioner.allocateResourceForVm(vm2, HALF_CAPACITY)); assertEquals(0, provisioner.getAvailableResource()); provisioner.deallocateResourceForVm(vm1); provisioner.deallocateResourceForVm(vm2); assertEquals(CAPACITY, provisioner.getAvailableResource()); assertEquals(0, vm1.getRam().getAllocatedResource()); assertEquals(0, vm2.getRam().getAllocatedResource()); }