package com.baeldung.eclipsecollections; 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.tuple.Tuples; import org.assertj.core.api.Assertions; import org.junit.Before; import org.junit.Test; public class ZipUnitTest { MutableList> expectedPairs; @SuppressWarnings("unchecked") @Before public void setup() { Pair pair1 = Tuples.pair("1", "Porsche"); Pair pair2 = Tuples.pair("2", "Volvo"); Pair pair3 = Tuples.pair("3", "Toyota"); expectedPairs = Lists.mutable.of(pair1, pair2, pair3); } @Test public void whenZip_thenCorrect() { MutableList numbers = Lists.mutable.with("1", "2", "3", "Ignored"); MutableList cars = Lists.mutable.with("Porsche", "Volvo", "Toyota"); MutableList> pairs = numbers.zip(cars); Assertions.assertThat(pairs).containsExactlyElementsOf(this.expectedPairs); } }