@Test
 public void detectIndexWithSmallList() {
   ArrayList<Integer> list = new ArrayList<Integer>(Interval.toReverseList(1, 5));
   Assert.assertEquals(4, Iterate.detectIndexWith(list, Predicates2.equal(), 1));
   Assert.assertEquals(0, Iterate.detectIndexWith(list, Predicates2.equal(), 5));
   Assert.assertEquals(-1, Iterate.detectIndexWith(list, Predicates2.equal(), 10));
 }
 @Test
 public void detectWith() {
   ImmutableCollection<Integer> integers = this.classUnderTest();
   Assert.assertEquals(
       Integer.valueOf(1), integers.detectWith(Predicates2.equal(), Integer.valueOf(1)));
   Assert.assertNull(
       integers.detectWith(Predicates2.equal(), Integer.valueOf(integers.size() + 1)));
 }
 @Test
 public void detectWithIfNone() {
   ArrayList<Integer> list = this.getIntegerList();
   Assert.assertEquals(
       Integer.valueOf(7), ArrayListIterate.detectWithIfNone(list, Predicates2.equal(), 6, 7));
   Assert.assertEquals(
       Integer.valueOf(2), ArrayListIterate.detectWithIfNone(list, Predicates2.equal(), 2, 7));
 }
 @Test
 public void detectWithIfNone() {
   ImmutableCollection<Integer> integers = this.classUnderTest();
   Integer sum = Integer.valueOf(integers.size() + 1);
   Function0<Integer> function = new PassThruFunction0<Integer>(sum);
   Assert.assertEquals(
       Integer.valueOf(1),
       integers.detectWithIfNone(Predicates2.equal(), Integer.valueOf(1), function));
   Assert.assertEquals(sum, integers.detectWithIfNone(Predicates2.equal(), sum, function));
 }
 @Test
 public void detectWith() {
   ArrayList<Integer> list = this.getIntegerList();
   Assert.assertEquals(
       Integer.valueOf(1), ArrayListIterate.detectWith(list, Predicates2.equal(), 1));
   //noinspection CachedNumberConstructorCall,UnnecessaryBoxing
   ArrayList<Integer> list2 =
       this.newArrayList(1, new Integer(2), 2); // test relies on having a unique instance of "2"
   Assert.assertSame(list2.get(1), ArrayListIterate.detectWith(list2, Predicates2.equal(), 2));
 }
 @Test
 public void selectAndRejectWith() {
   Twin<MutableList<String>> twin =
       this.unmodifiableCollection.selectAndRejectWith(Predicates2.equal(), METALLICA);
   Verify.assertSize(1, twin.getOne());
   Verify.assertSize(3, twin.getTwo());
 }
 @Test
 public void testRejectWith() {
   Verify.assertSize(
       3,
       this.unmodifiableStackString.rejectWith(
           Predicates2.equal(), 3, FastList.<String>newList()));
 }
 @Test
 public void testSelectWith() {
   Verify.assertSize(
       1,
       this.unmodifiableStackString.selectWith(
           Predicates2.equal(), "2", FastList.<String>newList()));
 }
  @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 noneSatisfyWith() {
   ImmutableCollection<Integer> integers = this.classUnderTest();
   Assert.assertTrue(integers.noneSatisfyWith(Predicates2.instanceOf(), String.class));
   Assert.assertFalse(integers.noneSatisfyWith(Predicates2.equal(), 1));
 }
 @Test
 public void detectWithIfNoneOver100() {
   ArrayList<Integer> list = new ArrayList<Integer>(Interval.oneTo(101));
   Assert.assertNull(ArrayListIterate.detectWithIfNone(list, Predicates2.equal(), 102, null));
 }
 @Test
 public void detectWithOver100() {
   ArrayList<Integer> list = new ArrayList<Integer>(Interval.oneTo(101));
   Assert.assertEquals(
       Integer.valueOf(1), ArrayListIterate.detectWith(list, Predicates2.equal(), 1));
 }