Skip to content

Symmetry error - why? #519

Answered by jqno
tracylynne99 asked this question in Q&A
Oct 14, 2021 · 4 comments · 2 replies
Discussion options

You must be logged in to vote

I see it now.

CategoryItemEntity implements equals. But it overrides ChartEntity which also implements equals. That means that we're talking about a type that adds state. That's the hardest thing to get right with EqualsVerifier, unfortunately. I have a short bit about that on the website, but you've probably already read that. I have a Devoxx talk that goes into a little more depth, if you prefer video.

Basically, if you don't want to change the existing implementation of equals, you need to add .withRedefinedSuperclass() on the CategoryItemEntity test, and .withRedefinedSubclass(CategoryItemEntity.class) on the ChartEntity test.

Replies: 4 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@tracylynne99
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@tracylynne99
Comment options

Answer selected by tracylynne99
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants