Search in sources :

Example 1 with GetTableMetadataRequest

use of com.scalar.db.rpc.GetTableMetadataRequest in project scalardb by scalar-labs.

the class DistributedStorageAdminServiceTest method getTableMetadata_IsCalledWithProperArguments_AdminShouldBeCalledProperly.

@Test
public void getTableMetadata_IsCalledWithProperArguments_AdminShouldBeCalledProperly() throws ExecutionException {
    // Arrange
    GetTableMetadataRequest request = GetTableMetadataRequest.newBuilder().setNamespace("namespace").setTable("table").build();
    @SuppressWarnings("unchecked") StreamObserver<GetTableMetadataResponse> responseObserver = mock(StreamObserver.class);
    // Act
    adminService.getTableMetadata(request, responseObserver);
    // Assert
    verify(admin).getTableMetadata(any(), any());
    verify(responseObserver).onNext(any());
    verify(responseObserver).onCompleted();
}
Also used : GetTableMetadataResponse(com.scalar.db.rpc.GetTableMetadataResponse) GetTableMetadataRequest(com.scalar.db.rpc.GetTableMetadataRequest) Test(org.junit.jupiter.api.Test)

Example 2 with GetTableMetadataRequest

use of com.scalar.db.rpc.GetTableMetadataRequest in project scalardb by scalar-labs.

the class DistributedTransactionAdminServiceTest method getTableMetadata_IsCalledWithProperArguments_AdminShouldBeCalledProperly.

@Test
public void getTableMetadata_IsCalledWithProperArguments_AdminShouldBeCalledProperly() throws ExecutionException {
    // Arrange
    GetTableMetadataRequest request = GetTableMetadataRequest.newBuilder().setNamespace("namespace").setTable("table").build();
    @SuppressWarnings("unchecked") StreamObserver<GetTableMetadataResponse> responseObserver = mock(StreamObserver.class);
    TableMetadata tableMetadata = TableMetadata.newBuilder().addColumn("col1", DataType.INT).addColumn("col2", DataType.INT).addColumn("col3", DataType.TEXT).addPartitionKey("col1").addClusteringKey("col2").build();
    when(admin.getTableMetadata("namespace", "table")).thenReturn(tableMetadata);
    // Act
    adminService.getTableMetadata(request, responseObserver);
    // Assert
    verify(admin).getTableMetadata(any(), any());
    verify(responseObserver).onNext(GetTableMetadataResponse.newBuilder().setTableMetadata(ProtoUtils.toTableMetadata(tableMetadata)).build());
    verify(responseObserver).onCompleted();
}
Also used : TableMetadata(com.scalar.db.api.TableMetadata) GetTableMetadataResponse(com.scalar.db.rpc.GetTableMetadataResponse) GetTableMetadataRequest(com.scalar.db.rpc.GetTableMetadataRequest) Test(org.junit.jupiter.api.Test)

Aggregations

GetTableMetadataRequest (com.scalar.db.rpc.GetTableMetadataRequest)2 GetTableMetadataResponse (com.scalar.db.rpc.GetTableMetadataResponse)2 Test (org.junit.jupiter.api.Test)2 TableMetadata (com.scalar.db.api.TableMetadata)1