Search in sources :

Example 1 with UpdateSinkRequest

use of com.google.logging.v2.UpdateSinkRequest 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 2 with UpdateSinkRequest

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

the class LoggingImplTest method testUpdateSink.

@Test
public void testUpdateSink() {
    LogSink sinkPb = SINK_INFO.toPb(PROJECT);
    ApiFuture<LogSink> response = ApiFutures.immediateFuture(sinkPb);
    UpdateSinkRequest request = UpdateSinkRequest.newBuilder().setSinkName(SINK_NAME_PB).setSink(sinkPb).build();
    EasyMock.expect(loggingRpcMock.update(request)).andReturn(response);
    EasyMock.replay(rpcFactoryMock, loggingRpcMock);
    logging = options.getService();
    Sink sink = logging.update(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) UpdateSinkRequest(com.google.logging.v2.UpdateSinkRequest) Test(org.junit.Test)

Example 3 with UpdateSinkRequest

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

the class LoggingImplTest method testUpdateSinkAsync.

@Test
public void testUpdateSinkAsync() throws ExecutionException, InterruptedException {
    LogSink sinkPb = SINK_INFO.toPb(PROJECT);
    ApiFuture<LogSink> response = ApiFutures.immediateFuture(sinkPb);
    UpdateSinkRequest request = UpdateSinkRequest.newBuilder().setSinkName(SINK_NAME_PB).setSink(sinkPb).build();
    EasyMock.expect(loggingRpcMock.update(request)).andReturn(response);
    EasyMock.replay(rpcFactoryMock, loggingRpcMock);
    logging = options.getService();
    Sink sink = logging.updateAsync(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) UpdateSinkRequest(com.google.logging.v2.UpdateSinkRequest) Test(org.junit.Test)

Aggregations

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