Search in sources :

Example 6 with RootChannelList

use of io.grpc.InternalChannelz.RootChannelList in project grpc-java by grpc.

the class ChannelzProtoUtilTest method toGetTopChannelsResponse.

@Test
public void toGetTopChannelsResponse() {
    // empty results
    assertEquals(GetTopChannelsResponse.newBuilder().setEnd(true).build(), ChannelzProtoUtil.toGetTopChannelResponse(new RootChannelList(Collections.<InternalInstrumented<ChannelStats>>emptyList(), true)));
    // 1 result, paginated
    assertEquals(GetTopChannelsResponse.newBuilder().addChannel(channelProto).build(), ChannelzProtoUtil.toGetTopChannelResponse(new RootChannelList(ImmutableList.<InternalInstrumented<ChannelStats>>of(channel), false)));
    // 1 result, end
    assertEquals(GetTopChannelsResponse.newBuilder().addChannel(channelProto).setEnd(true).build(), ChannelzProtoUtil.toGetTopChannelResponse(new RootChannelList(ImmutableList.<InternalInstrumented<ChannelStats>>of(channel), true)));
    // 2 results, end
    TestChannel channel2 = new TestChannel();
    assertEquals(GetTopChannelsResponse.newBuilder().addChannel(channelProto).addChannel(ChannelzProtoUtil.toChannel(channel2)).setEnd(true).build(), ChannelzProtoUtil.toGetTopChannelResponse(new RootChannelList(ImmutableList.<InternalInstrumented<ChannelStats>>of(channel, channel2), true)));
}
Also used : ChannelStats(io.grpc.InternalChannelz.ChannelStats) RootChannelList(io.grpc.InternalChannelz.RootChannelList) TestChannel(io.grpc.protobuf.services.ChannelzTestHelper.TestChannel) Test(org.junit.Test)

Aggregations

RootChannelList (io.grpc.InternalChannelz.RootChannelList)6 Test (org.junit.Test)6 ChannelStats (io.grpc.InternalChannelz.ChannelStats)5 TestChannel (io.grpc.protobuf.services.ChannelzTestHelper.TestChannel)1