Search in sources :

Example 1 with CreateSinkRequest

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

the class ConfigClientTest method createSinkTest.

@Test
@SuppressWarnings("all")
public void createSinkTest() {
    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);
    ParentNameOneof parent = ParentNameOneof.from(ProjectName.create("[PROJECT]"));
    LogSink sink = LogSink.newBuilder().build();
    LogSink actualResponse = client.createSink(parent, sink);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<GeneratedMessageV3> actualRequests = mockConfigServiceV2.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    CreateSinkRequest actualRequest = (CreateSinkRequest) actualRequests.get(0);
    Assert.assertEquals(parent, actualRequest.getParentAsParentNameOneof());
    Assert.assertEquals(sink, actualRequest.getSink());
}
Also used : LogSink(com.google.logging.v2.LogSink) ResourceName(com.google.api.resourcenames.ResourceName) ParentNameOneof(com.google.logging.v2.ParentNameOneof) CreateSinkRequest(com.google.logging.v2.CreateSinkRequest) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) Test(org.junit.Test)

Example 2 with CreateSinkRequest

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

the class LoggingImplTest method testCreateSink.

@Test
public void testCreateSink() {
    LogSink sinkPb = SINK_INFO.toPb(PROJECT);
    ApiFuture<LogSink> response = ApiFutures.immediateFuture(sinkPb);
    CreateSinkRequest request = CreateSinkRequest.newBuilder().setParent(PROJECT_PB).setSink(sinkPb).build();
    EasyMock.expect(loggingRpcMock.create(request)).andReturn(response);
    EasyMock.replay(rpcFactoryMock, loggingRpcMock);
    logging = options.getService();
    Sink sink = logging.create(SINK_INFO);
    assertEquals(new Sink(logging, new SinkInfo.BuilderImpl(SINK_INFO)), sink);
}
Also used : LogSink(com.google.logging.v2.LogSink) LogSink(com.google.logging.v2.LogSink) CreateSinkRequest(com.google.logging.v2.CreateSinkRequest) Test(org.junit.Test)

Example 3 with CreateSinkRequest

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

the class LoggingImplTest method testCreateSinkAsync.

@Test
public void testCreateSinkAsync() throws ExecutionException, InterruptedException {
    LogSink sinkPb = SINK_INFO.toPb(PROJECT);
    ApiFuture<LogSink> response = ApiFutures.immediateFuture(sinkPb);
    CreateSinkRequest request = CreateSinkRequest.newBuilder().setParent(PROJECT_PB).setSink(sinkPb).build();
    EasyMock.expect(loggingRpcMock.create(request)).andReturn(response);
    EasyMock.replay(rpcFactoryMock, loggingRpcMock);
    logging = options.getService();
    Sink sink = logging.createAsync(SINK_INFO).get();
    assertEquals(new Sink(logging, new SinkInfo.BuilderImpl(SINK_INFO)), sink);
}
Also used : LogSink(com.google.logging.v2.LogSink) LogSink(com.google.logging.v2.LogSink) CreateSinkRequest(com.google.logging.v2.CreateSinkRequest) Test(org.junit.Test)

Aggregations

CreateSinkRequest (com.google.logging.v2.CreateSinkRequest)3 LogSink (com.google.logging.v2.LogSink)3 Test (org.junit.Test)3 ResourceName (com.google.api.resourcenames.ResourceName)1 ParentNameOneof (com.google.logging.v2.ParentNameOneof)1 GeneratedMessageV3 (com.google.protobuf.GeneratedMessageV3)1