### Question:
ChannelzProtoUtil { static ChannelData extractChannelData(InternalChannelz.ChannelStats stats) { ChannelData.Builder builder = ChannelData.newBuilder(); builder.setTarget(stats.target) .setState(toChannelConnectivityState(stats.state)) .setCallsStarted(stats.callsStarted) .setCallsSucceeded(stats.callsSucceeded) .setCallsFailed(stats.callsFailed) .setLastCallStartedTimestamp(Timestamps.fromNanos(stats.lastCallStartedNanos)); if (stats.channelTrace != null) { builder.setTrace(toChannelTrace(stats.channelTrace)); } return builder.build(); } private  ChannelzProtoUtil();  static final String SO_LINGER; static final String SO_TIMEOUT; static final String TCP_INFO; }### Answer:
@Test public void extractChannelData() { assertEquals(channelData, ChannelzProtoUtil.extractChannelData(channel.stats)); }
@Test public void channelTrace_withoutEvents() { ChannelStats stats = toBuilder(channel.stats) .setChannelTrace(new InternalChannelz.ChannelTrace.Builder() .setNumEventsLogged(1234) .setCreationTimeNanos(1000) .build()) .build(); ChannelData protoStats = channelData.toBuilder().setTrace(channelTrace).build(); assertEquals(ChannelzProtoUtil.extractChannelData(stats), protoStats); }
@Test public void channelTrace_withEvents() { Event event1 = new Event.Builder() .setDescription("event1") .setSeverity(Severity.CT_ERROR) .setTimestampNanos(12) .setSubchannelRef(subchannel) .build(); Event event2 = new Event.Builder() .setDescription("event2") .setTimestampNanos(34) .setSeverity(Severity.CT_INFO) .setChannelRef(channel) .build(); ChannelStats stats = toBuilder(channel.stats) .setChannelTrace( new InternalChannelz.ChannelTrace.Builder() .setNumEventsLogged(1234) .setCreationTimeNanos(1000) .setEvents(Arrays.asList(event1, event2)) .build()) .build(); ChannelTraceEvent protoEvent1 = ChannelTraceEvent .newBuilder() .setDescription("event1") .setTimestamp(Timestamps.fromNanos(12)) .setSeverity(ChannelTraceEvent.Severity.CT_ERROR) .setSubchannelRef(subchannelRef) .build(); ChannelTraceEvent protoEvent2 = ChannelTraceEvent .newBuilder() .setDescription("event2") .setTimestamp(Timestamps.fromNanos(34)) .setSeverity(ChannelTraceEvent.Severity.CT_INFO) .setChannelRef(channelRef) .build(); ChannelData protoStats = channelData .toBuilder() .setTrace(channelTrace .toBuilder() .addAllEvents(Arrays.asList(protoEvent1, protoEvent2)) .build()) .build(); assertEquals(ChannelzProtoUtil.extractChannelData(stats), protoStats); }