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));
}
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));
}
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);
}
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);
}
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);
}
Aggregations