@@ -73,28 +73,29 @@ void initializeSchemaEmbeddedDefault() {
73
73
74
74
@ Test
75
75
void useAutoConfiguredJdbcChatMemoryRepository () {
76
- this .contextRunner .run (context -> {
77
- var chatMemoryRepository = context .getBean (JdbcChatMemoryRepository .class );
78
- var conversationId = UUID .randomUUID ().toString ();
79
- var userMessage = new UserMessage ("Message from the user" );
76
+ this .contextRunner .withPropertyValues ("spring.ai.chat.memory.repository.jdbc.initialize-schema=always" )
77
+ .run (context -> {
78
+ var chatMemoryRepository = context .getBean (JdbcChatMemoryRepository .class );
79
+ var conversationId = UUID .randomUUID ().toString ();
80
+ var userMessage = new UserMessage ("Message from the user" );
80
81
81
- chatMemoryRepository .saveAll (conversationId , List .of (userMessage ));
82
+ chatMemoryRepository .saveAll (conversationId , List .of (userMessage ));
82
83
83
- assertThat (chatMemoryRepository .findByConversationId (conversationId )).hasSize (1 );
84
- assertThat (chatMemoryRepository .findByConversationId (conversationId )).isEqualTo (List .of (userMessage ));
84
+ assertThat (chatMemoryRepository .findByConversationId (conversationId )).hasSize (1 );
85
+ assertThat (chatMemoryRepository .findByConversationId (conversationId )).isEqualTo (List .of (userMessage ));
85
86
86
- chatMemoryRepository .deleteByConversationId (conversationId );
87
+ chatMemoryRepository .deleteByConversationId (conversationId );
87
88
88
- assertThat (chatMemoryRepository .findByConversationId (conversationId )).isEmpty ();
89
+ assertThat (chatMemoryRepository .findByConversationId (conversationId )).isEmpty ();
89
90
90
- var multipleMessages = List .<Message >of (new UserMessage ("Message from the user 1" ),
91
- new AssistantMessage ("Message from the assistant 1" ));
91
+ var multipleMessages = List .<Message >of (new UserMessage ("Message from the user 1" ),
92
+ new AssistantMessage ("Message from the assistant 1" ));
92
93
93
- chatMemoryRepository .saveAll (conversationId , multipleMessages );
94
+ chatMemoryRepository .saveAll (conversationId , multipleMessages );
94
95
95
- assertThat (chatMemoryRepository .findByConversationId (conversationId )).hasSize (multipleMessages .size ());
96
- assertThat (chatMemoryRepository .findByConversationId (conversationId )).isEqualTo (multipleMessages );
97
- });
96
+ assertThat (chatMemoryRepository .findByConversationId (conversationId )).hasSize (multipleMessages .size ());
97
+ assertThat (chatMemoryRepository .findByConversationId (conversationId )).isEqualTo (multipleMessages );
98
+ });
98
99
}
99
100
100
101
@ Test
0 commit comments