Простой класс, например:
Код: Выделить всё
@SuperBuilder
@Data
@Setter
@Jacksonized
@JsonIgnoreProperties(ignoreUnknown = true)
Public Class Blurb {
String field1;
String field2;
String field3;
}
Код: Выделить всё
Blurb blurb = blurb.builder().build();
System.out.println(blurb);
restServiceServerMock
.expect(manyTimes(), request to("some-url")
.andExpect(header(set a header))
.andExpect(method(HTTPMethod.POST))
.andExpect(content.json("{'field':'value'}"))
.andRespond(withSuccess("%s".formatted(blurb), MediaType.APPLICATION.JSON
somemethodwhichticklestherestservice
Код: Выделить всё
JSONParseException Unrecognised token 'Blurb' was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false'Код: Выделить всё
{
"field1" : null,
"field2" : null,
"field3" : null
}
Код: Выделить всё
System.out.println(blurb)
Код: Выделить всё
Blurb(field1=null,field2=null,field3=null)
Подробнее здесь: https://stackoverflow.com/questions/787 ... -unit-test
Мобильная версия