### Question:
InternalChannelz { @Nullable public InternalInstrumented<SocketStats> getSocket(long id) { InternalInstrumented<SocketStats> clientSocket = otherSockets.get(id); if (clientSocket != null) { return clientSocket; } return getServerSocket(id); } @VisibleForTesting  InternalChannelz(); static InternalChannelz instance(); void addServer(InternalInstrumented<ServerStats> server); void addSubchannel(InternalInstrumented<ChannelStats> subchannel); void addRootChannel(InternalInstrumented<ChannelStats> rootChannel); void addClientSocket(InternalInstrumented<SocketStats> socket); void addListenSocket(InternalInstrumented<SocketStats> socket); void addServerSocket(
      InternalInstrumented<ServerStats> server, InternalInstrumented<SocketStats> socket); void removeServer(InternalInstrumented<ServerStats> server); void removeSubchannel(InternalInstrumented<ChannelStats> subchannel); void removeRootChannel(InternalInstrumented<ChannelStats> channel); void removeClientSocket(InternalInstrumented<SocketStats> socket); void removeListenSocket(InternalInstrumented<SocketStats> socket); void removeServerSocket(
      InternalInstrumented<ServerStats> server, InternalInstrumented<SocketStats> socket); RootChannelList getRootChannels(long fromId, int maxPageSize); @Nullable InternalInstrumented<ChannelStats> getChannel(long id); @Nullable InternalInstrumented<ChannelStats> getSubchannel(long id); ServerList getServers(long fromId, int maxPageSize); @Nullable ServerSocketsList getServerSockets(long serverId, long fromId, int maxPageSize); @Nullable InternalInstrumented<SocketStats> getSocket(long id); @VisibleForTesting boolean containsServer(InternalLogId serverRef); @VisibleForTesting boolean containsSubchannel(InternalLogId subchannelRef); InternalInstrumented<ChannelStats> getRootChannel(long id); @VisibleForTesting boolean containsClientSocket(InternalLogId transportRef); static long id(InternalWithLogId withLogId);  }### Answer:
@Test public void getSocket() { InternalInstrumented<SocketStats> socket = create(); assertNull(channelz.getSocket(id(socket))); channelz.addClientSocket(socket); assertSame(socket, channelz.getSocket(id(socket))); channelz.removeClientSocket(socket); assertNull(channelz.getSocket(id(socket))); }