@Test
  public void testHostAndPortConstructor() throws Exception {

    ClusterSlotRange clusterSlotRange =
        new ClusterSlotRange(
            100,
            200,
            HostAndPort.fromParts("1", 2),
            ImmutableList.of(HostAndPort.fromParts("1", 2)));

    RedisClusterNode masterNode = clusterSlotRange.getMasterNode();
    assertThat(masterNode).isNotNull();
    assertThat(masterNode.getNodeId()).isNull();
    assertThat(masterNode.getUri().getHost()).isEqualTo("1");
    assertThat(masterNode.getUri().getPort()).isEqualTo(2);
    assertThat(masterNode.getFlags()).contains(RedisClusterNode.NodeFlag.MASTER);

    assertThat(clusterSlotRange.getSlaves()).hasSize(1);
    assertThat(clusterSlotRange.getSlaveNodes()).hasSize(1);

    HostAndPort slave = clusterSlotRange.getSlaves().get(0);
    assertThat(slave.getHostText()).isEqualTo("1");
    assertThat(slave.getPort()).isEqualTo(2);

    RedisClusterNode slaveNode = clusterSlotRange.getSlaveNodes().get(0);

    assertThat(slaveNode.getNodeId()).isNull();
    assertThat(slaveNode.getSlaveOf()).isNull();
    assertThat(slaveNode.getFlags()).contains(RedisClusterNode.NodeFlag.SLAVE);
  }
  @Test
  public void testModel() throws Exception {

    ClusterSlotRange range = new ClusterSlotRange();
    range.setFrom(1);
    range.setTo(2);
    range.setSlaves(Lists.<HostAndPort>newArrayList());
    range.setMaster(HostAndPort.fromHost("localhost"));

    assertThat(range.toString()).contains(ClusterSlotRange.class.getSimpleName());
  }
  @Test
  public void testParseWithSlave() throws Exception {
    List<?> list =
        ImmutableList.of(
            Lists.newArrayList(
                "100",
                "200",
                Lists.newArrayList("1", "2", "nodeId1"),
                Lists.newArrayList("1", 2, "nodeId2")));
    List<ClusterSlotRange> result = ClusterSlotsParser.parse(list);
    assertThat(result).hasSize(1);
    ClusterSlotRange clusterSlotRange = result.get(0);

    assertThat(clusterSlotRange.getMaster()).isNotNull();
    assertThat(clusterSlotRange.getMaster().getHostText()).isEqualTo("1");
    assertThat(clusterSlotRange.getMaster().getPort()).isEqualTo(2);

    RedisClusterNode masterNode = clusterSlotRange.getMasterNode();
    assertThat(masterNode).isNotNull();
    assertThat(masterNode.getNodeId()).isEqualTo("nodeId1");
    assertThat(masterNode.getUri().getHost()).isEqualTo("1");
    assertThat(masterNode.getUri().getPort()).isEqualTo(2);
    assertThat(masterNode.getFlags()).contains(RedisClusterNode.NodeFlag.MASTER);
    assertThat(masterNode.getSlots()).contains(100, 101, 199, 200);
    assertThat(masterNode.getSlots()).doesNotContain(99, 201);
    assertThat(masterNode.getSlots()).hasSize(101);

    assertThat(clusterSlotRange.getSlaves()).hasSize(1);
    assertThat(clusterSlotRange.getSlaveNodes()).hasSize(1);

    HostAndPort slave = clusterSlotRange.getSlaves().get(0);
    assertThat(slave.getHostText()).isEqualTo("1");
    assertThat(slave.getPort()).isEqualTo(2);

    RedisClusterNode slaveNode = clusterSlotRange.getSlaveNodes().get(0);

    assertThat(slaveNode.getNodeId()).isEqualTo("nodeId2");
    assertThat(slaveNode.getSlaveOf()).isEqualTo("nodeId1");
    assertThat(slaveNode.getFlags()).contains(RedisClusterNode.NodeFlag.SLAVE);
  }