@Test public void provideAutoDiscovery() { when(runtimeContext.isDisablePeerDiscovery()).thenReturn(false); Discovery discovery = DiscoveryFactory.provider(); assertThat(discovery).isNotNull().isExactlyInstanceOf(AutoDiscovery.class); verify(runtimeContext).isDisablePeerDiscovery(); }
public static Discovery provider() { final NetworkStore networkStore = NetworkStore.getInstance(); final RuntimeContext runtimeContext = RuntimeContext.getInstance(); final Discovery discovery; if(runtimeContext.isDisablePeerDiscovery()) { final Set<NodeUri> knownNodes = runtimeContext.getPeers().stream() .map(NodeUri::create) .collect(Collectors.toUnmodifiableSet()); discovery = new DisabledAutoDiscovery(networkStore,knownNodes); } else { discovery = new AutoDiscovery(networkStore); } return discovery; }
DiscoveryFactory implements Discovery { public static Discovery provider() { final NetworkStore networkStore = NetworkStore.getInstance(); final RuntimeContext runtimeContext = RuntimeContext.getInstance(); final Discovery discovery; if(runtimeContext.isDisablePeerDiscovery()) { final Set<NodeUri> knownNodes = runtimeContext.getPeers().stream() .map(NodeUri::create) .collect(Collectors.toUnmodifiableSet()); discovery = new DisabledAutoDiscovery(networkStore,knownNodes); } else { discovery = new AutoDiscovery(networkStore); } return discovery; } }
DiscoveryFactory implements Discovery { public static Discovery provider() { final NetworkStore networkStore = NetworkStore.getInstance(); final RuntimeContext runtimeContext = RuntimeContext.getInstance(); final Discovery discovery; if(runtimeContext.isDisablePeerDiscovery()) { final Set<NodeUri> knownNodes = runtimeContext.getPeers().stream() .map(NodeUri::create) .collect(Collectors.toUnmodifiableSet()); discovery = new DisabledAutoDiscovery(networkStore,knownNodes); } else { discovery = new AutoDiscovery(networkStore); } return discovery; } DiscoveryFactory(); protected  DiscoveryFactory(Discovery discovery); }
DiscoveryFactory implements Discovery { public static Discovery provider() { final NetworkStore networkStore = NetworkStore.getInstance(); final RuntimeContext runtimeContext = RuntimeContext.getInstance(); final Discovery discovery; if(runtimeContext.isDisablePeerDiscovery()) { final Set<NodeUri> knownNodes = runtimeContext.getPeers().stream() .map(NodeUri::create) .collect(Collectors.toUnmodifiableSet()); discovery = new DisabledAutoDiscovery(networkStore,knownNodes); } else { discovery = new AutoDiscovery(networkStore); } return discovery; } DiscoveryFactory(); protected  DiscoveryFactory(Discovery discovery); static Discovery provider(); @Override void onCreate(); @Override void onUpdate(NodeInfo nodeInfo); @Override void onDisconnect(URI nodeUri); }
DiscoveryFactory implements Discovery { public static Discovery provider() { final NetworkStore networkStore = NetworkStore.getInstance(); final RuntimeContext runtimeContext = RuntimeContext.getInstance(); final Discovery discovery; if(runtimeContext.isDisablePeerDiscovery()) { final Set<NodeUri> knownNodes = runtimeContext.getPeers().stream() .map(NodeUri::create) .collect(Collectors.toUnmodifiableSet()); discovery = new DisabledAutoDiscovery(networkStore,knownNodes); } else { discovery = new AutoDiscovery(networkStore); } return discovery; } DiscoveryFactory(); protected  DiscoveryFactory(Discovery discovery); static Discovery provider(); @Override void onCreate(); @Override void onUpdate(NodeInfo nodeInfo); @Override void onDisconnect(URI nodeUri);  }