@Override
    public Optional<SimpleAddress> selectAddress(Optional<String> addressSelectionContext)
    {
        if (addressSelectionContext.isPresent()) {
            return addressSelectionContext
                    .map(HostAndPort::fromString)
                    .map(SimpleAddress::new);
        }
        List<HostAndPort> catalogServers = internalNodeManager.getCatalogServers().stream()
                .filter(node -> node.getThriftPort().isPresent())
                .map(catalogServerNode -> {
                    HostAddress hostAndPort = catalogServerNode.getHostAndPort();
                    return HostAndPort.fromParts(hostAndPort.getHostText(), catalogServerNode.getThriftPort().getAsInt());
                })
                .collect(toImmutableList());
        return hostSelector.apply(catalogServers).map(SimpleAddress::new);
    }
@Test
    public void testAddressSelectionNoContext()
    {
        InMemoryNodeManager internalNodeManager = new InMemoryNodeManager();
        RandomCatalogServerAddressSelector selector = new RandomCatalogServerAddressSelector(internalNodeManager, hostAndPorts -> Optional.of(hostAndPorts.get(0)));

        internalNodeManager.addNode(
                CONNECTOR_ID,
                new InternalNode(
                        "1",
                        URI.create("local://localhost:123/1"),
                        OptionalInt.empty(),
                        "1",
                        false,
                        false,
                        true,
                        false));
        internalNodeManager.addNode(
                CONNECTOR_ID,
                new InternalNode(
                        "2",
                        URI.create("local://localhost:456/1"),
                        OptionalInt.of(2),
                        "1",
                        false,
                        false,
                        true,
                        false));
        internalNodeManager.addNode(
                CONNECTOR_ID,
                new InternalNode(
                        "3",
                        URI.create("local://localhost:789/2"),
                        OptionalInt.of(3),
                        "1",
                        false,
                        false,
                        true,
                        false));

        Optional<SimpleAddressSelector.SimpleAddress> address = selector.selectAddress(Optional.empty());
        assertTrue(address.isPresent());
        assertEquals(address.get().getHostAndPort(), HostAndPort.fromParts("localhost", 2));
    }