You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2019/08/15 20:09:32 UTC
[commons-collections] branch master updated: Add missing test case.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-collections.git
The following commit(s) were added to refs/heads/master by this push:
new e0b5e62 Add missing test case.
e0b5e62 is described below
commit e0b5e624a7aec6d787b91770b6c2db43ddbf0d85
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Aug 15 13:09:28 2019 -0700
Add missing test case.
---
.../org/apache/commons/collections4/MapUtilsTest.java | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/src/test/java/org/apache/commons/collections4/MapUtilsTest.java b/src/test/java/org/apache/commons/collections4/MapUtilsTest.java
index 9a2470c..6420905 100644
--- a/src/test/java/org/apache/commons/collections4/MapUtilsTest.java
+++ b/src/test/java/org/apache/commons/collections4/MapUtilsTest.java
@@ -20,6 +20,8 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail;
import java.io.ByteArrayOutputStream;
@@ -1152,8 +1154,11 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
@Test
public void testgetBooleanValue() {
- final Map<String, Boolean> in = new HashMap<>();
+ final Map<String, Object> in = new HashMap<>();
in.put("key", true);
+ in.put("keyNumberTrue", 1);
+ in.put("keyNumberFalse", 0);
+ in.put("keyUnmapped", new Object());
assertTrue(MapUtils.getBooleanValue(in,"key", true));
assertTrue(MapUtils.getBooleanValue(in,"key"));
@@ -1167,21 +1172,20 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
assertTrue(MapUtils.getBoolean(in,"noKey", (key)->{
if (System.currentTimeMillis() > 0) {
return true;
- } else {
- return false;
}
+ return false;
}));
assertEquals(null, MapUtils.getBoolean(null,"noKey"));
-
-
+ // Values are Numbers
+ assertFalse(MapUtils.getBoolean(in,"keyNumberFalse"));
+ assertTrue(MapUtils.getBoolean(in,"keyNumberTrue"));
+ assertNull(MapUtils.getBoolean(in,"keyString"));
final Map<String, String> inStr = new HashMap<>();
inStr.put("str1", "true");
assertTrue(MapUtils.getBooleanValue(inStr,"str1", true));
assertTrue(MapUtils.getBoolean(inStr,"str1", true));
-
-
}
@Test