Skip to content

Commit

Permalink
update test to retrieve json format (GoogleCloudPlatform#2378)
Browse files Browse the repository at this point in the history
Same fix as GoogleCloudPlatform#2377, but for logging sample test.

The logging format switched from text to json in com.google.cloud.google-cloud-logging-logback:v0.117.0 (googleapis/java-logging-logback#43).

This PR fixes the trace integration test by switching from reading textPayload to jsonPayload for verification of trace correlation to log.
  • Loading branch information
kateryna216 authored and GitHub committed May 19, 2020
1 parent 37ed84d commit ac3c7bf
Showing 1 changed file with 3 additions and 1 deletion.
Expand Up @@ -16,6 +16,7 @@

package com.example;

import com.google.cloud.logging.Payload.JsonPayload;
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -108,7 +109,8 @@ public void testLogRecordedInStackDriver() {
});

List<String> logContents = logEntries.stream()
.map((logEntry) -> ((StringPayload) logEntry.getPayload()).getData())
.map((logEntry) -> (String) ((JsonPayload) logEntry.getPayload())
.getDataAsMap().get("message"))
.collect(Collectors.toList());

assertThat(logContents).containsExactlyInAnyOrder(
Expand Down

0 comments on commit ac3c7bf

Please sign in to comment.