use of com.scalar.db.api.Scan in project scalardb by scalar-labs.
the class OperationCheckerTest method whenCheckingScanOperationWithReverseOrderings_shouldNotThrowAnyException.
@Test
public void whenCheckingScanOperationWithReverseOrderings_shouldNotThrowAnyException() {
// Arrange
Key partitionKey = new Key(PKEY1, 1, PKEY2, "val1");
Key startClusteringKey = new Key(CKEY1, 2, CKEY2, "val1");
Key endClusteringKey = new Key(CKEY1, 2, CKEY2, "val9");
List<String> projections = Arrays.asList(COL1, COL2, COL3);
int limit = 10;
Scan scan = new Scan(partitionKey).withStart(startClusteringKey).withEnd(endClusteringKey).withProjections(projections).withLimit(limit).withOrdering(new Scan.Ordering(CKEY1, Scan.Ordering.Order.DESC)).withOrdering(new Scan.Ordering(CKEY2, Scan.Ordering.Order.ASC)).forNamespace(NAMESPACE).forTable(TABLE_NAME);
// Act Assert
assertThatCode(() -> operationChecker.check(scan)).doesNotThrowAnyException();
}
use of com.scalar.db.api.Scan in project scalardb by scalar-labs.
the class OperationCheckerTest method whenCheckingScanOperationWithInvalidPartitionKey_shouldThrowIllegalArgumentException.
@Test
public void whenCheckingScanOperationWithInvalidPartitionKey_shouldThrowIllegalArgumentException() {
// Arrange
Key partitionKey = new Key(PKEY1, 1, "p3", "val1");
Key startClusteringKey = new Key(CKEY1, 2, CKEY2, "val1");
Key endClusteringKey = new Key(CKEY1, 2, CKEY2, "val9");
List<String> projections = Arrays.asList(COL1, COL2, COL3);
int limit = 10;
Scan scan = new Scan(partitionKey).withStart(startClusteringKey).withEnd(endClusteringKey).withProjections(projections).withLimit(limit).withOrdering(new Scan.Ordering(CKEY1, Scan.Ordering.Order.ASC)).withOrdering(new Scan.Ordering(CKEY2, Scan.Ordering.Order.DESC)).forNamespace(NAMESPACE).forTable(TABLE_NAME);
// Act Assert
assertThatThrownBy(() -> operationChecker.check(scan)).isInstanceOf(IllegalArgumentException.class);
}
use of com.scalar.db.api.Scan in project scalardb by scalar-labs.
the class OperationCheckerTest method whenCheckingScanOperationWithInvalidOrderings_shouldThrowIllegalArgumentException.
@Test
public void whenCheckingScanOperationWithInvalidOrderings_shouldThrowIllegalArgumentException() {
// Arrange
Key partitionKey = new Key(PKEY1, 1, PKEY2, "val1");
Key startClusteringKey = new Key(CKEY1, 2, CKEY2, "val1");
Key endClusteringKey = new Key(CKEY1, 2, CKEY2, "val9");
List<String> projections = Arrays.asList(COL1, COL2, COL3);
int limit = -10;
Scan scan = new Scan(partitionKey).withStart(startClusteringKey).withEnd(endClusteringKey).withProjections(projections).withLimit(limit).withOrdering(new Scan.Ordering(CKEY1, Scan.Ordering.Order.DESC)).withOrdering(new Scan.Ordering(CKEY2, Scan.Ordering.Order.DESC)).forNamespace(NAMESPACE).forTable(TABLE_NAME);
// Act Assert
assertThatThrownBy(() -> operationChecker.check(scan)).isInstanceOf(IllegalArgumentException.class);
}
use of com.scalar.db.api.Scan in project scalardb by scalar-labs.
the class OperationCheckerTest method whenCheckingScanOperationWithPartialClusteringKey_shouldNotThrowAnyException.
@Test
public void whenCheckingScanOperationWithPartialClusteringKey_shouldNotThrowAnyException() {
// Arrange
Key partitionKey = new Key(PKEY1, 1, PKEY2, "val1");
Key startClusteringKey = new Key(CKEY1, 1);
Key endClusteringKey = new Key(CKEY1, 9);
List<String> projections = Arrays.asList(COL1, COL2, COL3);
int limit = 10;
Scan scan = new Scan(partitionKey).withStart(startClusteringKey).withEnd(endClusteringKey).withProjections(projections).withLimit(limit).withOrdering(new Scan.Ordering(CKEY1, Scan.Ordering.Order.ASC)).withOrdering(new Scan.Ordering(CKEY2, Scan.Ordering.Order.DESC)).forNamespace(NAMESPACE).forTable(TABLE_NAME);
// Act Assert
assertThatCode(() -> operationChecker.check(scan)).doesNotThrowAnyException();
}
use of com.scalar.db.api.Scan in project scalardb by scalar-labs.
the class OperationCheckerTest method whenCheckingScanOperationWithIndexedColumnAsPartitionKeyWithOrderings_shouldThrowIllegalArgumentException.
@Test
public void whenCheckingScanOperationWithIndexedColumnAsPartitionKeyWithOrderings_shouldThrowIllegalArgumentException() {
// Arrange
Key partitionKey = new Key(COL1, 1);
Key startClusteringKey = null;
Key endClusteringKey = null;
List<String> projections = Arrays.asList(COL1, COL2, COL3);
int limit = 10;
Scan scan = new Scan(partitionKey).withStart(startClusteringKey).withStart(endClusteringKey).withProjections(projections).withLimit(limit).withOrdering(new Scan.Ordering(CKEY1, Scan.Ordering.Order.ASC)).forNamespace(NAMESPACE).forTable(TABLE_NAME);
// Act Assert
assertThatThrownBy(() -> operationChecker.check(scan)).isInstanceOf(IllegalArgumentException.class);
}
Aggregations