### Question:
InMemoryCollectionRoutingMap implements CollectionRoutingMap { public static InMemoryCollectionRoutingMap tryCreateCompleteRoutingMap( Iterable<ImmutablePair<PartitionKeyRange, IServerIdentity>> ranges, String collectionUniqueId) { Map<String, ImmutablePair<PartitionKeyRange, IServerIdentity>> rangeById = new HashMap<>(); for (ImmutablePair<PartitionKeyRange, IServerIdentity> range: ranges) { rangeById.put(range.left.getId(), range); } List<ImmutablePair<PartitionKeyRange, IServerIdentity>> sortedRanges = new ArrayList<>(rangeById.values()); Collections.sort(sortedRanges, new MinPartitionKeyPairComparator()); List<PartitionKeyRange> orderedRanges = sortedRanges.stream().map(range -> range.left).collect(Collectors.toList()); if (!isCompleteSetOfRanges(orderedRanges)) { return null; } return new InMemoryCollectionRoutingMap(rangeById, orderedRanges, collectionUniqueId); } private  InMemoryCollectionRoutingMap(Map<String, ImmutablePair<PartitionKeyRange, IServerIdentity>> rangeById,
                                         List<PartitionKeyRange> orderedPartitionKeyRanges,
                                         String collectionUniqueId); static InMemoryCollectionRoutingMap tryCreateCompleteRoutingMap(
            Iterable<ImmutablePair<PartitionKeyRange, IServerIdentity>> ranges, String collectionUniqueId); String getCollectionUniqueId(); @Override List<PartitionKeyRange> getOrderedPartitionKeyRanges(); @Override PartitionKeyRange getRangeByEffectivePartitionKey(String effectivePartitionKeyValue); @Override PartitionKeyRange getRangeByPartitionKeyRangeId(String partitionKeyRangeId); @Override Collection<PartitionKeyRange> getOverlappingRanges(Range<String> range); @Override Collection<PartitionKeyRange> getOverlappingRanges(Collection<Range<String>> providedPartitionKeyRanges); @Override PartitionKeyRange tryGetRangeByPartitionKeyRangeId(String partitionKeyRangeId); @Override IServerIdentity tryGetInfoByPartitionKeyRangeId(String partitionKeyRangeId); @Override boolean IsGone(String partitionKeyRangeId); CollectionRoutingMap tryCombine(
        List<ImmutablePair<PartitionKeyRange, IServerIdentity>> ranges);  }### Answer:
@Test(groups = { "unit" }, expectedExceptions = IllegalStateException.class) public void invalidRoutingMap() { InMemoryCollectionRoutingMap.tryCreateCompleteRoutingMap(Arrays.asList( new ImmutablePair<>(new PartitionKeyRange("1", "0000000020", "0000000030"), ServerIdentityImp.of(2)), new ImmutablePair<>(new PartitionKeyRange("2", "0000000025", "0000000035"), ServerIdentityImp.of(2))), StringUtils.EMPTY); }
@Test(groups = { "unit" }) public void incompleteRoutingMap() { InMemoryCollectionRoutingMap routingMap = InMemoryCollectionRoutingMap .tryCreateCompleteRoutingMap(Arrays.asList( new ImmutablePair<>(new PartitionKeyRange("2", "", "0000000030"), ServerIdentityImp.of(2)), new ImmutablePair<>(new PartitionKeyRange("3", "0000000031", "FF"), ServerIdentityImp.of(2))), StringUtils.EMPTY); assertThat(routingMap).isNull(); routingMap = InMemoryCollectionRoutingMap.tryCreateCompleteRoutingMap(Arrays.asList( new ImmutablePair<>(new PartitionKeyRange("2", "", "0000000030"), ServerIdentityImp.of(2)), new ImmutablePair<>(new PartitionKeyRange("3", "0000000030", "FF"), ServerIdentityImp.of(2))), StringUtils.EMPTY); assertThat(routingMap).isNotNull(); }