### Question:
KVMNotifier extends GenericNotifier { @Override public List<VirtualSystemEvent> processEvent(final VirtualMachine virtualMachine, final PhysicalMachine machine, final VMEventType event) { logger.trace(String.format("Processing %s %s event from machine %s", virtualMachine.getName(), event.name(), machine.getAddress())); if (samePhysicalMachineAddress(virtualMachine.getPhysicalMachine(), machine)) { if (validEvents.contains(event) && !alreadyNotified(virtualMachine, event)) { return Collections.singletonList(buildVirtualSystemEvent(virtualMachine, event)); } } else if (mustNotifyMovement.contains(event)) { return buildMovementNotifications(virtualMachine, machine); } return Collections.emptyList(); } KVMNotifier(); @Override List<VirtualSystemEvent> processEvent(final VirtualMachine virtualMachine,
        final PhysicalMachine machine, final VMEventType event);  }### Answer:
@Test public void test_migration() { VirtualMachine vm = new VirtualMachine(); PhysicalMachine pm0 = new PhysicalMachine(); PhysicalMachine pm1 = new PhysicalMachine(); pm0.setId(0); pm0.setAddress("http: pm0.setUsername(""); pm0.setPassword(""); pm0.setType(Type.KVM.name()); pm1.setId(1); pm1.setAddress("http: pm1.setUsername(""); pm1.setPassword(""); pm1.setType(Type.KVM.name()); vm.setId(0); vm.setLastKnownState(null); vm.setName("ABQ_" + UUID.randomUUID().toString()); vm.setPhysicalMachine(pm0); List<VirtualSystemEvent> notifications; notifications = notifier.processEvent(vm, pm1, VMEventType.RESUMED); assertEquals(notifications.size(), 2); assertTrue(containsMovedEvent(notifications)); assertTrue(containsEvent(VMEventType.POWER_ON, notifications)); assertTrue(notificationsFromMachine(notifications, pm1)); vm.setPhysicalMachine(pm1); notifications = notifier.processEvent(vm, pm0, VMEventType.POWER_OFF); assertTrue(notifications.isEmpty()); vm.setPhysicalMachine(pm1); notifications = notifier.processEvent(vm, pm1, VMEventType.CREATED); assertTrue(notifications.isEmpty()); vm.setPhysicalMachine(pm0); notifications = notifier.processEvent(vm, pm1, VMEventType.POWER_ON); assertEquals(notifications.size(), 2); assertTrue(containsMovedEvent(notifications)); assertTrue(containsEvent(VMEventType.POWER_ON, notifications)); assertTrue(notificationsFromMachine(notifications, pm1)); vm.setPhysicalMachine(pm1); notifications = notifier.processEvent(vm, pm0, VMEventType.POWER_OFF); assertTrue(notifications.isEmpty()); vm.setPhysicalMachine(pm1); notifications = notifier.processEvent(vm, pm1, VMEventType.CREATED); assertTrue(notifications.isEmpty()); vm.setPhysicalMachine(pm0); notifications = notifier.processEvent(vm, pm1, VMEventType.POWER_OFF); assertFalse(containsMovedEvent(notifications)); notifications = notifier.processEvent(vm, pm1, VMEventType.PAUSED); assertFalse(containsMovedEvent(notifications)); notifications = notifier.processEvent(vm, pm1, VMEventType.CREATED); assertFalse(containsMovedEvent(notifications)); }