### Question:
BuilderUtils { public static InetSocketAddress toResolvedInetSocketAddress(final HostAndPort resolvedAddress) { try { return new InetSocketAddress(getByAddress(createByteArrayFromIpAddressString( resolvedAddress.hostName())), resolvedAddress.port()); } catch (UnknownHostException e) { throw new IllegalArgumentException("Invalid resolved address: " + resolvedAddress.hostName() + ", expected IP-address.", e); } } private  BuilderUtils(); static boolean useEpoll(EventLoopGroup group); static boolean useKQueue(EventLoopGroup group); static Class<? extends ServerChannel> serverChannel(EventLoopGroup group,
                                                               Class<? extends SocketAddress> addressClass); static Class<? extends Channel> socketChannel(EventLoopGroup group,
                                                         Class<? extends SocketAddress> addressClass); @Nullable static Channel socketChannel(EventLoopGroup group, FileDescriptorSocketAddress address); static SocketAddress toNettyAddress(Object address); static InetSocketAddress toResolvedInetSocketAddress(final HostAndPort resolvedAddress); static Class<? extends DatagramChannel> datagramChannel(EventLoopGroup group); static String formatCanonicalAddress(SocketAddress address); static void closeAndRethrowUnchecked(@Nullable Closeable closable);  }### Answer:
@Test @SuppressWarnings("PMD.AvoidUsingHardCodedIP") public void toResolvedInetSocketAddressFromIPv4() { final String localhostIp4Address = NetUtil.LOCALHOST4.getHostAddress(); InetSocketAddress address = toResolvedInetSocketAddress(HostAndPort.of(localhostIp4Address, 8080)); assertThat(address.isUnresolved(), is(false)); assertThat(address.getHostString(), equalTo(localhostIp4Address)); assertThat(address.getPort(), is(8080)); }
@Test @SuppressWarnings("PMD.AvoidUsingHardCodedIP") public void toResolvedInetSocketAddressFromIPv6() { final String localhostIp6Address = NetUtil.LOCALHOST6.getHostAddress(); InetSocketAddress address = toResolvedInetSocketAddress(HostAndPort.of(localhostIp6Address, 8080)); assertThat(address.isUnresolved(), is(false)); assertThat(address.getHostString(), equalTo(localhostIp6Address)); assertThat(address.getPort(), is(8080)); }
@Test public void toResolvedInetSocketAddressFromUnresolved() { Throwable t = assertThrows(IllegalArgumentException.class, () -> toResolvedInetSocketAddress(HostAndPort.of("unresolved-hostname", 8080))); assertThat(t.getCause(), instanceOf(UnknownHostException.class)); }