GatewayReceiverRealizer implements ConfigurationRealizer<GatewayReceiver, GatewayReceiverInfo> { @VisibleForTesting GatewayReceiverInfo generateGatewayReceiverInfo( org.apache.geode.cache.wan.GatewayReceiver receiver) { GatewayReceiverMBeanBridge bridge = new GatewayReceiverMBeanBridge(receiver); GatewayReceiverInfo info = new GatewayReceiverInfo(); info.setBindAddress(receiver.getBindAddress()); info.setHostnameForSenders(receiver.getHostnameForSenders()); info.setPort(receiver.getPort()); info.setRunning(receiver.isRunning()); info.setSenderCount(bridge.getClientConnectionCount()); info.setConnectedSenders(bridge.getConnectedGatewaySenders()); return info; }  @Override RealizationResult create(GatewayReceiver config, InternalCache cache); RealizationResult create(GatewayReceiverConfig config, InternalCache cache); @Override boolean exists(GatewayReceiver config, InternalCache cache); @Override GatewayReceiverInfo get(GatewayReceiver config, InternalCache cache); @Override RealizationResult update(GatewayReceiver config, InternalCache cache); @Override RealizationResult delete(GatewayReceiver config, InternalCache cache);  }
@Test public void generatesGatewayReceiverInfo() { GatewayReceiver gatewayReceiver = mock(GatewayReceiver.class); when(gatewayReceiver.getBindAddress()).thenReturn("localhost"); when(gatewayReceiver.getHostnameForSenders()).thenReturn("localhost"); when(gatewayReceiver.getPort()).thenReturn(321); when(gatewayReceiver.isRunning()).thenReturn(true); InternalCacheServer server = mock(InternalCacheServer.class); when(gatewayReceiver.getServer()).thenReturn(server); Acceptor acceptor = mock(Acceptor.class); when(server.getAcceptor()).thenReturn(acceptor); when(acceptor.getClientServerConnectionCount()).thenReturn(3); ServerConnection connection = mock(ServerConnection.class); when(connection.getMembershipID()).thenReturn("testId"); when(acceptor.getAllServerConnections()).thenReturn(Collections.singleton(connection)); GatewayReceiverInfo actual = gatewayReceiverRealizer.generateGatewayReceiverInfo(gatewayReceiver); assertThat(actual.getBindAddress()).isEqualTo("localhost"); assertThat(actual.getHostnameForSenders()).isEqualTo("localhost"); assertThat(actual.getPort()).isEqualTo(321); assertThat(actual.isRunning()).isEqualTo(true); assertThat(actual.getSenderCount()).isEqualTo(3); assertThat(actual.getConnectedSenders()).containsExactly("testId"); }