### Question:
VirtualMachineExpunged implements Predicate<VirtualMachine> { public boolean apply(VirtualMachine virtualMachine) { logger.trace("looking for state on virtualMachine %s", checkNotNull(virtualMachine, "virtualMachine")); return refresh(virtualMachine) == null; } @Inject  VirtualMachineExpunged(CloudStackApi client); boolean apply(VirtualMachine virtualMachine);  }### Answer:
@Test public void testWaitForVirtualMachineToBeExpunged() { VirtualMachine virtualMachine = VirtualMachine.builder().id("229").build(); expect(virtualMachineClient.getVirtualMachine(virtualMachine.getId())).andReturn(null); replay(client, virtualMachineClient); assertTrue(new VirtualMachineExpunged(client).apply(virtualMachine)); verify(client, virtualMachineClient); }
@Test public void testNoRemovedYet() { VirtualMachine virtualMachine = VirtualMachine.builder().id("229").build(); expect(virtualMachineClient.getVirtualMachine(virtualMachine.getId())).andReturn(virtualMachine); replay(client, virtualMachineClient); assertFalse(new VirtualMachineExpunged(client).apply(virtualMachine)); verify(client, virtualMachineClient); }