@Test
  public void validateGetPort() throws Exception {
    ClusterMapConfig clusterMapConfig;
    Properties props = new Properties();
    props.setProperty("clustermap.ssl.enabled.datacenters", "datacenter1,datacenter2,datacenter3");
    props.setProperty("clustermap.cluster.name", "test");
    props.setProperty("clustermap.datacenter.name", "dc1");
    props.setProperty("clustermap.host.name", "localhost");
    clusterMapConfig = new ClusterMapConfig(new VerifiableProperties(props));
    System.out.println(clusterMapConfig.clusterMapSslEnabledDatacenters);
    JSONObject jsonObject =
        TestUtils.getJsonDataNode(TestUtils.getLocalHost(), 6666, 7666, 8666, HardwareState.AVAILABLE, getDisks());

    DataNode dataNode = new TestDataNode("datacenter2", jsonObject, clusterMapConfig);
    assertEquals("The datacenter of the data node is in the ssl enabled datacenter list. SSL port should be returned",
        PortType.SSL, dataNode.getPortToConnectTo().getPortType());

    dataNode = new TestDataNode("datacenter5", jsonObject, clusterMapConfig);
    assertEquals(
        "The datacenter of the data node is not in the ssl enabled datacenter list. Plaintext port should be returned",
        PortType.PLAINTEXT, dataNode.getPortToConnectTo().getPortType());

    jsonObject.remove("sslport");
    dataNode = new TestDataNode("datacenter1", jsonObject, clusterMapConfig);
    try {
      dataNode.getPortToConnectTo();
      fail("Should have thrown Exception because there is no sslPort.");
    } catch (IllegalStateException e) {
      // The datacenter of the data node is in the ssl enabled datacenter list, but the data node does not have an ssl
      // port to connect. Exception should be thrown.
    }
  }
Validate {@link DataNodeId#getPortToConnectTo()} returns port type corresponding to the
SSL enabled datacenter list specified in {@link ClusterMapConfig}.
@throws Exception
ambry-clustermap/src/test/java/com/github/ambry/clustermap/DataNodeTest.java