ConstNodeDiscovery implements NodeDiscovery { @Override public List<NodeAddress> getNodeAddresses() { return nodes; } ConstNodeDiscovery(Collection<NodeAddress> nodes);  ConstNodeDiscovery(NodeAddress... nodes); @Override List<NodeAddress> getNodeAddresses();  }
@Test public void listConstructor() { List<NodeAddress> nodes = new ArrayList<>(); nodes.add( new NodeAddress("127.0.0.1",8000) ); nodes.add( new NodeAddress("127.0.0.1",8001) ); ConstNodeDiscovery discovery = new ConstNodeDiscovery(nodes); Assert.assertArrayEquals( nodes.toArray(), discovery.getNodeAddresses().toArray() ); }
@Test public void arrayConstructor() { NodeAddress[] nodes = new NodeAddress[]{ new NodeAddress("127.0.0.1",8000), new NodeAddress("127.0.0.1",8001) }; ConstNodeDiscovery discovery = new ConstNodeDiscovery(nodes); Assert.assertArrayEquals( nodes, discovery.getNodeAddresses().toArray() ); }
@Test public void varArgConstructor() { NodeAddress a = new NodeAddress("127.0.0.1",8000); NodeAddress b = new NodeAddress("127.0.0.1",8000); ConstNodeDiscovery discovery = new ConstNodeDiscovery(a, b); List<NodeAddress> nodes = discovery.getNodeAddresses(); Assert.assertEquals( nodes.get(0), a ); Assert.assertEquals( nodes.get(1), b ); }