@Test public void testLogRequest_jsontToProto() throws InvalidProtocolBufferException { List<LogEvent> events = new ArrayList<>(); events.add( LogEvent.protoBuilder(EMPTY_BYTE_ARRAY) .setEventTimeMs(100L) .setEventUptimeMs(4000L) .setTimezoneOffsetSeconds(123) .setNetworkConnectionInfo( NetworkConnectionInfo.builder() .setMobileSubtype(NetworkConnectionInfo.MobileSubtype.EDGE) .setNetworkType(NetworkConnectionInfo.NetworkType.BLUETOOTH) .build()) .build()); LogRequest request = LogRequest.builder() .setRequestUptimeMs(1000L) .setRequestTimeMs(4300L) .setClientInfo( ClientInfo.builder() .setClientType(ClientInfo.ClientType.ANDROID_FIREBASE) .setAndroidClientInfo(AndroidClientInfo.builder().setDevice("device").build()) .build()) .setSource("logSource") .setLogEvents(events) .build(); List<LogRequest> requests = new ArrayList<>(); requests.add(request); com.google.android.datatransport.cct.internal.BatchedLogRequest batchedLogRequest = com.google.android.datatransport.cct.internal.BatchedLogRequest.create(requests); String json = createDataEncoder().encode(batchedLogRequest); BatchedLogRequest.Builder protoLogRequestBuilder = BatchedLogRequest.newBuilder(); JsonFormat.parser().merge(json, protoLogRequestBuilder); BatchedLogRequest parsedProtoBatchedLogRequest = protoLogRequestBuilder.build(); BatchedLogRequest expectedProto = BatchedLogRequest.newBuilder() .addLogRequest( com.google.android.datatransport.cct.proto.LogRequest.newBuilder() .setRequestUptimeMs(1000L) .setRequestTimeMs(4300L) .setLogSourceName("logSource") .setClientInfo( com.google.android.datatransport.cct.proto.ClientInfo.newBuilder() .setClientType( com.google.android.datatransport.cct.proto.ClientInfo.ClientType .ANDROID_FIREBASE) .setAndroidClientInfo( com.google.android.datatransport.cct.proto.AndroidClientInfo .newBuilder() .setDevice("device") .build()) .build()) .addLogEvent( com.google.android.datatransport.cct.proto.LogEvent.newBuilder() .setSourceExtension(ByteString.EMPTY) .setEventUptimeMs(4000L) .setEventTimeMs(100L) .setTimezoneOffsetSeconds(123L) .setNetworkConnectionInfo( com.google.android.datatransport.cct.proto.NetworkConnectionInfo .newBuilder() .setMobileSubtype( com.google.android.datatransport.cct.proto .NetworkConnectionInfo.MobileSubtype.EDGE) .setNetworkType( com.google.android.datatransport.cct.proto .NetworkConnectionInfo.NetworkType.BLUETOOTH) .build()) .build()) .build()) .build(); assertThat(parsedProtoBatchedLogRequest).isEqualTo(expectedProto); }
@NonNull public static Builder builder() { return new AutoValue_LogRequest.Builder(); }
LogRequest { @NonNull public static Builder builder() { return new AutoValue_LogRequest.Builder(); } }
LogRequest { @NonNull public static Builder builder() { return new AutoValue_LogRequest.Builder(); }  }
LogRequest { @NonNull public static Builder builder() { return new AutoValue_LogRequest.Builder(); }  abstract long getRequestTimeMs(); abstract long getRequestUptimeMs(); @Nullable abstract ClientInfo getClientInfo(); @Nullable abstract Integer getLogSource(); @Nullable abstract String getLogSourceName(); @Nullable @Encodable.Field(name = "logEvent") abstract List<LogEvent> getLogEvents(); @Nullable abstract QosTier getQosTier(); @NonNull static Builder builder(); }
LogRequest { @NonNull public static Builder builder() { return new AutoValue_LogRequest.Builder(); }  abstract long getRequestTimeMs(); abstract long getRequestUptimeMs(); @Nullable abstract ClientInfo getClientInfo(); @Nullable abstract Integer getLogSource(); @Nullable abstract String getLogSourceName(); @Nullable @Encodable.Field(name = "logEvent") abstract List<LogEvent> getLogEvents(); @Nullable abstract QosTier getQosTier(); @NonNull static Builder builder();  }