@@ -66,9 +66,12 @@ public void testSendAIRequestSuccess() {
6666 public void testSendAITexGenRequestWithNoDialogueHistorySuccess () {
6767 final String fileId = "12345" ;
6868 final String prompt = "What is the name of the file?" ;
69+ String expectedRequestBody = String .format (
70+ "{\" prompt\" : \" %s\" , \" items\" : [{\" id\" : \" %s\" , \" type\" : \" file\" }]}" , prompt , fileId );
6971
7072 String result = TestUtils .getFixture ("BoxAI/SendAITextGen200" );
7173 wireMockRule .stubFor (WireMock .post (WireMock .urlPathEqualTo ("/2.0/ai/text_gen" ))
74+ .withRequestBody (WireMock .equalToJson (expectedRequestBody ))
7275 .willReturn (WireMock .aResponse ()
7376 .withHeader ("Content-Type" , APPLICATION_JSON )
7477 .withBody (result )));
@@ -92,18 +95,34 @@ public void testSendAITexGenRequestWithDialogueHistorySuccess() throws ParseExce
9295 final String prompt = "What is the name of the file?" ;
9396
9497 Date date1 = BoxDateFormat .parse ("2013-05-16T15:27:57-07:00" );
95- Date date2 = BoxDateFormat .parse ("2013-05-16T15:26:57-07:00" );
9698
9799 List <BoxAIDialogueEntry > dialogueHistory = new ArrayList <>();
98100 dialogueHistory .add (
99101 new BoxAIDialogueEntry ("What is the name of the file?" , "Test file" , date1 )
100102 );
101103 dialogueHistory .add (
102- new BoxAIDialogueEntry ("What is the size of the file?" , "10kb" , date2 )
104+ new BoxAIDialogueEntry ("What is the size of the file?" , "10kb" )
105+ );
106+
107+ String expectedRequestBody = String .format (
108+ "{\n "
109+ + " \" prompt\" : \" %s\" ,\n "
110+ + " \" items\" : [\n "
111+ + " {\" id\" : \" %s\" , \" type\" : \" file\" }\n "
112+ + " ],\n "
113+ + " \" dialogue_history\" : [\n "
114+ + " {\" prompt\" : \" What is the name of the file?\" , \" answer\" : \" Test file\" , "
115+ + " \" created_at\" : \" Fri May 17 00:27:57 CEST 2013\" },\n "
116+ + " {\" prompt\" : \" What is the size of the file?\" , \" answer\" : \" 10kb\" }\n "
117+ + " ]\n "
118+ + "}" ,
119+ prompt , fileId
103120 );
104121
122+
105123 String result = TestUtils .getFixture ("BoxAI/SendAITextGen200" );
106124 wireMockRule .stubFor (WireMock .post (WireMock .urlPathEqualTo ("/2.0/ai/text_gen" ))
125+ .withRequestBody (WireMock .equalToJson (expectedRequestBody ))
107126 .willReturn (WireMock .aResponse ()
108127 .withHeader ("Content-Type" , APPLICATION_JSON )
109128 .withBody (result )));
0 commit comments