CollectionTool extends org.apache.velocity.tools.generic.CollectionTool { public <E> Set<E> getOrderedSet() { return new LinkedHashSet<>(); }  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 getOrderedSet() { Set<Double> result = this.tool.getOrderedSet(); assertNotNull(result, "Returned null instead of a set"); assertTrue(result.isEmpty(), "Returned set wasn't initially empty"); Random r = new Random(); List<Double> values = new ArrayList<>(150); for (int i = 0; i < 100; ++i) { Double d = r.nextDouble(); result.add(d); values.add(d); } Iterator<Double> valueIterator = values.iterator(); for (Double e : result) { assertEquals(valueIterator.next(), e, "Set doesn't preserve the insertion order"); } }