@Test
    public void shouldUpdateNodesStatusAndWeightsAppropriately() {
      Set<Node> nodes = new HashSet<Node>();
      Node node1 = new Node();
      Node node2 = new Node();
      Node node3 = new Node();

      node1.setCondition(NodeCondition.ENABLED);
      node2.setCondition(NodeCondition.DRAINING);
      node3.setCondition(NodeCondition.DISABLED);
      node1.setWeight(null);
      node2.setWeight(0);
      node3.setWeight(10);
      nodes.add(node1);
      nodes.add(node2);
      nodes.add(node3);
      lb.setNodes(nodes);

      lbService.addDefaultValues(lb);

      Assert.assertEquals(NodeStatus.ONLINE, node1.getStatus());
      Assert.assertEquals(NodeStatus.ONLINE, node2.getStatus());
      Assert.assertEquals(NodeStatus.ONLINE, node3.getStatus());

      Assert.assertEquals(1, node1.getWeight().intValue());
      Assert.assertEquals(0, node2.getWeight().intValue());
      Assert.assertEquals(10, node3.getWeight().intValue());
    }
    @Test
    public void shouldSetStatusToBuildWhenStatusIsModified() {
      lb.setStatus(LoadBalancerStatus.ERROR);

      lbService.addDefaultValues(lb);

      Assert.assertEquals(LoadBalancerStatus.BUILD, lb.getStatus());
    }
    @Test
    public void shouldAddDefaultValuesWhenNoValuesAreSet() {
      lbService.addDefaultValues(lb);

      Assert.assertEquals(LoadBalancerAlgorithm.RANDOM, lb.getAlgorithm());
      Assert.assertEquals(LoadBalancerProtocol.HTTP, lb.getProtocol());
      Assert.assertFalse(lb.isConnectionLogging());
      Assert.assertEquals(defaultProtocol.getPort(), lb.getPort());
      Assert.assertEquals(SessionPersistence.NONE, lb.getSessionPersistence());
      Assert.assertEquals(LoadBalancerStatus.BUILD, lb.getStatus());
      Assert.assertEquals(false, lb.isHalfClosed());
    }
    @Test
    public void shouldNotAddDefaultValuesWhenValuesAreSet() {
      lb.setAlgorithm(LoadBalancerAlgorithm.LEAST_CONNECTIONS);
      lb.setProtocol(LoadBalancerProtocol.IMAPv3);
      lb.setConnectionLogging(true);
      lb.setPort(1234);
      lb.setSessionPersistence(SessionPersistence.HTTP_COOKIE);

      lbService.addDefaultValues(lb);

      Assert.assertEquals(LoadBalancerAlgorithm.LEAST_CONNECTIONS, lb.getAlgorithm());
      Assert.assertEquals(LoadBalancerProtocol.IMAPv3, lb.getProtocol());
      Assert.assertTrue(lb.isConnectionLogging());
      Assert.assertEquals(1234, lb.getPort().intValue());
      Assert.assertEquals(SessionPersistence.HTTP_COOKIE, lb.getSessionPersistence());
    }