Search in sources :

Example 6 with WriteLogEntriesRequest

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));
}
Also used : WriteLogEntriesRequest(com.google.logging.v2.WriteLogEntriesRequest) WriteLogEntriesResponse(com.google.logging.v2.WriteLogEntriesResponse) Test(org.junit.Test)

Example 7 with WriteLogEntriesRequest

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));
}
Also used : WriteLogEntriesRequest(com.google.logging.v2.WriteLogEntriesRequest) WriteLogEntriesResponse(com.google.logging.v2.WriteLogEntriesResponse) Test(org.junit.Test)

Aggregations

WriteLogEntriesRequest (com.google.logging.v2.WriteLogEntriesRequest)7 WriteLogEntriesResponse (com.google.logging.v2.WriteLogEntriesResponse)6 Test (org.junit.Test)6 MonitoredResource (com.google.api.MonitoredResource)1 MonitoredResource (com.google.cloud.MonitoredResource)1 LogEntry (com.google.logging.v2.LogEntry)1 LogNameOneof (com.google.logging.v2.LogNameOneof)1 GeneratedMessageV3 (com.google.protobuf.GeneratedMessageV3)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1