@Test public void testRequestPeerList() throws Exception { Method method = SocketRemoteSiteListener.class.getDeclaredMethod("handleRequest", ServerProtocol.class, Peer.class, RequestType.class); method.setAccessible(true); final NiFiProperties nifiProperties = spy(NiFiProperties.class); final int apiPort = 8080; final int remoteSocketPort = 8081; final String remoteInputHost = "node1.example.com"; when(nifiProperties.getPort()).thenReturn(apiPort); when(nifiProperties.getRemoteInputHost()).thenReturn(remoteInputHost); when(nifiProperties.getRemoteInputPort()).thenReturn(remoteSocketPort); when(nifiProperties.getRemoteInputHttpPort()).thenReturn(null); when(nifiProperties.isSiteToSiteHttpEnabled()).thenReturn(false); when(nifiProperties.isSiteToSiteSecure()).thenReturn(false); final SocketRemoteSiteListener listener = new SocketRemoteSiteListener(remoteSocketPort, null, nifiProperties); final ServerProtocol serverProtocol = mock(ServerProtocol.class); doAnswer(invocation -> { final NodeInformation self = invocation.getArgumentAt(2, NodeInformation.class); assertEquals(remoteInputHost, self.getSiteToSiteHostname()); assertEquals(remoteSocketPort, self.getSiteToSitePort().intValue()); assertNull(self.getSiteToSiteHttpApiPort()); assertEquals(apiPort, self.getAPIPort()); return null; }).when(serverProtocol).sendPeerList(any(Peer.class), any(Optional.class), any(NodeInformation.class)); final Peer peer = null; method.invoke(listener, serverProtocol, peer, RequestType.REQUEST_PEER_LIST); }
private int getPort() { return socketPort; }
SocketRemoteSiteListener implements RemoteSiteListener { private int getPort() { return socketPort; } }
SocketRemoteSiteListener implements RemoteSiteListener { private int getPort() { return socketPort; } SocketRemoteSiteListener(final int socketPort, final SSLContext sslContext, final NiFiProperties nifiProperties);  SocketRemoteSiteListener(final int socketPort, final SSLContext sslContext, final NiFiProperties nifiProperties, final NodeInformant nodeInformant); }
SocketRemoteSiteListener implements RemoteSiteListener { private int getPort() { return socketPort; } SocketRemoteSiteListener(final int socketPort, final SSLContext sslContext, final NiFiProperties nifiProperties);  SocketRemoteSiteListener(final int socketPort, final SSLContext sslContext, final NiFiProperties nifiProperties, final NodeInformant nodeInformant); @Override void setRootGroup(final ProcessGroup rootGroup); @Override void start(); @Override void stop(); }
SocketRemoteSiteListener implements RemoteSiteListener { private int getPort() { return socketPort; } SocketRemoteSiteListener(final int socketPort, final SSLContext sslContext, final NiFiProperties nifiProperties);  SocketRemoteSiteListener(final int socketPort, final SSLContext sslContext, final NiFiProperties nifiProperties, final NodeInformant nodeInformant); @Override void setRootGroup(final ProcessGroup rootGroup); @Override void start(); @Override void stop(); static final String DEFAULT_FLOWFILE_PATH; }