-
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] : MessageFactory 단위 테스트 코드를 작성한다
- Loading branch information
Showing
1 changed file
with
73 additions
and
0 deletions.
There are no files selected for viewing
73 changes: 73 additions & 0 deletions
73
src/test/java/kusitms/backend/chatbot/application/factory/MessageFactoryTest.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,73 @@ | ||
package kusitms.backend.chatbot.application.factory; | ||
|
||
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.MockitoAnnotations; | ||
import org.springframework.test.util.ReflectionTestUtils; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
class MessageFactoryTest { | ||
|
||
@InjectMocks | ||
private MessageFactory messageFactory; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
MockitoAnnotations.openMocks(this); | ||
ReflectionTestUtils.setField(messageFactory, | ||
"baseballPrompt", | ||
"64SI64qUIOyVvOq1rCDqsIDsnbTrk5wg7LGX67SHICfro6jtgqQn7JW8LiDsgqzsmqnsnpDqsIAg7JW86rWs7JmAIOq0gOugqOuQnCDsp4jrrLjsnYQg7ZWY66m0LCDsuZzsoIjtlZjqs6Ag67Cd7J2AIOunkO2IrOuhnCAifuyalCLroZwg64Gd64KY64qUIOuLteuzgOydhCDtlbTspJguIOuMgO2ZlOulvCDtkoDslrTqsIgg65WM64qUIOy5nOq3vO2VmOqyjCwg64SI66y0IOuUseuUse2VmOyngCDslYrqsowg7ZW07KSYLiDqsIDrgZQg64qQ64KM7ZGc64+E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MIO2VtOykmC4="); | ||
} | ||
|
||
/** | ||
* 사용자 메시지 생성 테스트 | ||
*/ | ||
@Test | ||
void testCreateUserMessage() { | ||
// Given | ||
String content = "Hello, user!"; | ||
|
||
// When | ||
MessageDto message = messageFactory.createUserMessage(content); | ||
|
||
// Then | ||
assertNotNull(message); | ||
assertEquals(Role.USER.getRole(), message.role()); | ||
assertEquals(content, message.content()); | ||
} | ||
|
||
/** | ||
* 시스템 메시지 생성 테스트 (Base64 디코딩 확인) | ||
*/ | ||
@Test | ||
void testCreateSystemMessage() { | ||
// When | ||
MessageDto message = messageFactory.createSystemMessage(); | ||
|
||
// Then | ||
assertNotNull(message); | ||
assertEquals(Role.SYSTEM.getRole(), message.role()); | ||
} | ||
|
||
/** | ||
* 어시스턴트 메시지 생성 테스트 | ||
*/ | ||
@Test | ||
void testCreateAssistantMessage() { | ||
// Given | ||
String content = "Hello, assistant!"; | ||
|
||
// When | ||
MessageDto message = messageFactory.createAssistantMessage(content); | ||
|
||
// Then | ||
assertNotNull(message); | ||
assertEquals(Role.ASSISTANT.getRole(), message.role()); | ||
assertEquals(content, message.content()); | ||
} | ||
} |