use of com.google.logging.v2.LogSink 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);
}
use of com.google.logging.v2.LogSink 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);
}
use of com.google.logging.v2.LogSink 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);
}
use of com.google.logging.v2.LogSink in project google-cloud-java by GoogleCloudPlatform.
the class ConfigClientTest method listSinksTest.
@Test
@SuppressWarnings("all")
public void listSinksTest() {
String nextPageToken = "";
LogSink sinksElement = LogSink.newBuilder().build();
List<LogSink> sinks = Arrays.asList(sinksElement);
ListSinksResponse expectedResponse = ListSinksResponse.newBuilder().setNextPageToken(nextPageToken).addAllSinks(sinks).build();
mockConfigServiceV2.addResponse(expectedResponse);
ParentNameOneof parent = ParentNameOneof.from(ProjectName.create("[PROJECT]"));
ListSinksPagedResponse pagedListResponse = client.listSinks(parent);
List<LogSink> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getSinksList().get(0), resources.get(0));
List<GeneratedMessageV3> actualRequests = mockConfigServiceV2.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListSinksRequest actualRequest = (ListSinksRequest) actualRequests.get(0);
Assert.assertEquals(parent, actualRequest.getParentAsParentNameOneof());
}
use of com.google.logging.v2.LogSink 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());
}
Aggregations