use of com.scalar.db.io.Key in project scalardb by scalar-labs.
the class DistributedStorageIntegrationTestBase method get_GetGivenForIndexedColumnMatchingMultipleRecords_ShouldThrowIllegalArgumentException.
@Test
public void get_GetGivenForIndexedColumnMatchingMultipleRecords_ShouldThrowIllegalArgumentException() {
// Arrange
populateRecords();
int c3 = 3;
Get get = new Get(new Key(COL_NAME3, c3));
// Act Assert
assertThatThrownBy(() -> storage.get(get)).isInstanceOf(IllegalArgumentException.class);
}
use of com.scalar.db.io.Key in project scalardb by scalar-labs.
the class DistributedStorageIntegrationTestBase method get_GetGivenForIndexedColumn_ShouldGet.
@Test
public void get_GetGivenForIndexedColumn_ShouldGet() throws ExecutionException {
// Arrange
// (0,0)
storage.put(preparePuts().get(0));
int c3 = 0;
Get get = new Get(new Key(COL_NAME3, c3));
// Act
Optional<Result> actual = storage.get(get);
// Assert
assertThat(actual.isPresent()).isTrue();
assertThat(actual.get().getValue(COL_NAME1)).isEqualTo(Optional.of(new IntValue(COL_NAME1, 0)));
assertThat(actual.get().getValue(COL_NAME4)).isEqualTo(Optional.of(new IntValue(COL_NAME4, 0)));
}
use of com.scalar.db.io.Key in project scalardb by scalar-labs.
the class DistributedStorageIntegrationTestBase method operation_NoTargetGiven_ShouldThrowIllegalArgumentException.
@Test
public void operation_NoTargetGiven_ShouldThrowIllegalArgumentException() {
// Arrange
storage.with(null, TABLE);
Key partitionKey = new Key(COL_NAME1, 0);
Key clusteringKey = new Key(COL_NAME4, 0);
Get get = new Get(partitionKey, clusteringKey);
// Act Assert
assertThatThrownBy(() -> storage.get(get)).isInstanceOf(IllegalArgumentException.class);
}
use of com.scalar.db.io.Key in project scalardb by scalar-labs.
the class DistributedStorageIntegrationTestBase method scannerIterator_IteratorCalledMultipleTimes_ShouldRetrieveCorrectResults.
@Test
public void scannerIterator_IteratorCalledMultipleTimes_ShouldRetrieveCorrectResults() throws ExecutionException, IOException {
// Arrange
populateRecords();
int pKey = 0;
// Act
Scan scan = new Scan(new Key(COL_NAME1, pKey));
List<Result> actual = new ArrayList<>();
Scanner scanner = storage.scan(scan);
actual.add(scanner.iterator().next());
actual.add(scanner.iterator().next());
actual.add(scanner.iterator().next());
scanner.close();
// Assert
assertThat(actual.size()).isEqualTo(3);
assertThat(actual.get(0).getValue(COL_NAME1).isPresent()).isTrue();
assertThat(actual.get(0).getValue(COL_NAME1).get().getAsInt()).isEqualTo(0);
assertThat(actual.get(0).getValue(COL_NAME4).isPresent()).isTrue();
assertThat(actual.get(0).getValue(COL_NAME4).get().getAsInt()).isEqualTo(0);
assertThat(actual.get(1).getValue(COL_NAME1).isPresent()).isTrue();
assertThat(actual.get(1).getValue(COL_NAME1).get().getAsInt()).isEqualTo(0);
assertThat(actual.get(1).getValue(COL_NAME4).isPresent()).isTrue();
assertThat(actual.get(1).getValue(COL_NAME4).get().getAsInt()).isEqualTo(1);
assertThat(actual.get(2).getValue(COL_NAME1).isPresent()).isTrue();
assertThat(actual.get(2).getValue(COL_NAME1).get().getAsInt()).isEqualTo(0);
assertThat(actual.get(2).getValue(COL_NAME4).isPresent()).isTrue();
assertThat(actual.get(2).getValue(COL_NAME4).get().getAsInt()).isEqualTo(2);
}
use of com.scalar.db.io.Key in project scalardb by scalar-labs.
the class DistributedStorageIntegrationTestBase method operation_WrongNamespaceGiven_ShouldThrowIllegalArgumentException.
@Test
public void operation_WrongNamespaceGiven_ShouldThrowIllegalArgumentException() {
// Arrange
// a wrong namespace
storage.with("wrong_" + namespace, TABLE);
Key partitionKey = new Key(COL_NAME1, 0);
Key clusteringKey = new Key(COL_NAME4, 0);
Get get = new Get(partitionKey, clusteringKey);
// Act Assert
assertThatThrownBy(() -> storage.get(get)).isInstanceOf(IllegalArgumentException.class);
}
Aggregations