2929/**
3030 * Test class demonstrating the generic streaming implementation.
3131 * This test shows how the BaseStreamingApi provides reusable functionality
32- * for any streaming endpoint that returns NDJSON format.
32+ * for any streaming endpoint that returns line-delimited JSON format.
3333 */
3434class StreamingApiTest {
3535
@@ -66,12 +66,12 @@ void setUp() {
6666
6767 @ Test
6868 void testStreamedListObjects_successfulStream () throws Exception {
69- // Arrange: Create NDJSON response with multiple objects
70- String ndjsonResponse = "{\" result\" :{\" object\" :\" document:1\" }}\n "
69+ // Arrange: Create response with multiple objects
70+ String Response = "{\" result\" :{\" object\" :\" document:1\" }}\n "
7171 + "{\" result\" :{\" object\" :\" document:2\" }}\n "
7272 + "{\" result\" :{\" object\" :\" document:3\" }}\n " ;
7373
74- Stream <String > lineStream = ndjsonResponse .lines ();
74+ Stream <String > lineStream = Response .lines ();
7575 when (mockHttpResponse .body ()).thenReturn (lineStream );
7676 when (mockHttpResponse .statusCode ()).thenReturn (200 );
7777
@@ -102,11 +102,11 @@ void testStreamedListObjects_successfulStream() throws Exception {
102102
103103 @ Test
104104 void testStreamedListObjects_withErrorInStream () throws Exception {
105- // Arrange: NDJSON with an error
106- String ndjsonResponse = "{\" result\" :{\" object\" :\" document:1\" }}\n "
105+ // Arrange: Streaming response with an error
106+ String Response = "{\" result\" :{\" object\" :\" document:1\" }}\n "
107107 + "{\" error\" :{\" code\" :400,\" message\" :\" Something went wrong\" }}\n " ;
108108
109- Stream <String > lineStream = ndjsonResponse .lines ();
109+ Stream <String > lineStream = Response .lines ();
110110 when (mockHttpResponse .body ()).thenReturn (lineStream );
111111 when (mockHttpResponse .statusCode ()).thenReturn (200 );
112112
@@ -168,10 +168,10 @@ void testStreamedListObjects_httpError() throws Exception {
168168
169169 @ Test
170170 void testStreamedListObjects_emptyStream () throws Exception {
171- // Arrange: Empty NDJSON response
172- String ndjsonResponse = "" ;
171+ // Arrange: Empty streaming response
172+ String streamResponse = "" ;
173173
174- Stream <String > lineStream = ndjsonResponse .lines ();
174+ Stream <String > lineStream = streamResponse .lines ();
175175 when (mockHttpResponse .body ()).thenReturn (lineStream );
176176 when (mockHttpResponse .statusCode ()).thenReturn (200 );
177177
@@ -194,17 +194,17 @@ void testStreamedListObjects_emptyStream() throws Exception {
194194
195195 @ Test
196196 void testStreamedListObjects_largeStream () throws Exception {
197- // Arrange: Large NDJSON response with many objects
198- StringBuilder ndjsonBuilder = new StringBuilder ();
197+ // Arrange: Large streaming response with many objects
198+ StringBuilder streamBuilder = new StringBuilder ();
199199 int objectCount = 1000 ;
200200 for (int i = 0 ; i < objectCount ; i ++) {
201- ndjsonBuilder
201+ streamBuilder
202202 .append ("{\" result\" :{\" object\" :\" document:" )
203203 .append (i )
204204 .append ("\" }}\n " );
205205 }
206206
207- Stream <String > lineStream = ndjsonBuilder .toString ().lines ();
207+ Stream <String > lineStream = streamBuilder .toString ().lines ();
208208 when (mockHttpResponse .body ()).thenReturn (lineStream );
209209 when (mockHttpResponse .statusCode ()).thenReturn (200 );
210210
0 commit comments