Search in sources :

Example 1 with UpdateViewRequest

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.
    }
}
Also used : UpdateViewRequest(com.google.logging.v2.UpdateViewRequest) InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) StatusRuntimeException(io.grpc.StatusRuntimeException) Test(org.junit.Test)

Example 2 with UpdateViewRequest

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();
    }
}
Also used : ConfigClient(com.google.cloud.logging.v2.ConfigClient) UpdateViewRequest(com.google.logging.v2.UpdateViewRequest) LogView(com.google.logging.v2.LogView)

Example 3 with UpdateViewRequest

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()));
}
Also used : UpdateViewRequest(com.google.logging.v2.UpdateViewRequest) AbstractMessage(com.google.protobuf.AbstractMessage) LogView(com.google.logging.v2.LogView) Test(org.junit.Test)

Example 4 with UpdateViewRequest

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.
    }
}
Also used : UpdateViewRequest(com.google.logging.v2.UpdateViewRequest) InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) StatusRuntimeException(io.grpc.StatusRuntimeException) Test(org.junit.Test)

Example 5 with UpdateViewRequest

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()));
}
Also used : UpdateViewRequest(com.google.logging.v2.UpdateViewRequest) AbstractMessage(com.google.protobuf.AbstractMessage) LogView(com.google.logging.v2.LogView) Test(org.junit.Test)

Aggregations

UpdateViewRequest (com.google.logging.v2.UpdateViewRequest)6 LogView (com.google.logging.v2.LogView)4 Test (org.junit.Test)4 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)2 ConfigClient (com.google.cloud.logging.v2.ConfigClient)2 AbstractMessage (com.google.protobuf.AbstractMessage)2 StatusRuntimeException (io.grpc.StatusRuntimeException)2