use of com.google.spanner.v1.Mutation in project gapic-generator-java by googleapis.
the class BaseBigtableDataClientTest method mutateRowExceptionTest4.
@Test
public void mutateRowExceptionTest4() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockBigtable.addException(exception);
try {
String tableName = "tableName-1988717703";
ByteString rowKey = ByteString.EMPTY;
List<Mutation> mutations = new ArrayList<>();
String appProfileId = "appProfileId704923523";
client.mutateRow(tableName, rowKey, mutations, appProfileId);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.spanner.v1.Mutation in project gapic-generator-java by googleapis.
the class BaseBigtableDataClientTest method mutateRowTest3.
@Test
public void mutateRowTest3() throws Exception {
MutateRowResponse expectedResponse = MutateRowResponse.newBuilder().build();
mockBigtable.addResponse(expectedResponse);
TableName tableName = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
ByteString rowKey = ByteString.EMPTY;
List<Mutation> mutations = new ArrayList<>();
String appProfileId = "appProfileId704923523";
MutateRowResponse actualResponse = client.mutateRow(tableName, rowKey, mutations, appProfileId);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockBigtable.getRequests();
Assert.assertEquals(1, actualRequests.size());
MutateRowRequest actualRequest = ((MutateRowRequest) actualRequests.get(0));
Assert.assertEquals(tableName.toString(), actualRequest.getTableName());
Assert.assertEquals(rowKey, actualRequest.getRowKey());
Assert.assertEquals(mutations, actualRequest.getMutationsList());
Assert.assertEquals(appProfileId, actualRequest.getAppProfileId());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.spanner.v1.Mutation in project gapic-generator-java by googleapis.
the class BaseBigtableDataClientTest method checkAndMutateRowTest3.
@Test
public void checkAndMutateRowTest3() throws Exception {
CheckAndMutateRowResponse expectedResponse = CheckAndMutateRowResponse.newBuilder().setPredicateMatched(true).build();
mockBigtable.addResponse(expectedResponse);
TableName tableName = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
ByteString rowKey = ByteString.EMPTY;
RowFilter predicateFilter = RowFilter.newBuilder().build();
List<Mutation> trueMutations = new ArrayList<>();
List<Mutation> falseMutations = new ArrayList<>();
String appProfileId = "appProfileId704923523";
CheckAndMutateRowResponse actualResponse = client.checkAndMutateRow(tableName, rowKey, predicateFilter, trueMutations, falseMutations, appProfileId);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockBigtable.getRequests();
Assert.assertEquals(1, actualRequests.size());
CheckAndMutateRowRequest actualRequest = ((CheckAndMutateRowRequest) actualRequests.get(0));
Assert.assertEquals(tableName.toString(), actualRequest.getTableName());
Assert.assertEquals(rowKey, actualRequest.getRowKey());
Assert.assertEquals(predicateFilter, actualRequest.getPredicateFilter());
Assert.assertEquals(trueMutations, actualRequest.getTrueMutationsList());
Assert.assertEquals(falseMutations, actualRequest.getFalseMutationsList());
Assert.assertEquals(appProfileId, actualRequest.getAppProfileId());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.spanner.v1.Mutation in project gapic-generator-java by googleapis.
the class BaseBigtableDataClientTest method checkAndMutateRowExceptionTest4.
@Test
public void checkAndMutateRowExceptionTest4() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockBigtable.addException(exception);
try {
String tableName = "tableName-1988717703";
ByteString rowKey = ByteString.EMPTY;
RowFilter predicateFilter = RowFilter.newBuilder().build();
List<Mutation> trueMutations = new ArrayList<>();
List<Mutation> falseMutations = new ArrayList<>();
String appProfileId = "appProfileId704923523";
client.checkAndMutateRow(tableName, rowKey, predicateFilter, trueMutations, falseMutations, appProfileId);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.spanner.v1.Mutation in project gapic-generator-java by googleapis.
the class SyncCheckAndMutateRow method syncCheckAndMutateRow.
public static void syncCheckAndMutateRow() throws Exception {
// It may require modifications to work in your environment.
try (BaseBigtableDataClient baseBigtableDataClient = BaseBigtableDataClient.create()) {
CheckAndMutateRowRequest request = CheckAndMutateRowRequest.newBuilder().setTableName(TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]").toString()).setAppProfileId("appProfileId704923523").setRowKey(ByteString.EMPTY).setPredicateFilter(RowFilter.newBuilder().build()).addAllTrueMutations(new ArrayList<Mutation>()).addAllFalseMutations(new ArrayList<Mutation>()).build();
CheckAndMutateRowResponse response = baseBigtableDataClient.checkAndMutateRow(request);
}
}
Aggregations