### Question:
UnibitIpTrie implements IpTree<T> { public boolean contains(T ip) { Assert.notNull(ip, "Ip must not be null"); return search(root, ip, 0) != null; }  void put(IpPrefix<T> prefix); boolean contains(T ip);  }### Answer:
@Test public void should_check_ipv4_prefixes() throws IOException { final File file = ResourceUtils.getFile("classpath:ip-ranges.json"); final IpTreeBuilder ipTreeBuilder = IpTreeBuilder.fromFile(file); IpTree<Ipv4Address> ipPrefixTree = ipTreeBuilder.buildIpv4Tree(); List<String> ipv4Prefixes = ipTreeBuilder.ipRanges().getIpv4Prefixes(); ipv4Prefixes.forEach(prefix -> { final IpPrefix<Ipv4Address> ipPrefix = IpPrefix.fromIpv4(prefix); assertThat(ipPrefixTree.contains(ipPrefix.getAddress())) .describedAs("Expected %s to be in tree", ipPrefix.toString()) .isTrue(); }); }
@Test public void should_check_ipv6_prefixes() throws IOException { final File file = ResourceUtils.getFile("classpath:ip-ranges.json"); final IpTreeBuilder ipTreeBuilder = IpTreeBuilder.fromFile(file); IpTree<Ipv6Address> ipPrefixTree = ipTreeBuilder.buildIpv6Tree(); List<String> ipv6Prefixes = ipTreeBuilder.ipRanges().getIpv6Prefixes(); ipv6Prefixes.forEach(prefix -> { final IpPrefix<Ipv6Address> ipPrefix = IpPrefix.fromIpv6(prefix); assertThat(ipPrefixTree.contains(ipPrefix.getAddress())) .describedAs("Expected %s to be in tree", ipPrefix.toString()) .isTrue(); }); }