From 30bf670ba4514a54d082f726965e1ca092a93f8e Mon Sep 17 00:00:00 2001 From: David Calap Date: Wed, 2 Oct 2019 09:19:21 +0200 Subject: [PATCH] BAEL-3323 filterNot example added. Rename package, class and file --- .../baeldung/lists/{ListsTest.kt => ListsUnitTest.kt} | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) rename core-kotlin-2/src/test/kotlin/com/baeldung/lists/{ListsTest.kt => ListsUnitTest.kt} (68%) diff --git a/core-kotlin-2/src/test/kotlin/com/baeldung/lists/ListsTest.kt b/core-kotlin-2/src/test/kotlin/com/baeldung/lists/ListsUnitTest.kt similarity index 68% rename from core-kotlin-2/src/test/kotlin/com/baeldung/lists/ListsTest.kt rename to core-kotlin-2/src/test/kotlin/com/baeldung/lists/ListsUnitTest.kt index 8515a6f078..1e7136d08b 100644 --- a/core-kotlin-2/src/test/kotlin/com/baeldung/lists/ListsTest.kt +++ b/core-kotlin-2/src/test/kotlin/com/baeldung/lists/ListsUnitTest.kt @@ -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 = 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")) + } + } \ No newline at end of file