### Question:
NodeService { public static String createHostname(String clusterName, String clusterId, int nodeNum, String dnsSuffix) { String actualSuffix = (dnsSuffix == null || dnsSuffix.isEmpty()) ? "local" : dnsSuffix; if (actualSuffix.startsWith(".")) { actualSuffix = actualSuffix.substring(1); } long clusterIdNum = Long.parseLong(clusterId); String labelSuffix = clusterIdNum + "-" + nodeNum; String labelPrefix = StringUtils.stripLeadingDigits(clusterName); if (labelPrefix.length() + labelSuffix.length() > 63) { labelPrefix = labelPrefix.substring(0, 63 - labelSuffix.length()); } labelPrefix = labelPrefix.replace("_", "-"); labelPrefix = labelPrefix.replace(".", "-"); labelPrefix = labelPrefix.toLowerCase(); return labelPrefix + labelSuffix + "." + actualSuffix; } @Inject private  NodeService(ClusterStoreService clusterStoreService, Configuration conf); void startAction(Node node, String taskId, String service, String action); void completeAction(Node node); void failAction(Node node, String stdout, String stderr); static String createHostname(String clusterName, String clusterId, int nodeNum, String dnsSuffix);  }### Answer:
@Test public void testCreateHostname() { String clusterId = "00000001"; Assert.assertEquals("i-am-a-cluster1-1002.local", NodeService.createHostname("123i.am-a_clusTer", clusterId, 1002, null)); }
@Test public void testLongHostname() { String clusterId = "00000123"; String domain = "dev.company.com"; String labelSuffix = "123-1002"; StringBuilder longName = new StringBuilder(); for (int i = 0; i < 63 - labelSuffix.length(); i++) { longName.append("a"); } String bigName = longName.toString(); Assert.assertEquals(bigName + labelSuffix + "." + domain, NodeService.createHostname(bigName + "bcde", clusterId, 1002, domain)); }