@Override
@Before
public void setUp() {
ComponentContext.initComponentsLifeCycle();
//mockito for .getApplicationLoadBalancer tests
Mockito.when(_lbDao.findById(1L)).thenReturn(new ApplicationLoadBalancerRuleVO());
Mockito.when(_lbDao.findById(2L)).thenReturn(null);
//mockito for .deleteApplicationLoadBalancer tests
Mockito.when(_lbService.deleteLoadBalancerRule(existingLbId, true)).thenReturn(true);
Mockito.when(_lbService.deleteLoadBalancerRule(nonExistingLbId, true)).thenReturn(false);
//mockito for .createApplicationLoadBalancer tests
NetworkVO guestNetwork = new NetworkVO(TrafficType.Guest, null, null, 1, null, 1, 1L);
setId(guestNetwork, validGuestNetworkId);
guestNetwork.setCidr("10.1.1.1/24");
NetworkVO publicNetwork = new NetworkVO(TrafficType.Public, null, null, 1, null, 1, 1L);
Mockito.when(_ntwkModel.getNetwork(validGuestNetworkId)).thenReturn(guestNetwork);
Mockito.when(_ntwkModel.getNetwork(invalidGuestNetworkId)).thenReturn(null);
Mockito.when(_ntwkModel.getNetwork(validPublicNetworkId)).thenReturn(publicNetwork);
Mockito.when(_accountMgr.getAccount(validAccountId)).thenReturn(new AccountVO());
Mockito.when(_accountMgr.getAccount(invalidAccountId)).thenReturn(null);
Mockito.when(_ntwkModel.areServicesSupportedInNetwork(validGuestNetworkId, Service.Lb)).thenReturn(true);
Mockito.when(_ntwkModel.areServicesSupportedInNetwork(invalidGuestNetworkId, Service.Lb)).thenReturn(false);
ApplicationLoadBalancerRuleVO lbRule =
new ApplicationLoadBalancerRuleVO("new", "new", 22, 22, "roundrobin", validGuestNetworkId, validAccountId, 1L, new Ip(validRequestedIp), validGuestNetworkId,
Scheme.Internal);
Mockito.when(_lbDao.persist(Matchers.any(ApplicationLoadBalancerRuleVO.class))).thenReturn(lbRule);
Mockito.when(_lbMgr.validateLbRule(Matchers.any(LoadBalancingRule.class))).thenReturn(true);