@Test(groups = {"unit"})

public void getOverlappingRangesWithList() {
    Function<PartitionKeyRange, String> func = new Function<PartitionKeyRange, String>() {
        @Override
        public String apply(PartitionKeyRange range) {
            return range.getId();
        }
    };
    IRoutingMapProvider routingMapProviderMock = Mockito.mock(IRoutingMapProvider.class);
    List<PartitionKeyRange> rangeList = Arrays.asList(new PartitionKeyRange("0", "", "000A"),
            new PartitionKeyRange("1", "000A", "000D"),
            new PartitionKeyRange("2", "000D", "0012"),
            new PartitionKeyRange("3", "0012", "0015"),
            new PartitionKeyRange("4", "0015", "0020"),
            new PartitionKeyRange("5", "0020", "0040"),
            new PartitionKeyRange("6", "0040", "FF"));
    Single<List<PartitionKeyRange>> listSingle = Single.just(rangeList);
    Map<Range, List<PartitionKeyRange>> resultMap = new HashMap<>();
    resultMap.put(new Range<>("000D", "0012", true, false),
            Collections.singletonList(new PartitionKeyRange("2", "000D", "0012")));
    resultMap.put(new Range<>("0012", "0015", true, false),
            Collections.singletonList(new PartitionKeyRange("3", "0012", "0015")));
    resultMap.put(new Range<>("0015", "0020", true, false),
            Collections.singletonList(new PartitionKeyRange("4", "0015", "00120")));
    Mockito.doAnswer(invocationOnMock -> {
        Range range = invocationOnMock.getArgumentAt(1, Range.class);
        return Single.just(resultMap.get(range));
    }).when(routingMapProviderMock).tryGetOverlappingRangesAsync(Matchers.anyString(),
            Matchers.any(),
            Matchers.anyBoolean(),
            Matchers.anyMap());
    Single<List<PartitionKeyRange>> overlappingRanges;
    overlappingRanges = RoutingMapProviderHelper.getOverlappingRanges(routingMapProviderMock,
            "/dbs/db1/colls/coll1",
            Arrays.asList(new Range<String>("000D", "0012", true, false),
                    new Range<String>("0012", "0015", true, false),
                    new Range<>("0015", "0020", true, false)));
    assertThat("2,3,4").isEqualTo(overlappingRanges.toBlocking().value().stream().map(func).collect(Collectors.joining(",")));
    overlappingRanges = RoutingMapProviderHelper.getOverlappingRanges(routingMapProviderMock,
            "/dbs/db1/colls/coll1",
            Arrays.asList(new Range<String>("000D", "0012", true, false)));
    assertThat("2").isEqualTo(overlappingRanges.toBlocking().value().stream().map(func).collect(Collectors.joining(",")));
}