Simplify several assertions in MapUtilsTest.

This commit is contained in:
Isira Seneviratne 2020-04-18 17:53:41 +05:30
parent 6b1e2eb08b
commit 0ba5024a3d
1 changed files with 39 additions and 39 deletions

View File

@ -148,8 +148,8 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
final Set<String> outKeySet = new HashSet<>(out.keySet());
final Set<String> outValSet = new HashSet<>(out.values());
assertTrue( inKeySet.equals( outValSet ));
assertTrue( inValSet.equals( outKeySet ));
assertEquals(inKeySet, outValSet);
assertEquals(inValSet, outKeySet);
assertEquals( "1", out.get("A"));
assertEquals( "2", out.get("B"));
@ -178,11 +178,11 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
{"GREEN", "#00FF00"},
{"BLUE", "#0000FF"}
});
assertEquals(true, test.containsKey("RED"));
assertTrue(test.containsKey("RED"));
assertEquals("#FF0000", test.get("RED"));
assertEquals(true, test.containsKey("GREEN"));
assertTrue(test.containsKey("GREEN"));
assertEquals("#00FF00", test.get("GREEN"));
assertEquals(true, test.containsKey("BLUE"));
assertTrue(test.containsKey("BLUE"));
assertEquals("#0000FF", test.get("BLUE"));
assertEquals(3, test.size());
@ -219,11 +219,11 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
"GREEN", "#00FF00",
"BLUE", "#0000FF"
});
assertEquals(true, test.containsKey("RED"));
assertTrue(test.containsKey("RED"));
assertEquals("#FF0000", test.get("RED"));
assertEquals(true, test.containsKey("GREEN"));
assertTrue(test.containsKey("GREEN"));
assertEquals("#00FF00", test.get("GREEN"));
assertEquals(true, test.containsKey("BLUE"));
assertTrue(test.containsKey("BLUE"));
assertEquals("#0000FF", test.get("BLUE"));
assertEquals(3, test.size());
@ -233,11 +233,11 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
"BLUE", "#0000FF",
"PURPLE" // ignored
});
assertEquals(true, test.containsKey("RED"));
assertTrue(test.containsKey("RED"));
assertEquals("#FF0000", test.get("RED"));
assertEquals(true, test.containsKey("GREEN"));
assertTrue(test.containsKey("GREEN"));
assertEquals("#00FF00", test.get("GREEN"));
assertEquals(true, test.containsKey("BLUE"));
assertTrue(test.containsKey("BLUE"));
assertEquals("#0000FF", test.get("BLUE"));
assertEquals(3, test.size());
@ -250,11 +250,11 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
new DefaultMapEntry<>("GREEN", "#00FF00"),
new DefaultMapEntry<>("BLUE", "#0000FF")
});
assertEquals(true, test.containsKey("RED"));
assertTrue(test.containsKey("RED"));
assertEquals("#FF0000", test.get("RED"));
assertEquals(true, test.containsKey("GREEN"));
assertTrue(test.containsKey("GREEN"));
assertEquals("#00FF00", test.get("GREEN"));
assertEquals(true, test.containsKey("BLUE"));
assertTrue(test.containsKey("BLUE"));
assertEquals("#0000FF", test.get("BLUE"));
assertEquals(3, test.size());
@ -264,11 +264,11 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
new DefaultKeyValue<>("GREEN", "#00FF00"),
new DefaultKeyValue<>("BLUE", "#0000FF")
});
assertEquals(true, test.containsKey("RED"));
assertTrue(test.containsKey("RED"));
assertEquals("#FF0000", test.get("RED"));
assertEquals(true, test.containsKey("GREEN"));
assertTrue(test.containsKey("GREEN"));
assertEquals("#00FF00", test.get("GREEN"));
assertEquals(true, test.containsKey("BLUE"));
assertTrue(test.containsKey("BLUE"));
assertEquals("#0000FF", test.get("BLUE"));
assertEquals(3, test.size());
}
@ -301,7 +301,7 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
final Map<String, Object> out = MapUtils.toMap(b);
assertTrue( in.equals(out));
assertEquals(in, out);
}
@Test
@ -745,39 +745,39 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
@Test
public void testIsEmptyWithEmptyMap() {
final Map<Object, Object> map = new HashMap<>();
assertEquals(true, MapUtils.isEmpty(map));
assertTrue(MapUtils.isEmpty(map));
}
@Test
public void testIsEmptyWithNonEmptyMap() {
final Map<String, String> map = new HashMap<>();
map.put("item", "value");
assertEquals(false, MapUtils.isEmpty(map));
assertFalse(MapUtils.isEmpty(map));
}
@Test
public void testIsEmptyWithNull() {
final Map<Object, Object> map = null;
assertEquals(true, MapUtils.isEmpty(map));
assertTrue(MapUtils.isEmpty(map));
}
@Test
public void testIsNotEmptyWithEmptyMap() {
final Map<Object, Object> map = new HashMap<>();
assertEquals(false, MapUtils.isNotEmpty(map));
assertFalse(MapUtils.isNotEmpty(map));
}
@Test
public void testIsNotEmptyWithNonEmptyMap() {
final Map<String, String> map = new HashMap<>();
map.put("item", "value");
assertEquals(true, MapUtils.isNotEmpty(map));
assertTrue(MapUtils.isNotEmpty(map));
}
@Test
public void testIsNotEmptyWithNull() {
final Map<Object, Object> map = null;
assertEquals(false, MapUtils.isNotEmpty(map));
assertFalse(MapUtils.isNotEmpty(map));
}
@Test
@ -798,9 +798,9 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
assertEquals(list.size(), map.size());
for (int i = 0; i < list.size(); i++) {
assertEquals(true, map.containsKey(Integer.valueOf(list.get(i))));
assertEquals(false, map.containsKey(list.get(i)));
assertEquals(true, map.containsValue(list.get(i)));
assertTrue(map.containsKey(Integer.valueOf(list.get(i))));
assertFalse(map.containsKey(list.get(i)));
assertTrue(map.containsValue(list.get(i)));
assertEquals(list.get(i), map.get(Integer.valueOf(list.get(i))));
}
@ -810,9 +810,9 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
assertEquals(list.size(), map.size());
for (int i = 0; i < list.size(); i++) {
assertEquals(true, map.containsKey(Integer.valueOf(list.get(i))));
assertEquals(false, map.containsKey(list.get(i)));
assertEquals(true, map.containsValue(Integer.valueOf(list.get(i))));
assertTrue(map.containsKey(Integer.valueOf(list.get(i))));
assertFalse(map.containsKey(list.get(i)));
assertTrue(map.containsValue(Integer.valueOf(list.get(i))));
assertEquals(Integer.valueOf(list.get(i)), map.get(Integer.valueOf(list.get(i))));
}
}
@ -851,8 +851,8 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
assertEquals(list.size(), map.totalSize());
for (int i = 0; i < list.size(); i++) {
assertEquals(true, map.containsKey(list.get(i).key));
assertEquals(true, map.containsValue(list.get(i)));
assertTrue(map.containsKey(list.get(i).key));
assertTrue(map.containsValue(list.get(i)));
}
}
@ -1110,7 +1110,7 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
assertEquals("str", MapUtils.getString(in, "key", "defualt"));
assertEquals("str", MapUtils.getString(in, "key"));
assertEquals(null, MapUtils.getString(null, "key"));
assertNull(MapUtils.getString(null, "key"));
assertEquals("default", MapUtils.getString(in, "noKey", "default"));
assertEquals("default", MapUtils.getString(in, "noKey", key -> {
if ("noKey".equals(key)) {
@ -1130,7 +1130,7 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
assertEquals("str", MapUtils.getObject(in, "key", "defualt"));
assertEquals("str", MapUtils.getObject(in, "key"));
assertEquals(null, MapUtils.getObject(null, "key"));
assertNull(MapUtils.getObject(null, "key"));
assertEquals("default", MapUtils.getObject(in, "noKey", "default"));
assertEquals("default", MapUtils.getObject(null, "noKey", "default"));
}
@ -1152,7 +1152,7 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
assertTrue(MapUtils.getBooleanValue(in, "noKey", key -> {
return true;
}));
assertTrue(!MapUtils.getBooleanValue(in, "noKey"));
assertFalse(MapUtils.getBooleanValue(in, "noKey"));
assertTrue(MapUtils.getBoolean(in, "key", true));
assertTrue(MapUtils.getBoolean(in, "noKey", true));
assertTrue(MapUtils.getBoolean(in, "noKey", key -> {
@ -1167,7 +1167,7 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
assertFalse(MapUtils.getBooleanValue(in, "noKey", key -> {
return null;
}));
assertEquals(null, MapUtils.getBoolean(null, "noKey"));
assertNull(MapUtils.getBoolean(null, "noKey"));
// Values are Numbers
assertFalse(MapUtils.getBoolean(in, "keyNumberFalse"));
assertTrue(MapUtils.getBoolean(in, "keyNumberTrue"));
@ -1192,9 +1192,9 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
final Map<?, ?> outValue = MapUtils.getMap(in, "key1", (Map<?, ?>) null);
assertEquals("value1", outValue.get("key1"));
assertEquals(null, outValue.get("key2"));
assertEquals(null, MapUtils.getMap(in, "key2", (Map<?, ?>) null));
assertEquals(null, MapUtils.getMap(null, "key2", (Map<?, ?>) null));
assertNull(outValue.get("key2"));
assertNull(MapUtils.getMap(in, "key2", (Map<?, ?>) null));
assertNull(MapUtils.getMap(null, "key2", (Map<?, ?>) null));
}
@Test