use of com.scalar.db.api.Get in project scalardb by scalar-labs.
the class GrpcStorageTest method get_StubThrowInternalError_ShouldThrowExecutionException.
@Test
public void get_StubThrowInternalError_ShouldThrowExecutionException() {
// Arrange
Key partitionKey = new Key("col1", 1);
Get get = new Get(partitionKey);
when(blockingStub.get(any())).thenThrow(Status.INTERNAL.asRuntimeException());
// Act
assertThatThrownBy(() -> storage.get(get)).isInstanceOf(ExecutionException.class);
}
use of com.scalar.db.api.Get in project scalardb by scalar-labs.
the class GrpcStorageTest method get_isCalledWithProperArguments_StubShouldBeCalledProperly.
@Test
public void get_isCalledWithProperArguments_StubShouldBeCalledProperly() throws ExecutionException {
// Arrange
Key partitionKey = new Key("col1", 1);
Get get = new Get(partitionKey);
when(blockingStub.get(any())).thenReturn(GetResponse.newBuilder().build());
// Act
storage.get(get);
// Assert
verify(blockingStub).get(any());
}
use of com.scalar.db.api.Get in project scalardb by scalar-labs.
the class ConsensusCommitTest 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).forTable(ANY_TABLE_NAME);
}
use of com.scalar.db.api.Get in project scalardb by scalar-labs.
the class CrudHandlerTest method get_KeyNotExistsInCrudSetAndExceptionThrownInStorage_ShouldThrowCrudException.
@Test
public void get_KeyNotExistsInCrudSetAndExceptionThrownInStorage_ShouldThrowCrudException() throws CrudException, ExecutionException {
// Arrange
Get get = prepareGet();
when(snapshot.get(new Snapshot.Key(get))).thenReturn(Optional.empty());
ExecutionException toThrow = mock(ExecutionException.class);
when(storage.get(get)).thenThrow(toThrow);
// Act Assert
assertThatThrownBy(() -> handler.get(get)).isInstanceOf(CrudException.class).hasCause(toThrow);
}
use of com.scalar.db.api.Get in project scalardb by scalar-labs.
the class CrudHandlerTest method get_KeyNotExistsInSnapshotAndRecordInStorageNotCommitted_ShouldThrowUncommittedRecordException.
@Test
public void get_KeyNotExistsInSnapshotAndRecordInStorageNotCommitted_ShouldThrowUncommittedRecordException() throws CrudException, ExecutionException {
// Arrange
Get get = prepareGet();
Optional<Result> expected = Optional.of(prepareResult(TransactionState.PREPARED));
when(snapshot.get(new Snapshot.Key(get))).thenReturn(Optional.empty());
when(storage.get(get)).thenReturn(expected);
// Act Assert
assertThatThrownBy(() -> handler.get(get)).isInstanceOf(UncommittedRecordException.class);
}
Aggregations