'Junit5 returning Map from @MethodSource annotation

I'm using @MethodSource annotation on my Junit test case in order to receive from another method a Map<String, Object>.

Seems that @MethodSource cannot support "Map" object.

This is the error I received: org.junit.platform.commons.PreconditionViolationException: Cannot convert instance of java.util.HashMap into a Stream: {1=Obj1, 2=Obj2}

Do you know if there is a way to receive back a "Map" object like in this example?

@ParameterizedTest
@MethodSource("hashMapProvider")
void testMyMapObj(Map<String, Object> argument) {
    assertNotNull(argument);
    Object obj1 = argument.get("1");
}


static Map<String, Object> hashMapProvider() {
    Map<String, Object> map = new HashMap<>();
    map.put("1", "Obj1");
    map.put("2", "Obj2");
    return map;
 }


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source