### Question:
IpUtils { public static InetSocketAddress parseAddress(String address) { if(StringUtils.isBlank(address)) { return null; } Matcher matcher = ipv6Pattern.matcher(address); if(matcher.matches()) { return parseMatch(matcher); } matcher = ipv4Pattern.matcher(address); if(StringUtils.countMatches(address, ":") == 1 && matcher.matches()) { return parseMatch(matcher); } logger.debug("Invalid address: {}. For ipv6 use de convention [address]:port. For ipv4 address:port", address); return null; }  static InetSocketAddress parseAddress(String address); static List<InetSocketAddress> parseAddresses(List<String> addresses);  }### Answer:
@Test public void parseIPv6() { InetSocketAddress result = IpUtils.parseAddress(IPV6_WITH_PORT); Assert.assertNotNull(result); }
@Test public void parseIPv6NoPort() { InetSocketAddress result = IpUtils.parseAddress(IPV6_NO_PORT); Assert.assertNull(result); }
@Test public void parseIPv6InvalidFormat() { InetSocketAddress result = IpUtils.parseAddress(IPV6_INVALID); Assert.assertNull(result); }
@Test public void parseIPv4() { InetSocketAddress result = IpUtils.parseAddress(IPV4_WITH_PORT); Assert.assertNotNull(result); }
@Test public void parseIPv4NoPort() { InetSocketAddress result = IpUtils.parseAddress(IPV4_NO_PORT); Assert.assertNull(result); }