@Test(groups = { "unit" })

public void getOverlappingRanges() {
    Collection<PartitionKeyRange> ranges = RoutingMapProviderHelper.getOverlappingRanges(ROUTING_MAP_PROVIDER,
            "dbs/db1/colls/coll1",
            Arrays.asList(new Range<String>("000B", "000E", true, false),
                    new Range<String>("000E", "000F", true, false), new Range<String>("000F", "0010", true, true),
                    new Range<String>("0015", "0015", true, true)));
    Function<PartitionKeyRange, String> func = new Function<PartitionKeyRange, String>() {
        @Override
        public String apply(PartitionKeyRange range) {
            return range.getId();
        }
    };
    assertThat("1,2,4").isEqualTo(ranges.stream().map(func).collect(Collectors.joining(",")));
    // query for minimal point
    ranges = RoutingMapProviderHelper.getOverlappingRanges(ROUTING_MAP_PROVIDER, "dbs/db1/colls/coll1",
            Collections.singletonList(new Range<String>("", "", true, true)));
    assertThat("0").isEqualTo(ranges.stream().map(func).collect(Collectors.joining(",")));
    // query for empty range
    ranges = RoutingMapProviderHelper.getOverlappingRanges(ROUTING_MAP_PROVIDER, "dbs/db1/colls/coll1",
            Collections.singletonList(new Range<String>("", "", true, false)));
    assertThat(0).isEqualTo(ranges.size());
    // entire range
    ranges = RoutingMapProviderHelper.getOverlappingRanges(ROUTING_MAP_PROVIDER, "dbs/db1/colls/coll1",
            Collections.singletonList(new Range<String>("", "FF", true, false)));
    assertThat("0,1,2,3,4,5,6").isEqualTo(ranges.stream().map(func).collect(Collectors.joining(",")));
    // matching range
    ranges = RoutingMapProviderHelper.getOverlappingRanges(ROUTING_MAP_PROVIDER, "dbs/db1/colls/coll1",
            Collections.singletonList(new Range<String>("0012", "0015", true, false)));
    assertThat("3").isEqualTo(ranges.stream().map(func).collect(Collectors.joining(",")));
    // matching range with empty ranges
    ranges = RoutingMapProviderHelper.getOverlappingRanges(ROUTING_MAP_PROVIDER, "dbs/db1/colls/coll1",
            Arrays.asList(new Range<String>("", "", true, false), new Range<String>("0012", "0015", true, false)));
    assertThat("3").isEqualTo(ranges.stream().map(func).collect(Collectors.joining(",")));
    // matching range and a little bit more.
    ranges = RoutingMapProviderHelper.getOverlappingRanges(ROUTING_MAP_PROVIDER, "dbs/db1/colls/coll1",
            Collections.singletonList(new Range<String>("0012", "0015", false, true)));
    assertThat("3,4").isEqualTo(ranges.stream().map(func).collect(Collectors.joining(",")));
}