ํจํค์ง, ์์ค์ฝ๋ ๋ฆฌํฉํ ๋ง ํ restdocs๋ฅผ ๋ฆฌํฉํ ๋ง ํ๋ ค๋๋ฐ ๋ค์๊ณผ ๊ฐ์ ์ค๋ฅ๊ฐ ๋ฌ๋ค.
com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class com.objects.marketbridge.order.controller.dto.ConfirmCancelReturnHttp$Request and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS)
at com.fasterxml.jackson.databind.exc.InvalidDefinitionException.from(InvalidDefinitionException.java:77)
at com.fasterxml.jackson.databind.SerializerProvider.reportBadDefinition(SerializerProvider.java:1308)
at com.fasterxml.jackson.databind.DatabindContext.reportBadDefinition(DatabindContext.java:414)
at com.fasterxml.jackson.databind.ser.impl.UnknownSerializer.failForEmpty(UnknownSerializer.java:53)
at com.fasterxml.jackson.databind.ser.impl.UnknownSerializer.serialize(UnknownSerializer.java:30)
at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider._serialize(DefaultSerializerProvider.java:479)
at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:318)
at com.fasterxml.jackson.databind.ObjectMapper._writeValueAndClose(ObjectMapper.java:4719)
at com.fasterxml.jackson.databind.ObjectMapper.writeValueAsString(ObjectMapper.java:3964)
at com.objects.marketbridge.order.controller.docs.OrderCancelReturnControllerRestDocsTest.confirmCancelReturn(OrderCancelReturnControllerRestDocsTest.java:126)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
์๋ฌ์ ๊ฒ์ด ๋ซ์ง๋ง ์ฐพ์๋ณด๋ ๋ณ๊ฑฐ ์๋์๋ค. ๊ธฐ๋ณธ์์ฑ์๊ฐ ์๊ธฐ ๋๋ฌธ์ด์๋ค.
@Getter
@NoArgsConstructor
public static class Request {
@NotNull
private String orderNo;
@NotNull
private String cancelReason;
@Builder
public Request(String orderNo, String cancelReason) {
this.orderNo = orderNo;
this.cancelReason = cancelReason;
}
public ConfirmCancelReturnDto.Request toServiceRequest() {
return ConfirmCancelReturnDto.Request.builder()
.orderNo(orderNo)
.cancelReason(cancelReason)
.build();
}
}
๊ธฐ์กด์ ์์๋ @NoArgsConstructor๋ฅผ ์ถ๊ฐํ์ฌ ๊ธฐ๋ณธ ์์ฑ์๋ฅผ ๋ง๋ค์ด ์ฃผ์๋ค!