-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#92 [feat] : ClovaRequestFactory 단위 테스트 코드를 작성한다
- Loading branch information
Showing
1 changed file
with
53 additions
and
0 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
src/test/java/kusitms/backend/chatbot/application/factory/ClovaRequestFactoryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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()); | ||
} | ||
} |