PeProvisionerSimple extends PeProvisioner { @Override public void deallocateMipsForVm(Vm vm) { if (getPeTable().containsKey(vm.getUid())) { for (double mips : getPeTable().get(vm.getUid())) { setAvailableMips(getAvailableMips() + mips); } getPeTable().remove(vm.getUid()); } } PeProvisionerSimple(double availableMips); @Override boolean allocateMipsForVm(Vm vm, double mips); @Override boolean allocateMipsForVm(String vmUid, double mips); @Override boolean allocateMipsForVm(Vm vm, List<Double> mips); @Override void deallocateMipsForAllVms(); @Override double getAllocatedMipsForVmByVirtualPeId(Vm vm, int peId); @Override List<Double> getAllocatedMipsForVm(Vm vm); @Override double getTotalAllocatedMipsForVm(Vm vm); @Override void deallocateMipsForVm(Vm vm);  }
@Test public void testDeallocateMipsForVM() { Vm vm1 = new Vm(0, 0, MIPS / 2, 1, 0, 0, 0, "", null); Vm vm2 = new Vm(1, 0, MIPS / 2, 1, 0, 0, 0, "", null); peProvisioner.allocateMipsForVm(vm1, MIPS / 2); peProvisioner.allocateMipsForVm(vm2, MIPS / 4); assertEquals(MIPS / 4, peProvisioner.getAvailableMips(), 0); peProvisioner.deallocateMipsForVm(vm1); assertEquals(MIPS * 3 / 4, peProvisioner.getAvailableMips(), 0); peProvisioner.deallocateMipsForVm(vm2); assertEquals(MIPS, peProvisioner.getAvailableMips(), 0); }