### Question:
NetUtils { public static @Nonnull String getIpAddrFromPrefix(@Nullable String prefix) { String newPrefix = Strings.nullToEmpty(prefix); int slashIndex = newPrefix.indexOf("/"); if (slashIndex == -1) { slashIndex = newPrefix.length(); } return newPrefix.substring(0, slashIndex); }  static int getMaskFromPrefix(@Nullable String prefix); static @Nonnull String getIpAddrFromPrefix(@Nullable String prefix); static @Nullable Ipv6Address applyMaskOnIpv6Prefix(@Nullable Ipv6Prefix ipv6Prefix, int ipv6MaskLength); static @Nullable Ipv6Address applyMaskOnIpv6Address(@Nullable Ipv6Address ipv6Address, int ipv6MaskLength); static boolean samePrefix(@Nullable IpPrefix prefix1, @Nullable IpPrefix prefix2); static boolean isInRange(@Nullable IpPrefix prefix, @Nullable String ipAddress);  }### Answer:
@Test public void testGetIpAddrFromPrefix_FromNull () { String result = NetUtils.getIpAddrFromPrefix(null); Assert.assertTrue(result.isEmpty()); }
@Test public void testGetIpAddrFromPrefix_StringWithouPrefixLength () { String result = NetUtils.getIpAddrFromPrefix(IPV4_ADDRESS_1); Assert.assertEquals(IPV4_ADDRESS_1, result); }
@Test public void testGetIpAddrFromPrefix_Ipv4Prefix () { String result = NetUtils.getIpAddrFromPrefix(IPV4_ADDRESS_1 + MASK_24); Assert.assertEquals(IPV4_ADDRESS_1, result); }
@Test public void testGetIpAddrFromPrefix_Ipv6Prefix () { String result = NetUtils.getIpAddrFromPrefix(IPV6_HOST_ADDRESS + MASK_64); Assert.assertEquals(IPV6_HOST_ADDRESS, result); }