### Question:
RangeUtils { static Map<String, Iterable<Comparable>> fetchTokens(String query, final Pair<Session, String> sessionWithHost, IPartitioner partitioner) { ResultSet rSet = sessionWithHost.left.execute(query); final AbstractType tkValidator = partitioner.getTokenValidator(); final Map<String, Iterable<Comparable>> tokens = Maps.newHashMap(); Iterable<Pair<String, Iterable<Comparable>>> pairs = transform(rSet.all(), new FetchTokensRowPairFunction(sessionWithHost, tkValidator)); for (Pair<String, Iterable<Comparable>> pair : pairs) { tokens.put(pair.left, pair.right); } return tokens; } private  RangeUtils(); static List<DeepTokenRange> getSplits(CassandraDeepJobConfig config); static IPartitioner getPartitioner(ICassandraDeepJobConfig config); static List<DeepTokenRange> getSplitsBySize(
            CassandraDeepJobConfig config);  }### Answer:
@Test public void testFetchSortedTokens1() { Map<String, Iterable<Comparable>> sortedTokens = RangeUtils.fetchTokens("none", Pair.create(mockSession1, "localhost"), new Murmur3Partitioner()); assertEquals(sortedTokens.size(), 2); List<Comparable> localTokens = Lists.newArrayList(sortedTokens.get("localhost")); assertNotNull(localTokens); assertEquals(localTokens.size(), 16); Iterable sortedLocalTokens1 = Ordering.natural().immutableSortedCopy(Iterables.transform(localTokens1, new Function<String, Long>() { @Nullable @Override public Long apply( @Nullable String input) { return Long.parseLong(input); } })); boolean elementsEquals = Iterables.elementsEqual( Ordering.natural().sortedCopy(localTokens), sortedLocalTokens1); assertTrue(elementsEquals); List<Comparable> remoteTokens = Lists.newArrayList(sortedTokens.get("fake-hostname")); assertNotNull(remoteTokens); assertEquals(remoteTokens.size(), 16); Iterable sortedRemoteTokens1 = Ordering.natural().immutableSortedCopy(Iterables.transform(remoteTokens1, new Function<String, Long>() { @Nullable @Override public Long apply( @Nullable String input) { return Long.parseLong(input); } })); elementsEquals = Iterables.elementsEqual( Ordering.natural().sortedCopy(sortedRemoteTokens1), Ordering.natural().sortedCopy(remoteTokens)); assertTrue(elementsEquals); }
@Test public void testFetchSortedTokens2() { Map<String, Iterable<Comparable>> sortedTokens = RangeUtils.fetchTokens("none", Pair.create(mockSession2, "localhost"), new Murmur3Partitioner()); assertEquals(sortedTokens.size(), 2); List<Comparable> localTokens = Lists.newArrayList(sortedTokens.get("localhost")); assertNotNull(localTokens); assertEquals(localTokens.size(), 255); Iterable sortedLocalTokens1 = Ordering.natural().immutableSortedCopy(Iterables.transform(localTokens2, new Function<String, Long>() { @Nullable @Override public Long apply( @Nullable String input) { return Long.parseLong(input); } })); boolean elementsEquals = Iterables.elementsEqual( Ordering.natural().sortedCopy(localTokens), sortedLocalTokens1); assertTrue(elementsEquals); List<Comparable> remoteTokens = Lists.newArrayList(sortedTokens.get("fake-hostname")); assertNotNull(remoteTokens); assertEquals(remoteTokens.size(), 256); Iterable sortedRemoteTokens1 = Ordering.natural().immutableSortedCopy(Iterables.transform(remoteTokens2, new Function<String, Long>() { @Nullable @Override public Long apply( @Nullable String input) { return Long.parseLong(input); } })); elementsEquals = Iterables.elementsEqual( Ordering.natural().sortedCopy(sortedRemoteTokens1), Ordering.natural().sortedCopy(remoteTokens)); assertTrue(elementsEquals); }