๐Ÿ“Œ [MarketBridge] 08. ๊ฐœ๋ฐœ์ผ์ง€ - RestDoct ์ž‘์„ฑ ์ค‘ ์˜ค๋ฅ˜ [com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class...]

๋ชจ๊น…ยท2024๋…„ 2์›” 5์ผ
0

๊ฐœ๋ฐœ์ผ์ง€ - MarketBridge

๋ชฉ๋ก ๋ณด๊ธฐ
8/8
post-thumbnail
post-custom-banner

๐Ÿ“– RestDocs ์ž‘์„ฑ ์ค‘ serializer ์—๋Ÿฌ ๋ฐœ์ƒ!

ํŒจํ‚ค์ง€, ์†Œ์Šค์ฝ”๋“œ ๋ฆฌํŒฉํ† ๋ง ํ›„ 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๋ฅผ ์ถ”๊ฐ€ํ•˜์—ฌ ๊ธฐ๋ณธ ์ƒ์„ฑ์ž๋ฅผ ๋งŒ๋“ค์–ด ์ฃผ์—ˆ๋‹ค!

profile
๋ฉˆ์ถ”์ง€ ์•Š๊ธฐ
post-custom-banner

0๊ฐœ์˜ ๋Œ“๊ธ€