From 5bd44857875cb6ca2be3d4f9aa2fee9280733e0e Mon Sep 17 00:00:00 2001 From: bbbang105 <2018111366@dgu.ac.kr> Date: Wed, 27 Nov 2024 20:33:43 +0900 Subject: [PATCH] =?UTF-8?q?#92=20[feat]=20:=20ClovaRequestFactory=20?= =?UTF-8?q?=EB=8B=A8=EC=9C=84=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=EB=A5=BC=20=EC=9E=91=EC=84=B1=ED=95=9C=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../factory/ClovaRequestFactoryTest.java | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 src/test/java/kusitms/backend/chatbot/application/factory/ClovaRequestFactoryTest.java diff --git a/src/test/java/kusitms/backend/chatbot/application/factory/ClovaRequestFactoryTest.java b/src/test/java/kusitms/backend/chatbot/application/factory/ClovaRequestFactoryTest.java new file mode 100644 index 0000000..62e1ade --- /dev/null +++ b/src/test/java/kusitms/backend/chatbot/application/factory/ClovaRequestFactoryTest.java @@ -0,0 +1,53 @@ +package kusitms.backend.chatbot.application.factory; + +import kusitms.backend.chatbot.application.dto.request.ChatbotRequestDto; +import kusitms.backend.chatbot.application.dto.request.ClovaRequestDto; +import kusitms.backend.chatbot.application.dto.request.MessageDto; +import kusitms.backend.chatbot.domain.enums.Role; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.mockito.Mockito.when; + +class ClovaRequestFactoryTest { + + @InjectMocks + private ClovaRequestFactory clovaRequestFactory; + + @Mock + private MessageFactory messageFactory; + + @BeforeEach + void setUp() { + MockitoAnnotations.openMocks(this); + } + + /** + * ClovaRequestFactory의 createClovaRequest 메서드 테스트 + */ + @Test + void testCreateClovaRequest() { + // Given + MessageDto systemMessage = new MessageDto(Role.SYSTEM.getRole(), "System message content"); + when(messageFactory.createSystemMessage()).thenReturn(systemMessage); + + // When + ChatbotRequestDto chatbotRequest = clovaRequestFactory.createClovaRequest(); + + // Then + assertNotNull(chatbotRequest); + assertEquals(1, chatbotRequest.getMessages().size()); + assertEquals(systemMessage, chatbotRequest.getMessages().get(0)); + + ClovaRequestDto clovaRequest = (ClovaRequestDto) chatbotRequest; + assertEquals(0.8, clovaRequest.topP()); + assertEquals(0.3, clovaRequest.temperature()); + assertEquals(256, clovaRequest.maxTokens()); + assertEquals(5.0, clovaRequest.repeatPenalty()); + } +}