use of com.google.logging.v2.GetViewRequest in project gapic-generator-java by googleapis.
the class ConfigClientTest method getViewTest.
@Test
public void getViewTest() throws Exception {
LogView expectedResponse = LogView.newBuilder().setName(LogViewName.ofProjectLocationBucketViewName("[PROJECT]", "[LOCATION]", "[BUCKET]", "[VIEW]").toString()).setDescription("description-1724546052").setCreateTime(Timestamp.newBuilder().build()).setUpdateTime(Timestamp.newBuilder().build()).setFilter("filter-1274492040").build();
mockConfigServiceV2.addResponse(expectedResponse);
GetViewRequest request = GetViewRequest.newBuilder().setName(LogViewName.ofProjectLocationBucketViewName("[PROJECT]", "[LOCATION]", "[BUCKET]", "[VIEW]").toString()).build();
LogView actualResponse = client.getView(request);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockConfigServiceV2.getRequests();
Assert.assertEquals(1, actualRequests.size());
GetViewRequest actualRequest = ((GetViewRequest) actualRequests.get(0));
Assert.assertEquals(request.getName(), actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.logging.v2.GetViewRequest in project gapic-generator-java by googleapis.
the class AsyncGetView method asyncGetView.
public static void asyncGetView() throws Exception {
// It may require modifications to work in your environment.
try (ConfigClient configClient = ConfigClient.create()) {
GetViewRequest request = GetViewRequest.newBuilder().setName(LogViewName.ofProjectLocationBucketViewName("[PROJECT]", "[LOCATION]", "[BUCKET]", "[VIEW]").toString()).build();
ApiFuture<LogView> future = configClient.getViewCallable().futureCall(request);
// Do something.
LogView response = future.get();
}
}
use of com.google.logging.v2.GetViewRequest in project gapic-generator-java by googleapis.
the class SyncGetView method syncGetView.
public static void syncGetView() throws Exception {
// It may require modifications to work in your environment.
try (ConfigClient configClient = ConfigClient.create()) {
GetViewRequest request = GetViewRequest.newBuilder().setName(LogViewName.ofProjectLocationBucketViewName("[PROJECT]", "[LOCATION]", "[BUCKET]", "[VIEW]").toString()).build();
LogView response = configClient.getView(request);
}
}
use of com.google.logging.v2.GetViewRequest in project java-logging by googleapis.
the class ConfigClientTest method getViewTest.
@Test
public void getViewTest() throws Exception {
LogView expectedResponse = LogView.newBuilder().setName(LogViewName.ofProjectLocationBucketViewName("[PROJECT]", "[LOCATION]", "[BUCKET]", "[VIEW]").toString()).setDescription("description-1724546052").setCreateTime(Timestamp.newBuilder().build()).setUpdateTime(Timestamp.newBuilder().build()).setFilter("filter-1274492040").build();
mockConfigServiceV2.addResponse(expectedResponse);
GetViewRequest request = GetViewRequest.newBuilder().setName(LogViewName.ofProjectLocationBucketViewName("[PROJECT]", "[LOCATION]", "[BUCKET]", "[VIEW]").toString()).build();
LogView actualResponse = client.getView(request);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockConfigServiceV2.getRequests();
Assert.assertEquals(1, actualRequests.size());
GetViewRequest actualRequest = ((GetViewRequest) actualRequests.get(0));
Assert.assertEquals(request.getName(), actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.logging.v2.GetViewRequest in project java-logging by googleapis.
the class ConfigClientTest method getViewExceptionTest.
@Test
public void getViewExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockConfigServiceV2.addException(exception);
try {
GetViewRequest request = GetViewRequest.newBuilder().setName(LogViewName.ofProjectLocationBucketViewName("[PROJECT]", "[LOCATION]", "[BUCKET]", "[VIEW]").toString()).build();
client.getView(request);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
Aggregations