### Question:
DataNode implements DataNodeId { List<Disk> getDisks() { return disks; } DataNode(Datacenter datacenter, JSONObject jsonObject, ClusterMapConfig clusterMapConfig); @Override String getHostname(); @Override int getPort(); @Override boolean hasSSLPort(); @Override int getSSLPort(); @Override boolean hasHttp2Port(); @Override int getHttp2Port(); @Override Port getPortToConnectTo(); @Override HardwareState getState(); @Override String getDatacenterName(); @Override String getRackId(); @Override long getXid(); @Override JSONObject getSnapshot(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode();  }### Answer:
@Test public void validation() throws JSONException { JSONObject jsonObject; ClusterMapConfig clusterMapConfig = new ClusterMapConfig(new VerifiableProperties(props)); try { jsonObject = TestUtils.getJsonDataNode(TestUtils.getLocalHost(), 6666, 7666, 8666, HardwareState.AVAILABLE, getDisks()); new DataNode(null, jsonObject, clusterMapConfig); fail("Should have failed validation."); } catch (IllegalStateException e) { } jsonObject = TestUtils.getJsonDataNode("", 6666, 7666, 8666, HardwareState.AVAILABLE, getDisks()); failValidation(jsonObject, clusterMapConfig); jsonObject = TestUtils.getJsonDataNode("hostname.invalid", 6666, 7666, 8666, HardwareState.AVAILABLE, getDisks()); failValidation(jsonObject, clusterMapConfig); int[][] portsToTest = {{-1, 7666, 8666}, {100 * 1000, 7666, 8666}, {6666, -1, 8666}, {6666, 100 * 1000, 8666}, {6666, 7777, -1}, {6666, 7777, 100 * 1000}}; for (int[] ports : portsToTest) { jsonObject = TestUtils.getJsonDataNode(TestUtils.getLocalHost(), ports[0], ports[1], ports[2], HardwareState.AVAILABLE, getDisks()); failValidation(jsonObject, clusterMapConfig); } jsonObject = TestUtils.getJsonDataNode(TestUtils.getLocalHost(), 6666, 6666, 8666, HardwareState.AVAILABLE, getDisks()); failValidation(jsonObject, clusterMapConfig); jsonObject = TestUtils.getJsonDataNode(TestUtils.getLocalHost(), 6666, 7666, 6666, HardwareState.AVAILABLE, getDisks()); failValidation(jsonObject, clusterMapConfig); jsonObject = TestUtils.getJsonDataNode(TestUtils.getLocalHost(), 6666, 8666, 8666, HardwareState.AVAILABLE, getDisks()); failValidation(jsonObject, clusterMapConfig); }