Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
a-i-ks opened this issue Sep 30, 2019 · 0 comments
Open

Comments

@a-i-ks
Copy link

a-i-ks commented Sep 30, 2019

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.

@orien orien changed the title hasValidGettersAndSetters is not working for maps Support getters returning proxy objects (Collections.unmodifiableMap) Jan 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants