BAEL-3323 filterNot example added. Rename package, class and file

This commit is contained in:
David Calap 2019-10-02 09:19:21 +02:00
parent dc9a78ab18
commit 30bf670ba4
1 changed files with 9 additions and 2 deletions

View File

@ -1,10 +1,10 @@
package com.baeldung.lambda
package com.baeldung.lists
import org.junit.jupiter.api.Test
import kotlin.test.assertEquals
import kotlin.test.assertTrue
class ListsTest {
class ListsUnitTest {
var batmans: List<String> = listOf("Christian Bale", "Michael Keaton", "Ben Affleck", "George Clooney")
@ -22,4 +22,11 @@ class ListsTest {
assertTrue(theCoolestBatmans.contains("Christian Bale") && theCoolestBatmans.contains("Michael Keaton"))
}
@Test
fun whenFilterNotWithPredicate_thenMatchingItemsAreReturned() {
//Returns a list containing only elements not matching the given predicate.
val theMehBatmans = batmans.filterNot { actor -> actor.contains("a") }
assertTrue(!theMehBatmans.contains("Christian Bale") && !theMehBatmans.contains("Michael Keaton"))
}
}