Skip to content

Invalid getter/setter if using @Accessors(chain = true) #142

@in3des

Description

@in3des

Hi,
It comes out there is an issue if you are using Lombok annotation @Accessors(chain = true).
Tests couldn't pass and give the following error:
bean with valid setter and getter methods for all properties bean of type "..." had an invalid getter/setter for the property "..."

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
public class KeyValue {
    private String key;
    private String value;
}

If remove it - then everything works just fine.
But I hope there is possibility to add some extra options or settings, so it could also work with this annotation.

Thanks!

simple test itself

import static com.google.code.beanmatchers.BeanMatchers.*;
import static org.hamcrest.CoreMatchers.allOf;
import static org.hamcrest.MatcherAssert.assertThat;

class KVTest {

    @Test
    void testBean() {
        assertThat(KeyValue.class, allOf(
                hasValidBeanConstructor(),
                hasValidGettersAndSetters(),
                hasValidBeanHashCode(),
                hasValidBeanEquals(),
                hasValidBeanToString()
        ));
    }
}

PS.
only one assertion works so far... ((

    @Test
    void testBean() {
        assertThat(KeyValue.class, allOf(
                hasValidBeanConstructor()
//                hasValidGettersAndSetters(),
//                hasValidBeanHashCode(),
//                hasValidBeanEquals(),
//                hasValidBeanToString()
        ));
    }

these three hasValidBeanHashCode(), hasValidBeanEquals(), hasValidBeanToString()
produce com.google.code.beanmatchers.AccessorMissingException: missing setter for the property key

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions