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

Assertion hasNoNullFieldsOrProperties() throw error for delegate Map implementation #1759

Closed
amizurov opened this issue Jan 19, 2020 · 1 comment · Fixed by #1763
Closed
Assignees
Milestone

Comments

@amizurov
Copy link

Summary

We have some own classes with extra logic that implement Map interface but delegate invocation to backed HashMap. This is related commit 337f99e

Example

 @Test
    void expectedHasNoNullFieldsOrProperties() {
        DelegateMap map = new DelegateMap(new HashMap<>());
        Assertions.assertThat(map).hasNoNullFieldsOrProperties();
    }

    static class DelegateMap implements Map<String, String> {

        private final Map<String, String> delegate;

        public DelegateMap(Map<String, String> delegate) {
            this.delegate = delegate;
        }

        @Override
        public int size() {
            return delegate.size();
        }

        @Override
        public boolean isEmpty() {
            return delegate.isEmpty();
        }

        @Override
        public boolean containsKey(Object key) {
            return delegate.containsKey(key);
        }

        @Override
        public boolean containsValue(Object value) {
            return delegate.containsValue(value);
        }

        @Override
        public String get(Object key) {
            return delegate.get(key);
        }

        @Override
        public String put(String key, String value) {
            return delegate.put(key, value);
        }

        @Override
        public String remove(Object key) {
            return delegate.remove(key);
        }

        @Override
        public void putAll(Map<? extends String, ? extends String> m) {
            delegate.putAll(m);
        }

        @Override
        public void clear() {
            delegate.clear();
        }

        @Override
        public Set<String> keySet() {
            return delegate.keySet();
        }

        @Override
        public Collection<String> values() {
            return delegate.values();
        }

        @Override
        public Set<Entry<String, String>> entrySet() {
            return delegate.entrySet();
        }

        @Override
        public boolean equals(Object o) {
            return delegate.equals(o);
        }

        @Override
        public int hashCode() {
            return delegate.hashCode();
        }

        @Override
        public String getOrDefault(Object key, String defaultValue) {
            return delegate.getOrDefault(key, defaultValue);
        }

        @Override
        public void forEach(BiConsumer<? super String, ? super String> action) {
            delegate.forEach(action);
        }

        @Override
        public void replaceAll(BiFunction<? super String, ? super String, ? extends String> function) {
            delegate.replaceAll(function);
        }

        @Override
        public String putIfAbsent(String key, String value) {
            return delegate.putIfAbsent(key, value);
        }

        @Override
        public boolean remove(Object key, Object value) {
            return delegate.remove(key, value);
        }

        @Override
        public boolean replace(String key, String oldValue, String newValue) {
            return delegate.replace(key, oldValue, newValue);
        }

        @Override
        public String replace(String key, String value) {
            return delegate.replace(key, value);
        }

        @Override
        public String computeIfAbsent(String key, Function<? super String, ? extends String> mappingFunction) {
            return delegate.computeIfAbsent(key, mappingFunction);
        }

        @Override
        public String computeIfPresent(String key, BiFunction<? super String, ? super String, ? extends String> remappingFunction) {
            return delegate.computeIfPresent(key, remappingFunction);
        }

        @Override
        public String compute(String key, BiFunction<? super String, ? super String, ? extends String> remappingFunction) {
            return delegate.compute(key, remappingFunction);
        }

        @Override
        public String merge(String key, String value, BiFunction<? super String, ? super String, ? extends String> remappingFunction) {
            return delegate.merge(key, value, remappingFunction);
        }
    }
@joel-costigliola
Copy link
Member

Thanks for reporting this, we are going to look at it shortly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants