Search in sources :

Example 91 with ResultSet

use of com.google.api.ads.admanager.jaxws.v202205.ResultSet in project grpc-gcp-java by GoogleCloudPlatform.

the class SpannerProbesTest method testExecuteSql.

@Test
public void testExecuteSql() throws Exception {
    Value value = Value.newBuilder().setStringValue(TEST_USERNAME).build();
    ListValue row = ListValue.newBuilder().addValues(value).build();
    ResultSet response = ResultSet.newBuilder().addRows(row).build();
    PartialResultSet responseList = PartialResultSet.newBuilder().addValues(value).build();
    serviceImpl.addResponse(session);
    serviceImpl.addResponse(response);
    serviceImpl.addResponse(responseList);
    serviceImpl.addResponse(emptyResponse);
    SpannerProbes.executeSqlProber(stub);
    verify(serviceImpl, times(1)).createSession(any(), any());
    verify(serviceImpl, times(1)).executeSql(any(), any());
    verify(serviceImpl, times(1)).executeStreamingSql(any(), any());
    verify(serviceImpl, times(1)).deleteSession(any(), any());
}
Also used : ListValue(com.google.protobuf.ListValue) Value(com.google.protobuf.Value) ListValue(com.google.protobuf.ListValue) PartialResultSet(com.google.spanner.v1.PartialResultSet) ResultSet(com.google.spanner.v1.ResultSet) PartialResultSet(com.google.spanner.v1.PartialResultSet) Test(org.junit.Test)

Example 92 with ResultSet

use of com.google.api.ads.admanager.jaxws.v202205.ResultSet in project grpc-gcp-java by GoogleCloudPlatform.

the class SpannerProbesTest method testRead.

@Test
public void testRead() throws Exception {
    Value value = Value.newBuilder().setStringValue(TEST_USERNAME).build();
    ListValue row = ListValue.newBuilder().addValues(value).build();
    ResultSet response = ResultSet.newBuilder().addRows(row).build();
    PartialResultSet responseList = PartialResultSet.newBuilder().addValues(value).build();
    serviceImpl.addResponse(session);
    serviceImpl.addResponse(response);
    serviceImpl.addResponse(responseList);
    serviceImpl.addResponse(emptyResponse);
    SpannerProbes.readProber(stub);
    verify(serviceImpl, times(1)).createSession(any(), any());
    verify(serviceImpl, times(1)).read(any(), any());
    verify(serviceImpl, times(1)).streamingRead(any(), any());
    verify(serviceImpl, times(1)).deleteSession(any(), any());
}
Also used : ListValue(com.google.protobuf.ListValue) Value(com.google.protobuf.Value) ListValue(com.google.protobuf.ListValue) PartialResultSet(com.google.spanner.v1.PartialResultSet) ResultSet(com.google.spanner.v1.ResultSet) PartialResultSet(com.google.spanner.v1.PartialResultSet) Test(org.junit.Test)

Example 93 with ResultSet

use of com.google.api.ads.admanager.jaxws.v202205.ResultSet in project grpc-gcp-java by GoogleCloudPlatform.

the class SpannerClientV1TestCases method testRead.

void testRead() throws InterruptedException {
    System.out.println("\nTestRead");
    SpannerClient client = getClient();
    Session session = client.createSession(CreateSessionRequest.newBuilder().setDatabase(database).build());
    ReadRequest request = ReadRequest.newBuilder().setSession(session.getName()).setTable(TABLE).setKeySet(KeySet.newBuilder().setAll(true).build()).addColumns("users").addColumns("firstname").addColumns("lastname").build();
    RpcCall<ReadRequest, ResultSet> rpcCall = (ReadRequest req) -> client.read(req);
    doTestBlocking(request, rpcCall);
    cleanUpClient(client, session.getName());
}
Also used : PartialResultSet(com.google.spanner.v1.PartialResultSet) ResultSet(com.google.spanner.v1.ResultSet) SpannerClient(com.google.cloud.spanner.v1.SpannerClient) Session(com.google.spanner.v1.Session) ReadRequest(com.google.spanner.v1.ReadRequest)

Example 94 with ResultSet

use of com.google.api.ads.admanager.jaxws.v202205.ResultSet in project grpc-gcp-java by GoogleCloudPlatform.

the class SpannerTestCases method testExecuteSql.

void testExecuteSql() throws InterruptedException {
    System.out.println("\nTestExecuteSql");
    ManagedChannel channel = getChannel();
    SpannerBlockingStub stub = getBlockingStub(channel);
    Session session = stub.createSession(CreateSessionRequest.newBuilder().setDatabase(database).build());
    ExecuteSqlRequest request = ExecuteSqlRequest.newBuilder().setSession(session.getName()).setSql("select * FROM " + TABLE).build();
    BlockingCall<ExecuteSqlRequest, ResultSet> blockingCall = (ExecuteSqlRequest req) -> stub.executeSql(req);
    doTestBlocking(channel, request, blockingCall);
    stub.deleteSession(DeleteSessionRequest.newBuilder().setName(session.getName()).build());
    channel.shutdown().awaitTermination(5, TimeUnit.SECONDS);
}
Also used : SpannerBlockingStub(com.google.spanner.v1.SpannerGrpc.SpannerBlockingStub) ExecuteSqlRequest(com.google.spanner.v1.ExecuteSqlRequest) PartialResultSet(com.google.spanner.v1.PartialResultSet) ResultSet(com.google.spanner.v1.ResultSet) ManagedChannel(io.grpc.ManagedChannel) GcpManagedChannel(com.google.grpc.gcp.GcpManagedChannel) Session(com.google.spanner.v1.Session)

Example 95 with ResultSet

use of com.google.api.ads.admanager.jaxws.v202205.ResultSet in project grpc-gcp-java by GoogleCloudPlatform.

the class SpannerTestCases method testExecuteSqlAsync.

void testExecuteSqlAsync() throws InterruptedException {
    System.out.println("\nTestExecuteSqlAsync");
    ManagedChannel channel = getChannel();
    SpannerStub stub = getStub(channel);
    AsyncResponseObserver<Session> sessionObs = new AsyncResponseObserver<>();
    stub.createSession(CreateSessionRequest.newBuilder().setDatabase(database).build(), sessionObs);
    ExecuteSqlRequest request = ExecuteSqlRequest.newBuilder().setSession(sessionObs.get().getName()).setSql("select * FROM " + TABLE).build();
    AsyncCall<ExecuteSqlRequest, ResultSet> asyncCall = (ExecuteSqlRequest req, AsyncResponseObserver<ResultSet> resp) -> stub.executeSql(req, resp);
    doTestAsync(channel, request, asyncCall);
    deleteAndCloseAsync(stub, channel, sessionObs.get().getName());
}
Also used : ExecuteSqlRequest(com.google.spanner.v1.ExecuteSqlRequest) SpannerStub(com.google.spanner.v1.SpannerGrpc.SpannerStub) PartialResultSet(com.google.spanner.v1.PartialResultSet) ResultSet(com.google.spanner.v1.ResultSet) ManagedChannel(io.grpc.ManagedChannel) GcpManagedChannel(com.google.grpc.gcp.GcpManagedChannel) Session(com.google.spanner.v1.Session)

Aggregations

Test (org.junit.Test)37 ResultSet (com.google.spanner.v1.ResultSet)21 PartialResultSet (com.google.spanner.v1.PartialResultSet)14 ResultSet (com.google.api.ads.admanager.axis.v202108.ResultSet)12 ResultSet (com.google.api.ads.admanager.axis.v202111.ResultSet)12 ResultSet (com.google.api.ads.admanager.axis.v202202.ResultSet)12 ResultSet (com.google.api.ads.admanager.axis.v202205.ResultSet)12 Function (com.google.common.base.Function)10 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202108.StatementBuilder)8 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder)8 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202202.StatementBuilder)8 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202205.StatementBuilder)8 PublisherQueryLanguageServiceInterface (com.google.api.ads.admanager.axis.v202108.PublisherQueryLanguageServiceInterface)8 PublisherQueryLanguageServiceInterface (com.google.api.ads.admanager.axis.v202111.PublisherQueryLanguageServiceInterface)8 PublisherQueryLanguageServiceInterface (com.google.api.ads.admanager.axis.v202202.PublisherQueryLanguageServiceInterface)8 PublisherQueryLanguageServiceInterface (com.google.api.ads.admanager.axis.v202205.PublisherQueryLanguageServiceInterface)8 Session (com.google.spanner.v1.Session)8 DateTime (org.joda.time.DateTime)8 ListValue (com.google.protobuf.ListValue)5 ResultSet (org.apache.cassandra.cql3.ResultSet)5