CollectionTool extends org.apache.velocity.tools.generic.CollectionTool { public <K extends Comparable<K>, V> SortedMap<K, V> getSortedMap() { return new TreeMap<>(); }  List<E> getArrayList(); List<E> getLinkedList(); Map<K, V> getMap(); SortedMap<K, V> getSortedMap(); Map<K, V> getOrderedMap(); Set<E> getSet(); SortedSet<E> getSortedSet(); Set<E> getOrderedSet(); Queue<E> getQueue(); BlockingQueue<E> getBlockingQueue(); Queue<E> getPriorityQueue(); List<E> unmodifiable(List<E> input); Map<K, V> unmodifiable(Map<K, V> input); Set<E> unmodifiable(Set<E> input); Collection<E> unmodifiable(Collection<E> input); Collection<E> union(Collection<E> a, Collection<E> b); Collection<E> intersection(Collection<E> a, Collection<E> b); Collection<E> disjunction(Collection<E> a, Collection<E> b); boolean reverseModifiable(List<E> input); boolean sortModifiable(List<E> input);  }
@Test void getSortedMap() { SortedMap<Double, Integer> result = this.tool.getSortedMap(); assertNotNull(result, "Returned null instead of a map"); assertTrue(result.isEmpty(), "Returned map wasn't initially empty"); Random r = new Random(); for (int i = 0; i < 100; ++i) { result.put(r.nextDouble(), i); } Double d = 0.0; for (Map.Entry<Double, Integer> e : result.entrySet()) { assertTrue(e.getKey() >= d, "Map doesn't preserve the natural order of the elements"); d = e.getKey(); } }