API: Serialization using Builder pattern ( lombok) in rest assured

References:

https://medium.com/@hudsonmendes/immutable-the-builder-pattern-vs-messy-pojos-or-pocos-e6b5be894a9d

https://medium.com/@ajinkyabadve/builder-design-patterns-in-java-1ffb12648850

Ignoring NULL (optional field) while making POJO:

Option 1 : (Recommended) To add in class level
@JsonInclude(JsonInclude.Include.NON_NULL)
* This is best suitable while using Lombok and builder pattern

Option 2 : To add in Getter level
@JsonInclude(Include.NON_NULL)
* This is only suitable while using without lombok and only with builder pattern

Error: Lombok 1.18.12 does not compile well with maven compiler 3.8.1.
So downgrade lombok to 1.16.6

Note: This lombok feature is now already available java 14 as built -in feature

Leave a Reply