AutonomiccsSystemVmsGuru implements VirtualMachineGuru, InitializingBean { @Override public void finalizeExpunge(VirtualMachine vm) { AutonomiccsSystemVm autonomiccsSystemVm = autonomiccsSystemVmDao.findById(vm.getId()); if (autonomiccsSystemVm == null) { return; } autonomiccsSystemVm.setPublicIpAddress(null); autonomiccsSystemVm.setPrivateMacAddress(null); autonomiccsSystemVm.setPrivateIpAddress(null); autonomiccsSystemVm.setManagementIpAddress(null); autonomiccsSystemVmDao.update(autonomiccsSystemVm.getId(), autonomiccsSystemVm); }  @Override void afterPropertiesSet(); @Override boolean finalizeCommandsOnStart(Commands arg0, VirtualMachineProfile arg1); @Override boolean finalizeDeployment(Commands cmds, VirtualMachineProfile profile, DeployDestination dest, ReservationContext context); @Override void finalizeExpunge(VirtualMachine vm); @Override boolean finalizeStart(VirtualMachineProfile arg0, long arg1, Commands arg2, ReservationContext arg3); @Override void finalizeStop(VirtualMachineProfile arg0, Answer arg1); @Override boolean finalizeVirtualMachineProfile(VirtualMachineProfile profile, DeployDestination dest, ReservationContext context); @Override void prepareStop(VirtualMachineProfile arg0);  }
@Test public void finalizeExpungeTest() { VirtualMachine vm = Mockito.mock(VirtualMachine.class); AutonomiccsSystemVm autonomiccsSystemVm = Mockito.mock(AutonomiccsSystemVm.class); configureFinalizeExpungeTest(vm, autonomiccsSystemVm); spy.finalizeExpunge(vm); Mockito.verify(autonomiccsSystemVmDao).findById(Mockito.anyLong()); InOrder inOrder = Mockito.inOrder(autonomiccsSystemVm); inOrder.verify(autonomiccsSystemVm).setPublicIpAddress(null); inOrder.verify(autonomiccsSystemVm).setPrivateMacAddress(null); inOrder.verify(autonomiccsSystemVm).setPrivateIpAddress(null); inOrder.verify(autonomiccsSystemVm).setManagementIpAddress(null); Mockito.verify(autonomiccsSystemVmDao).update(Mockito.anyLong(), Mockito.any(AutonomiccsSystemVm.class)); }
@Test public void finalizeExpungeTestAutonomiccsSystemVmIsNull() { VirtualMachine vm = Mockito.mock(VirtualMachine.class); configureFinalizeExpungeTest(vm, null); spy.finalizeExpunge(vm); Mockito.verify(autonomiccsSystemVmDao, Mockito.times(0)).update(Mockito.anyLong(), Mockito.any(AutonomiccsSystemVm.class)); }