### Question:
EnvironmentBasedDomainNameProvider { public String getCommonName(String endpointName, String environmentName, String accountName) { String domain = getDomainName(environmentName, accountName); String uniqueNameToBeHashed = endpointName + environmentName; String clusterHash = sipHash24().hashUnencodedChars(uniqueNameToBeHashed).toString(); return clusterHash + DOMAIN_PART_DELIMITER + domain; }  String getDomainName(String environmentName, String accountName); String getFullyQualifiedEndpointName(String endpointName, String environmentName, String accountName); String getCommonName(String endpointName, String environmentName, String accountName);  }### Answer:
@Test void testGetCommonNameWhenTheEndpointNameIsLessThan17AndEnvNameLessThan8Chars() { String endpointName = "test-cl-master0"; String envName = "shrt-nv"; String accountName = "xcu2-8y8x"; String rootDomain = "wl.cloudera.site"; ReflectionTestUtils.setField(underTest, "rootDomain", rootDomain); String commonName = underTest.getCommonName(endpointName, envName, accountName); String expected = String.format("bbd9025ff9fd7c4d.%s.%s.%s", envName, accountName, rootDomain); assertEquals(expected, commonName); }
@Test void testGetCommonNameWhenTheEndpointNameIsLongerThan17AndEnvNameLongerThan8Chars() { String endpointName = "test-cl-longyloooooooooooong-name-master0"; String envName = "notashort-env-name-as28chars"; String accountName = "xcu2-8y8x"; String rootDomain = "wl.cloudera.site"; ReflectionTestUtils.setField(underTest, "rootDomain", rootDomain); String commonName = underTest.getCommonName(endpointName, envName, accountName); String expected = String.format("a7c2a45fc8f917fe.%s.%s.%s", envName.substring(0, 8), accountName, rootDomain); assertEquals(expected, commonName); }