Skip to content

Commit 81fa5cf

Browse files
committed
fix: spotless apply
1 parent db6d6bd commit 81fa5cf

6 files changed

Lines changed: 37 additions & 44 deletions

File tree

src/main/java/dev/openfga/sdk/api/client/ApiClient.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,8 @@ public OAuth2Client getOAuth2Client() {
356356
* @throws ApiException if token acquisition fails
357357
*/
358358
public String getAccessToken(Configuration configuration) throws ApiException {
359-
dev.openfga.sdk.api.configuration.CredentialsMethod credentialsMethod = configuration.getCredentials().getCredentialsMethod();
359+
dev.openfga.sdk.api.configuration.CredentialsMethod credentialsMethod =
360+
configuration.getCredentials().getCredentialsMethod();
360361

361362
if (credentialsMethod == dev.openfga.sdk.api.configuration.CredentialsMethod.NONE) {
362363
return null;

src/test-integration/java/dev/openfga/sdk/api/client/StreamedListObjectsAuthIntegrationTest.java

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,10 @@
1010
import dev.openfga.sdk.api.configuration.ClientConfiguration;
1111
import dev.openfga.sdk.api.configuration.Credentials;
1212
import dev.openfga.sdk.api.model.*;
13-
import java.io.IOException;
1413
import java.nio.file.Files;
1514
import java.nio.file.Paths;
1615
import java.util.ArrayList;
1716
import java.util.List;
18-
import java.util.concurrent.CompletableFuture;
1917
import org.junit.jupiter.api.BeforeAll;
2018
import org.junit.jupiter.api.Test;
2119
import org.junit.jupiter.api.TestInstance;
@@ -54,13 +52,12 @@ public void setup() throws Exception {
5452
fga = new OpenFgaClient(config);
5553

5654
// Create store
57-
var storeResponse =
58-
fga.createStore(new CreateStoreRequest().name("auth-integration-test")).get();
55+
var storeResponse = fga.createStore(new CreateStoreRequest().name("auth-integration-test"))
56+
.get();
5957
fga.setStoreId(storeResponse.getId());
6058

6159
// Write authorization model
62-
String authModelJson =
63-
Files.readString(Paths.get("src", "test-integration", "resources", "auth-model.json"));
60+
String authModelJson = Files.readString(Paths.get("src", "test-integration", "resources", "auth-model.json"));
6461
var authModelRequest = mapper.readValue(authModelJson, WriteAuthorizationModelRequest.class);
6562
var modelResponse = fga.writeAuthorizationModel(authModelRequest).get();
6663
fga.setAuthorizationModelId(modelResponse.getAuthorizationModelId());
@@ -105,30 +102,29 @@ public void streamedListObjects_succeeds_withAuth() throws Exception {
105102
public void streamingApiExecutor_succeeds_withAuth() throws Exception {
106103
List<StreamedListObjectsResponse> received = new ArrayList<>();
107104

108-
ApiExecutorRequestBuilder request =
109-
ApiExecutorRequestBuilder.builder(HttpMethod.POST, "/stores/{store_id}/streamed-list-objects")
110-
.body(new ListObjectsRequest()
111-
.user("user:alice")
112-
.relation("reader")
113-
.type("document"))
114-
.build();
105+
ApiExecutorRequestBuilder request = ApiExecutorRequestBuilder.builder(
106+
HttpMethod.POST, "/stores/{store_id}/streamed-list-objects")
107+
.body(new ListObjectsRequest()
108+
.user("user:alice")
109+
.relation("reader")
110+
.type("document"))
111+
.build();
115112

116-
fga.streamingApiExecutor(StreamedListObjectsResponse.class)
117-
.stream(request, received::add)
113+
fga.streamingApiExecutor(StreamedListObjectsResponse.class).stream(request, received::add)
118114
.get();
119115

120116
assertEquals(3, received.size());
121117
}
122118

123119
@Test
124120
public void apiExecutor_succeeds_withAuth() throws Exception {
125-
ApiExecutorRequestBuilder request =
126-
ApiExecutorRequestBuilder.builder(HttpMethod.POST, "/stores/{store_id}/list-objects")
127-
.body(new ListObjectsRequest()
128-
.user("user:alice")
129-
.relation("reader")
130-
.type("document"))
131-
.build();
121+
ApiExecutorRequestBuilder request = ApiExecutorRequestBuilder.builder(
122+
HttpMethod.POST, "/stores/{store_id}/list-objects")
123+
.body(new ListObjectsRequest()
124+
.user("user:alice")
125+
.relation("reader")
126+
.type("document"))
127+
.build();
132128

133129
ApiResponse<ListObjectsResponse> response =
134130
fga.apiExecutor().send(request, ListObjectsResponse.class).get();
@@ -137,4 +133,3 @@ public void apiExecutor_succeeds_withAuth() throws Exception {
137133
assertEquals(3, response.getData().getObjects().size());
138134
}
139135
}
140-

src/test/java/dev/openfga/sdk/api/client/ApiClientTest.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,8 @@ public void getAccessToken_withClientCredentials_returnsTokenFromOAuth2Client()
7171
.clientSecret("secret")
7272
.apiTokenIssuer("issuer.example")
7373
.apiAudience("audience");
74-
Configuration config = new Configuration()
75-
.apiUrl("https://test.example")
76-
.credentials(new Credentials(clientCreds));
74+
Configuration config =
75+
new Configuration().apiUrl("https://test.example").credentials(new Credentials(clientCreds));
7776

7877
assertEquals("oauth2-token-abc", apiClient.getAccessToken(config));
7978
verify(mockOAuth2, times(1)).getAccessToken();
@@ -89,9 +88,8 @@ public void getAccessToken_withClientCredentials_noOAuth2Client_throwsIllegalSta
8988
.clientSecret("secret")
9089
.apiTokenIssuer("issuer.example")
9190
.apiAudience("audience");
92-
Configuration config = new Configuration()
93-
.apiUrl("https://test.example")
94-
.credentials(new Credentials(clientCreds));
91+
Configuration config =
92+
new Configuration().apiUrl("https://test.example").credentials(new Credentials(clientCreds));
9593

9694
assertThrows(IllegalStateException.class, () -> apiClient.getAccessToken(config));
9795
}
@@ -109,9 +107,8 @@ public void getAccessToken_withClientCredentials_oAuth2Fails_throwsApiException(
109107
.clientSecret("secret")
110108
.apiTokenIssuer("issuer.example")
111109
.apiAudience("audience");
112-
Configuration config = new Configuration()
113-
.apiUrl("https://test.example")
114-
.credentials(new Credentials(clientCreds));
110+
Configuration config =
111+
new Configuration().apiUrl("https://test.example").credentials(new Credentials(clientCreds));
115112

116113
assertThrows(ApiException.class, () -> apiClient.getAccessToken(config));
117114
}

src/test/java/dev/openfga/sdk/api/client/ApiExecutorTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -470,8 +470,7 @@ public void rawApi_withClientCredentials_attachesAuthorizationHeader() throws Ex
470470
.willReturn(aResponse()
471471
.withStatus(200)
472472
.withHeader("Content-Type", "application/json")
473-
.withBody(String.format(
474-
"{\"access_token\":\"%s\",\"expires_in\":3600}", generatedToken))));
473+
.withBody(String.format("{\"access_token\":\"%s\",\"expires_in\":3600}", generatedToken))));
475474

476475
// API endpoint
477476
stubFor(get(urlEqualTo("/stores/" + DEFAULT_STORE_ID + "/experimental-feature"))

src/test/java/dev/openfga/sdk/api/client/StreamedListObjectsTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import static org.mockito.Mockito.*;
66

77
import com.fasterxml.jackson.databind.ObjectMapper;
8-
import dev.openfga.sdk.api.auth.OAuth2Client;
98
import dev.openfga.sdk.api.client.model.ClientListObjectsRequest;
109
import dev.openfga.sdk.api.client.model.ClientStreamedListObjectsOptions;
1110
import dev.openfga.sdk.api.configuration.ClientConfiguration;
@@ -444,7 +443,8 @@ public void streamedListObjects_withApiToken_attachesAuthorizationHeader() throw
444443

445444
// Capture the HttpRequest to verify headers
446445
var requestCaptor = org.mockito.ArgumentCaptor.forClass(HttpRequest.class);
447-
when(mockHttpClient.<Stream<String>>sendAsync(requestCaptor.capture(), any())).thenReturn(responseFuture);
446+
when(mockHttpClient.<Stream<String>>sendAsync(requestCaptor.capture(), any()))
447+
.thenReturn(responseFuture);
448448

449449
List<StreamedListObjectsResponse> receivedObjects = new ArrayList<>();
450450
ClientListObjectsRequest request = new ClientListObjectsRequest()
@@ -527,7 +527,8 @@ public void streamedListObjects_withNoCredentials_noAuthorizationHeader() throws
527527
CompletableFuture.completedFuture(mockResponse);
528528

529529
var requestCaptor = org.mockito.ArgumentCaptor.forClass(HttpRequest.class);
530-
when(mockHttpClient.<Stream<String>>sendAsync(requestCaptor.capture(), any())).thenReturn(responseFuture);
530+
when(mockHttpClient.<Stream<String>>sendAsync(requestCaptor.capture(), any()))
531+
.thenReturn(responseFuture);
531532

532533
List<StreamedListObjectsResponse> receivedObjects = new ArrayList<>();
533534
ClientListObjectsRequest request = new ClientListObjectsRequest()

src/test/java/dev/openfga/sdk/api/client/StreamingApiExecutorTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -412,8 +412,8 @@ public void stream_withApiToken_attachesAuthorizationHeader() throws Exception {
412412
List<StreamedListObjectsResponse> received = new ArrayList<>();
413413

414414
// When
415-
authedFga.streamingApiExecutor(StreamedListObjectsResponse.class)
416-
.stream(buildStreamedListObjectsRequest(), received::add)
415+
authedFga.streamingApiExecutor(StreamedListObjectsResponse.class).stream(
416+
buildStreamedListObjectsRequest(), received::add)
417417
.get();
418418

419419
// Then
@@ -459,8 +459,8 @@ public void stream_withClientCredentials_attachesAuthorizationHeader() throws Ex
459459
List<StreamedListObjectsResponse> received = new ArrayList<>();
460460

461461
// When
462-
authedFga.streamingApiExecutor(StreamedListObjectsResponse.class)
463-
.stream(buildStreamedListObjectsRequest(), received::add)
462+
authedFga.streamingApiExecutor(StreamedListObjectsResponse.class).stream(
463+
buildStreamedListObjectsRequest(), received::add)
464464
.get();
465465

466466
// Then
@@ -483,8 +483,8 @@ public void stream_withNoCredentials_noAuthorizationHeader() throws Exception {
483483
List<StreamedListObjectsResponse> received = new ArrayList<>();
484484

485485
// When
486-
fga.streamingApiExecutor(StreamedListObjectsResponse.class)
487-
.stream(buildStreamedListObjectsRequest(), received::add)
486+
fga.streamingApiExecutor(StreamedListObjectsResponse.class).stream(
487+
buildStreamedListObjectsRequest(), received::add)
488488
.get();
489489

490490
// Then

0 commit comments

Comments
 (0)