commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gary Gregory <garydgreg...@gmail.com>
Subject Re: commons-collections git commit: MapUtilsTest: fix order of expected and actual parameter in assertions (closes #32)
Date Sat, 14 Oct 2017 18:58:08 GMT
How does it compare to RelaxNG?

G

On Sat, Oct 14, 2017 at 12:49 PM, Matt Sicker <boards@gmail.com> wrote:

> AssertJ is an assertion library and works with JUnit or whatever testing
> framework you want. Essentially, it's a replacement for Hamcrest +
> org.junit.Assert.
>
> On 14 October 2017 at 13:27, Gary Gregory <garydgregory@gmail.com> wrote:
>
> > I have no interest in switching from JUnit, especially with JUnit 5
> around
> > the corner.
> >
> > Gary
> >
> > On Sat, Oct 14, 2017 at 12:25 PM, Pascal Schumacher <
> > pascalschumacher@gmx.net> wrote:
> >
> > > Any time. :-)
> > >
> > > Migrating is not hard, as there are scripts to do most of the work,
> see:
> > >
> > > https://joel-costigliola.github.io/assertj/assertj-core-
> > > converting-junit-assertions-to-assertj.html
> > >
> > > Am 14.10.2017 um 19:06 schrieb Benedikt Ritter:
> > >
> > >> About time we migrate to AssertJ. :-)
> > >>
> > >> Gary Gregory <garydgregory@gmail.com> schrieb am Sa. 14. Okt. 2017
um
> > >> 18:55:
> > >>
> > >> Thank you for doing that! That was driving me nuts!
> > >>>
> > >>> Gary
> > >>>
> > >>> On Oct 14, 2017 10:53, <pascalschumacher@apache.org> wrote:
> > >>>
> > >>> Repository: commons-collections
> > >>>> Updated Branches:
> > >>>>    refs/heads/master 641aa1c66 -> b9522976f
> > >>>>
> > >>>>
> > >>>> MapUtilsTest: fix order of expected and actual parameter in
> assertions
> > >>>> (closes #32)
> > >>>>
> > >>>>
> > >>>> Project: http://git-wip-us.apache.org/
> repos/asf/commons-collections/r
> > >>>> epo
> > >>>> Commit: http://git-wip-us.apache.org/repos/asf/commons-collections/
> > >>>> commit/b9522976
> > >>>> Tree: http://git-wip-us.apache.org/repos/asf/commons-collections/
> > >>>> tree/b9522976
> > >>>> Diff: http://git-wip-us.apache.org/repos/asf/commons-collections/
> > >>>> diff/b9522976
> > >>>>
> > >>>> Branch: refs/heads/master
> > >>>> Commit: b9522976f462687b0693b7229ba5c7faee0cb74b
> > >>>> Parents: 641aa1c
> > >>>> Author: Kavuri, Vamsi <vamsi.kavuri@capitalone.com>
> > >>>> Authored: Sat Oct 14 12:30:35 2017 -0400
> > >>>> Committer: pascalschumacher <pascalschumacher@gmx.net>
> > >>>> Committed: Sat Oct 14 18:52:04 2017 +0200
> > >>>>
> > >>>> ------------------------------------------------------------
> > ----------
> > >>>>   .../commons/collections4/MapUtilsTest.java      | 110
> > >>>>
> > >>> +++++++++----------
> > >>>
> > >>>>   1 file changed, 55 insertions(+), 55 deletions(-)
> > >>>> ------------------------------------------------------------
> > ----------
> > >>>>
> > >>>>
> > >>>> http://git-wip-us.apache.org/repos/asf/commons-collections/
> > >>>> blob/b9522976/src/test/java/org/apache/commons/
> > >>>> collections4/MapUtilsTest.java
> > >>>> ------------------------------------------------------------
> > ----------
> > >>>> diff --git
> > >>>>
> > >>> a/src/test/java/org/apache/commons/collections4/MapUtilsTest.java
> > >>>
> > >>>> b/src/test/java/org/apache/commons/collections4/MapUtilsTest.java
> > >>>> index fc3e3d6..21f20c4 100644
> > >>>> --- a/src/test/java/org/apache/commons/collections4/
> MapUtilsTest.java
> > >>>> +++ b/src/test/java/org/apache/commons/collections4/
> MapUtilsTest.java
> > >>>> @@ -950,12 +950,12 @@ public class MapUtilsTest extends
> > >>>> AbstractAvailableLocalesTest {
> > >>>>           final Map<String, Double> in = new HashMap<>();
> > >>>>           in.put("key", 2.0);
> > >>>>
> > >>>> -        assertEquals(MapUtils.getDoubleValue(in,"key", 0.0), 2.0,
> > 0);
> > >>>> -        assertEquals(MapUtils.getDoubleValue(in,"key"), 2.0, 0);
> > >>>> -        assertEquals(MapUtils.getDoubleValue(in,"noKey", 1.0),
> 1.0,
> > >>>> 0);
> > >>>> -        assertEquals(MapUtils.getDoubleValue(in,"noKey"), 0, 0);
> > >>>> -        assertEquals(MapUtils.getDouble(in,"key", 0.0), 2.0, 0);
> > >>>> -        assertEquals(MapUtils.getDouble(in,"noKey", 1.0), 1.0,
0);
> > >>>> +        assertEquals(2.0, MapUtils.getDoubleValue(in,"key", 0.0),
> > 0);
> > >>>> +        assertEquals(2.0, MapUtils.getDoubleValue(in,"key"), 0);
> > >>>> +        assertEquals(1.0, MapUtils.getDoubleValue(in,"noKey",
> 1.0),
> > >>>> 0);
> > >>>> +        assertEquals(0, MapUtils.getDoubleValue(in,"noKey"), 0);
> > >>>> +        assertEquals(2.0, MapUtils.getDouble(in,"key", 0.0), 0);
> > >>>> +        assertEquals(1.0, MapUtils.getDouble(in,"noKey", 1.0),
0);
> > >>>>
> > >>>>
> > >>>>           final Map<String, String> inStr = new HashMap<>();
> > >>>> @@ -970,12 +970,12 @@ public class MapUtilsTest extends
> > >>>> AbstractAvailableLocalesTest {
> > >>>>           final Map<String, Float> in = new HashMap<>();
> > >>>>           in.put("key", 2.0f);
> > >>>>
> > >>>> -        assertEquals(MapUtils.getFloatValue(in,"key", 0.0f), 2.0,
> > 0);
> > >>>> -        assertEquals(MapUtils.getFloatValue(in,"key"), 2.0, 0);
> > >>>> -        assertEquals(MapUtils.getFloatValue(in,"noKey", 1.0f),
> 1.0,
> > >>>> 0);
> > >>>> -        assertEquals(MapUtils.getFloatValue(in,"noKey"), 0, 0);
> > >>>> -        assertEquals(MapUtils.getFloat(in,"key", 0.0f), 2.0, 0);
> > >>>> -        assertEquals(MapUtils.getFloat(in,"noKey", 1.0f), 1.0,
0);
> > >>>> +        assertEquals(2.0, MapUtils.getFloatValue(in,"key", 0.0f),
> > 0);
> > >>>> +        assertEquals(2.0, MapUtils.getFloatValue(in,"key"), 0);
> > >>>> +        assertEquals(1.0, MapUtils.getFloatValue(in,"noKey",
> 1.0f),
> > >>>> 0);
> > >>>> +        assertEquals(0, MapUtils.getFloatValue(in,"noKey"), 0);
> > >>>> +        assertEquals(2.0, MapUtils.getFloat(in,"key", 0.0f), 0);
> > >>>> +        assertEquals(1.0, MapUtils.getFloat(in,"noKey", 1.0f),
0);
> > >>>>
> > >>>>           final Map<String, String> inStr = new HashMap<>();
> > >>>>           char decimalSeparator = getDecimalSeparator();
> > >>>> @@ -989,12 +989,12 @@ public class MapUtilsTest extends
> > >>>> AbstractAvailableLocalesTest {
> > >>>>           final Map<String, Long> in = new HashMap<>();
> > >>>>           in.put("key", 2L);
> > >>>>
> > >>>> -        assertEquals(MapUtils.getLongValue(in,"key", 0L), 2.0,
0);
> > >>>> -        assertEquals(MapUtils.getLongValue(in,"key"), 2.0, 0);
> > >>>> -        assertEquals(MapUtils.getLongValue(in,"noKey", 1L), 1,
0);
> > >>>> -        assertEquals(MapUtils.getLongValue(in,"noKey"), 0, 0);
> > >>>> -        assertEquals(MapUtils.getLong(in,"key", 0L), 2.0, 0);
> > >>>> -        assertEquals(MapUtils.getLong(in,"noKey", 1L), 1, 0);
> > >>>> +        assertEquals(2.0, MapUtils.getLongValue(in,"key", 0L),
0);
> > >>>> +        assertEquals(2.0, MapUtils.getLongValue(in,"key"), 0);
> > >>>> +        assertEquals(1, MapUtils.getLongValue(in,"noKey", 1L),
0);
> > >>>> +        assertEquals(0, MapUtils.getLongValue(in,"noKey"), 0);
> > >>>> +        assertEquals(2.0, MapUtils.getLong(in,"key", 0L), 0);
> > >>>> +        assertEquals(1, MapUtils.getLong(in,"noKey", 1L), 0);
> > >>>>
> > >>>>           final Map<String, String> inStr = new HashMap<>();
> > >>>>           inStr.put("str1", "2");
> > >>>> @@ -1009,12 +1009,12 @@ public class MapUtilsTest extends
> > >>>> AbstractAvailableLocalesTest {
> > >>>>           final Map<String, Integer> in = new HashMap<>();
> > >>>>           in.put("key", 2);
> > >>>>
> > >>>> -        assertEquals(MapUtils.getIntValue(in,"key", 0), 2, 0);
> > >>>> -        assertEquals(MapUtils.getIntValue(in,"key"), 2, 0);
> > >>>> -        assertEquals(MapUtils.getIntValue(in,"noKey", 0), 0, 0);
> > >>>> -        assertEquals(MapUtils.getIntValue(in,"noKey"), 0, 0);
> > >>>> -        assertEquals(MapUtils.getInteger(in,"key", 0), 2, 0);
> > >>>> -        assertEquals(MapUtils.getInteger(in,"noKey", 0), 0, 0);
> > >>>> +        assertEquals(2, MapUtils.getIntValue(in,"key", 0), 0);
> > >>>> +        assertEquals(2, MapUtils.getIntValue(in,"key"), 0);
> > >>>> +        assertEquals(0, MapUtils.getIntValue(in,"noKey", 0), 0);
> > >>>> +        assertEquals(0, MapUtils.getIntValue(in,"noKey"), 0);
> > >>>> +        assertEquals(2, MapUtils.getInteger(in,"key", 0), 0);
> > >>>> +        assertEquals(0, MapUtils.getInteger(in,"noKey", 0), 0);
> > >>>>
> > >>>>           final Map<String, String> inStr = new HashMap<>();
> > >>>>           inStr.put("str1", "2");
> > >>>> @@ -1028,12 +1028,12 @@ public class MapUtilsTest extends
> > >>>> AbstractAvailableLocalesTest {
> > >>>>           final short val = 10;
> > >>>>           in.put("key", val);
> > >>>>
> > >>>> -        assertEquals(MapUtils.getShortValue(in,"key", val), val,
> 0);
> > >>>> -        assertEquals(MapUtils.getShortValue(in,"key"), val, 0);
> > >>>> -        assertEquals(MapUtils.getShortValue(in,"noKey", val),
val,
> > 0);
> > >>>> -        assertEquals(MapUtils.getShortValue(in,"noKey"), 0, 0);
> > >>>> -        assertEquals(MapUtils.getShort(in,"key", val), val, 0);
> > >>>> -        assertEquals(MapUtils.getShort(in,"noKey", val), val,
0);
> > >>>> +        assertEquals(val, MapUtils.getShortValue(in,"key", val),
> 0);
> > >>>> +        assertEquals(val, MapUtils.getShortValue(in,"key"), 0);
> > >>>> +        assertEquals(val, MapUtils.getShortValue(in,"noKey", val),
> > 0);
> > >>>> +        assertEquals(0, MapUtils.getShortValue(in,"noKey"), 0);
> > >>>> +        assertEquals(val, MapUtils.getShort(in,"key", val), 0);
> > >>>> +        assertEquals(val,MapUtils.getShort(in,"noKey", val), 0);
> > >>>>
> > >>>>           final Map<String, String> inStr = new HashMap<>();
> > >>>>           inStr.put("str1", "10");
> > >>>> @@ -1047,12 +1047,12 @@ public class MapUtilsTest extends
> > >>>> AbstractAvailableLocalesTest {
> > >>>>           final byte val = 100;
> > >>>>           in.put("key", val);
> > >>>>
> > >>>> -        assertEquals(MapUtils.getByteValue(in,"key", val), val,
> 0);
> > >>>> -        assertEquals(MapUtils.getByteValue(in,"key"), val, 0);
> > >>>> -        assertEquals(MapUtils.getByteValue(in,"noKey", val), val,
> > 0);
> > >>>> -        assertEquals(MapUtils.getByteValue(in,"noKey"), 0, 0);
> > >>>> -        assertEquals(MapUtils.getByte(in,"key", val), val, 0);
> > >>>> -        assertEquals(MapUtils.getByte(in,"noKey", val), val, 0);
> > >>>> +        assertEquals(val, MapUtils.getByteValue(in,"key", val),
> 0);
> > >>>> +        assertEquals(val, MapUtils.getByteValue(in,"key"), 0);
> > >>>> +        assertEquals(val, MapUtils.getByteValue(in,"noKey", val),
> > 0);
> > >>>> +        assertEquals(0, MapUtils.getByteValue(in,"noKey"), 0);
> > >>>> +        assertEquals(val, MapUtils.getByte(in,"key", val), 0);
> > >>>> +        assertEquals(val, MapUtils.getByte(in,"noKey", val), 0);
> > >>>>
> > >>>>
> > >>>>           final Map<String, String> inStr = new HashMap<>();
> > >>>> @@ -1067,8 +1067,8 @@ public class MapUtilsTest extends
> > >>>> AbstractAvailableLocalesTest {
> > >>>>           final Number val = 1000;
> > >>>>           in.put("key", val);
> > >>>>
> > >>>> -        assertEquals(MapUtils.getNumber(in,"key", val).intValue(),
> > >>>> val.intValue(), 0);
> > >>>> -        assertEquals(MapUtils.getNumber(in,"noKey",
> val).intValue(),
> > >>>> val.intValue(), 0);
> > >>>> +        assertEquals(val.intValue(), MapUtils.getNumber(in,"key",
> > >>>> val).intValue(), 0);
> > >>>> +        assertEquals(val.intValue(), MapUtils.getNumber(in,"noKey",
> > >>>> val).intValue(), 0);
> > >>>>
> > >>>>       }
> > >>>>
> > >>>> @@ -1077,11 +1077,11 @@ public class MapUtilsTest extends
> > >>>> AbstractAvailableLocalesTest {
> > >>>>           final Map<String, String> in = new HashMap<>();
> > >>>>           in.put("key", "str");
> > >>>>
> > >>>> -        assertEquals(MapUtils.getString(in,"key", "defualt"),
> > "str");
> > >>>> -        assertEquals(MapUtils.getString(in,"key"), "str");
> > >>>> -        assertEquals(MapUtils.getString(null,"key"), null);
> > >>>> -        assertEquals(MapUtils.getString(in,"noKey", "default"),
> > >>>> "default");
> > >>>> -        assertEquals(MapUtils.getString(null,"noKey", "default"),
> > >>>> "default");
> > >>>> +        assertEquals("str", MapUtils.getString(in,"key",
> "defualt"));
> > >>>> +        assertEquals("str", MapUtils.getString(in,"key"));
> > >>>> +        assertEquals(null, MapUtils.getString(null,"key"));
> > >>>> +        assertEquals("default", MapUtils.getString(in,"noKey",
> > >>>> "default"));
> > >>>> +        assertEquals("default", MapUtils.getString(null,"noKey",
> > >>>> "default"));
> > >>>>
> > >>>>       }
> > >>>>
> > >>>> @@ -1090,11 +1090,11 @@ public class MapUtilsTest extends
> > >>>> AbstractAvailableLocalesTest {
> > >>>>           final Map<String, Object> in = new HashMap<>();
> > >>>>           in.put("key", "str");
> > >>>>
> > >>>> -        assertEquals(MapUtils.getObject(in,"key", "defualt"),
> > "str");
> > >>>> -        assertEquals(MapUtils.getObject(in,"key"), "str");
> > >>>> -        assertEquals(MapUtils.getObject(null,"key"), null);
> > >>>> -        assertEquals(MapUtils.getObject(in,"noKey", "default"),
> > >>>> "default");
> > >>>> -        assertEquals(MapUtils.getObject(null,"noKey", "default"),
> > >>>> "default");
> > >>>> +        assertEquals("str", MapUtils.getObject(in,"key",
> "defualt"));
> > >>>> +        assertEquals("str", MapUtils.getObject(in,"key"));
> > >>>> +        assertEquals(null, MapUtils.getObject(null,"key"));
> > >>>> +        assertEquals("default", MapUtils.getObject(in,"noKey",
> > >>>> "default"));
> > >>>> +        assertEquals("default", MapUtils.getObject(null,"noKey",
> > >>>> "default"));
> > >>>>
> > >>>>       }
> > >>>>
> > >>>> @@ -1109,7 +1109,7 @@ public class MapUtilsTest extends
> > >>>> AbstractAvailableLocalesTest {
> > >>>>           assertTrue(!MapUtils.getBooleanValue(in,"noKey"));
> > >>>>           assertTrue(MapUtils.getBoolean(in,"key", true));
> > >>>>           assertTrue(MapUtils.getBoolean(in,"noKey", true));
> > >>>> -        assertEquals(MapUtils.getBoolean(null,"noKey"),null);
> > >>>> +        assertEquals(null, MapUtils.getBoolean(null,"noKey"));
> > >>>>
> > >>>>
> > >>>>
> > >>>> @@ -1130,10 +1130,10 @@ public class MapUtilsTest extends
> > >>>> AbstractAvailableLocalesTest {
> > >>>>           in.put("key1", valMap);
> > >>>>           final Map<?, ?> outValue =  MapUtils.getMap(in,"key1",
> > null);
> > >>>>
> > >>>> -        assertEquals( outValue.get("key1"), "value1");
> > >>>> -        assertEquals( outValue.get("key2"), null);
> > >>>> -        assertEquals( MapUtils.getMap(in,"key2", null), null);
> > >>>> -        assertEquals( MapUtils.getMap(null,"key2", null), null);
> > >>>> +        assertEquals("value1", outValue.get("key1"));
> > >>>> +        assertEquals(null, outValue.get("key2"));
> > >>>> +        assertEquals(null, MapUtils.getMap(in,"key2", null));
> > >>>> +        assertEquals(null, MapUtils.getMap(null,"key2", null));
> > >>>>       }
> > >>>>
> > >>>>       @Test
> > >>>> @@ -1143,8 +1143,8 @@ public class MapUtilsTest extends
> > >>>> AbstractAvailableLocalesTest {
> > >>>>
> > >>>>           MapUtils.safeAddToMap(inMap,"key1", "value1");
> > >>>>           MapUtils.safeAddToMap(inMap,"key2", null);
> > >>>> -        assertEquals( inMap.get("key1"), "value1");
> > >>>> -        assertEquals( inMap.get("key2"), "");
> > >>>> +        assertEquals("value1", inMap.get("key1"));
> > >>>> +        assertEquals("", inMap.get("key2"));
> > >>>>       }
> > >>>>
> > >>>>       @Test
> > >>>>
> > >>>>
> > >>>>
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> > > For additional commands, e-mail: dev-help@commons.apache.org
> > >
> > >
> >
>
>
>
> --
> Matt Sicker <boards@gmail.com>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message