How do I assert that two HashMap with Javabean values are equal?

后端 未结 8 1308
一整个雨季
一整个雨季 2021-02-13 18:45

I have two HashMap maps that I would like to compare. Question in this case is a Javabean I have written.

How do I ass

8条回答
  •  自闭症患者
    2021-02-13 19:28

    If your Question class implements equals then you can just do

    assertEquals(expectedMap, hashMap);
    
    assertTrue(expectedMap.equals(hashMap));
    

    The Map interface specifies that two Maps are equal if they contain equal elements for equal keys.

提交回复
热议问题