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

后端 未结 8 1260
一整个雨季
一整个雨季 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:25

    Here is the solution I eventually ended up using which worked perfectly for unit testing purposes.

    for(Map.Entry entry : questionMap.entrySet()) {
        assertReflectionEquals(entry.getValue(), expectedQuestionMap.get(entry.getKey()), ReflectionComparatorMode.LENIENT_ORDER);
    }
    

    This involves invoking assertReflectionEquals() from the unitils package.

    
        org.unitils
        unitils-core
        3.3
        test
    
    

提交回复
热议问题