use of com.google.longrunning.stub.OperationsStub in project gax-java by googleapis.
the class GrpcLongRunningClientTest method get.
@Test
public void get() {
OperationsStub operationsStub = mock(OperationsStub.class);
when(operationsStub.getOperationCallable()).thenReturn(new UnaryCallable<GetOperationRequest, Operation>() {
@Override
public ApiFuture<Operation> futureCall(GetOperationRequest request, ApiCallContext context) {
if (!request.getName().equals("poseidon")) {
return ApiFutures.immediateFailedFuture(new IllegalStateException("Unexpected request: " + request));
} else {
return ApiFutures.immediateFuture(Operation.newBuilder().setName("greece").build());
}
}
});
LongRunningClient longRunningClient = new GrpcLongRunningClient(operationsStub);
Truth.assertThat(longRunningClient.getOperationCallable().call("poseidon").getName()).isEqualTo("greece");
}
use of com.google.longrunning.stub.OperationsStub in project gax-java by googleapis.
the class GrpcLongRunningClientTest method delete.
@Test
public void delete() {
OperationsStub operationsStub = mock(OperationsStub.class);
when(operationsStub.deleteOperationCallable()).thenReturn(new UnaryCallable<DeleteOperationRequest, Empty>() {
@Override
public ApiFuture<Empty> futureCall(DeleteOperationRequest request, ApiCallContext context) {
if (!request.getName().equals("poseidon")) {
return ApiFutures.immediateFailedFuture(new IllegalStateException("Unexpected request: " + request));
} else {
return ApiFutures.immediateFuture(Empty.getDefaultInstance());
}
}
});
LongRunningClient longRunningClient = new GrpcLongRunningClient(operationsStub);
Truth.assertThat(longRunningClient.deleteOperationCallable().call("poseidon")).isNull();
}
use of com.google.longrunning.stub.OperationsStub in project gax-java by googleapis.
the class GrpcLongRunningClientTest method cancel.
@Test
public void cancel() {
OperationsStub operationsStub = mock(OperationsStub.class);
when(operationsStub.cancelOperationCallable()).thenReturn(new UnaryCallable<CancelOperationRequest, Empty>() {
@Override
public ApiFuture<Empty> futureCall(CancelOperationRequest request, ApiCallContext context) {
if (!request.getName().equals("poseidon")) {
return ApiFutures.immediateFailedFuture(new IllegalStateException("Unexpected request: " + request));
} else {
return ApiFutures.immediateFuture(Empty.getDefaultInstance());
}
}
});
LongRunningClient longRunningClient = new GrpcLongRunningClient(operationsStub);
Truth.assertThat(longRunningClient.cancelOperationCallable().call("poseidon")).isNull();
}
Aggregations