Search in sources :

Example 81 with Get

use of com.scalar.db.api.Get in project scalardb by scalar-labs.

the class MultiStorageTest method whenGetDataFromTable1InNamespace2_DataShouldBeGottenFromStorage2.

@Test
public void whenGetDataFromTable1InNamespace2_DataShouldBeGottenFromStorage2() throws ExecutionException {
    // Arrange
    String namespace = NAMESPACE2;
    String table = TABLE1;
    Key partitionKey = new Key(COL_NAME1, 1);
    Key clusteringKey = new Key(COL_NAME2, 2);
    Get get = new Get(partitionKey, clusteringKey).forNamespace(namespace).forTable(table);
    // Act
    multiStorage.get(get);
    // Assert
    verify(storage2).get(any(Get.class));
}
Also used : Get(com.scalar.db.api.Get) Key(com.scalar.db.io.Key) Test(org.junit.jupiter.api.Test)

Example 82 with Get

use of com.scalar.db.api.Get in project scalardb by scalar-labs.

the class MultiStorageTest method whenGetDataFromTable3_DataShouldBeGottenFromDefaultStorage.

@Test
public void whenGetDataFromTable3_DataShouldBeGottenFromDefaultStorage() throws ExecutionException {
    // Arrange
    String namespace = NAMESPACE1;
    String table = TABLE3;
    Key partitionKey = new Key(COL_NAME1, 1);
    Key clusteringKey = new Key(COL_NAME2, 2);
    Get get = new Get(partitionKey, clusteringKey).forNamespace(namespace).forTable(table);
    // Act
    multiStorage.get(get);
    // Assert
    verify(storage3).get(any(Get.class));
}
Also used : Get(com.scalar.db.api.Get) Key(com.scalar.db.io.Key) Test(org.junit.jupiter.api.Test)

Example 83 with Get

use of com.scalar.db.api.Get in project scalardb by scalar-labs.

the class DynamoOperationTest method prepareGet.

private Get prepareGet() {
    Key partitionKey = new Key(ANY_NAME_1, ANY_TEXT_1);
    Key clusteringKey = new Key(ANY_NAME_2, ANY_TEXT_2);
    return new Get(partitionKey, clusteringKey).forNamespace(ANY_NAMESPACE_NAME).forTable(ANY_TABLE_NAME);
}
Also used : Get(com.scalar.db.api.Get) Key(com.scalar.db.io.Key)

Example 84 with Get

use of com.scalar.db.api.Get in project scalardb by scalar-labs.

the class DynamoOperationTest method getTableName_GetGiven_ShouldReturnTableName.

@Test
public void getTableName_GetGiven_ShouldReturnTableName() {
    // Arrange
    Get get = prepareGet();
    DynamoOperation dynamoOperation = new DynamoOperation(get, metadata);
    // Act
    String actual = dynamoOperation.getTableName();
    // Assert
    assertThat(actual).isEqualTo(ANY_NAMESPACE_NAME + "." + ANY_TABLE_NAME);
}
Also used : Get(com.scalar.db.api.Get) Test(org.junit.jupiter.api.Test)

Example 85 with Get

use of com.scalar.db.api.Get in project scalardb by scalar-labs.

the class DynamoOperationTest method getKeyMap_GetGiven_ShouldReturnMap.

@Test
public void getKeyMap_GetGiven_ShouldReturnMap() {
    // Arrange
    Get get = prepareGet();
    DynamoOperation dynamoOperation = new DynamoOperation(get, metadata);
    Map<String, AttributeValue> expected = new HashMap<>();
    expected.put(DynamoOperation.PARTITION_KEY, AttributeValue.builder().b(SdkBytes.fromByteBuffer(new KeyBytesEncoder().encode(new Key(ANY_NAME_1, ANY_TEXT_1)))).build());
    expected.put(DynamoOperation.CLUSTERING_KEY, AttributeValue.builder().b(SdkBytes.fromByteBuffer(new KeyBytesEncoder().encode(new Key(ANY_NAME_2, ANY_TEXT_2)))).build());
    // Act
    Map<String, AttributeValue> actual = dynamoOperation.getKeyMap();
    // Assert
    assertThat(actual).isEqualTo(expected);
}
Also used : AttributeValue(software.amazon.awssdk.services.dynamodb.model.AttributeValue) KeyBytesEncoder(com.scalar.db.storage.dynamo.bytes.KeyBytesEncoder) HashMap(java.util.HashMap) Get(com.scalar.db.api.Get) Key(com.scalar.db.io.Key) Test(org.junit.jupiter.api.Test)

Aggregations

Get (com.scalar.db.api.Get)286 Test (org.junit.jupiter.api.Test)130 Result (com.scalar.db.api.Result)129 Key (com.scalar.db.io.Key)126 Test (org.junit.Test)88 Put (com.scalar.db.api.Put)86 GrpcTransaction (com.scalar.db.transaction.rpc.GrpcTransaction)32 Delete (com.scalar.db.api.Delete)28 IntValue (com.scalar.db.io.IntValue)28 Assertions.catchThrowable (org.assertj.core.api.Assertions.catchThrowable)21 TextValue (com.scalar.db.io.TextValue)16 ConditionalExpression (com.scalar.db.api.ConditionalExpression)13 PartitionKey (com.azure.cosmos.models.PartitionKey)12 TableMetadata (com.scalar.db.api.TableMetadata)10 BooleanValue (com.scalar.db.io.BooleanValue)10 PutIf (com.scalar.db.api.PutIf)8 BigIntValue (com.scalar.db.io.BigIntValue)7 HashMap (java.util.HashMap)7 BlobValue (com.scalar.db.io.BlobValue)6 DistributedTransactionServiceWithConsensusCommitIntegrationTest.prepareGet (com.scalar.db.server.DistributedTransactionServiceWithConsensusCommitIntegrationTest.prepareGet)6