@Test(expected = BadRequestException.class) public void shouldVerifySharedVipLbs() throws Exception { List<LoadBalancer> lbs = new ArrayList<LoadBalancer>(); LoadBalancer loadBalancer = new LoadBalancer(); loadBalancer.setId(3333); loadBalancer.setAccountId(55555); Set<LoadBalancerJoinVip> jvips = new HashSet<LoadBalancerJoinVip>(); LoadBalancerJoinVip jvip = new LoadBalancerJoinVip(); jvip.setVirtualIp(new VirtualIp()); jvip.setId(new LoadBalancerJoinVip.Id(loadBalancer.getId(), 676)); jvip.setLoadBalancer(lb); jvips.add(jvip); loadBalancer.setLoadBalancerJoinVipSet(jvips); List<LoadBalancer> sharedlbs = new ArrayList<LoadBalancer>(); LoadBalancer sharedlb = new LoadBalancer(); sharedlb.setId(9844); sharedlbs.add(sharedlb); when(virtualIpRepository.getLoadBalancersByVipId(Matchers.anyInt())).thenReturn(sharedlbs); lbs.add(loadBalancer); when(lbRepository.getById(Matchers.anyInt())).thenReturn(loadBalancer); List<LoadBalancer> newLbs; newLbs = lbService.reassignLoadBalancerHost(lbs); LoadBalancer newLb; newLb = newLbs.get(0); Assert.assertEquals((Object) 55555, newLb.getAccountId()); }
@Test(expected = BadRequestException.class) public void shouldFailIfLbisSticky() throws Exception { when(lbRepository.getById(Matchers.<Integer>any())).thenReturn(lb); List<LoadBalancer> lbs = new ArrayList<LoadBalancer>(); LoadBalancer loadBalancer = new LoadBalancer(); loadBalancer.setId(3333); lb.setSticky(true); lbs.add(loadBalancer); List<LoadBalancer> newLbs; newLbs = lbService.reassignLoadBalancerHost(lbs); LoadBalancer newLb; newLb = newLbs.get(0); Assert.assertEquals((Object) 555555, newLb.getAccountId()); }