@Override
 @Test
 public void toSortedMap() {
   MutableSortedMap<String, String> map =
       this.newBag().toSortedMap(Functions.getStringPassThru(), Functions.getStringPassThru());
   Verify.assertEmpty(map);
   Verify.assertInstanceOf(TreeSortedMap.class, map);
 }
 @Test
 public void collect_target() {
   ImmutableBag<String> strings = this.newBag();
   HashBag<String> target = HashBag.<String>newBag();
   HashBag<String> actual = strings.collect(Functions.getStringPassThru(), target);
   Assert.assertEquals(strings, actual);
   Assert.assertSame(target, actual);
   Assert.assertEquals(
       strings,
       strings.collect(Functions.getStringPassThru(), FastList.<String>newList()).toBag());
 }
 @Override
 @Test
 public void toSortedMap_with_comparator() {
   MutableSortedMap<String, String> map =
       this.newBag()
           .toSortedMap(
               Comparators.<String>reverseNaturalOrder(),
               Functions.getStringPassThru(),
               Functions.getStringPassThru());
   Verify.assertEmpty(map);
   Verify.assertInstanceOf(TreeSortedMap.class, map);
   Assert.assertEquals(Comparators.<String>reverseNaturalOrder(), map.comparator());
 }
 @Test
 public void collectIfWithTarget() {
   ImmutableBag<String> strings = this.newBag();
   Assert.assertEquals(
       strings,
       strings.collectIf(
           String.class::isInstance, Functions.getStringPassThru(), HashBag.<String>newBag()));
 }
  @Test
  public void delegatingMethods() {
    Assert.assertEquals(this.mutableCollection.notEmpty(), this.unmodifiableCollection.notEmpty());
    Assert.assertEquals(this.mutableCollection.isEmpty(), this.unmodifiableCollection.isEmpty());
    Assert.assertEquals(this.mutableCollection.size(), this.unmodifiableCollection.size());
    Assert.assertEquals(this.mutableCollection.getFirst(), this.unmodifiableCollection.getFirst());
    Assert.assertEquals(this.mutableCollection.getLast(), this.unmodifiableCollection.getLast());
    Assert.assertEquals(
        this.mutableCollection.count(Predicates.alwaysTrue()),
        this.unmodifiableCollection.count(Predicates.alwaysTrue()));
    Verify.assertSize(4, this.unmodifiableCollection.select(Predicates.alwaysTrue()));
    Verify.assertSize(
        4, this.unmodifiableCollection.select(Predicates.alwaysTrue(), FastList.<String>newList()));
    Verify.assertSize(1, this.unmodifiableCollection.selectWith(Predicates2.equal(), METALLICA));
    Verify.assertSize(
        1,
        this.unmodifiableCollection.selectWith(
            Predicates2.equal(), METALLICA, FastList.<String>newList()));
    Verify.assertSize(2, this.unmodifiableCollection.reject(StringPredicates.contains("p")));
    Verify.assertSize(
        2,
        this.unmodifiableCollection.reject(
            StringPredicates.contains("p"), FastList.<String>newList()));
    Verify.assertSize(3, this.unmodifiableCollection.rejectWith(Predicates2.equal(), METALLICA));
    Verify.assertSize(
        3,
        this.unmodifiableCollection.rejectWith(
            Predicates2.equal(), METALLICA, FastList.<String>newList()));
    Verify.assertSize(4, this.unmodifiableCollection.collect(Functions.getStringPassThru()));
    Verify.assertSize(
        4,
        this.unmodifiableCollection.collect(
            Functions.getStringPassThru(), FastList.<String>newList()));

    Function<String, Collection<String>> flattenFunction =
        new Function<String, Collection<String>>() {
          public Collection<String> valueOf(String object) {
            return FastList.newListWith(object, object);
          }
        };
    Verify.assertSize(8, this.unmodifiableCollection.flatCollect(flattenFunction));
    Verify.assertSize(
        8, this.unmodifiableCollection.flatCollect(flattenFunction, FastList.<String>newList()));

    Verify.assertSize(
        4,
        this.unmodifiableCollection.collectIf(
            Predicates.alwaysTrue(), Functions.getStringPassThru()));
    Verify.assertSize(
        4,
        this.unmodifiableCollection.collectIf(
            Predicates.alwaysTrue(), Functions.getStringPassThru(), FastList.<String>newList()));
    Assert.assertEquals(
        METALLICA, this.unmodifiableCollection.detect(StringPredicates.contains("allic")));
    Assert.assertEquals(
        "Not found",
        this.unmodifiableCollection.detectIfNone(
            StringPredicates.contains("donna"), new PassThruFunction0<String>("Not found")));
    Assert.assertEquals(
        METALLICA, this.unmodifiableCollection.detectWith(Predicates2.equal(), METALLICA));
    Assert.assertEquals(
        "Not found",
        this.unmodifiableCollection.detectWithIfNone(
            Predicates2.equal(), "Madonna", new PassThruFunction0<String>("Not found")));
    Assert.assertEquals(4, this.unmodifiableCollection.count(Predicates.alwaysTrue()));
    Assert.assertEquals(1, this.unmodifiableCollection.countWith(Predicates2.equal(), METALLICA));
    Assert.assertTrue(this.unmodifiableCollection.anySatisfy(StringPredicates.contains("allic")));
    Assert.assertTrue(this.unmodifiableCollection.anySatisfyWith(Predicates2.equal(), METALLICA));
    Assert.assertTrue(this.unmodifiableCollection.allSatisfy(Predicates.notNull()));
    Assert.assertTrue(this.unmodifiableCollection.allSatisfyWith(Predicates2.alwaysTrue(), ""));
    Assert.assertEquals(this.mutableCollection, this.unmodifiableCollection.toList());
    Verify.assertListsEqual(
        Lists.mutable.of("Bon Jovi", "Europe", METALLICA, "Scorpions"),
        this.unmodifiableCollection.toSortedList());
    Verify.assertListsEqual(
        Lists.mutable.of("Scorpions", METALLICA, "Europe", "Bon Jovi"),
        this.unmodifiableCollection.toSortedList(Collections.reverseOrder()));
    Verify.assertSize(4, this.unmodifiableCollection.toSet());
    Verify.assertSize(
        4,
        this.unmodifiableCollection.toMap(
            Functions.getStringPassThru(), Functions.getStringPassThru()));
  }
 @Test
 public void collect() {
   Assert.assertEquals(this.newBag(), this.newBag().collect(Functions.getStringPassThru()));
 }
 @Test(expected = NoSuchElementException.class)
 public void minBy() {
   this.classUnderTest().minBy(Functions.getStringPassThru());
 }