use of com.google.cloud.dialogflow.v2beta1.SessionName in project java-spanner by googleapis.
the class SpannerClientTest method rollbackExceptionTest.
@Test
public void rollbackExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockSpanner.addException(exception);
try {
SessionName session = SessionName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]");
ByteString transactionId = ByteString.EMPTY;
client.rollback(session, transactionId);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.cloud.dialogflow.v2beta1.SessionName in project java-spanner by googleapis.
the class SpannerClientTest method deleteSessionExceptionTest.
@Test
public void deleteSessionExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockSpanner.addException(exception);
try {
SessionName name = SessionName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]");
client.deleteSession(name);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.cloud.dialogflow.v2beta1.SessionName in project java-spanner by googleapis.
the class SpannerClientTest method getSessionTest.
@Test
public void getSessionTest() throws Exception {
Session expectedResponse = Session.newBuilder().setName(SessionName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]").toString()).putAllLabels(new HashMap<String, String>()).setCreateTime(Timestamp.newBuilder().build()).setApproximateLastUseTime(Timestamp.newBuilder().build()).build();
mockSpanner.addResponse(expectedResponse);
SessionName name = SessionName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]");
Session actualResponse = client.getSession(name);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockSpanner.getRequests();
Assert.assertEquals(1, actualRequests.size());
GetSessionRequest actualRequest = ((GetSessionRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations