3838import org .mockito .junit .jupiter .MockitoExtension ;
3939import org .slf4j .LoggerFactory ;
4040
41+ import org .springframework .ai .util .TextBlockAssertion ;
4142import org .springframework .core .ParameterizedTypeReference ;
4243
4344import static org .assertj .core .api .Assertions .assertThat ;
@@ -246,83 +247,86 @@ class FormatTest {
246247 @ Test
247248 void formatClassType () {
248249 var converter = new BeanOutputConverter <>(TestClass .class );
249- assertThat (converter .getFormat ()).isEqualTo (
250- """
251- Your response should be in JSON format.
252- Do not include any explanations, only provide a RFC8259 compliant JSON response following this format without deviation.
253- Do not include markdown code blocks in your response.
254- Remove the ```json markdown from the output.
255- Here is the JSON Schema instance your output must adhere to:
256- ```{
257- "$schema" : "https://json-schema.org/draft/2020-12/schema",
258- "type" : "object",
259- "properties" : {
260- "someString" : {
261- "type" : "string"
262- }
263- },
264- "additionalProperties" : false
265- }```
266- """ );
250+ TextBlockAssertion .assertThat (converter .getFormat ())
251+ .isEqualTo (
252+ """
253+ Your response should be in JSON format.
254+ Do not include any explanations, only provide a RFC8259 compliant JSON response following this format without deviation.
255+ Do not include markdown code blocks in your response.
256+ Remove the ```json markdown from the output.
257+ Here is the JSON Schema instance your output must adhere to:
258+ ```{
259+ "$schema" : "https://json-schema.org/draft/2020-12/schema",
260+ "type" : "object",
261+ "properties" : {
262+ "someString" : {
263+ "type" : "string"
264+ }
265+ },
266+ "additionalProperties" : false
267+ }```
268+ """ );
267269 }
268270
269271 @ Test
270272 void formatTypeReference () {
271273 var converter = new BeanOutputConverter <>(new ParameterizedTypeReference <TestClass >() {
272274
273275 });
274- assertThat (converter .getFormat ()).isEqualTo (
275- """
276- Your response should be in JSON format.
277- Do not include any explanations, only provide a RFC8259 compliant JSON response following this format without deviation.
278- Do not include markdown code blocks in your response.
279- Remove the ```json markdown from the output.
280- Here is the JSON Schema instance your output must adhere to:
281- ```{
282- "$schema" : "https://json-schema.org/draft/2020-12/schema",
283- "type" : "object",
284- "properties" : {
285- "someString" : {
286- "type" : "string"
287- }
288- },
289- "additionalProperties" : false
290- }```
291- """ );
276+ TextBlockAssertion .assertThat (converter .getFormat ())
277+ .isEqualTo (
278+ """
279+ Your response should be in JSON format.
280+ Do not include any explanations, only provide a RFC8259 compliant JSON response following this format without deviation.
281+ Do not include markdown code blocks in your response.
282+ Remove the ```json markdown from the output.
283+ Here is the JSON Schema instance your output must adhere to:
284+ ```{
285+ "$schema" : "https://json-schema.org/draft/2020-12/schema",
286+ "type" : "object",
287+ "properties" : {
288+ "someString" : {
289+ "type" : "string"
290+ }
291+ },
292+ "additionalProperties" : false
293+ }```
294+ """ );
292295 }
293296
294297 @ Test
295298 void formatTypeReferenceArray () {
296299 var converter = new BeanOutputConverter <>(new ParameterizedTypeReference <List <TestClass >>() {
297300
298301 });
299- assertThat (converter .getFormat ()).isEqualTo (
300- """
301- Your response should be in JSON format.
302- Do not include any explanations, only provide a RFC8259 compliant JSON response following this format without deviation.
303- Do not include markdown code blocks in your response.
304- Remove the ```json markdown from the output.
305- Here is the JSON Schema instance your output must adhere to:
306- ```{
307- "$schema" : "https://json-schema.org/draft/2020-12/schema",
308- "type" : "array",
309- "items" : {
310- "type" : "object",
311- "properties" : {
312- "someString" : {
313- "type" : "string"
314- }
315- },
316- "additionalProperties" : false
317- }
318- }```
319- """ );
302+ TextBlockAssertion .assertThat (converter .getFormat ())
303+ .isEqualTo (
304+ """
305+ Your response should be in JSON format.
306+ Do not include any explanations, only provide a RFC8259 compliant JSON response following this format without deviation.
307+ Do not include markdown code blocks in your response.
308+ Remove the ```json markdown from the output.
309+ Here is the JSON Schema instance your output must adhere to:
310+ ```{
311+ "$schema" : "https://json-schema.org/draft/2020-12/schema",
312+ "type" : "array",
313+ "items" : {
314+ "type" : "object",
315+ "properties" : {
316+ "someString" : {
317+ "type" : "string"
318+ }
319+ },
320+ "additionalProperties" : false
321+ }
322+ }```
323+ """ );
320324 }
321325
322326 @ Test
323327 void formatClassTypeWithAnnotations () {
324328 var converter = new BeanOutputConverter <>(TestClassWithJsonAnnotations .class );
325- assertThat (converter .getFormat ()).contains ("""
329+ TextBlockAssertion . assertThat (converter .getFormat ()).contains ("""
326330 ```{
327331 "$schema" : "https://json-schema.org/draft/2020-12/schema",
328332 "type" : "object",
@@ -342,7 +346,7 @@ void formatTypeReferenceWithAnnotations() {
342346 var converter = new BeanOutputConverter <>(new ParameterizedTypeReference <TestClassWithJsonAnnotations >() {
343347
344348 });
345- assertThat (converter .getFormat ()).contains ("""
349+ TextBlockAssertion . assertThat (converter .getFormat ()).contains ("""
346350 ```{
347351 "$schema" : "https://json-schema.org/draft/2020-12/schema",
348352 "type" : "object",
0 commit comments