Skip to content

Commit

Permalink
Fix map assertion in TestLazyMap
Browse files Browse the repository at this point in the history
`org.testng.Assert.assertEquals(Map, Map)` does not really check  map
equality when the actual map contains null values.

Migrate to AssertJ and fix the test.
  • Loading branch information
findepi committed Jan 10, 2024
1 parent d86d5ab commit 6174c79
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import static org.apache.hadoop.hive.serde2.lazy.LazyFactory.createLazyObject;
import static org.apache.hadoop.hive.serde2.lazy.objectinspector.LazyObjectInspectorFactory.getLazySimpleMapObjectInspector;
import static org.apache.hadoop.hive.serde2.lazy.objectinspector.primitive.LazyPrimitiveObjectInspectorFactory.getLazyStringObjectInspector;
import static org.testng.Assert.assertEquals;
import static org.assertj.core.api.Assertions.assertThat;

public class TestLazyMap
{
Expand All @@ -45,7 +45,7 @@ public void test()
assertMapDecode("\\N\u0003ignored\u0002\u0003", ImmutableMap.of(lazyString(""), lazyString("")));

HashMap<Object, Object> expectedMap = new HashMap<>();
expectedMap.put("null", null);
expectedMap.put(lazyString("null"), null);
assertMapDecode("\\N\u0003ignored\u0002null\u0003\\N", expectedMap);
}

Expand All @@ -63,7 +63,7 @@ public static void assertMapDecode(String encodedMap, Map<? extends Object, ? ex
lazyMap.init(newByteArrayRef(encodedMap), 0, encodedMap.length());

Map<Object, Object> map = lazyMap.getMap();
assertEquals(map, expectedMap);
assertThat(map).isEqualTo(expectedMap);
}

private static LazyString lazyString(String string)
Expand Down

0 comments on commit 6174c79

Please sign in to comment.