diff --git a/config/clients/java/template/client-OpenFgaClient.java.mustache b/config/clients/java/template/client-OpenFgaClient.java.mustache index aa86a494..6ab5b16a 100644 --- a/config/clients/java/template/client-OpenFgaClient.java.mustache +++ b/config/clients/java/template/client-OpenFgaClient.java.mustache @@ -351,7 +351,7 @@ public class OpenFgaClient { return writeTransactions(storeId, request, options); } - private CompletableFuture writeNonTransaction( + private CompletableFuture writeTransactions( String storeId, ClientWriteRequest request, ClientWriteOptions options) { WriteRequest body = new WriteRequest(); @@ -378,7 +378,7 @@ public class OpenFgaClient { return call(() -> api.write(storeId, body, overrides)).thenApply(ClientWriteResponse::new); } - private CompletableFuture writeTransactions( + private CompletableFuture writeNonTransaction( String storeId, ClientWriteRequest request, ClientWriteOptions writeOptions) { var options = writeOptions != null @@ -400,10 +400,10 @@ public class OpenFgaClient { if(transactions.isEmpty()) { var emptyTransaction = new ClientWriteRequest().writes(null).deletes(null); - return this.writeNonTransaction(storeId, emptyTransaction, writeOptions); + return this.writeTransactions(storeId, emptyTransaction, writeOptions); } - var futureResponse = this.writeNonTransaction(storeId, transactions.get(0), options); + var futureResponse = this.writeTransactions(storeId, transactions.get(0), options); for (int i = 1; i < transactions.size(); i++) { final int index = i; // Must be final in this scope for closure. @@ -412,7 +412,7 @@ public class OpenFgaClient { // 1. The first exception thrown in a failed completion. Other thenCompose() will not be evaluated. // 2. The final successful ClientWriteResponse. futureResponse = futureResponse.thenCompose( - _response -> this.writeNonTransaction(storeId, transactions.get(index), options)); + _response -> this.writeTransactions(storeId, transactions.get(index), options)); } return futureResponse; diff --git a/config/clients/java/template/client-OpenFgaClientTest.java.mustache b/config/clients/java/template/client-OpenFgaClientTest.java.mustache index 2f95beb5..708b8f38 100644 --- a/config/clients/java/template/client-OpenFgaClientTest.java.mustache +++ b/config/clients/java/template/client-OpenFgaClientTest.java.mustache @@ -1096,7 +1096,7 @@ public class OpenFgaClientTest { } @Test - public void writeTest_transactions() throws Exception { + public void writeTest_nonTransaction() throws Exception { // Given String postPath = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/write"; String writeTupleBody = String.format( @@ -1132,7 +1132,7 @@ public class OpenFgaClientTest { .writes(List.of(writeTuple, writeTuple, writeTuple, writeTuple, writeTuple)) .deletes(List.of(tuple, tuple, tuple, tuple, tuple)); ClientWriteOptions options = - new ClientWriteOptions().disableTransactions(false).transactionChunkSize(2); + new ClientWriteOptions().disableTransactions(true).transactionChunkSize(2); // When var response = fga.write(request, options).get(); @@ -1170,7 +1170,7 @@ public class OpenFgaClientTest { } @Test - public void writeTest_transactionsWithFailure() throws Exception { + public void writeTest_nonTransactionsWithFailure() { // Given String postPath = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/write"; String firstUser = "user:first"; @@ -1200,7 +1200,7 @@ public class OpenFgaClientTest { .condition(DEFAULT_CONDITION)) .collect(Collectors.toList())); ClientWriteOptions options = - new ClientWriteOptions().disableTransactions(false).transactionChunkSize(1); + new ClientWriteOptions().disableTransactions(true).transactionChunkSize(1); // When var execException = assertThrows( @@ -1233,7 +1233,7 @@ public class OpenFgaClientTest { } @Test - public void writeTest_nonTransaction() throws Exception { + public void writeTest_transaction() throws Exception { // Given String postPath = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/write"; String writeTupleBody = String.format( @@ -1262,7 +1262,7 @@ public class OpenFgaClientTest { // We expect transactionChunkSize will be ignored, and exactly one request will be sent. ClientWriteOptions options = - new ClientWriteOptions().disableTransactions(true).transactionChunkSize(1); + new ClientWriteOptions().disableTransactions(false).transactionChunkSize(1); // When var response = fga.write(request, options).get(); @@ -1273,7 +1273,7 @@ public class OpenFgaClientTest { } @Test - public void writeTest_nonTransactionsWithFailure() throws Exception { + public void writeTest_transactionWithFailure() { // Given String postPath = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/write"; String writeTupleBody = String.format( @@ -1305,7 +1305,7 @@ public class OpenFgaClientTest { // We expect transactionChunkSize will be ignored, and exactly one request will be sent. ClientWriteOptions options = - new ClientWriteOptions().disableTransactions(true).transactionChunkSize(1); + new ClientWriteOptions().disableTransactions(false).transactionChunkSize(1); // When var execException = assertThrows(