@@ -82,18 +82,13 @@ void testStreamedListObjects_successfulStream() throws Exception {
8282 List <String > receivedObjects = Collections .synchronizedList (new ArrayList <>());
8383 CountDownLatch latch = new CountDownLatch (3 );
8484
85- ListObjectsRequest request = new ListObjectsRequest ()
86- .type ("document" )
87- .relation ("viewer" )
88- .user ("user:anne" );
85+ ListObjectsRequest request =
86+ new ListObjectsRequest ().type ("document" ).relation ("viewer" ).user ("user:anne" );
8987
90- CompletableFuture <Void > future = streamingApi .streamedListObjects (
91- "store123" ,
92- request ,
93- response -> {
94- receivedObjects .add (response .getObject ());
95- latch .countDown ();
96- });
88+ CompletableFuture <Void > future = streamingApi .streamedListObjects ("store123" , request , response -> {
89+ receivedObjects .add (response .getObject ());
90+ latch .countDown ();
91+ });
9792
9893 // Assert: Wait for completion and verify results
9994 assertTrue (latch .await (5 , TimeUnit .SECONDS ), "Should receive all objects" );
@@ -123,16 +118,11 @@ void testStreamedListObjects_withErrorInStream() throws Exception {
123118 List <Throwable > receivedErrors = Collections .synchronizedList (new ArrayList <>());
124119 CountDownLatch latch = new CountDownLatch (1 );
125120
126- ListObjectsRequest request = new ListObjectsRequest ()
127- .type ("document" )
128- .relation ("viewer" )
129- .user ("user:anne" );
121+ ListObjectsRequest request =
122+ new ListObjectsRequest ().type ("document" ).relation ("viewer" ).user ("user:anne" );
130123
131124 CompletableFuture <Void > future = streamingApi .streamedListObjects (
132- "store123" ,
133- request ,
134- response -> receivedObjects .add (response .getObject ()),
135- error -> {
125+ "store123" , request , response -> receivedObjects .add (response .getObject ()), error -> {
136126 receivedErrors .add (error );
137127 latch .countDown ();
138128 });
@@ -151,9 +141,8 @@ void testStreamedListObjects_withErrorInStream() throws Exception {
151141 void testStreamedListObjects_httpError () throws Exception {
152142 // Arrange: HTTP error response
153143 when (mockHttpResponse .statusCode ()).thenReturn (400 );
154- when (mockHttpResponse .headers ()).thenReturn (java .net .http .HttpHeaders .of (
155- Collections .emptyMap (),
156- (k , v ) -> true ));
144+ when (mockHttpResponse .headers ())
145+ .thenReturn (java .net .http .HttpHeaders .of (Collections .emptyMap (), (k , v ) -> true ));
157146
158147 when (mockHttpClient .sendAsync (any (HttpRequest .class ), any (HttpResponse .BodyHandler .class )))
159148 .thenReturn (CompletableFuture .completedFuture (mockHttpResponse ));
@@ -162,10 +151,8 @@ void testStreamedListObjects_httpError() throws Exception {
162151 List <String > receivedObjects = Collections .synchronizedList (new ArrayList <>());
163152 AtomicBoolean errorReceived = new AtomicBoolean (false );
164153
165- ListObjectsRequest request = new ListObjectsRequest ()
166- .type ("document" )
167- .relation ("viewer" )
168- .user ("user:anne" );
154+ ListObjectsRequest request =
155+ new ListObjectsRequest ().type ("document" ).relation ("viewer" ).user ("user:anne" );
169156
170157 CompletableFuture <Void > future = streamingApi .streamedListObjects (
171158 "store123" ,
@@ -194,15 +181,11 @@ void testStreamedListObjects_emptyStream() throws Exception {
194181 // Act: Stream with no results
195182 List <String > receivedObjects = Collections .synchronizedList (new ArrayList <>());
196183
197- ListObjectsRequest request = new ListObjectsRequest ()
198- .type ("document" )
199- .relation ("viewer" )
200- .user ("user:anne" );
184+ ListObjectsRequest request =
185+ new ListObjectsRequest ().type ("document" ).relation ("viewer" ).user ("user:anne" );
201186
202187 CompletableFuture <Void > future = streamingApi .streamedListObjects (
203- "store123" ,
204- request ,
205- response -> receivedObjects .add (response .getObject ()));
188+ "store123" , request , response -> receivedObjects .add (response .getObject ()));
206189
207190 // Assert: Should complete without errors
208191 future .join ();
@@ -215,7 +198,10 @@ void testStreamedListObjects_largeStream() throws Exception {
215198 StringBuilder ndjsonBuilder = new StringBuilder ();
216199 int objectCount = 1000 ;
217200 for (int i = 0 ; i < objectCount ; i ++) {
218- ndjsonBuilder .append ("{\" result\" :{\" object\" :\" document:" ).append (i ).append ("\" }}\n " );
201+ ndjsonBuilder
202+ .append ("{\" result\" :{\" object\" :\" document:" )
203+ .append (i )
204+ .append ("\" }}\n " );
219205 }
220206
221207 Stream <String > lineStream = ndjsonBuilder .toString ().lines ();
@@ -229,18 +215,13 @@ void testStreamedListObjects_largeStream() throws Exception {
229215 List <String > receivedObjects = Collections .synchronizedList (new ArrayList <>());
230216 CountDownLatch latch = new CountDownLatch (objectCount );
231217
232- ListObjectsRequest request = new ListObjectsRequest ()
233- .type ("document" )
234- .relation ("viewer" )
235- .user ("user:anne" );
218+ ListObjectsRequest request =
219+ new ListObjectsRequest ().type ("document" ).relation ("viewer" ).user ("user:anne" );
236220
237- CompletableFuture <Void > future = streamingApi .streamedListObjects (
238- "store123" ,
239- request ,
240- response -> {
241- receivedObjects .add (response .getObject ());
242- latch .countDown ();
243- });
221+ CompletableFuture <Void > future = streamingApi .streamedListObjects ("store123" , request , response -> {
222+ receivedObjects .add (response .getObject ());
223+ latch .countDown ();
224+ });
244225
245226 // Assert: Should handle large stream efficiently
246227 assertTrue (latch .await (10 , TimeUnit .SECONDS ), "Should receive all " + objectCount + " objects" );
@@ -259,8 +240,8 @@ void testGenericStreamResult_deserialization() throws Exception {
259240 // Test with result
260241 String jsonWithResult = "{\" result\" :{\" object\" :\" document:1\" }}" ;
261242 var resultType = mapper .getTypeFactory ()
262- .constructParametricType (dev . openfga . sdk . api . model . StreamResult . class ,
263- StreamedListObjectsResponse .class );
243+ .constructParametricType (
244+ dev . openfga . sdk . api . model . StreamResult . class , StreamedListObjectsResponse .class );
264245
265246 Object streamResult = mapper .readValue (jsonWithResult , resultType );
266247 assertNotNull (streamResult );
@@ -271,4 +252,3 @@ void testGenericStreamResult_deserialization() throws Exception {
271252 assertNotNull (streamResultWithError );
272253 }
273254}
274-
0 commit comments