Created
January 27, 2011 09:53
-
-
Save dwursteisen/798309 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package itw; | |
import java.util.Collection; | |
public class AboutCollections { | |
/** | |
* La méthode retourne une liste avec les élements de stringList sans les doublons. | |
* | |
* @param stringList | |
* @return | |
*/ | |
public Collection<String> uniqueElements(final Collection<String> stringList) { | |
} | |
/** | |
* La méthode retourne une liste contenant les élements de toutes les listes passées en paramètre. | |
* | |
* @param lists | |
* @return | |
*/ | |
public Collection<String> createOneBigCollection(Collection<String> l1, Collection<String> l2, Collection<String> l3) { | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package itw; | |
import org.junit.Before; | |
import org.junit.Test; | |
import java.util.Arrays; | |
import java.util.Collection; | |
import static org.junit.Assert.assertEquals; | |
import static org.junit.Assert.assertTrue; | |
public class AboutCollectionsTest { | |
private AboutCollections obj; | |
@Before | |
public void setUp() { | |
obj = new AboutCollections(); | |
} | |
@Test | |
public void testUniqueElements() { | |
Collection<String> stringList = Arrays.asList("david", "alexandre", "nicolas", "beko", "alexandre", "nicolas"); | |
Collection<String> result = obj.uniqueElements(stringList); | |
assertEquals(4, result.size()); | |
assertTrue(result.contains("david")); | |
assertTrue(result.contains("alexandre")); | |
assertTrue(result.contains("nicolas")); | |
assertTrue(result.contains("beko")); | |
} | |
@Test | |
public void testOneBigCollection() { | |
Collection<String> stringList1 = Arrays.asList("mickey", "donald"); | |
Collection<String> stringList2 = Arrays.asList("pluto", "daisy"); | |
Collection<String> stringList3 = Arrays.asList("bugs bunny", "picsou"); | |
Collection<String> result = obj.createOneBigCollection(stringList1, stringList2, stringList3); | |
assertEquals(6, result.size()); | |
assertTrue(result.contains("mickey")); | |
assertTrue(result.contains("daisy")); | |
assertTrue(result.contains("bugs bunny")); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment