### Question:
NetworkDataProvider { public long getPeerCount() { return network.streamPeers().count(); } NetworkDataProvider(final Eth2Network network); Optional<String> getEnr(); String getNodeIdAsBase58(); List<String> getPeersAsBase58(); long getPeerCount(); int getListenPort(); List<String> getListeningAddresses(); List<String> getDiscoveryAddresses(); Metadata getMetadata(); List<tech.pegasys.teku.api.response.v1.node.Peer> getPeers(); Optional<tech.pegasys.teku.api.response.v1.node.Peer> getPeerById(final String peerId);  }### Answer:
@Test void getPeerCount_shouldReturnTotalPeers() { final NetworkDataProvider network = new NetworkDataProvider(p2pNetwork); final Eth2Peer peer1 = mock(Eth2Peer.class); final Eth2Peer peer2 = mock(Eth2Peer.class); when(p2pNetwork.streamPeers()).thenReturn(Stream.of(peer1, peer2)); assertThat(network.getPeerCount()).isEqualTo(2); verify(p2pNetwork).streamPeers(); }
@Test void getPeerCount_shouldReturnTotalPeersIfEmpty() { final NetworkDataProvider network = new NetworkDataProvider(p2pNetwork); when(p2pNetwork.streamPeers()).thenReturn(Stream.of()); assertThat(network.getPeerCount()).isEqualTo(0); verify(p2pNetwork).streamPeers(); }