use of com.scalar.db.rpc.GetRequest in project scalardb by scalar-labs.
the class DistributedStorageServiceTest method get_GateKeeperReturnsFalse_ShouldThrowUnavailableError.
@Test
public void get_GateKeeperReturnsFalse_ShouldThrowUnavailableError() {
// Arrange
GetRequest request = GetRequest.newBuilder().build();
@SuppressWarnings("unchecked") StreamObserver<GetResponse> responseObserver = mock(StreamObserver.class);
when(gateKeeper.letIn()).thenReturn(false);
// Act
storageService.get(request, responseObserver);
// Assert
verify(responseObserver).onError(exceptionCaptor.capture());
assertThat(exceptionCaptor.getValue().getStatus().getCode()).isEqualTo(Code.UNAVAILABLE);
}
use of com.scalar.db.rpc.GetRequest in project scalardb by scalar-labs.
the class DistributedStorageServiceTest method get_IsCalledWithProperArguments_StorageShouldBeCalledProperly.
@Test
public void get_IsCalledWithProperArguments_StorageShouldBeCalledProperly() throws ExecutionException {
// Arrange
GetRequest request = GetRequest.newBuilder().build();
@SuppressWarnings("unchecked") StreamObserver<GetResponse> responseObserver = mock(StreamObserver.class);
// Act
storageService.get(request, responseObserver);
// Assert
verify(storage).get(any());
verify(responseObserver).onNext(any());
verify(responseObserver).onCompleted();
}
use of com.scalar.db.rpc.GetRequest in project scalardb by scalar-labs.
the class DistributedStorageServiceTest method get_StorageThrowsExecutionException_ShouldThrowInternalError.
@Test
public void get_StorageThrowsExecutionException_ShouldThrowInternalError() throws ExecutionException {
// Arrange
GetRequest request = GetRequest.newBuilder().build();
@SuppressWarnings("unchecked") StreamObserver<GetResponse> responseObserver = mock(StreamObserver.class);
when(storage.get(any())).thenThrow(ExecutionException.class);
// Act
storageService.get(request, responseObserver);
// Assert
verify(responseObserver).onError(exceptionCaptor.capture());
assertThat(exceptionCaptor.getValue().getStatus().getCode()).isEqualTo(Status.Code.INTERNAL);
}
use of com.scalar.db.rpc.GetRequest in project scalardb by scalar-labs.
the class DistributedStorageServiceTest method get_StorageThrowsIllegalArgumentException_ShouldThrowInvalidArgumentError.
@Test
public void get_StorageThrowsIllegalArgumentException_ShouldThrowInvalidArgumentError() throws ExecutionException {
// Arrange
GetRequest request = GetRequest.newBuilder().build();
@SuppressWarnings("unchecked") StreamObserver<GetResponse> responseObserver = mock(StreamObserver.class);
when(storage.get(any())).thenThrow(IllegalArgumentException.class);
// Act
storageService.get(request, responseObserver);
// Assert
verify(responseObserver).onError(exceptionCaptor.capture());
assertThat(exceptionCaptor.getValue().getStatus().getCode()).isEqualTo(Status.Code.INVALID_ARGUMENT);
}
Aggregations