error creating class Getter and Setter with Pojo

29 views
Skip to first unread message

Marcelo Esperandio Lucio

unread,
Dec 15, 2023, 5:34:12 PM12/15/23
to REST assured
Guys, I'm learning to work with setter and getter, but I got a Json that was too complex for me.

can you help me?

It's a request that I need to send, the Json is the one below.

{
  "properties": {
    "headers": {
      "eventLayout": "qa",
      "eventReferenceDate": "2021-09-22"
    }
  },
  "routing_key": "tvm.teste.teste.UPDATED",
  "payload": "string",
  "payload_encoding": "string"
}

it has two objects, but whenever I go to create and run the test, I receive bad-Request because I didn't provide the complete json, following the structure below.

{
  "properties": {
    "headers": {etc...}

Here's how I implemented my code.

package com.automation.models;

import com.fasterxml.jackson.annotation.JsonProperty;

public class PostRequestPojo {

public static class Properties {
private Headers headers;

public Properties() {
}

public Properties(Headers headers) {
this.headers = headers;
}

public Headers getHeaders() {
return headers;
}

public void setHeaders(Headers headers) {
this.headers = headers;
}
}

@JsonProperty("eventLayout")
public String eventLayout;

public String getEventLayout() {
return eventLayout;
}

public void setEventLayout(String eventLayout) {
this.eventLayout = eventLayout;
}

@JsonProperty("eventReferenceDate")
public String eventReferenceDate;

public String getEventReferenceDate() {
return eventReferenceDate;
}

public void setEventReferenceDate(String eventReferenceDate) {
this.eventReferenceDate = eventReferenceDate;
}

@JsonProperty("routing_key")
public String routing_key;

public String getRouting_key() {
return routing_key;
}

public void setRouting_key(String routing_key) {
this.routing_key = routing_key;
}

@JsonProperty("payload")
public String payload;

public String getPayload() {
return payload;
}

public void setPayload(String payload) {
this.payload = payload;
}

@JsonProperty("payload_encoding")
public String payload_encoding;

public String payload_encoding() {
return payload_encoding;
}

public void payload_encoding(String payload_encoding) {
this.payload_encoding = payload_encoding;
}

public PostRequestPojo() {
"properties":{
"headers":{
eventLayout = "qa",
eventReferenceDate = "2021-09-22";
}
} ;
routing_key = "UPDATED";
payload = "string";
payload_encoding = "string";

}
}

Michael Pinnegar

unread,
Dec 15, 2023, 7:19:40 PM12/15/23
to rest-a...@googlegroups.com
I would ask this on stack overflow. This is really just a general question about Jackson not rest assured.

--
You received this message because you are subscribed to the Google Groups "REST assured" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rest-assured...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rest-assured/c0e5aafe-0693-42c4-9f74-943729ef2fcfn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages