Java Test Automation / Quiz

POJOs on the Wire: Jackson, GSON, and .as()

Object in, JSON out, and back again. Serialization precedence, @JsonProperty mapping, and the unknown-field trap in deserialization.

Difficulty
Medium
Format
Quiz
Points
150
Estimate
9 min

// MISSION BRIEF

Your Mission

Hand RestAssured a POJO and it becomes JSON on the way out; call .as(User.class) and JSON becomes a typed object on the way in. Between those two moments sit the mapper libraries (Jackson, GSON) and their rules.

This quiz covers the round trip: who serializes, in what precedence, how field names map, and what breaks when the API grows a field your POJO has never met.

// FIRST CONTACT

Battle teaser

given().contentType(ContentType.JSON).body(bookingPojo) works because:

  1. ARestAssured serializes the POJO to JSON using a mapper it finds on the classpath (Jackson/GSON), no manual string building involved
  2. BPOJOs must pre-implement a toJson() interface
  3. CJava serialization (ObjectOutputStream) is used
  4. DIt calls toString() on the POJO
Answers, scoring, hints, and the full battle stay sealed.

// SKILL TAGS

javarestassuredserializationjackson