Skip to content

How to test class with 'simple' inner class #240

@boly38

Description

@boly38

Hi

I would like to use PoJo tester 0.7.6 to test the following class:
(I'm using Lombok annotations too)

@Data
@Builder
@EqualsAndHashCode
public class Questionnaire {
    private String questionnaireId;
    private String id;
    private String label;
    private String text;
    private String comment;
    private List<String> tags;
    private Answer answer;

    @Data
    @Builder
    @EqualsAndHashCode
    public static class Answer {
        String type;
        List<String> options;
    }
}

I doubt that this class is no more a strict PoJo but I would like to use pojo tester if feasible.

So In my test I'm calling assertPojoMethodsFor(Questionnaire.class.getName()).areWellImplemented();

As result I've:

16:31:22.823 [main] DEBUG pl.pojo.tester.internal.field.AbstractFieldValueChanger - Could not change value 'Questionnaire.Answer(type=www.pojo.pl, options=[])' ot type class Questionnaire$Answer by any field value changer
16:31:22.823 [main] DEBUG pl.pojo.tester.internal.instantiator.ObjectGenerator - End of generating different objects (size=128) for base class Questionnaire(questionnaireId,id,label,text,comment,tags,answer) 

pl.pojo.tester.internal.assertion.equals.NotEqualEqualsAssertionError: 


Class Questionnaire has bad 'equals' method implementation.
The equals method should return false if objects should not be equal.
Current implementation returns true.
Object:
Questionnaire(questionnaireId=www.pojo.pl, id=www.pojo.pl, label=www.pojo.pl, text=www.pojo.pl, comment=www.pojo.pl, tags=[], answer=Questionnaire.Answer(type=www.pojo.pl, options=[]))
should not be equal to:
Questionnaire(questionnaireId=www.pojo.pl, id=www.pojo.pl, label=www.pojo.pl, text=www.pojo.pl, comment=www.pojo.pl, tags=[], answer=Questionnaire.Answer(type=www.pojo.pl, options=[]))

I think I do need to add a field value changer for my inner class
How can I do that ?

I would like to ask this on rocketChat or check the documentation but pojo.pl domain is unavailable at all.

Thanks
PS/ seems not exactly the same as #126

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