@Test public void testWhenURLIsOwn() { final NodeInfo partyInfo = NodeInfo.Builder.create().withUrl(OWN_URL).build(); when(partyStore.getParties()).thenReturn(Set.of(URI.create(OWN_URL))); when(discovery.getCurrent()).thenReturn(partyInfo); when(partyInfoParser.to(any(PartyInfo.class))).thenReturn(DATA); when(p2pClient.sendPartyInfo(OWN_URL, DATA)).thenReturn(true); partyInfoBroadcaster.run(); verify(partyStore).loadFromConfigIfEmpty(); verify(partyStore).getParties(); verify(partyInfoParser).to(any(PartyInfo.class)); verify(discovery).getCurrent(); }
@Override public void run() { LOGGER.info("Started PartyInfo polling round"); partyStore.loadFromConfigIfEmpty(); final NodeInfo nodeInfo = discovery.getCurrent(); final NodeUri ourUrl = NodeUri.create(nodeInfo.getUrl()); final PartyInfo partyInfo = PartyInfoBuilder.create() .withUri(nodeInfo.getUrl()) .withRecipients(nodeInfo.getRecipientsAsMap()) .build(); final byte[] encodedPartyInfo = partyInfoParser.to(partyInfo); LOGGER.debug("Contacting following peers with PartyInfo: {}", partyInfo.getParties()); LOGGER.debug("Sending party info {}", nodeInfo); partyStore.getParties().stream() .map(NodeUri::create) .filter(url -> !ourUrl.equals(url)) .forEach(url -> pollSingleParty(url.asString(), encodedPartyInfo)); LOGGER.info("Finished PartyInfo polling round"); }
PartyInfoBroadcaster implements Runnable { @Override public void run() { LOGGER.info("Started PartyInfo polling round"); partyStore.loadFromConfigIfEmpty(); final NodeInfo nodeInfo = discovery.getCurrent(); final NodeUri ourUrl = NodeUri.create(nodeInfo.getUrl()); final PartyInfo partyInfo = PartyInfoBuilder.create() .withUri(nodeInfo.getUrl()) .withRecipients(nodeInfo.getRecipientsAsMap()) .build(); final byte[] encodedPartyInfo = partyInfoParser.to(partyInfo); LOGGER.debug("Contacting following peers with PartyInfo: {}", partyInfo.getParties()); LOGGER.debug("Sending party info {}", nodeInfo); partyStore.getParties().stream() .map(NodeUri::create) .filter(url -> !ourUrl.equals(url)) .forEach(url -> pollSingleParty(url.asString(), encodedPartyInfo)); LOGGER.info("Finished PartyInfo polling round"); } }
PartyInfoBroadcaster implements Runnable { @Override public void run() { LOGGER.info("Started PartyInfo polling round"); partyStore.loadFromConfigIfEmpty(); final NodeInfo nodeInfo = discovery.getCurrent(); final NodeUri ourUrl = NodeUri.create(nodeInfo.getUrl()); final PartyInfo partyInfo = PartyInfoBuilder.create() .withUri(nodeInfo.getUrl()) .withRecipients(nodeInfo.getRecipientsAsMap()) .build(); final byte[] encodedPartyInfo = partyInfoParser.to(partyInfo); LOGGER.debug("Contacting following peers with PartyInfo: {}", partyInfo.getParties()); LOGGER.debug("Sending party info {}", nodeInfo); partyStore.getParties().stream() .map(NodeUri::create) .filter(url -> !ourUrl.equals(url)) .forEach(url -> pollSingleParty(url.asString(), encodedPartyInfo)); LOGGER.info("Finished PartyInfo polling round"); } PartyInfoBroadcaster(final P2pClient p2pClient);  PartyInfoBroadcaster(
        final Discovery discovery,
        final PartyInfoParser partyInfoParser,
        final P2pClient p2pClient,
        final Executor executor,
        final PartyStore partyStore); }
PartyInfoBroadcaster implements Runnable { @Override public void run() { LOGGER.info("Started PartyInfo polling round"); partyStore.loadFromConfigIfEmpty(); final NodeInfo nodeInfo = discovery.getCurrent(); final NodeUri ourUrl = NodeUri.create(nodeInfo.getUrl()); final PartyInfo partyInfo = PartyInfoBuilder.create() .withUri(nodeInfo.getUrl()) .withRecipients(nodeInfo.getRecipientsAsMap()) .build(); final byte[] encodedPartyInfo = partyInfoParser.to(partyInfo); LOGGER.debug("Contacting following peers with PartyInfo: {}", partyInfo.getParties()); LOGGER.debug("Sending party info {}", nodeInfo); partyStore.getParties().stream() .map(NodeUri::create) .filter(url -> !ourUrl.equals(url)) .forEach(url -> pollSingleParty(url.asString(), encodedPartyInfo)); LOGGER.info("Finished PartyInfo polling round"); } PartyInfoBroadcaster(final P2pClient p2pClient);  PartyInfoBroadcaster(
        final Discovery discovery,
        final PartyInfoParser partyInfoParser,
        final P2pClient p2pClient,
        final Executor executor,
        final PartyStore partyStore); @Override void run(); }
PartyInfoBroadcaster implements Runnable { @Override public void run() { LOGGER.info("Started PartyInfo polling round"); partyStore.loadFromConfigIfEmpty(); final NodeInfo nodeInfo = discovery.getCurrent(); final NodeUri ourUrl = NodeUri.create(nodeInfo.getUrl()); final PartyInfo partyInfo = PartyInfoBuilder.create() .withUri(nodeInfo.getUrl()) .withRecipients(nodeInfo.getRecipientsAsMap()) .build(); final byte[] encodedPartyInfo = partyInfoParser.to(partyInfo); LOGGER.debug("Contacting following peers with PartyInfo: {}", partyInfo.getParties()); LOGGER.debug("Sending party info {}", nodeInfo); partyStore.getParties().stream() .map(NodeUri::create) .filter(url -> !ourUrl.equals(url)) .forEach(url -> pollSingleParty(url.asString(), encodedPartyInfo)); LOGGER.info("Finished PartyInfo polling round"); } PartyInfoBroadcaster(final P2pClient p2pClient);  PartyInfoBroadcaster(
        final Discovery discovery,
        final PartyInfoParser partyInfoParser,
        final P2pClient p2pClient,
        final Executor executor,
        final PartyStore partyStore); @Override void run();  }