use of com.google.bigtable.admin.v2.DropRowRangeRequest in project java-bigtable by googleapis.
the class BigtableTableAdminClientTest method testDropRowRange.
@Test
public void testDropRowRange() {
// Setup
Mockito.when(mockStub.dropRowRangeCallable()).thenReturn(mockDropRowRangeCallable);
DropRowRangeRequest expectedRequest = DropRowRangeRequest.newBuilder().setName(TABLE_NAME).setRowKeyPrefix(ByteString.copyFromUtf8("rowKeyPrefix")).build();
final Empty expectedResponse = Empty.getDefaultInstance();
final AtomicBoolean wasCalled = new AtomicBoolean(false);
Mockito.when(mockDropRowRangeCallable.futureCall(expectedRequest)).thenAnswer((Answer<ApiFuture<Empty>>) invocationOnMock -> {
wasCalled.set(true);
return ApiFutures.immediateFuture(expectedResponse);
});
// Execute
adminClient.dropRowRange(TABLE_ID, "rowKeyPrefix");
// Verify
assertThat(wasCalled.get()).isTrue();
}
use of com.google.bigtable.admin.v2.DropRowRangeRequest in project java-bigtable by googleapis.
the class BaseBigtableTableAdminClientTest method dropRowRangeTest.
@Test
public void dropRowRangeTest() throws Exception {
Empty expectedResponse = Empty.newBuilder().build();
mockBigtableTableAdmin.addResponse(expectedResponse);
DropRowRangeRequest request = DropRowRangeRequest.newBuilder().setName(TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]").toString()).build();
client.dropRowRange(request);
List<AbstractMessage> actualRequests = mockBigtableTableAdmin.getRequests();
Assert.assertEquals(1, actualRequests.size());
DropRowRangeRequest actualRequest = ((DropRowRangeRequest) actualRequests.get(0));
Assert.assertEquals(request.getName(), actualRequest.getName());
Assert.assertEquals(request.getRowKeyPrefix(), actualRequest.getRowKeyPrefix());
Assert.assertEquals(request.getDeleteAllDataFromTable(), actualRequest.getDeleteAllDataFromTable());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.bigtable.admin.v2.DropRowRangeRequest in project java-bigtable by googleapis.
the class BaseBigtableTableAdminClientTest method dropRowRangeExceptionTest.
@Test
public void dropRowRangeExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockBigtableTableAdmin.addException(exception);
try {
DropRowRangeRequest request = DropRowRangeRequest.newBuilder().setName(TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]").toString()).build();
client.dropRowRange(request);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.bigtable.admin.v2.DropRowRangeRequest in project java-bigtable by googleapis.
the class BigtableTableAdminClientTests method testDropRowRange.
@Test
public void testDropRowRange() {
// Setup
Mockito.when(mockStub.dropRowRangeCallable()).thenReturn(mockDropRowRangeCallable);
DropRowRangeRequest expectedRequest = DropRowRangeRequest.newBuilder().setName(TABLE_NAME).setRowKeyPrefix(ByteString.copyFromUtf8("rowKeyPrefix")).build();
final Empty expectedResponse = Empty.getDefaultInstance();
final AtomicBoolean wasCalled = new AtomicBoolean(false);
Mockito.when(mockDropRowRangeCallable.futureCall(expectedRequest)).thenAnswer((Answer<ApiFuture<Empty>>) invocationOnMock -> {
wasCalled.set(true);
return ApiFutures.immediateFuture(expectedResponse);
});
// Execute
adminClient.dropRowRange(TABLE_ID, "rowKeyPrefix");
// Verify
assertThat(wasCalled.get()).isTrue();
}
use of com.google.bigtable.admin.v2.DropRowRangeRequest in project java-bigtable-hbase by googleapis.
the class BigtableAdminTest method testDeleteRowRangeByPrefixNonUtf8.
@Test
public void testDeleteRowRangeByPrefixNonUtf8() throws IOException, InterruptedException {
TableName tableName = TableName.valueOf(TABLE_ID);
ByteString expectedKey = ByteString.copyFrom(new byte[] { 0, 0, 0, (byte) 128 });
DropRowRangeRequest expectedRequest = DropRowRangeRequest.newBuilder().setName(TABLE_NAME).setRowKeyPrefix(expectedKey).build();
responseQueue.put(Empty.getDefaultInstance());
admin.deleteRowRangeByPrefix(tableName, expectedKey.toByteArray());
assertEquals(expectedRequest, requestQueue.take());
}
Aggregations