3434import com .google .cloud .logging .Logging ;
3535import com .google .cloud .logging .Logging .WriteOption ;
3636import com .google .cloud .logging .LoggingOptions ;
37- import com .google .cloud .logging .Payload .StringPayload ;
37+ import com .google .cloud .logging .Payload .JsonPayload ;
3838import com .google .cloud .logging .Severity ;
3939import com .google .common .collect .ImmutableMap ;
40+ import java .util .HashMap ;
4041import java .util .Map ;
4142import org .easymock .Capture ;
4243import org .easymock .EasyMock ;
@@ -82,8 +83,11 @@ public void setUp() {
8283
8384 @ Test
8485 public void testFlushLevelConfigUpdatesLoggingFlushSeverity () {
86+ Map <String , Object > jsonContent = new HashMap <>();
87+ jsonContent .put ("message" , "this is a test" );
88+ JsonPayload payload = JsonPayload .of (jsonContent );
8589 LogEntry logEntry =
86- LogEntry .newBuilder (StringPayload . of ( "this is a test" ) )
90+ LogEntry .newBuilder (payload )
8791 .setTimestamp (100000L )
8892 .setSeverity (Severity .WARNING )
8993 .setLabels (
@@ -110,8 +114,14 @@ public void testFlushLevelConfigUpdatesLoggingFlushSeverity() {
110114
111115 @ Test
112116 public void testFilterLogsOnlyLogsAtOrAboveLogLevel () {
117+ Map <String , Object > jsonContent = new HashMap <>();
118+ jsonContent .put ("message" , "this is a test" );
119+ jsonContent .put (
120+ "@type" ,
121+ "type.googleapis.com/google.devtools.clouderrorreporting.v1beta1.ReportedErrorEvent" );
122+ JsonPayload payload = JsonPayload .of (jsonContent );
113123 LogEntry logEntry =
114- LogEntry .newBuilder (StringPayload . of ( "this is a test" ) )
124+ LogEntry .newBuilder (payload )
115125 .setTimestamp (100000L )
116126 .setSeverity (Severity .ERROR )
117127 .setLabels (
@@ -145,8 +155,11 @@ public void testFilterLogsOnlyLogsAtOrAboveLogLevel() {
145155
146156 @ Test
147157 public void testEnhancersAddCorrectLabelsToLogEntries () {
158+ Map <String , Object > jsonContent = new HashMap <>();
159+ jsonContent .put ("message" , "this is a test" );
160+ JsonPayload payload = JsonPayload .of (jsonContent );
148161 LogEntry logEntry =
149- LogEntry .newBuilder (StringPayload . of ( "this is a test" ) )
162+ LogEntry .newBuilder (payload )
150163 .setTimestamp (100000L )
151164 .setSeverity (Severity .WARNING )
152165 .setLabels (
@@ -194,8 +207,11 @@ public void testDefaultWriteOptionsHasExpectedDefaults() {
194207
195208 @ Test
196209 public void testMdcValuesAreConvertedToLabels () {
210+ Map <String , Object > jsonContent = new HashMap <>();
211+ jsonContent .put ("message" , "this is a test" );
212+ JsonPayload payload = JsonPayload .of (jsonContent );
197213 LogEntry logEntry =
198- LogEntry .newBuilder (StringPayload . of ( "this is a test" ) )
214+ LogEntry .newBuilder (payload )
199215 .setTimestamp (100000L )
200216 .setSeverity (Severity .INFO )
201217 .setLabels (
0 commit comments