Skip to content

Support getters returning proxy objects (Collections.unmodifiableMap) #17

@a-i-ks

Description

@a-i-ks

Assuming I have the following DTO

class Foo {
  private Map<Integer, String> map = new LinkedHashMap<>();

  public Map<Integer, String> getMap() {
    return Collections.unmodifiableMap(map);
  }

  public void setMap(Map<Integer, String> map) {
    this.map = map != null ? Collections.unmodifiableMap(map) : Collections.emptyMap();
  }
}

The setters store an unmodifiable hash map and the getters return an unmodifiable copy of the map.

The method beanDoesNotHaveValidGetterAndSetterForProperty in AbstractBeanAccessorMatcher generates a Mockito Map and calls the setter of the class and then the getter.

The check testValue.equals(result) always evaluates to false.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions