private static boolean resultsMatch(QueryResult controlResult, QueryResult testResult, int precision) { SortedMultiset<List<Object>> control = ImmutableSortedMultiset.copyOf(rowComparator(precision), controlResult.getResults()); SortedMultiset<List<Object>> test = ImmutableSortedMultiset.copyOf(rowComparator(precision), testResult.getResults()); try { return control.equals(test); } catch (TypesDoNotMatchException e) { return false; } }
public String getResultsComparison(int precision) { List<List<Object>> controlResults = controlResult.getResults(); List<List<Object>> testResults = testResult.getResults(); if (valid() || (controlResults == null) || (testResults == null)) { return ""; } Multiset<List<Object>> control = ImmutableSortedMultiset.copyOf(rowComparator(precision), controlResults); Multiset<List<Object>> test = ImmutableSortedMultiset.copyOf(rowComparator(precision), testResults); try { Iterable<ChangedRow> diff = ImmutableSortedMultiset.<ChangedRow>naturalOrder() .addAll(Iterables.transform(Multisets.difference(control, test), row -> new ChangedRow(Changed.REMOVED, row, precision))) .addAll(Iterables.transform(Multisets.difference(test, control), row -> new ChangedRow(Changed.ADDED, row, precision))) .build(); diff = Iterables.limit(diff, 100); StringBuilder sb = new StringBuilder(); sb.append(format("Control %s rows, Test %s rows%n", control.size(), test.size())); if (verboseResultsComparison) { Joiner.on("\n").appendTo(sb, diff); } else { sb.append("RESULTS DO NOT MATCH\n"); } return sb.toString(); } catch (TypesDoNotMatchException e) { return e.getMessage(); } }
@Test public void testToImmutableSortedMultiset() throws Exception { ImmutableSortedMultiset<String> multiset = Stream.of("b", "c", "a", "a", "b", "a", "a", "f") .collect(MoreCollectors.toImmutableSortedMultiset()); assertThat(multiset.size()).isEqualTo(8); assertThat(multiset.count("a")).isEqualTo(4); assertThat(multiset.count("b")).isEqualTo(2); assertThat(multiset.elementSet()).containsExactly("a", "b", "c", "f"); }
@Test public void testToImmutableSortedMultisetWithComparator() throws Exception { ImmutableSortedMultiset<String> multiset = Stream.of("b", "c", "a", "a", "b", "a", "a", "f") .collect(MoreCollectors.toImmutableSortedMultiset((a, b) -> b.compareTo(a))); assertThat(multiset.size()).isEqualTo(8); assertThat(multiset.count("a")).isEqualTo(4); assertThat(multiset.count("b")).isEqualTo(2); assertThat(multiset.elementSet()).containsExactly("f", "c", "b", "a"); }
@Value.ReverseOrder ImmutableSortedMultiset<Elem> getElemMultiset();
@Value.ReverseOrder ImmutableSortedMultiset<ImmutableElem> getImmutableElemMultiset();
@Generates private static <E extends Comparable<E>> ImmutableSortedMultiset<E> generateImmutableSortedMultiset(E freshElement) { return ImmutableSortedMultiset.of(freshElement); }
public void testImmutableSortedMultiset() { assertFreshInstance(new TypeToken<ImmutableSortedMultiset<String>>() {}); }
public static <T extends Comparable<T>> Collector<T, ?, ImmutableSortedMultiset<T>> toImmutableSortedMultiset() { return toImmutableSortedMultiset(Comparator.<T>naturalOrder()); }
public static <T> Collector<T, ?, ImmutableSortedMultiset<T>> toImmutableSortedMultiset(Comparator<T> comparator) { return toImmutableMultiset(() -> ImmutableSortedMultiset.orderedBy(comparator), CONCURRENT); }
/** * Construct ImmutableAnnotationList from a {@link Collection} of {@link Annotation} objects. * * Note that <code>variant</code> is converted to the forward strand using {@link GenomeVariant#withStrand}. * * @param variant * {@link GenomeVariant} that this anotation list annotates * @param entries * {@link Collection} of {@link Annotation} objects */ public VariantAnnotations(GenomeVariant variant, Collection<Annotation> entries) { this.change = variant.withStrand(Strand.FWD); this.entries = ImmutableList.copyOf(ImmutableSortedMultiset.copyOf(entries)); }
public static <E> ImmutableSortedMultiset<E> emptySortedMultiset() { return ImmutableSortedMultiset.of(); }
public static <E extends Comparable<? super E>> ImmutableSortedMultiset<E> sortedMultiset(E element) { return ImmutableSortedMultiset.of(element); }
public static <E extends Comparable<? super E>> ImmutableSortedMultiset<E> sortedMultiset(E e1, E e2) { return ImmutableSortedMultiset.of(e1, e2); }
public static <E extends Comparable<? super E>> ImmutableSortedMultiset<E> sortedMultiset(E e1, E e2, E e3) { return ImmutableSortedMultiset.of(e1, e2, e3); }
public static <E extends Comparable<? super E>> ImmutableSortedMultiset<E> sortedMultiset(E e1, E e2, E e3, E e4) { return ImmutableSortedMultiset.of(e1, e2, e3, e4); }
public static <E extends Comparable<? super E>> ImmutableSortedMultiset<E> sortedMultiset(E e1, E e2, E e3, E e4, E e5) { return ImmutableSortedMultiset.of(e1, e2, e3, e4, e5); }
public static <E extends Comparable<? super E>> ImmutableSortedMultiset<E> sortedMultiset(E e1, E e2, E e3, E e4, E e5, E e6, E... others) { return ImmutableSortedMultiset.of(e1, e2, e3, e4, e5, e6, others); }