use of com.google.logging.v2.UpdateViewRequest in project gapic-generator-java by googleapis.
the class ConfigClientTest method updateViewExceptionTest.
@Test
public void updateViewExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockConfigServiceV2.addException(exception);
try {
UpdateViewRequest request = UpdateViewRequest.newBuilder().setName("name3373707").setView(LogView.newBuilder().build()).setUpdateMask(FieldMask.newBuilder().build()).build();
client.updateView(request);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.logging.v2.UpdateViewRequest in project gapic-generator-java by googleapis.
the class AsyncUpdateView method asyncUpdateView.
public static void asyncUpdateView() throws Exception {
// It may require modifications to work in your environment.
try (ConfigClient configClient = ConfigClient.create()) {
UpdateViewRequest request = UpdateViewRequest.newBuilder().setName("name3373707").setView(LogView.newBuilder().build()).setUpdateMask(FieldMask.newBuilder().build()).build();
ApiFuture<LogView> future = configClient.updateViewCallable().futureCall(request);
// Do something.
LogView response = future.get();
}
}
use of com.google.logging.v2.UpdateViewRequest in project java-logging by googleapis.
the class ConfigClientTest method updateViewTest.
@Test
public void updateViewTest() 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);
UpdateViewRequest request = UpdateViewRequest.newBuilder().setName("name3373707").setView(LogView.newBuilder().build()).setUpdateMask(FieldMask.newBuilder().build()).build();
LogView actualResponse = client.updateView(request);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockConfigServiceV2.getRequests();
Assert.assertEquals(1, actualRequests.size());
UpdateViewRequest actualRequest = ((UpdateViewRequest) actualRequests.get(0));
Assert.assertEquals(request.getName(), actualRequest.getName());
Assert.assertEquals(request.getView(), actualRequest.getView());
Assert.assertEquals(request.getUpdateMask(), actualRequest.getUpdateMask());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.logging.v2.UpdateViewRequest in project java-logging by googleapis.
the class ConfigClientTest method updateViewExceptionTest.
@Test
public void updateViewExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockConfigServiceV2.addException(exception);
try {
UpdateViewRequest request = UpdateViewRequest.newBuilder().setName("name3373707").setView(LogView.newBuilder().build()).setUpdateMask(FieldMask.newBuilder().build()).build();
client.updateView(request);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.logging.v2.UpdateViewRequest in project gapic-generator-java by googleapis.
the class ConfigClientTest method updateViewTest.
@Test
public void updateViewTest() 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);
UpdateViewRequest request = UpdateViewRequest.newBuilder().setName("name3373707").setView(LogView.newBuilder().build()).setUpdateMask(FieldMask.newBuilder().build()).build();
LogView actualResponse = client.updateView(request);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockConfigServiceV2.getRequests();
Assert.assertEquals(1, actualRequests.size());
UpdateViewRequest actualRequest = ((UpdateViewRequest) actualRequests.get(0));
Assert.assertEquals(request.getName(), actualRequest.getName());
Assert.assertEquals(request.getView(), actualRequest.getView());
Assert.assertEquals(request.getUpdateMask(), actualRequest.getUpdateMask());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations