@Test
public void canHandleTest() {

    final Network net = mock(Network.class);
    when(net.getBroadcastDomainType()).thenReturn(BroadcastDomainType.Lswitch);
    when(net.getId()).thenReturn(NETWORK_ID);
    when(ntwkSrvcDao.canProviderSupportServiceInNetwork(NETWORK_ID, Service.Connectivity, Provider.NiciraNvp)).thenReturn(true);
    // Golden path
    assertTrue(element.canHandle(net, Service.Connectivity));
    when(net.getBroadcastDomainType()).thenReturn(BroadcastDomainType.Vlan);
    // Only broadcastdomaintype lswitch is supported
    assertFalse(element.canHandle(net, Service.Connectivity));
    when(net.getBroadcastDomainType()).thenReturn(BroadcastDomainType.Lswitch);
    when(ntwkSrvcDao.canProviderSupportServiceInNetwork(NETWORK_ID, Service.Connectivity, Provider.NiciraNvp)).thenReturn(false);
    // No nvp provider in the network
    assertFalse(element.canHandle(net, Service.Connectivity));
    when(networkModel.isProviderForNetwork(Provider.NiciraNvp, NETWORK_ID)).thenReturn(false);
    when(ntwkSrvcDao.canProviderSupportServiceInNetwork(NETWORK_ID, Service.Connectivity, Provider.NiciraNvp)).thenReturn(true);
    // NVP provider does not provide Connectivity for this network
    assertFalse(element.canHandle(net, Service.Connectivity));
    when(networkModel.isProviderForNetwork(Provider.NiciraNvp, NETWORK_ID)).thenReturn(true);
    // Only service Connectivity is supported
    assertFalse(element.canHandle(net, Service.Dhcp));
}