use of com.swiftmq.impl.routing.single.smqpr.v942.CommitRequest in project java-spanner by googleapis.
the class DatabaseClientImplTest method testTransactionManagerCommitWithPriority.
@Test
public void testTransactionManagerCommitWithPriority() {
DatabaseClient client = spanner.getDatabaseClient(DatabaseId.of(TEST_PROJECT, TEST_INSTANCE, TEST_DATABASE));
TransactionManager manager = client.transactionManager(Options.priority(RpcPriority.HIGH));
TransactionContext transaction = manager.begin();
transaction.buffer(Mutation.delete("TEST", KeySet.all()));
manager.commit();
List<CommitRequest> requests = mockSpanner.getRequestsOfType(CommitRequest.class);
assertThat(requests).hasSize(1);
CommitRequest request = requests.get(0);
assertNotNull(request.getRequestOptions());
assertEquals(Priority.PRIORITY_HIGH, request.getRequestOptions().getPriority());
}
use of com.swiftmq.impl.routing.single.smqpr.v942.CommitRequest in project java-spanner by googleapis.
the class DatabaseClientImplTest method testTransactionManagerCommitWithTag.
@Test
public void testTransactionManagerCommitWithTag() {
DatabaseClient client = spanner.getDatabaseClient(DatabaseId.of(TEST_PROJECT, TEST_INSTANCE, TEST_DATABASE));
TransactionManager manager = client.transactionManager(Options.tag("app=spanner,env=test,action=manager"));
TransactionContext transaction = manager.begin();
transaction.buffer(Mutation.delete("TEST", KeySet.all()));
manager.commit();
List<CommitRequest> requests = mockSpanner.getRequestsOfType(CommitRequest.class);
assertThat(requests).hasSize(1);
CommitRequest request = requests.get(0);
assertNotNull(request.getRequestOptions());
assertThat(request.getRequestOptions().getRequestTag()).isEmpty();
assertThat(request.getRequestOptions().getTransactionTag()).isEqualTo("app=spanner,env=test,action=manager");
}
use of com.swiftmq.impl.routing.single.smqpr.v942.CommitRequest in project java-spanner by googleapis.
the class DatabaseClientImplTest method testCommitWithPriority.
@Test
public void testCommitWithPriority() {
DatabaseClient client = spanner.getDatabaseClient(DatabaseId.of(TEST_PROJECT, TEST_INSTANCE, TEST_DATABASE));
TransactionRunner runner = client.readWriteTransaction(Options.priority(RpcPriority.HIGH));
runner.run(transaction -> {
transaction.buffer(Mutation.delete("TEST", KeySet.all()));
return null;
});
List<CommitRequest> requests = mockSpanner.getRequestsOfType(CommitRequest.class);
assertThat(requests).hasSize(1);
CommitRequest request = requests.get(0);
assertNotNull(request.getRequestOptions());
assertEquals(Priority.PRIORITY_HIGH, request.getRequestOptions().getPriority());
}
use of com.swiftmq.impl.routing.single.smqpr.v942.CommitRequest in project java-spanner by googleapis.
the class DatabaseClientImplTest method testWriteAtLeastOnceWithCommitStats.
@Test
public void testWriteAtLeastOnceWithCommitStats() {
DatabaseClient client = spanner.getDatabaseClient(DatabaseId.of(TEST_PROJECT, TEST_INSTANCE, TEST_DATABASE));
CommitResponse response = client.writeAtLeastOnceWithOptions(Collections.singletonList(Mutation.newInsertBuilder("FOO").set("ID").to(1L).set("NAME").to("Bar").build()), Options.commitStats());
assertNotNull(response);
assertNotNull(response.getCommitTimestamp());
assertNotNull(response.getCommitStats());
List<CommitRequest> commitRequests = mockSpanner.getRequestsOfType(CommitRequest.class);
assertThat(commitRequests).hasSize(1);
CommitRequest commit = commitRequests.get(0);
assertNotNull(commit.getSingleUseTransaction());
assertTrue(commit.getSingleUseTransaction().hasReadWrite());
assertNotNull(commit.getRequestOptions());
assertEquals(Priority.PRIORITY_UNSPECIFIED, commit.getRequestOptions().getPriority());
}
use of com.swiftmq.impl.routing.single.smqpr.v942.CommitRequest in project java-spanner by googleapis.
the class DatabaseClientImplTest method testWriteWithOptions.
@Test
public void testWriteWithOptions() {
DatabaseClient client = spanner.getDatabaseClient(DatabaseId.of(TEST_PROJECT, TEST_INSTANCE, TEST_DATABASE));
client.writeWithOptions(Collections.singletonList(Mutation.newInsertBuilder("FOO").set("ID").to(1L).set("NAME").to("Bar").build()), Options.priority(RpcPriority.HIGH));
List<CommitRequest> commits = mockSpanner.getRequestsOfType(CommitRequest.class);
assertThat(commits).hasSize(1);
CommitRequest commit = commits.get(0);
assertNotNull(commit.getRequestOptions());
assertEquals(Priority.PRIORITY_HIGH, commit.getRequestOptions().getPriority());
}
Aggregations