### Question:
StringHelper { public static Optional<InetAddress> toInetAddress(String ip) { ip = StringUtils.trimToNull(ip); if (ip == null) { return Optional.empty(); } InetAddress addr = null; try { addr = InetAddress.getByName(ip); } catch (UnknownHostException | SecurityException e) { LOG.warn("Cannot convert: " + ip + " to valid IP: " + e.getMessage()); LOG.debug(e.getMessage(), e); } return Optional.ofNullable(addr); }  static String decorate(String toDecorate, StringDecorator decorator, String... keywordsLc); static Optional<InetAddress> toInetAddress(String ip);  }### Answer:
@Test public void testToInetAddress_OK() throws Exception { assertEquals(InetAddress.getByName("192.168.0.1"), StringHelper.toInetAddress("192.168.0.1").get()); assertEquals(InetAddress.getByName("0.0.0.0"), StringHelper.toInetAddress("0.0.0.0").get()); }
@Test public void testToInetAddress_Incorrect() throws Exception { { Optional<InetAddress> addr = StringHelper.toInetAddress("192.1328.01"); assertFalse(addr.toString(), addr.isPresent()); } { Optional<InetAddress> addr = StringHelper.toInetAddress(null); assertFalse(addr.toString(), addr.isPresent()); } { Optional<InetAddress> addr = StringHelper.toInetAddress(""); assertFalse(addr.toString(), addr.isPresent()); } { Optional<InetAddress> addr = StringHelper.toInetAddress("asdasd"); assertFalse(addr.toString(), addr.isPresent()); } }