use of com.google.logging.v2.WriteLogEntriesRequest in project google-cloud-java by GoogleCloudPlatform.
the class LoggingImplTest method testWriteLogEntriesWithOptions.
@Test
public void testWriteLogEntriesWithOptions() {
Map<String, String> labels = ImmutableMap.of("key", "value");
WriteLogEntriesRequest request = WriteLogEntriesRequest.newBuilder().putAllLabels(labels).setLogName(LOG_NAME_PB).setResource(MONITORED_RESOURCE.toPb()).addAllEntries(Iterables.transform(ImmutableList.of(LOG_ENTRY1, LOG_ENTRY2), LogEntry.toPbFunction(PROJECT))).build();
WriteLogEntriesResponse response = WriteLogEntriesResponse.newBuilder().build();
EasyMock.expect(loggingRpcMock.write(request)).andReturn(ApiFutures.immediateFuture(response));
EasyMock.replay(rpcFactoryMock, loggingRpcMock);
logging = options.getService();
logging.write(ImmutableList.of(LOG_ENTRY1, LOG_ENTRY2), WriteOption.logName(LOG_NAME), WriteOption.resource(MONITORED_RESOURCE), WriteOption.labels(labels));
}
use of com.google.logging.v2.WriteLogEntriesRequest in project google-cloud-java by GoogleCloudPlatform.
the class LoggingImplTest method testWriteLogEntries.
@Test
public void testWriteLogEntries() {
WriteLogEntriesRequest request = WriteLogEntriesRequest.newBuilder().addAllEntries(Iterables.transform(ImmutableList.of(LOG_ENTRY1, LOG_ENTRY2), LogEntry.toPbFunction(PROJECT))).build();
WriteLogEntriesResponse response = WriteLogEntriesResponse.newBuilder().build();
EasyMock.expect(loggingRpcMock.write(request)).andReturn(ApiFutures.immediateFuture(response));
EasyMock.replay(rpcFactoryMock, loggingRpcMock);
logging = options.getService();
logging.write(ImmutableList.of(LOG_ENTRY1, LOG_ENTRY2));
}
Aggregations