Search in sources :

Example 1 with SinkNameOneof

use of com.google.logging.v2.SinkNameOneof in project google-cloud-java by GoogleCloudPlatform.

the class ConfigClientTest method updateSinkExceptionTest.

@Test
@SuppressWarnings("all")
public void updateSinkExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
    mockConfigServiceV2.addException(exception);
    try {
        SinkNameOneof sinkName = SinkNameOneof.from(SinkName.create("[PROJECT]", "[SINK]"));
        LogSink sink = LogSink.newBuilder().build();
        client.updateSink(sinkName, sink);
        Assert.fail("No exception raised");
    } catch (ApiException e) {
        Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
    }
}
Also used : LogSink(com.google.logging.v2.LogSink) SinkNameOneof(com.google.logging.v2.SinkNameOneof) StatusRuntimeException(io.grpc.StatusRuntimeException) ApiException(com.google.api.gax.grpc.ApiException) Test(org.junit.Test)

Example 2 with SinkNameOneof

use of com.google.logging.v2.SinkNameOneof in project google-cloud-java by GoogleCloudPlatform.

the class ConfigClientTest method updateSinkTest.

@Test
@SuppressWarnings("all")
public void updateSinkTest() {
    String name = "name3373707";
    ResourceName destination = ProjectName.create("[PROJECT]");
    String filter = "filter-1274492040";
    String writerIdentity = "writerIdentity775638794";
    LogSink expectedResponse = LogSink.newBuilder().setName(name).setDestinationWithResourceName(destination).setFilter(filter).setWriterIdentity(writerIdentity).build();
    mockConfigServiceV2.addResponse(expectedResponse);
    SinkNameOneof sinkName = SinkNameOneof.from(SinkName.create("[PROJECT]", "[SINK]"));
    LogSink sink = LogSink.newBuilder().build();
    LogSink actualResponse = client.updateSink(sinkName, sink);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<GeneratedMessageV3> actualRequests = mockConfigServiceV2.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    UpdateSinkRequest actualRequest = (UpdateSinkRequest) actualRequests.get(0);
    Assert.assertEquals(sinkName, actualRequest.getSinkNameAsSinkNameOneof());
    Assert.assertEquals(sink, actualRequest.getSink());
}
Also used : LogSink(com.google.logging.v2.LogSink) ResourceName(com.google.api.resourcenames.ResourceName) SinkNameOneof(com.google.logging.v2.SinkNameOneof) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) UpdateSinkRequest(com.google.logging.v2.UpdateSinkRequest) Test(org.junit.Test)

Example 3 with SinkNameOneof

use of com.google.logging.v2.SinkNameOneof in project google-cloud-java by GoogleCloudPlatform.

the class ConfigClientTest method deleteSinkExceptionTest.

@Test
@SuppressWarnings("all")
public void deleteSinkExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
    mockConfigServiceV2.addException(exception);
    try {
        SinkNameOneof sinkName = SinkNameOneof.from(SinkName.create("[PROJECT]", "[SINK]"));
        client.deleteSink(sinkName);
        Assert.fail("No exception raised");
    } catch (ApiException e) {
        Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
    }
}
Also used : SinkNameOneof(com.google.logging.v2.SinkNameOneof) StatusRuntimeException(io.grpc.StatusRuntimeException) ApiException(com.google.api.gax.grpc.ApiException) Test(org.junit.Test)

Example 4 with SinkNameOneof

use of com.google.logging.v2.SinkNameOneof in project google-cloud-java by GoogleCloudPlatform.

the class ConfigClientTest method deleteSinkTest.

@Test
@SuppressWarnings("all")
public void deleteSinkTest() {
    Empty expectedResponse = Empty.newBuilder().build();
    mockConfigServiceV2.addResponse(expectedResponse);
    SinkNameOneof sinkName = SinkNameOneof.from(SinkName.create("[PROJECT]", "[SINK]"));
    client.deleteSink(sinkName);
    List<GeneratedMessageV3> actualRequests = mockConfigServiceV2.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    DeleteSinkRequest actualRequest = (DeleteSinkRequest) actualRequests.get(0);
    Assert.assertEquals(sinkName, actualRequest.getSinkNameAsSinkNameOneof());
}
Also used : Empty(com.google.protobuf.Empty) DeleteSinkRequest(com.google.logging.v2.DeleteSinkRequest) SinkNameOneof(com.google.logging.v2.SinkNameOneof) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) Test(org.junit.Test)

Example 5 with SinkNameOneof

use of com.google.logging.v2.SinkNameOneof in project google-cloud-java by GoogleCloudPlatform.

the class ConfigClientTest method getSinkExceptionTest.

@Test
@SuppressWarnings("all")
public void getSinkExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
    mockConfigServiceV2.addException(exception);
    try {
        SinkNameOneof sinkName = SinkNameOneof.from(SinkName.create("[PROJECT]", "[SINK]"));
        client.getSink(sinkName);
        Assert.fail("No exception raised");
    } catch (ApiException e) {
        Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
    }
}
Also used : SinkNameOneof(com.google.logging.v2.SinkNameOneof) StatusRuntimeException(io.grpc.StatusRuntimeException) ApiException(com.google.api.gax.grpc.ApiException) Test(org.junit.Test)

Aggregations

SinkNameOneof (com.google.logging.v2.SinkNameOneof)6 Test (org.junit.Test)6 ApiException (com.google.api.gax.grpc.ApiException)3 LogSink (com.google.logging.v2.LogSink)3 GeneratedMessageV3 (com.google.protobuf.GeneratedMessageV3)3 StatusRuntimeException (io.grpc.StatusRuntimeException)3 ResourceName (com.google.api.resourcenames.ResourceName)2 DeleteSinkRequest (com.google.logging.v2.DeleteSinkRequest)2 GetSinkRequest (com.google.logging.v2.GetSinkRequest)1 UpdateSinkRequest (com.google.logging.v2.UpdateSinkRequest)1 Empty (com.google.protobuf.Empty)1