### Question:
HddsUtils { public static Optional<String> getHostName(String value) { if ((value == null) || value.isEmpty()) { return Optional.empty(); } String hostname = value.replaceAll("\\:[0-9]+$", ""); if (hostname.length() == 0) { return Optional.empty(); } else { return Optional.of(hostname); } } private  HddsUtils(); static InetSocketAddress getScmAddressForClients(
      ConfigurationSource conf); static InetSocketAddress getScmAddressForBlockClients(
      ConfigurationSource conf); static Optional<String> getHostNameFromConfigKeys(
      ConfigurationSource conf,
      String... keys); static Optional<String> getHostName(String value); static OptionalInt getHostPort(String value); static OptionalInt getPortNumberFromConfigKeys(
      ConfigurationSource conf, String... keys); static Collection<InetSocketAddress> getSCMAddresses(
      ConfigurationSource conf); static InetSocketAddress getReconAddresses(
      ConfigurationSource conf); static InetSocketAddress getSingleSCMAddress(
      ConfigurationSource conf); static String getHostName(ConfigurationSource conf); static boolean isReadOnly(
      ContainerProtos.ContainerCommandRequestProto proto); static boolean requireBlockToken(
      ContainerProtos.Type cmdType); static BlockID getBlockID(ContainerCommandRequestProto msg); static ObjectName registerWithJmxProperties(
      String serviceName, String mBeanName, Map<String, String> jmxProperties,
      Object mBean); static long getTime(); static void validatePath(Path path, Path ancestor); static final String OZONE_SCM_SERVICE_ID; static final String OZONE_SCM_SERVICE_INSTANCE_ID; }### Answer:
@Test public void testGetHostName() { Assert.assertEquals(Optional.of("localhost"), HddsUtils.getHostName("localhost:1234")); Assert.assertEquals(Optional.of("localhost"), HddsUtils.getHostName("localhost")); Assert.assertEquals(Optional.empty(), HddsUtils.getHostName(":1234")); }