DynamicMemberConfig extends TcpIpConfig { @Override public List<String> getMembers() { List<String> addresses = this.infoProvider.getClusterMemberAddresses(this.clusterName); addresses.forEach(ip->LOGGER.info("Found member of cluster {} with address {}", this.clusterName, ip)); return addresses; } DynamicMemberConfig(ClusterInfoProvider infoProvider); @Override List<String> getMembers();  }
@Test public void getMembers() throws Exception { String groupName = "myGroup"; String memberAddress = "192.168.1.1"; Mockito.when(this.provider.getClusterName()).thenReturn(groupName); Mockito.when(this.provider.getClusterMemberAddresses(groupName)).thenReturn(Collections.singletonList(memberAddress)); DynamicMemberConfig cfg = new DynamicMemberConfig(this.provider); Mockito.verify(this.provider, Mockito.atLeastOnce()).getClusterName(); List<String> members = cfg.getMembers(); Assert.assertEquals(1, members.size()); Assert.assertEquals(memberAddress, members.get(0)); Mockito.verify(this.provider, Mockito.atLeastOnce()).getClusterMemberAddresses(groupName); }