import "copyrightAndOthers.stg"
import "primitiveEquals.stg"
import "primitiveHashCode.stg"
import "primitiveLiteral.stg"

skipBoolean() ::= "true"

hasTwoPrimitives() ::= "true"

isTest() ::= "true"

targetPath() ::= "org/eclipse/collections/impl/map/primitive"

fileName(primitive1, primitive2, sameTwoPrimitives) ::= "Abstract<primitive1.name><primitive2.name>MapKeyValuesViewTestCase"

class(primitive1, primitive2, sameTwoPrimitives) ::= <<
<body(primitive1.type, primitive2.type, primitive1.name, primitive2.name, primitive1.wrapperName, primitive2.wrapperName)>
>>

body(type1, type2, name1, name2, wrapper1, wrapper2) ::= <<
<copyrightAndOthers()>

package org.eclipse.collections.impl.map.primitive;

import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.concurrent.atomic.AtomicInteger;

import org.eclipse.collections.api.BooleanIterable;
import org.eclipse.collections.api.ByteIterable;
import org.eclipse.collections.api.CharIterable;
import org.eclipse.collections.api.DoubleIterable;
import org.eclipse.collections.api.FloatIterable;
import org.eclipse.collections.api.IntIterable;
import org.eclipse.collections.api.LongIterable;
import org.eclipse.collections.api.RichIterable;
import org.eclipse.collections.api.ShortIterable;
import org.eclipse.collections.api.bag.MutableBag;
import org.eclipse.collections.api.block.function.Function;
import org.eclipse.collections.api.block.function.Function0;
import org.eclipse.collections.api.block.function.Function2;
import org.eclipse.collections.api.block.procedure.Procedure2;
import org.eclipse.collections.api.list.MutableList;
import org.eclipse.collections.api.bag.sorted.MutableSortedBag;
import org.eclipse.collections.impl.bag.sorted.mutable.TreeBag;
import org.eclipse.collections.api.map.MapIterable;
import org.eclipse.collections.api.map.MutableMap;
import org.eclipse.collections.api.map.primitive.<name1><name2>Map;
import org.eclipse.collections.api.map.sorted.MutableSortedMap;
import org.eclipse.collections.api.multimap.Multimap;
import org.eclipse.collections.api.partition.PartitionIterable;
import org.eclipse.collections.api.set.MutableSet;
import org.eclipse.collections.api.set.sorted.MutableSortedSet;
import org.eclipse.collections.api.tuple.Pair;
import org.eclipse.collections.api.tuple.primitive.<name1><name2>Pair;
import org.eclipse.collections.impl.bag.mutable.HashBag;
import org.eclipse.collections.impl.bag.mutable.primitive.BooleanHashBag;
import org.eclipse.collections.impl.bag.mutable.primitive.ByteHashBag;
import org.eclipse.collections.impl.bag.mutable.primitive.CharHashBag;
import org.eclipse.collections.impl.bag.mutable.primitive.DoubleHashBag;
import org.eclipse.collections.impl.bag.mutable.primitive.FloatHashBag;
import org.eclipse.collections.impl.bag.mutable.primitive.IntHashBag;
import org.eclipse.collections.impl.bag.mutable.primitive.LongHashBag;
import org.eclipse.collections.impl.bag.mutable.primitive.ShortHashBag;
import org.eclipse.collections.impl.block.factory.Comparators;
import org.eclipse.collections.impl.block.factory.Functions0;
import org.eclipse.collections.impl.block.factory.Predicates;
import org.eclipse.collections.impl.block.factory.Predicates2;
import org.eclipse.collections.impl.block.procedure.CollectionAddProcedure;
import org.eclipse.collections.impl.factory.Bags;
import org.eclipse.collections.impl.factory.Lists;
import org.eclipse.collections.impl.list.Interval;
import org.eclipse.collections.impl.list.mutable.FastList;
import org.eclipse.collections.impl.map.mutable.UnifiedMap;
import org.eclipse.collections.impl.map.sorted.mutable.TreeSortedMap;
import org.eclipse.collections.impl.set.mutable.UnifiedSet;
import org.eclipse.collections.impl.set.sorted.mutable.TreeSortedSet;
import org.eclipse.collections.impl.test.Verify;
import org.eclipse.collections.impl.tuple.Tuples;
import org.eclipse.collections.impl.tuple.primitive.PrimitiveTuples;
import org.junit.Assert;
import org.junit.Test;

/**
 * Abstract JUnit test for {@link <name1><name2>Map#keyValuesView()}.
 * This file was automatically generated from template file abstractPrimitivePrimitiveMapKeyValuesViewTestCase.stg.
 */
public abstract class Abstract<name1><name2>MapKeyValuesViewTestCase
{
    public abstract <name1><name2>Map newWithKeysValues(<type1> key1, <type2> value1, <type1> key2, <type2> value2, <type1> key3, <type2> value3);

    public abstract <name1><name2>Map newWithKeysValues(<type1> key1, <type2> value1, <type1> key2, <type2> value2);

    public abstract <name1><name2>Map newWithKeysValues(<type1> key1, <type2> value1);

    public abstract <name1><name2>Map newEmpty();

    public RichIterable\<<name1><name2>Pair> newWith()
    {
        return this.newEmpty().keyValuesView();
    }

    public RichIterable\<<name1><name2>Pair> newWith(<type1> key1, <type2> value1)
    {
        return this.newWithKeysValues(key1, value1).keyValuesView();
    }

    public RichIterable\<<name1><name2>Pair> newWith(<type1> key1, <type2> value1, <type1> key2, <type2> value2)
    {
        return this.newWithKeysValues(key1, value1, key2, value2).keyValuesView();
    }

    public RichIterable\<<name1><name2>Pair> newWith(<type1> key1, <type2> value1, <type1> key2, <type2> value2, <type1> key3, <type2> value3)
    {
        return this.newWithKeysValues(key1, value1, key2, value2, key3, value3).keyValuesView();
    }

    @Test
    public void containsAllIterable()
    {
        RichIterable\<<name1><name2>Pair> collection = this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>);
        Assert.assertTrue(collection.containsAllIterable(FastList.newListWith(PrimitiveTuples.pair(<(literal.(type1))("1")>, <(literal.(type2))("2")>), PrimitiveTuples.pair(<(literal.(type1))("2")>, <(literal.(type2))("3")>))));
        Assert.assertFalse(collection.containsAllIterable(FastList.newListWith(PrimitiveTuples.pair(<(literal.(type1))("1")>, <(literal.(type2))("2")>), PrimitiveTuples.pair(<(literal.(type1))("1")>, <(literal.(type2))("5")>))));
    }

    @Test
    public void containsAllArray()
    {
        RichIterable\<<name1><name2>Pair> collection = this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>);
        Assert.assertTrue(collection.containsAllArguments(PrimitiveTuples.pair(<(literal.(type1))("1")>, <(literal.(type2))("2")>), PrimitiveTuples.pair(<(literal.(type1))("2")>, <(literal.(type2))("3")>)));
        Assert.assertFalse(collection.containsAllArguments(PrimitiveTuples.pair(<(literal.(type1))("1")>, <(literal.(type2))("2")>), PrimitiveTuples.pair(<(literal.(type1))("1")>, <(literal.(type2))("5")>)));
    }

    @Test
    public void forEach()
    {
        MutableList\<<name1><name2>Pair> result = Lists.mutable.of();
        RichIterable\<<name1><name2>Pair> collection = this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>);
        collection.forEach(CollectionAddProcedure.on(result));
        Verify.assertSize(3, result);
        Verify.assertContainsAll(result, PrimitiveTuples.pair(<(literal.(type1))("1")>, <(literal.(type2))("2")>), PrimitiveTuples.pair(<(literal.(type1))("2")>, <(literal.(type2))("3")>), PrimitiveTuples.pair(<(literal.(type1))("3")>, <(literal.(type2))("4")>));

        MutableList\<<name1><name2>Pair> result2 = Lists.mutable.of();
        RichIterable\<<name1><name2>Pair> collection2 = this.newWith(<(literal.(type1))("0")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>);
        collection2.forEach(CollectionAddProcedure.on(result2));
        Verify.assertSize(3, result2);
        Verify.assertContainsAll(result2, PrimitiveTuples.pair(<(literal.(type1))("0")>, <(literal.(type2))("2")>), PrimitiveTuples.pair(<(literal.(type1))("2")>, <(literal.(type2))("3")>), PrimitiveTuples.pair(<(literal.(type1))("3")>, <(literal.(type2))("4")>));
    }

    @Test
    public void forEachWith()
    {
        MutableBag\<<name1><name2>Pair> result = Bags.mutable.of();
        MutableBag\<Integer> result2 = Bags.mutable.of();
        RichIterable\<<name1><name2>Pair> collection = this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("0")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>);
        collection.forEachWith((<name1><name2>Pair argument1, Integer argument2) ->
        {
            result.add(argument1);
            result2.add(argument2);
        }, 0);

        Assert.assertEquals(Bags.immutable.of(PrimitiveTuples.pair(<(literal.(type1))("1")>, <(literal.(type2))("0")>), PrimitiveTuples.pair(<(literal.(type1))("2")>, <(literal.(type2))("3")>), PrimitiveTuples.pair(<(literal.(type1))("3")>, <(literal.(type2))("4")>)), result);
        Assert.assertEquals(Bags.immutable.of(0, 0, 0), result2);

        MutableBag\<<name1><name2>Pair> result3 = Bags.mutable.of();
        MutableBag\<Integer> result4 = Bags.mutable.of();
        RichIterable\<<name1><name2>Pair> collection2 = this.newWith(<(literal.(type1))("2")>, <(literal.(type2))("5")>, <(literal.(type1))("6")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>);
        collection2.forEachWith((<name1><name2>Pair argument1, Integer argument2) ->
        {
            result3.add(argument1);
            result4.add(argument2);
        }, 0);

        Assert.assertEquals(Bags.immutable.of(PrimitiveTuples.pair(<(literal.(type1))("2")>, <(literal.(type2))("5")>), PrimitiveTuples.pair(<(literal.(type1))("6")>, <(literal.(type2))("3")>), PrimitiveTuples.pair(<(literal.(type1))("3")>, <(literal.(type2))("4")>)), result3);
        Assert.assertEquals(Bags.immutable.of(0, 0, 0), result4);
    }

    @Test
    public void forEachWithIndex()
    {
        MutableBag\<<name1><name2>Pair> elements = Bags.mutable.of();
        MutableBag\<Integer> indexes = Bags.mutable.of();
        RichIterable\<<name1><name2>Pair> collection = this.newWith(<(literal.(type1))("2")>, <(literal.(type2))("2")>, <(literal.(type1))("6")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>);
        collection.forEachWithIndex((<name1><name2>Pair object, int index) ->
        {
            elements.add(object);
            indexes.add(index);
        });
        Assert.assertEquals(Bags.mutable.of(PrimitiveTuples.pair(<(literal.(type1))("2")>, <(literal.(type2))("2")>), PrimitiveTuples.pair(<(literal.(type1))("6")>, <(literal.(type2))("3")>), PrimitiveTuples.pair(<(literal.(type1))("3")>, <(literal.(type2))("4")>)), elements);
        Assert.assertEquals(Bags.mutable.of(0, 1, 2), indexes);

        MutableBag\<<name1><name2>Pair> elements2 = Bags.mutable.of();
        MutableBag\<Integer> indexes2 = Bags.mutable.of();
        RichIterable\<<name1><name2>Pair> collection2 = this.newWith(<(literal.(type1))("0")>, <(literal.(type2))("1")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>);
        collection2.forEachWithIndex((<name1><name2>Pair object, int index) ->
        {
            elements2.add(object);
            indexes2.add(index);
        });
        Assert.assertEquals(Bags.mutable.of(PrimitiveTuples.pair(<(literal.(type1))("0")>, <(literal.(type2))("1")>), PrimitiveTuples.pair(<(literal.(type1))("2")>, <(literal.(type2))("3")>), PrimitiveTuples.pair(<(literal.(type1))("3")>, <(literal.(type2))("4")>)), elements2);
        Assert.assertEquals(Bags.mutable.of(0, 1, 2), indexes2);
    }

    @Test
    public void select()
    {
        MutableList\<<name1><name2>Pair> result = this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>).select(PrimitiveTuples.pair(<(literal.(type1))("2")>, <(literal.(type2))("3")>)::equals).toList();
        Verify.assertContains(PrimitiveTuples.pair(<(literal.(type1))("2")>, <(literal.(type2))("3")>), result);
        Verify.assertNotContains(PrimitiveTuples.pair(<(literal.(type1))("1")>, <(literal.(type2))("2")>), result);
        Verify.assertNotContains(PrimitiveTuples.pair(<(literal.(type1))("3")>, <(literal.(type2))("4")>), result);
    }

    @Test
    public void selectWith()
    {
        MutableList\<<name1><name2>Pair> result = this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>).selectWith(Object::equals, PrimitiveTuples.pair(<(literal.(type1))("2")>, <(literal.(type2))("3")>)).toList();
        Verify.assertContains(PrimitiveTuples.pair(<(literal.(type1))("2")>, <(literal.(type2))("3")>), result);
        Verify.assertNotContains(PrimitiveTuples.pair(<(literal.(type1))("1")>, <(literal.(type2))("2")>), result);
        Verify.assertNotContains(PrimitiveTuples.pair(<(literal.(type1))("3")>, <(literal.(type2))("4")>), result);
    }

    @Test
    public void selectWith_target()
    {
        HashBag\<<name1><name2>Pair> result = this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>).selectWith(Predicates2.notEqual(), PrimitiveTuples.pair(<(literal.(type1))("2")>, <(literal.(type2))("3")>), HashBag.\<<name1><name2>Pair>newBag());
        Assert.assertEquals(Bags.immutable.of(PrimitiveTuples.pair(<(literal.(type1))("1")>, <(literal.(type2))("2")>), PrimitiveTuples.pair(<(literal.(type1))("3")>, <(literal.(type2))("4")>)), result);
    }

    @Test
    public void reject()
    {
        MutableList\<<name1><name2>Pair> result = this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>).reject(Predicates.notEqual(PrimitiveTuples.pair(<(literal.(type1))("2")>, <(literal.(type2))("3")>))).toList();
        Verify.assertContains(PrimitiveTuples.pair(<(literal.(type1))("2")>, <(literal.(type2))("3")>), result);
        Verify.assertNotContains(PrimitiveTuples.pair(<(literal.(type1))("1")>, <(literal.(type2))("2")>), result);
        Verify.assertNotContains(PrimitiveTuples.pair(<(literal.(type1))("3")>, <(literal.(type2))("4")>), result);
    }

    @Test
    public void rejectWith()
    {
        MutableList\<<name1><name2>Pair> result = this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>).rejectWith(Predicates2.notEqual(), PrimitiveTuples.pair(<(literal.(type1))("2")>, <(literal.(type2))("3")>)).toList();
        Verify.assertContains(PrimitiveTuples.pair(<(literal.(type1))("2")>, <(literal.(type2))("3")>), result);
        Verify.assertNotContains(PrimitiveTuples.pair(<(literal.(type1))("1")>, <(literal.(type2))("2")>), result);
        Verify.assertNotContains(PrimitiveTuples.pair(<(literal.(type1))("3")>, <(literal.(type2))("4")>), result);
    }

    @Test
    public void rejectWith_target()
    {
        HashBag\<<name1><name2>Pair> result = this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>).rejectWith(Object::equals, PrimitiveTuples.pair(<(literal.(type1))("2")>, <(literal.(type2))("3")>), HashBag.\<<name1><name2>Pair>newBag());
        Assert.assertEquals(Bags.immutable.of(PrimitiveTuples.pair(<(literal.(type1))("1")>, <(literal.(type2))("2")>), PrimitiveTuples.pair(<(literal.(type1))("3")>, <(literal.(type2))("4")>)), result);
    }

    @Test
    public void selectInstancesOf()
    {
        RichIterable\<<name1><name2>Pair> pairs = this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>);
        Verify.assertIterableEmpty(pairs.selectInstancesOf(Integer.class));
        Verify.assertContainsAll(pairs.selectInstancesOf(<name1><name2>Pair.class), PrimitiveTuples.pair(<(literal.(type1))("1")>, <(literal.(type2))("2")>), PrimitiveTuples.pair(<(literal.(type1))("3")>, <(literal.(type2))("4")>), PrimitiveTuples.pair(<(literal.(type1))("2")>, <(literal.(type2))("3")>));
    }

    @Test
    public void collect()
    {
        RichIterable\<Integer> result1 =
                this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>).collect((<name1><name2>Pair object) -> (int) object.getOne());
        Assert.assertEquals(Bags.immutable.of(1, 2, 3), result1.toBag());
        RichIterable\<Long> result2 =
                this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>).collect((<name1><name2>Pair object) -> (long) object.getTwo());
        Assert.assertEquals(Bags.immutable.of(2L, 3L, 4L), result2.toBag());
    }

    @Test
    public void collectBoolean()
    {
        BooleanIterable result = this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>).collectBoolean((<name1><name2>Pair each) -> (each.getOne() % 2) == 0);
        Assert.assertEquals(BooleanHashBag.newBagWith(true, false, false), result.toBag());
    }

    @Test
    public void collectByte()
    {
        ByteIterable result = this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>).collectByte((<name1><name2>Pair anObject) -> (byte) anObject.getOne());
        Assert.assertEquals(ByteHashBag.newBagWith((byte) 1, (byte) 2, (byte) 3), result.toBag());
    }

    @Test
    public void collectChar()
    {
        CharIterable result = this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>).collectChar((<name1><name2>Pair anObject) -> (char) anObject.getOne());
        Assert.assertEquals(CharHashBag.newBagWith((char) 1, (char) 2, (char) 3), result.toBag());
    }

    @Test
    public void collectDouble()
    {
        DoubleIterable result = this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>).collectDouble((<name1><name2>Pair anObject) -> (double) anObject.getOne());
        Assert.assertEquals(DoubleHashBag.newBagWith(1.0, 2.0, 3.0), result.toBag());
    }

    @Test
    public void collectFloat()
    {
        FloatIterable result = this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>).collectFloat((<name1><name2>Pair anObject) -> (float) anObject.getOne());
        Assert.assertEquals(FloatHashBag.newBagWith(1.0f, 2.0f, 3.0f), result.toBag());
    }

    @Test
    public void collectInt()
    {
        IntIterable result = this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>).collectInt((<name1><name2>Pair anObject) -> (int) anObject.getOne());
        Assert.assertEquals(IntHashBag.newBagWith(1, 2, 3), result.toBag());
    }

    @Test
    public void collectLong()
    {
        LongIterable result = this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>).collectLong((<name1><name2>Pair anObject) -> (long) anObject.getOne());
        Assert.assertEquals(LongHashBag.newBagWith(1L, 2L, 3L), result.toBag());
    }

    @Test
    public void collectShort()
    {
        ShortIterable result = this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>).collectShort((<name1><name2>Pair anObject) -> (short) anObject.getOne());
        Assert.assertEquals(ShortHashBag.newBagWith((short) 1, (short) 2, (short) 3), result.toBag());
    }

    @Test
    public void flatCollect()
    {
        RichIterable\<<name1><name2>Pair> collection = this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>);
        Function\<<name1><name2>Pair, MutableList\<String>\> function = (<name1><name2>Pair object) -> FastList.newListWith(String.valueOf(object));

        Verify.assertListsEqual(
                FastList.newListWith("<(toStringLiteral.(type1))("1")>:<(toStringLiteral.(type2))("2")>", "<(toStringLiteral.(type1))("2")>:<(toStringLiteral.(type2))("3")>", "<(toStringLiteral.(type1))("3")>:<(toStringLiteral.(type2))("4")>"),
                collection.flatCollect(function).toSortedList());

        Verify.assertSetsEqual(
                UnifiedSet.newSetWith("<(toStringLiteral.(type1))("1")>:<(toStringLiteral.(type2))("2")>", "<(toStringLiteral.(type1))("2")>:<(toStringLiteral.(type2))("3")>", "<(toStringLiteral.(type1))("3")>:<(toStringLiteral.(type2))("4")>"),
                collection.flatCollect(function, UnifiedSet.\<String>newSet()));
    }

    @Test
    public void detect()
    {
        Assert.assertEquals(PrimitiveTuples.pair(<(literal.(type1))("2")>, <(literal.(type2))("3")>), this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>).detect(PrimitiveTuples.pair(<(literal.(type1))("2")>, <(literal.(type2))("3")>)::equals));
        Assert.assertNull(this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>).detect(PrimitiveTuples.pair(<(literal.(type1))("2")>, <(literal.(type2))("4")>)::equals));
    }

    @Test(expected = NoSuchElementException.class)
    public void min_empty_throws()
    {
        this.newWith().min(Comparators.naturalOrder());
    }

    @Test(expected = NoSuchElementException.class)
    public void max_empty_throws()
    {
        this.newWith().max(Comparators.naturalOrder());
    }

    @Test
    public void min()
    {
        Assert.assertEquals(PrimitiveTuples.pair(<(literal.(type1))("1")>, <(literal.(type2))("2")>), this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>).min(Comparators.naturalOrder()));
    }

    @Test
    public void max()
    {
        Assert.assertEquals(PrimitiveTuples.pair(<(literal.(type1))("3")>, <(literal.(type2))("4")>), this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>).max(Comparators.naturalOrder()));
    }

    @Test
    public void min_without_comparator()
    {
        Assert.assertEquals(PrimitiveTuples.pair(<(literal.(type1))("1")>, <(literal.(type2))("2")>), this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>).min(Comparators.naturalOrder()));
    }

    @Test
    public void max_without_comparator()
    {
        Assert.assertEquals(PrimitiveTuples.pair(<(literal.(type1))("3")>, <(literal.(type2))("4")>), this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>).max(Comparators.naturalOrder()));
    }

    @Test
    public void minBy()
    {
        Assert.assertEquals(PrimitiveTuples.pair(<(literal.(type1))("2")>, <(literal.(type2))("3")>), this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>).minBy((<name1><name2>Pair object) -> (int) object.getOne() & 1));
    }

    @Test
    public void maxBy()
    {
        Assert.assertEquals(PrimitiveTuples.pair(<(literal.(type1))("1")>, <(literal.(type2))("2")>), this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("4")>, <(literal.(type2))("5")>).maxBy((<name1><name2>Pair object) -> (int) object.getOne() & 1));
    }

    @Test
    public void detectWith()
    {
        Assert.assertEquals(PrimitiveTuples.pair(<(literal.(type1))("2")>, <(literal.(type2))("3")>), this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>).detectWith(Object::equals, PrimitiveTuples.pair(<(literal.(type1))("2")>, <(literal.(type2))("3")>)));
        Assert.assertNull(this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>).detectWith(Object::equals, PrimitiveTuples.pair(2, 4L)));
    }

    @Test
    public void detectIfNone()
    {
        Function0\<<name1><name2>Pair> function = Functions0.value(PrimitiveTuples.pair(<(literal.(type1))("5")>, <(literal.(type2))("6")>));
        Assert.assertEquals(PrimitiveTuples.pair(<(literal.(type1))("2")>, <(literal.(type2))("3")>), this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>).detectIfNone(PrimitiveTuples.pair(<(literal.(type1))("2")>, <(literal.(type2))("3")>)::equals, function));
        Assert.assertEquals(PrimitiveTuples.pair(<(literal.(type1))("5")>, <(literal.(type2))("6")>), this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>).detectIfNone(PrimitiveTuples.pair(2, 4L)::equals, function));
    }

    @Test
    public void detectWithIfNoneBlock()
    {
        Function0\<<name1><name2>Pair> function = Functions0.value(PrimitiveTuples.pair(<(literal.(type1))("5")>, <(literal.(type2))("6")>));
        Assert.assertEquals(
                PrimitiveTuples.pair(<(literal.(type1))("2")>, <(literal.(type2))("3")>),
                this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>).detectWithIfNone(
                        Object::equals,
                        PrimitiveTuples.pair(<(literal.(type1))("2")>, <(literal.(type2))("3")>),
                        function));
        Assert.assertEquals(
                PrimitiveTuples.pair(<(literal.(type1))("5")>, <(literal.(type2))("6")>),
                this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>).detectWithIfNone(
                        Object::equals,
                        PrimitiveTuples.pair(2, 4L),
                        function));
    }

    @Test
    public void allSatisfy()
    {
        Assert.assertTrue(this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>).allSatisfy(<name1><name2>Pair.class::isInstance));
        Assert.assertFalse(this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>).allSatisfy(PrimitiveTuples.pair(<(literal.(type1))("2")>, <(literal.(type2))("3")>)::equals));
    }

    @Test
    public void allSatisfyWith()
    {
        Assert.assertTrue(this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>).allSatisfyWith(Predicates2.instanceOf(), <name1><name2>Pair.class));
        Assert.assertFalse(this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>).allSatisfyWith(Object::equals, PrimitiveTuples.pair(<(literal.(type1))("2")>, <(literal.(type2))("3")>)));
    }

    @Test
    public void noneSatisfy()
    {
        Assert.assertTrue(this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>).noneSatisfy(Boolean.class::isInstance));
        Assert.assertFalse(this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>).noneSatisfy(PrimitiveTuples.pair(<(literal.(type1))("2")>, <(literal.(type2))("3")>)::equals));
    }

    @Test
    public void noneSatisfyWith()
    {
        Assert.assertTrue(this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>).noneSatisfyWith(Predicates2.instanceOf(), Boolean.class));
        Assert.assertFalse(this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>).noneSatisfyWith(Object::equals, PrimitiveTuples.pair(<(literal.(type1))("2")>, <(literal.(type2))("3")>)));
    }

    @Test
    public void anySatisfy()
    {
        Assert.assertTrue(this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>).anySatisfy(PrimitiveTuples.pair(<(literal.(type1))("2")>, <(literal.(type2))("3")>)::equals));
        Assert.assertFalse(this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>).anySatisfy(PrimitiveTuples.pair(<(literal.(type1))("2")>, <(literal.(type2))("5")>)::equals));
    }

    @Test
    public void anySatisfyWith()
    {
        Assert.assertTrue(this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>).anySatisfyWith(Object::equals, PrimitiveTuples.pair(<(literal.(type1))("2")>, <(literal.(type2))("3")>)));
        Assert.assertFalse(this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>).anySatisfyWith(Object::equals, PrimitiveTuples.pair(<(literal.(type1))("2")>, <(literal.(type2))("5")>)));
    }

    @Test
    public void count()
    {
        Assert.assertEquals(0, this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>).count(Boolean.class::isInstance));
        Assert.assertEquals(3, this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>).count(<name1><name2>Pair.class::isInstance));
        Assert.assertEquals(1, this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>).count(PrimitiveTuples.pair(<(literal.(type1))("2")>, <(literal.(type2))("3")>)::equals));
    }

    @Test
    public void countWith()
    {
        Assert.assertEquals(0, this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>).countWith(Predicates2.instanceOf(), Boolean.class));
        Assert.assertEquals(3, this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>).countWith(Predicates2.instanceOf(), <name1><name2>Pair.class));
        Assert.assertEquals(1, this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>).countWith(Object::equals, PrimitiveTuples.pair(<(literal.(type1))("2")>, <(literal.(type2))("3")>)));
    }

    @Test
    public void collectIf()
    {
        Verify.assertContainsAll(
                this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>).collectIf(
                        <name1><name2>Pair.class::isInstance,
                        String::valueOf),
                "<(toStringLiteral.(type1))("1")>:<(toStringLiteral.(type2))("2")>", "<(toStringLiteral.(type1))("2")>:<(toStringLiteral.(type2))("3")>", "<(toStringLiteral.(type1))("3")>:<(toStringLiteral.(type2))("4")>");
        Verify.assertContainsAll(
                this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>).collectIf(
                        <name1><name2>Pair.class::isInstance,
                        String::valueOf,
                        UnifiedSet.\<String>newSet()),
                "<(toStringLiteral.(type1))("1")>:<(toStringLiteral.(type2))("2")>", "<(toStringLiteral.(type1))("2")>:<(toStringLiteral.(type2))("3")>", "<(toStringLiteral.(type1))("3")>:<(toStringLiteral.(type2))("4")>");
    }

    @Test
    public void collectWith()
    {
        Assert.assertEquals(
                Bags.mutable.of(4L, 6L, 8L),
                this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>).collectWith((<name1><name2>Pair argument1, Long argument2) -> (long) (argument1.getOne() + argument1.getTwo() + argument2), 1L).toBag());
    }

    @Test
    public void collectWith_target()
    {
        Assert.assertEquals(
                Bags.mutable.of(4L, 6L, 8L),
                this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>).collectWith((<name1><name2>Pair argument1, Long argument2) -> (long) (argument1.getOne() + argument1.getTwo() + argument2), 1L, HashBag.\<Long>newBag()));
    }

    @Test
    public void getFirst()
    {
        <name1><name2>Pair first = this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>).getFirst();
        Assert.assertTrue(PrimitiveTuples.pair(<(literal.(type1))("1")>, <(literal.(type2))("2")>).equals(first)
                || PrimitiveTuples.pair(<(literal.(type1))("2")>, <(literal.(type2))("3")>).equals(first)
                || PrimitiveTuples.pair(<(literal.(type1))("3")>, <(literal.(type2))("4")>).equals(first));
        Assert.assertEquals(PrimitiveTuples.pair(<(literal.(type1))("1")>, <(literal.(type2))("2")>), this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>).getFirst());
    }

    @Test
    public void getLast()
    {
        <name1><name2>Pair last = this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>).getLast();
        Assert.assertTrue(PrimitiveTuples.pair(<(literal.(type1))("1")>, <(literal.(type2))("2")>).equals(last)
                || PrimitiveTuples.pair(<(literal.(type1))("2")>, <(literal.(type2))("3")>).equals(last)
                || PrimitiveTuples.pair(<(literal.(type1))("3")>, <(literal.(type2))("4")>).equals(last));
        Assert.assertEquals(PrimitiveTuples.pair(<(literal.(type1))("1")>, <(literal.(type2))("2")>), this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>).getLast());
    }

    @Test
    public void isEmpty()
    {
        Verify.assertIterableEmpty(this.newWith());
        Verify.assertIterableNotEmpty(this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>));
        Assert.assertTrue(this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>).notEmpty());
    }

    @Test
    public void iterator()
    {
        RichIterable\<<name1><name2>Pair> objects = this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("0")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>);
        MutableBag\<<name1><name2>Pair> actual = Bags.mutable.of();
        Iterator\<<name1><name2>Pair> iterator = objects.iterator();
        for (int i = objects.size(); i-- > 0; )
        {
            Assert.assertTrue(iterator.hasNext());
            actual.add(iterator.next());
        }
        Assert.assertFalse(iterator.hasNext());
        Assert.assertEquals(objects.toBag(), actual);
    }

    @Test
    public void iterator_no_sentinels()
    {
        RichIterable\<<name1><name2>Pair> objects = this.newWith(<(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("4")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>);
        MutableBag\<<name1><name2>Pair> actual = Bags.mutable.of();
        Iterator\<<name1><name2>Pair> iterator = objects.iterator();
        for (int i = objects.size(); i-- > 0; )
        {
            Assert.assertTrue(iterator.hasNext());
            actual.add(iterator.next());
        }
        Assert.assertFalse(iterator.hasNext());
        Assert.assertEquals(objects.toBag(), actual);
    }

    @Test(expected = NoSuchElementException.class)
    public void iterator_next_throws()
    {
        RichIterable\<<name1><name2>Pair> objects = this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>);
        Iterator\<<name1><name2>Pair> iterator = objects.iterator();
        for (int i = objects.size(); i-- > 0; )
        {
            Assert.assertTrue(iterator.hasNext());
            iterator.next();
        }
        Assert.assertFalse(iterator.hasNext());
        iterator.next();
    }

    @Test(expected = UnsupportedOperationException.class)
    public void iterator_remove_throws()
    {
        RichIterable\<<name1><name2>Pair> objects = this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>);
        Iterator\<<name1><name2>Pair> iterator = objects.iterator();
        iterator.remove();
    }

    @Test
    public void injectInto()
    {
        RichIterable\<<name1><name2>Pair> objects = this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>);
        Long result = objects.injectInto(1L, (Long argument1, <name1><name2>Pair argument2) -> (long) (argument1 + argument2.getOne() + argument2.getTwo()));
        Assert.assertEquals(Long.valueOf(16), result);
    }

    @Test
    public void injectIntoInt()
    {
        RichIterable\<<name1><name2>Pair> objects = this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>);
        int result = objects.injectInto(1, (int intParameter, <name1><name2>Pair argument2) -> (int) (intParameter + argument2.getOne() + argument2.getTwo()));
        Assert.assertEquals(16, result);
    }

    @Test
    public void injectIntoLong()
    {
        RichIterable\<<name1><name2>Pair> objects = this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>);
        long result = objects.injectInto(1L, (long parameter, <name1><name2>Pair argument2) -> (long) (parameter + argument2.getOne() + argument2.getTwo()));
        Assert.assertEquals(16, result);
    }

    @Test
    public void injectIntoDouble()
    {
        RichIterable\<<name1><name2>Pair> objects = this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>);
        double result = objects.injectInto(1.0, (double parameter, <name1><name2>Pair argument2) -> (double) (parameter + argument2.getOne() + argument2.getTwo()));
        Assert.assertEquals(16.0, result, 0.0);
    }

    @Test
    public void injectIntoFloat()
    {
        RichIterable\<<name1><name2>Pair> objects = this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>);
        float result = objects.injectInto(1.0f, (float parameter, <name1><name2>Pair argument2) -> (float) (parameter + argument2.getOne() + argument2.getTwo()));
        Assert.assertEquals(16.0, result, 0.0);
    }

    @Test
    public void sumFloat()
    {
        RichIterable\<<name1><name2>Pair> objects = this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>);
        double actual = objects.sumOfFloat((<name1><name2>Pair each) -> (float) (each.getOne() + each.getTwo()));
        Assert.assertEquals(15.0, actual, 0.0);
    }

    @Test
    public void sumDouble()
    {
        RichIterable\<<name1><name2>Pair> objects = this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>);
        double actual = objects.sumOfDouble((<name1><name2>Pair each) -> (double) (each.getOne() + each.getTwo()));
        Assert.assertEquals(15.0, actual, 0.0);
    }

    @Test
    public void sumInteger()
    {
        RichIterable\<<name1><name2>Pair> objects = this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>);
        long actual = objects.sumOfInt((<name1><name2>Pair each) -> (int) (each.getOne() + each.getTwo()));
        Assert.assertEquals(15, actual);
    }

    @Test
    public void sumLong()
    {
        RichIterable\<<name1><name2>Pair> objects = this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>);
        long actual = objects.sumOfLong((<name1><name2>Pair each) -> (long) (each.getOne() + each.getTwo()));
        Assert.assertEquals(15, actual);
    }

    @Test
    public void toArray()
    {
        RichIterable\<<name1><name2>Pair> objects = this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>);
        Object[] array = objects.toArray();
        Verify.assertSize(3, array);
        <name1><name2>Pair[] array2 = objects.toArray(new <name1><name2>Pair[3]);
        Verify.assertSize(3, array2);
    }

    @Test
    public void partition()
    {
        PartitionIterable\<<name1><name2>Pair> result = this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>).partition(PrimitiveTuples.pair(<(literal.(type1))("2")>, <(literal.(type2))("3")>)::equals);
        Verify.assertContains(PrimitiveTuples.pair(<(literal.(type1))("2")>, <(literal.(type2))("3")>), result.getSelected().toList());
        Verify.assertIterableSize(1, result.getSelected());
        Verify.assertContains(PrimitiveTuples.pair(<(literal.(type1))("1")>, <(literal.(type2))("2")>), result.getRejected().toList());
        Verify.assertContains(PrimitiveTuples.pair(<(literal.(type1))("3")>, <(literal.(type2))("4")>), result.getRejected().toList());
        Verify.assertIterableSize(2, result.getRejected());
    }

    @Test
    public void toList()
    {
        MutableList\<<name1><name2>Pair> list = this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>).toList();
        Verify.assertContainsAll(list, PrimitiveTuples.pair(<(literal.(type1))("1")>, <(literal.(type2))("2")>), PrimitiveTuples.pair(<(literal.(type1))("2")>, <(literal.(type2))("3")>), PrimitiveTuples.pair(<(literal.(type1))("3")>, <(literal.(type2))("4")>));
    }

    @Test
    public void toBag()
    {
        MutableBag\<<name1><name2>Pair> bag = this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>).toBag();
        Verify.assertContainsAll(bag, PrimitiveTuples.pair(<(literal.(type1))("1")>, <(literal.(type2))("2")>), PrimitiveTuples.pair(<(literal.(type1))("2")>, <(literal.(type2))("3")>), PrimitiveTuples.pair(<(literal.(type1))("3")>, <(literal.(type2))("4")>));
    }

    @Test
    public void toSortedList_natural_ordering()
    {
        RichIterable\<<name1><name2>Pair> pairs = this.newWith(<(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>);
        MutableList\<<name1><name2>Pair> list = pairs.toSortedList();
        Assert.assertEquals(Lists.mutable.of(PrimitiveTuples.pair(<(literal.(type1))("1")>, <(literal.(type2))("2")>), PrimitiveTuples.pair(<(literal.(type1))("2")>, <(literal.(type2))("3")>), PrimitiveTuples.pair(<(literal.(type1))("3")>, <(literal.(type2))("4")>)), list);
    }

    @Test
    public void toSortedList_with_comparator()
    {
        RichIterable\<<name1><name2>Pair> pairs = this.newWith(<(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>);
        MutableList\<<name1><name2>Pair> list = pairs.toSortedList(Comparators.reverseNaturalOrder());
        Assert.assertEquals(Lists.mutable.of(PrimitiveTuples.pair(<(literal.(type1))("3")>, <(literal.(type2))("4")>), PrimitiveTuples.pair(<(literal.(type1))("2")>, <(literal.(type2))("3")>), PrimitiveTuples.pair(<(literal.(type1))("1")>, <(literal.(type2))("2")>)), list);
    }

    @Test
    public void toSortedListBy()
    {
        RichIterable\<<name1><name2>Pair> pairs = this.newWith(<(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>);
        MutableList\<<name1><name2>Pair> list = pairs.toSortedListBy(String::valueOf);
        Assert.assertEquals(Lists.mutable.of(PrimitiveTuples.pair(<(literal.(type1))("1")>, <(literal.(type2))("2")>), PrimitiveTuples.pair(<(literal.(type1))("2")>, <(literal.(type2))("3")>), PrimitiveTuples.pair(<(literal.(type1))("3")>, <(literal.(type2))("4")>)), list);
    }

    @Test
    public void toSortedBag_natural_ordering()
    {
        RichIterable\<<name1><name2>Pair> pairs = this.newWith(<(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>);
        MutableSortedBag\<<name1><name2>Pair> bag = pairs.toSortedBag();
        Verify.assertSortedBagsEqual(TreeBag.newBagWith(PrimitiveTuples.pair(<(literal.(type1))("1")>, <(literal.(type2))("2")>), PrimitiveTuples.pair(<(literal.(type1))("2")>, <(literal.(type2))("3")>), PrimitiveTuples.pair(<(literal.(type1))("3")>, <(literal.(type2))("4")>)), bag);
    }

    @Test
    public void toSortedBag_with_comparator()
    {
        RichIterable\<<name1><name2>Pair> pairs = this.newWith(<(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>);
        MutableSortedBag\<<name1><name2>Pair> bag = pairs.toSortedBag(Comparators.reverseNaturalOrder());
        Verify.assertSortedBagsEqual(TreeBag.newBagWith(Comparators.reverseNaturalOrder(), PrimitiveTuples.pair(<(literal.(type1))("3")>, <(literal.(type2))("4")>), PrimitiveTuples.pair(<(literal.(type1))("2")>, <(literal.(type2))("3")>), PrimitiveTuples.pair(<(literal.(type1))("1")>, <(literal.(type2))("2")>)), bag);
    }

    @Test
    public void toSortedBagBy()
    {
        RichIterable\<<name1><name2>Pair> pairs = this.newWith(<(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>);
        MutableSortedBag\<<name1><name2>Pair> bag = pairs.toSortedBagBy(String::valueOf);
        Verify.assertSortedBagsEqual(TreeBag.newBagWith(PrimitiveTuples.pair(<(literal.(type1))("1")>, <(literal.(type2))("2")>), PrimitiveTuples.pair(<(literal.(type1))("2")>, <(literal.(type2))("3")>), PrimitiveTuples.pair(<(literal.(type1))("3")>, <(literal.(type2))("4")>)), bag);
    }

    @Test
    public void toSortedSet_natural_ordering()
    {
        RichIterable\<<name1><name2>Pair> pairs = this.newWith(<(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>);
        MutableSortedSet\<<name1><name2>Pair> set = pairs.toSortedSet();
        Verify.assertSortedSetsEqual(TreeSortedSet.newSetWith(PrimitiveTuples.pair(<(literal.(type1))("1")>, <(literal.(type2))("2")>), PrimitiveTuples.pair(<(literal.(type1))("2")>, <(literal.(type2))("3")>), PrimitiveTuples.pair(<(literal.(type1))("3")>, <(literal.(type2))("4")>)), set);
    }

    @Test
    public void toSortedSet_with_comparator()
    {
        RichIterable\<<name1><name2>Pair> pairs = this.newWith(<(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>);
        MutableSortedSet\<<name1><name2>Pair> set = pairs.toSortedSet(Comparators.reverseNaturalOrder());
        Verify.assertSortedSetsEqual(TreeSortedSet.newSetWith(Comparators.reverseNaturalOrder(),
                PrimitiveTuples.pair(<(literal.(type1))("3")>, <(literal.(type2))("4")>),
                PrimitiveTuples.pair(<(literal.(type1))("2")>, <(literal.(type2))("3")>),
                PrimitiveTuples.pair(<(literal.(type1))("1")>, <(literal.(type2))("2")>)),
                set);
    }

    @Test
    public void toSortedSetBy()
    {
        RichIterable\<<name1><name2>Pair> pairs = this.newWith(<(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>);
        MutableSortedSet\<<name1><name2>Pair> set = pairs.toSortedSetBy(String::valueOf);
        Verify.assertSortedSetsEqual(TreeSortedSet.newSetWith(PrimitiveTuples.pair(<(literal.(type1))("1")>, <(literal.(type2))("2")>), PrimitiveTuples.pair(<(literal.(type1))("2")>, <(literal.(type2))("3")>), PrimitiveTuples.pair(<(literal.(type1))("3")>, <(literal.(type2))("4")>)), set);
    }

    @Test
    public void toSet()
    {
        RichIterable\<<name1><name2>Pair> pairs = this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>);
        MutableSet\<<name1><name2>Pair> set = pairs.toSet();
        Verify.assertContainsAll(set, PrimitiveTuples.pair(<(literal.(type1))("1")>, <(literal.(type2))("2")>), PrimitiveTuples.pair(<(literal.(type1))("2")>, <(literal.(type2))("3")>), PrimitiveTuples.pair(<(literal.(type1))("3")>, <(literal.(type2))("4")>));
    }

    @Test
    public void toMap()
    {
        RichIterable\<<name1><name2>Pair> pairs = this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>);
        MutableMap\<String, String> map =
                pairs.toMap(String::valueOf, String::valueOf);
        Assert.assertEquals(UnifiedMap.newWithKeysValues("<(toStringLiteral.(type1))("1")>:<(toStringLiteral.(type2))("2")>", "<(toStringLiteral.(type1))("1")>:<(toStringLiteral.(type2))("2")>", "<(toStringLiteral.(type1))("2")>:<(toStringLiteral.(type2))("3")>", "<(toStringLiteral.(type1))("2")>:<(toStringLiteral.(type2))("3")>", "<(toStringLiteral.(type1))("3")>:<(toStringLiteral.(type2))("4")>", "<(toStringLiteral.(type1))("3")>:<(toStringLiteral.(type2))("4")>"), map);
    }

    @Test
    public void toSortedMap()
    {
        RichIterable\<<name1><name2>Pair> pairs = this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>);
        MutableSortedMap\<String, String> map =
                pairs.toSortedMap(String::valueOf, String::valueOf);
        Assert.assertEquals(TreeSortedMap.newMapWith("<(toStringLiteral.(type1))("1")>:<(toStringLiteral.(type2))("2")>", "<(toStringLiteral.(type1))("1")>:<(toStringLiteral.(type2))("2")>", "<(toStringLiteral.(type1))("2")>:<(toStringLiteral.(type2))("3")>", "<(toStringLiteral.(type1))("2")>:<(toStringLiteral.(type2))("3")>", "<(toStringLiteral.(type1))("3")>:<(toStringLiteral.(type2))("4")>", "<(toStringLiteral.(type1))("3")>:<(toStringLiteral.(type2))("4")>"), map);
    }

    @Test
    public void toSortedMap_with_comparator()
    {
        RichIterable\<<name1><name2>Pair> pairs = this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>);
        MutableSortedMap\<String, String> map =
                pairs.toSortedMap(Comparators.reverseNaturalOrder(), String::valueOf, String::valueOf);
        Assert.assertEquals(TreeSortedMap.newMapWith(Comparators.reverseNaturalOrder(), "<(toStringLiteral.(type1))("1")>:<(toStringLiteral.(type2))("2")>", "<(toStringLiteral.(type1))("1")>:<(toStringLiteral.(type2))("2")>", "<(toStringLiteral.(type1))("2")>:<(toStringLiteral.(type2))("3")>", "<(toStringLiteral.(type1))("2")>:<(toStringLiteral.(type2))("3")>", "<(toStringLiteral.(type1))("3")>:<(toStringLiteral.(type2))("4")>", "<(toStringLiteral.(type1))("3")>:<(toStringLiteral.(type2))("4")>"), map);
    }

    @Test
    public void toSortedMapBy()
    {
        RichIterable\<<name1><name2>Pair> pairs = this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>);
        MutableSortedMap\<String, String> map =
                pairs.toSortedMapBy(String::valueOf, String::valueOf, String::valueOf);
        Assert.assertEquals(TreeSortedMap.newMapWith(Comparators.naturalOrder(), "<(toStringLiteral.(type1))("1")>:<(toStringLiteral.(type2))("2")>", "<(toStringLiteral.(type1))("1")>:<(toStringLiteral.(type2))("2")>", "<(toStringLiteral.(type1))("2")>:<(toStringLiteral.(type2))("3")>", "<(toStringLiteral.(type1))("2")>:<(toStringLiteral.(type2))("3")>", "<(toStringLiteral.(type1))("3")>:<(toStringLiteral.(type2))("4")>", "<(toStringLiteral.(type1))("3")>:<(toStringLiteral.(type2))("4")>"), map);
    }

    @Test
    public void testToString()
    {
        RichIterable\<<name1><name2>Pair> collection = this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>);
        Assert.assertTrue("[<(toStringLiteral.(type1))("1")>:<(toStringLiteral.(type2))("2")>, <(toStringLiteral.(type1))("2")>:<(toStringLiteral.(type2))("3")>]".equals(collection.toString())
                || "[<(toStringLiteral.(type1))("2")>:<(toStringLiteral.(type2))("3")>, <(toStringLiteral.(type1))("1")>:<(toStringLiteral.(type2))("2")>]".equals(collection.toString()));
    }

    @Test
    public void makeString()
    {
        RichIterable\<<name1><name2>Pair> collection = this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>);
        Assert.assertEquals(collection.toString(), '[' + collection.makeString() + ']');
    }

    @Test
    public void makeStringWithSeparator()
    {
        RichIterable\<<name1><name2>Pair> collection = this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>);
        Assert.assertEquals(collection.toString(), '[' + collection.makeString(", ") + ']');
    }

    @Test
    public void makeStringWithSeparatorAndStartAndEnd()
    {
        RichIterable\<<name1><name2>Pair> collection = this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>);
        Assert.assertEquals(collection.toString(), collection.makeString("[", ", ", "]"));
    }

    @Test
    public void appendString()
    {
        RichIterable\<<name1><name2>Pair> collection = this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>);
        Appendable builder = new StringBuilder();
        collection.appendString(builder);
        Assert.assertEquals(collection.toString(), '[' + builder.toString() + ']');
    }

    @Test
    public void appendStringWithSeparator()
    {
        RichIterable\<<name1><name2>Pair> collection = this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>);
        Appendable builder = new StringBuilder();
        collection.appendString(builder, ", ");
        Assert.assertEquals(collection.toString(), '[' + builder.toString() + ']');
    }

    @Test
    public void appendStringWithSeparatorAndStartAndEnd()
    {
        RichIterable\<<name1><name2>Pair> collection = this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>);
        Appendable builder = new StringBuilder();
        collection.appendString(builder, "[", ", ", "]");
        Assert.assertEquals(collection.toString(), builder.toString());
    }

    @Test
    public void groupBy()
    {
        RichIterable\<<name1><name2>Pair> collection = this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>);
        Function\<<name1><name2>Pair, Boolean> function = (<name1><name2>Pair object) -> PrimitiveTuples.pair(<(literal.(type1))("1")>, <(literal.(type2))("2")>).equals(object);

        Multimap\<Boolean, <name1><name2>Pair> multimap = collection.groupBy(function);
        Assert.assertEquals(3, multimap.size());
        Assert.assertTrue(multimap.containsKeyAndValue(Boolean.TRUE, PrimitiveTuples.pair(<(literal.(type1))("1")>, <(literal.(type2))("2")>)));
        Assert.assertTrue(multimap.containsKeyAndValue(Boolean.FALSE, PrimitiveTuples.pair(<(literal.(type1))("2")>, <(literal.(type2))("3")>)));
        Assert.assertTrue(multimap.containsKeyAndValue(Boolean.FALSE, PrimitiveTuples.pair(<(literal.(type1))("3")>, <(literal.(type2))("4")>)));
    }

    @Test
    public void groupByEach()
    {
        RichIterable\<<name1><name2>Pair> collection = this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>);
        Function\<<name1><name2>Pair, MutableList\<Boolean>\> function = (<name1><name2>Pair object) -> Lists.mutable.of(PrimitiveTuples.pair(<(literal.(type1))("1")>, <(literal.(type2))("2")>).equals(object));

        Multimap\<Boolean, <name1><name2>Pair> multimap = collection.groupByEach(function);
        Assert.assertEquals(3, multimap.size());
        Assert.assertTrue(multimap.containsKeyAndValue(Boolean.TRUE, PrimitiveTuples.pair(<(literal.(type1))("1")>, <(literal.(type2))("2")>)));
        Assert.assertTrue(multimap.containsKeyAndValue(Boolean.FALSE, PrimitiveTuples.pair(<(literal.(type1))("2")>, <(literal.(type2))("3")>)));
        Assert.assertTrue(multimap.containsKeyAndValue(Boolean.FALSE, PrimitiveTuples.pair(<(literal.(type1))("3")>, <(literal.(type2))("4")>)));
    }

    @Test
    public void zip()
    {
        RichIterable\<<name1><name2>Pair> collection = this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>);
        RichIterable\<Pair\<<name1><name2>Pair, Integer>\> result = collection.zip(Interval.oneTo(5));

        Assert.assertTrue(Bags.mutable.of(Tuples.pair(PrimitiveTuples.pair(<(literal.(type1))("1")>, <(literal.(type2))("2")>), 1), Tuples.pair(PrimitiveTuples.pair(<(literal.(type1))("2")>, <(literal.(type2))("3")>), 2)).equals(result.toBag())
                || Bags.mutable.of(Tuples.pair(PrimitiveTuples.pair(<(literal.(type1))("2")>, <(literal.(type2))("3")>), 1), Tuples.pair(PrimitiveTuples.pair(<(literal.(type1))("1")>, <(literal.(type2))("2")>), 2)).equals(result.toBag()));
    }

    @Test
    public void zipWithIndex()
    {
        RichIterable\<<name1><name2>Pair> collection = this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>);
        RichIterable\<Pair\<<name1><name2>Pair, Integer>\> result = collection.zipWithIndex();
        Assert.assertTrue(Bags.mutable.of(Tuples.pair(PrimitiveTuples.pair(<(literal.(type1))("1")>, <(literal.(type2))("2")>), 0), Tuples.pair(PrimitiveTuples.pair(<(literal.(type1))("2")>, <(literal.(type2))("3")>), 1)).equals(result.toBag())
                || Bags.mutable.of(Tuples.pair(PrimitiveTuples.pair(<(literal.(type1))("2")>, <(literal.(type2))("3")>), 0), Tuples.pair(PrimitiveTuples.pair(<(literal.(type1))("1")>, <(literal.(type2))("2")>), 1)).equals(result.toBag()));
    }

    @Test
    public void chunk()
    {
        RichIterable\<<name1><name2>Pair> collection = this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>);
        Assert.assertEquals(Bags.immutable.of(FastList.newListWith(PrimitiveTuples.pair(<(literal.(type1))("1")>, <(literal.(type2))("2")>)),
                FastList.newListWith(PrimitiveTuples.pair(<(literal.(type1))("2")>, <(literal.(type2))("3")>)),
                FastList.newListWith(PrimitiveTuples.pair(<(literal.(type1))("3")>, <(literal.(type2))("4")>))),
                collection.chunk(1).toBag());
    }

    @Test(expected = IllegalArgumentException.class)
    public void chunk_zero_throws()
    {
        RichIterable\<<name1><name2>Pair> collection = this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>);
        collection.chunk(0);
    }

    @Test
    public void chunk_large_size()
    {
        RichIterable\<<name1><name2>Pair> collection = this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>);
        Verify.assertIterableSize(3, collection.chunk(10).getFirst());
    }

    @Test
    public void empty()
    {
        Verify.assertIterableEmpty(this.newWith());
        Assert.assertTrue(this.newWith().isEmpty());
        Assert.assertFalse(this.newWith().notEmpty());
    }

    @Test
    public void notEmpty()
    {
        RichIterable\<<name1><name2>Pair> notEmpty = this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>);
        Verify.assertIterableNotEmpty(notEmpty);
    }

    @Test
    public void aggregateByMutating()
    {
        Function0\<AtomicInteger> valueCreator = Functions0.zeroAtomicInteger();
        Procedure2\<AtomicInteger, <name1><name2>Pair> sumAggregator = (AtomicInteger aggregate, <name1><name2>Pair value) -> aggregate.addAndGet((int) value.getOne());
        RichIterable\<<name1><name2>Pair> collection = this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>);
        MapIterable\<String, AtomicInteger> aggregation = collection.aggregateInPlaceBy(String::valueOf, valueCreator, sumAggregator);
        Assert.assertEquals(3, aggregation.get("<(toStringLiteral.(type1))("3")>:<(toStringLiteral.(type2))("4")>").intValue());
        Assert.assertEquals(2, aggregation.get("<(toStringLiteral.(type1))("2")>:<(toStringLiteral.(type2))("3")>").intValue());
        Assert.assertEquals(1, aggregation.get("<(toStringLiteral.(type1))("1")>:<(toStringLiteral.(type2))("2")>").intValue());
    }

    @Test
    public void aggregateByNonMutating()
    {
        Function0\<Integer> valueCreator = Functions0.value(0);
        Function2\<Integer, <name1><name2>Pair, Integer> sumAggregator = (Integer aggregate, <name1><name2>Pair value) -> (int) (aggregate + value.getOne());
        RichIterable\<<name1><name2>Pair> collection = this.newWith(<(literal.(type1))("1")>, <(literal.(type2))("1")>, <(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>);
        MapIterable\<String, Integer> aggregation = collection.aggregateBy(String::valueOf, valueCreator, sumAggregator);
        Assert.assertEquals(2, aggregation.get("<(toStringLiteral.(type1))("2")>:<(toStringLiteral.(type2))("3")>").intValue());
        Assert.assertEquals(1, aggregation.get("<(toStringLiteral.(type1))("1")>:<(toStringLiteral.(type2))("2")>").intValue());
    }
}

>>
