use of com.scalar.db.api.TableMetadata in project scalardb by scalar-labs.
the class DynamoAdminTest method createTable_tableMetadataWithBooleanSecondaryIndexGiven_ShouldThrowIllegalArgumentException.
@Test
public void createTable_tableMetadataWithBooleanSecondaryIndexGiven_ShouldThrowIllegalArgumentException() {
// Arrange
TableMetadata metadata = TableMetadata.newBuilder().addPartitionKey("c1").addColumn("c1", DataType.INT).addColumn("c2", DataType.BOOLEAN).addSecondaryIndex("c2").build();
// Act Assert
assertThatThrownBy(() -> admin.createTable(NAMESPACE, TABLE, metadata)).isInstanceOf(IllegalArgumentException.class);
}
use of com.scalar.db.api.TableMetadata in project scalardb by scalar-labs.
the class DynamoOperationCheckerTest method setUp.
@BeforeEach
public void setUp() throws Exception {
openMocks(this).close();
TableMetadata tableMetadata = TableMetadata.newBuilder().addColumn(PKEY1, DataType.INT).addColumn(COL1, DataType.INT).addColumn(COL2, DataType.DOUBLE).addPartitionKey(PKEY1).addSecondaryIndex(COL1).build();
when(metadataManager.getTableMetadata(any())).thenReturn(tableMetadata);
operationChecker = new DynamoOperationChecker(metadataManager);
}
use of com.scalar.db.api.TableMetadata in project scalardb by scalar-labs.
the class CosmosAdminTest method createTable_WithBlobClusteringKey_ShouldThrowIllegalArgumentException.
@Test
public void createTable_WithBlobClusteringKey_ShouldThrowIllegalArgumentException() {
// Arrange
String namespace = "ns";
String table = "sample_table";
TableMetadata metadata = TableMetadata.newBuilder().addPartitionKey("c3").addClusteringKey("c1").addColumn("c1", DataType.BLOB).addColumn("c2", DataType.BIGINT).addColumn("c3", DataType.BOOLEAN).build();
// Act Assert
assertThatThrownBy(() -> admin.createTable(namespace, table, metadata)).isInstanceOf(IllegalArgumentException.class);
}
use of com.scalar.db.api.TableMetadata in project scalardb by scalar-labs.
the class TableMetadataManagerTest method getTableMetadata_CalledOnce_ShouldCallDistributedStorageAdminOnce.
@Test
public void getTableMetadata_CalledOnce_ShouldCallDistributedStorageAdminOnce() throws ExecutionException {
// Arrange
TableMetadataManager tableMetadataManager = new TableMetadataManager(admin, -1);
TableMetadata expectedTableMetadata = TableMetadata.newBuilder().addColumn("c1", DataType.INT).addColumn("c2", DataType.INT).addPartitionKey("c1").build();
when(admin.getTableMetadata(anyString(), anyString())).thenReturn(expectedTableMetadata);
// Act
TableMetadata actualTableMetadata = tableMetadataManager.getTableMetadata(new Get(new Key("c1", "aaa")).forNamespace("ns").forTable("tbl"));
// Assert
verify(admin).getTableMetadata(anyString(), anyString());
assertThat(actualTableMetadata).isEqualTo(expectedTableMetadata);
}
use of com.scalar.db.api.TableMetadata in project scalardb by scalar-labs.
the class GrpcTransactionOnBidirectionalStream method get.
public Optional<Result> get(Get get) throws CrudException {
throwIfTransactionFinished();
ResponseOrError responseOrError = sendRequest(TransactionRequest.newBuilder().setGetRequest(GetRequest.newBuilder().setGet(ProtoUtils.toGet(get))).build());
throwIfErrorForCrud(responseOrError);
GetResponse getResponse = responseOrError.getResponse().getGetResponse();
if (getResponse.hasResult()) {
TableMetadata tableMetadata = getTableMetadata(get);
return Optional.of(ProtoUtils.toResult(getResponse.getResult(), tableMetadata));
}
return Optional.empty();
}
Aggregations