package com.baeldung.eclipsecollections; import org.assertj.core.api.Assertions; import org.eclipse.collections.api.list.MutableList; import org.eclipse.collections.api.tuple.Pair; import org.eclipse.collections.impl.factory.Lists; import org.eclipse.collections.impl.list.mutable.FastList; import org.eclipse.collections.impl.tuple.Tuples; import org.junit.Before; import org.junit.Test; public class ZipWithIndexUnitTest { MutableList> expectedPairs; @SuppressWarnings("unchecked") @Before public void setup() { Pair pair1 = Tuples.pair("Porsche", 0); Pair pair2 = Tuples.pair("Volvo", 1); Pair pair3 = Tuples.pair("Toyota", 2); expectedPairs = Lists.mutable.of(pair1, pair2, pair3); } @Test public void whenZip_thenCorrect() { MutableList cars = FastList.newListWith("Porsche", "Volvo", "Toyota"); MutableList> pairs = cars.zipWithIndex(); Assertions.assertThat(pairs).containsExactlyElementsOf(this.expectedPairs); } }