Testing entity classes in Spring Boot with @EqualsAndHashCode

I am creating a @Test class to test all entity classes and increase the coverage level. Right now I'm trying to test the @EqualsAndHashCode annotation but I'm having trouble doing it.

This is my entity class:

@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Table(schema = "public",  name = "view_absence_type")
public class AbsenceTypeView extends CodeBasedCatalogEntity {

    @Column(name = "doc_mandatory")
    private boolean docMandatory;


This is my @Test class:

    public void AbsenceTypeViewTest() {
        AbsenceTypeView obj = BeanBuilder.builder(AbsenceTypeView.class).createRandomBean();
        validateJson(obj, "doc_mandatory");

This is the problema:

enter image description here

enter image description here

My problem: How can I test the @EqualsAndHashCode annotation to fix the bug? What do I have to change in the test method?

Read more here: https://stackoverflow.com/questions/66532100/testing-entity-classes-in-spring-boot-with-equalsandhashcode

Content Attribution

This content was originally published by sinfryd95 at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: