@GwtIncompatible // suite private static Test testsForFilter() { return CollectionTestSuiteBuilder.using( new TestStringCollectionGenerator() { @Override public Collection<String> create(String[] elements) { List<String> unfiltered = newArrayList(); unfiltered.add("yyy"); Collections.addAll(unfiltered, elements); unfiltered.add("zzz"); return Collections2.filter(unfiltered, NOT_YYY_ZZZ); } }) .named("Collections2.filter") .withFeatures( CollectionFeature.SUPPORTS_ADD, CollectionFeature.SUPPORTS_REMOVE, CollectionFeature.ALLOWS_NULL_VALUES, CollectionFeature.KNOWN_ORDER, CollectionSize.ANY) .createTestSuite(); }
@GwtIncompatible // suite private static Test testsForFilterAll() { return CollectionTestSuiteBuilder.using( new TestStringCollectionGenerator() { @Override public Collection<String> create(String[] elements) { List<String> unfiltered = newArrayList(); Collections.addAll(unfiltered, elements); return Collections2.filter(unfiltered, NOT_YYY_ZZZ); } }) .named("Collections2.filter") .withFeatures( CollectionFeature.SUPPORTS_ADD, CollectionFeature.SUPPORTS_REMOVE, CollectionFeature.ALLOWS_NULL_VALUES, CollectionFeature.KNOWN_ORDER, CollectionSize.ANY) .createTestSuite(); }
@GwtIncompatible // suite private static Test testsForFilterLinkedList() { return CollectionTestSuiteBuilder.using( new TestStringCollectionGenerator() { @Override public Collection<String> create(String[] elements) { List<String> unfiltered = newLinkedList(); unfiltered.add("yyy"); Collections.addAll(unfiltered, elements); unfiltered.add("zzz"); return Collections2.filter(unfiltered, NOT_YYY_ZZZ); } }) .named("Collections2.filter") .withFeatures( CollectionFeature.SUPPORTS_ADD, CollectionFeature.SUPPORTS_REMOVE, CollectionFeature.ALLOWS_NULL_VALUES, CollectionFeature.KNOWN_ORDER, CollectionSize.ANY) .createTestSuite(); }
@GwtIncompatible // suite private static Test testsForFilterNoNulls() { return CollectionTestSuiteBuilder.using( new TestStringCollectionGenerator() { @Override public Collection<String> create(String[] elements) { List<String> unfiltered = newArrayList(); unfiltered.add("yyy"); unfiltered.addAll(ImmutableList.copyOf(elements)); unfiltered.add("zzz"); return Collections2.filter(unfiltered, LENGTH_1); } }) .named("Collections2.filter, no nulls") .withFeatures( CollectionFeature.SUPPORTS_ADD, CollectionFeature.SUPPORTS_REMOVE, CollectionFeature.ALLOWS_NULL_QUERIES, CollectionFeature.KNOWN_ORDER, CollectionSize.ANY) .createTestSuite(); }
@GwtIncompatible // suite private static Test testsForFilterFiltered() { return CollectionTestSuiteBuilder.using( new TestStringCollectionGenerator() { @Override public Collection<String> create(String[] elements) { List<String> unfiltered = newArrayList(); unfiltered.add("yyy"); unfiltered.addAll(ImmutableList.copyOf(elements)); unfiltered.add("zzz"); unfiltered.add("abc"); return Collections2.filter( Collections2.filter(unfiltered, LENGTH_1), NOT_YYY_ZZZ); } }) .named("Collections2.filter, filtered input") .withFeatures( CollectionFeature.SUPPORTS_ADD, CollectionFeature.SUPPORTS_REMOVE, CollectionFeature.KNOWN_ORDER, CollectionFeature.ALLOWS_NULL_QUERIES, CollectionSize.ANY) .createTestSuite(); }
@GwtIncompatible // suite private static Test testsForTransform() { return CollectionTestSuiteBuilder.using( new TestStringCollectionGenerator() { @Override public Collection<String> create(String[] elements) { List<String> list = newArrayList(); for (String element : elements) { list.add((element == null) ? null : "q" + element); } return Collections2.transform(list, REMOVE_FIRST_CHAR); } }) .named("Collections2.transform") .withFeatures( CollectionFeature.REMOVE_OPERATIONS, CollectionFeature.ALLOWS_NULL_VALUES, CollectionFeature.KNOWN_ORDER, CollectionSize.ANY) .createTestSuite(); }
@GwtIncompatible("suite") private static Test testsForFilter() { return CollectionTestSuiteBuilder.using( new TestStringCollectionGenerator() { @Override public Collection<String> create(String[] elements) { List<String> unfiltered = newArrayList(); unfiltered.add("yyy"); Collections.addAll(unfiltered, elements); unfiltered.add("zzz"); return Collections2.filter(unfiltered, NOT_YYY_ZZZ); } }) .named("Collections2.filter") .withFeatures( CollectionFeature.SUPPORTS_ADD, CollectionFeature.SUPPORTS_REMOVE, CollectionFeature.ALLOWS_NULL_VALUES, CollectionFeature.KNOWN_ORDER, CollectionSize.ANY) .createTestSuite(); }
@GwtIncompatible("suite") private static Test testsForFilterAll() { return CollectionTestSuiteBuilder.using( new TestStringCollectionGenerator() { @Override public Collection<String> create(String[] elements) { List<String> unfiltered = newArrayList(); Collections.addAll(unfiltered, elements); return Collections2.filter(unfiltered, NOT_YYY_ZZZ); } }) .named("Collections2.filter") .withFeatures( CollectionFeature.SUPPORTS_ADD, CollectionFeature.SUPPORTS_REMOVE, CollectionFeature.ALLOWS_NULL_VALUES, CollectionFeature.KNOWN_ORDER, CollectionSize.ANY) .createTestSuite(); }
@GwtIncompatible("suite") private static Test testsForFilterLinkedList() { return CollectionTestSuiteBuilder.using( new TestStringCollectionGenerator() { @Override public Collection<String> create(String[] elements) { List<String> unfiltered = newLinkedList(); unfiltered.add("yyy"); Collections.addAll(unfiltered, elements); unfiltered.add("zzz"); return Collections2.filter(unfiltered, NOT_YYY_ZZZ); } }) .named("Collections2.filter") .withFeatures( CollectionFeature.SUPPORTS_ADD, CollectionFeature.SUPPORTS_REMOVE, CollectionFeature.ALLOWS_NULL_VALUES, CollectionFeature.KNOWN_ORDER, CollectionSize.ANY) .createTestSuite(); }
@GwtIncompatible("suite") private static Test testsForFilterNoNulls() { return CollectionTestSuiteBuilder.using( new TestStringCollectionGenerator() { @Override public Collection<String> create(String[] elements) { List<String> unfiltered = newArrayList(); unfiltered.add("yyy"); unfiltered.addAll(ImmutableList.copyOf(elements)); unfiltered.add("zzz"); return Collections2.filter(unfiltered, LENGTH_1); } }) .named("Collections2.filter, no nulls") .withFeatures( CollectionFeature.SUPPORTS_ADD, CollectionFeature.SUPPORTS_REMOVE, CollectionFeature.ALLOWS_NULL_QUERIES, CollectionFeature.KNOWN_ORDER, CollectionSize.ANY) .createTestSuite(); }
@GwtIncompatible("suite") private static Test testsForFilterFiltered() { return CollectionTestSuiteBuilder.using( new TestStringCollectionGenerator() { @Override public Collection<String> create(String[] elements) { List<String> unfiltered = newArrayList(); unfiltered.add("yyy"); unfiltered.addAll(ImmutableList.copyOf(elements)); unfiltered.add("zzz"); unfiltered.add("abc"); return Collections2.filter( Collections2.filter(unfiltered, LENGTH_1), NOT_YYY_ZZZ); } }) .named("Collections2.filter, filtered input") .withFeatures( CollectionFeature.SUPPORTS_ADD, CollectionFeature.SUPPORTS_REMOVE, CollectionFeature.KNOWN_ORDER, CollectionFeature.ALLOWS_NULL_QUERIES, CollectionSize.ANY) .createTestSuite(); }
@GwtIncompatible("suite") private static Test testsForTransform() { return CollectionTestSuiteBuilder.using( new TestStringCollectionGenerator() { @Override public Collection<String> create(String[] elements) { List<String> list = newArrayList(); for (String element : elements) { list.add((element == null) ? null : "q" + element); } return Collections2.transform(list, REMOVE_FIRST_CHAR); } }) .named("Collections2.transform") .withFeatures( CollectionFeature.REMOVE_OPERATIONS, CollectionFeature.ALLOWS_NULL_VALUES, CollectionFeature.KNOWN_ORDER, CollectionSize.ANY) .createTestSuite(); }
@GwtIncompatible // suite private static Test testsForFilterFiltered() { return CollectionTestSuiteBuilder.using( new TestStringCollectionGenerator() { @Override public Collection<String> create(String[] elements) { List<String> unfiltered = newArrayList(); unfiltered.add("yyy"); unfiltered.addAll(ImmutableList.copyOf(elements)); unfiltered.add("zzz"); unfiltered.add("abc"); return Collections2.filter(Collections2.filter(unfiltered, LENGTH_1), NOT_YYY_ZZZ); } }) .named("Collections2.filter, filtered input") .withFeatures( CollectionFeature.SUPPORTS_ADD, CollectionFeature.SUPPORTS_REMOVE, CollectionFeature.KNOWN_ORDER, CollectionFeature.ALLOWS_NULL_QUERIES, CollectionSize.ANY) .createTestSuite(); }