@Test
public void testRemoveDhcpServiceWithNic() {

    // make local mocks
    VirtualMachineProfile vm =  mock(VirtualMachineProfile.class);
    NicVO nic = mock(NicVO.class);
    NetworkVO network = mock(NetworkVO.class);
    // make sure that release dhcp will be called
    when(vm.getType()).thenReturn(Type.User);
    when(testOrchastrator._networkModel.areServicesSupportedInNetwork(network.getId(), Service.Dhcp)).thenReturn(true);
    when(network.getTrafficType()).thenReturn(TrafficType.Guest);
    when(network.getGuestType()).thenReturn(GuestType.Shared);
    when(testOrchastrator._nicDao.listByNetworkIdTypeAndGatewayAndBroadcastUri(nic.getNetworkId(), VirtualMachine.Type.User, nic.getIPv4Gateway(), nic.getBroadcastUri())).thenReturn(new ArrayList<NicVO>());
    when(network.getGuruName()).thenReturn(guruName);
    when(testOrchastrator._networksDao.findById(nic.getNetworkId())).thenReturn(network);
    testOrchastrator.removeNic(vm, nic);
    verify(nic, times(1)).setState(Nic.State.Deallocating);
    verify(testOrchastrator._networkModel, times(2)).getElementImplementingProvider(dhcpProvider);
    verify(testOrchastrator._ntwkSrvcDao, times(2)).getProviderForServiceInNetwork(network.getId(), Service.Dhcp);
    verify(testOrchastrator._networksDao, times(2)).findById(nic.getNetworkId());
}