### Question:
NetworkUtils { public static String getIpAddress(final Enumeration<NetworkInterface> nis) { while (nis.hasMoreElements()) { final NetworkInterface ni = nis.nextElement(); final String address = getIpAddress(ni); if (address != null && !address.startsWith("127.") && !address.startsWith("169.")) { return address; } } return null; } NetworkUtils(); static String getIpAddress(final Enumeration<NetworkInterface> nis);  }### Answer:
@Test public void testEmptyInterfaces() { final Enumeration<NetworkInterface> nis = enumeration(emptyList()); assertNull(NetworkUtils.getIpAddress(nis)); }
@Test public void testLoopbackOnly() { final Enumeration<NetworkInterface> nis = enumeration(singletonList(createInterface("127.0.0.1"))); assertNull(NetworkUtils.getIpAddress(nis)); }
@Test public void testLinkLocalOnly() { final Enumeration<NetworkInterface> nis = enumeration(singletonList(createInterface("169.254.172.42"))); assertNull(NetworkUtils.getIpAddress(nis)); }
@Test public void testIpv6Only() { final Enumeration<NetworkInterface> nis = enumeration(singletonList(createInterface("2001:0db8:85a3:0000:0000:8a2e:0370:7334"))); assertNull(NetworkUtils.getIpAddress(nis)); }
@Test public void testFargate() { final Enumeration<NetworkInterface> nis = enumeration(asList( createInterface("127.0.0.1"), createInterface("169.254.172.42"), createInterface("2001:0db8:85a3:0000:0000:8a2e:0370:7334", "10.0.0.1"))); assertEquals("10.0.0.1", NetworkUtils.getIpAddress(nis)); }