Search in sources :

Example 1 with GetSinkRequest

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

the class LoggingImplTest method testGetSink.

@Test
public void testGetSink() {
    LogSink sinkPb = SINK_INFO.toPb(PROJECT);
    ApiFuture<LogSink> response = ApiFutures.immediateFuture(sinkPb);
    GetSinkRequest request = GetSinkRequest.newBuilder().setSinkName(SINK_NAME_PB).build();
    EasyMock.expect(loggingRpcMock.get(request)).andReturn(response);
    EasyMock.replay(rpcFactoryMock, loggingRpcMock);
    logging = options.getService();
    Sink sink = logging.getSink(SINK_NAME);
    assertEquals(new Sink(logging, new SinkInfo.BuilderImpl(SINK_INFO)), sink);
}
Also used : LogSink(com.google.logging.v2.LogSink) GetSinkRequest(com.google.logging.v2.GetSinkRequest) LogSink(com.google.logging.v2.LogSink) Test(org.junit.Test)

Example 2 with GetSinkRequest

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

the class LoggingImplTest method testGetSinkAsync_Null.

@Test
public void testGetSinkAsync_Null() throws ExecutionException, InterruptedException {
    ApiFuture<LogSink> response = ApiFutures.immediateFuture(null);
    GetSinkRequest request = GetSinkRequest.newBuilder().setSinkName(SINK_NAME_PB).build();
    EasyMock.expect(loggingRpcMock.get(request)).andReturn(response);
    EasyMock.replay(rpcFactoryMock, loggingRpcMock);
    logging = options.getService();
    assertNull(logging.getSinkAsync(SINK_NAME).get());
}
Also used : LogSink(com.google.logging.v2.LogSink) GetSinkRequest(com.google.logging.v2.GetSinkRequest) Test(org.junit.Test)

Example 3 with GetSinkRequest

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

the class LoggingImplTest method testGetSink_Null.

@Test
public void testGetSink_Null() {
    ApiFuture<LogSink> response = ApiFutures.immediateFuture(null);
    GetSinkRequest request = GetSinkRequest.newBuilder().setSinkName(SINK_NAME_PB).build();
    EasyMock.expect(loggingRpcMock.get(request)).andReturn(response);
    EasyMock.replay(rpcFactoryMock, loggingRpcMock);
    logging = options.getService();
    assertNull(logging.getSink(SINK_NAME));
}
Also used : LogSink(com.google.logging.v2.LogSink) GetSinkRequest(com.google.logging.v2.GetSinkRequest) Test(org.junit.Test)

Example 4 with GetSinkRequest

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

the class LoggingImplTest method testGetSinkAsync.

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

Example 5 with GetSinkRequest

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

the class ConfigClientTest method getSinkTest.

@Test
@SuppressWarnings("all")
public void getSinkTest() {
    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 actualResponse = client.getSink(sinkName);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<GeneratedMessageV3> actualRequests = mockConfigServiceV2.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    GetSinkRequest actualRequest = (GetSinkRequest) actualRequests.get(0);
    Assert.assertEquals(sinkName, actualRequest.getSinkNameAsSinkNameOneof());
}
Also used : LogSink(com.google.logging.v2.LogSink) GetSinkRequest(com.google.logging.v2.GetSinkRequest) ResourceName(com.google.api.resourcenames.ResourceName) SinkNameOneof(com.google.logging.v2.SinkNameOneof) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) Test(org.junit.Test)

Aggregations

GetSinkRequest (com.google.logging.v2.GetSinkRequest)5 LogSink (com.google.logging.v2.LogSink)5 Test (org.junit.Test)5 ResourceName (com.google.api.resourcenames.ResourceName)1 SinkNameOneof (com.google.logging.v2.SinkNameOneof)1 GeneratedMessageV3 (com.google.protobuf.GeneratedMessageV3)1