SdxParticipantsConfig extends Config<ApplicationId> { public Set<PeerConfig> bgpPeers() { Set<PeerConfig> peers = Sets.newHashSet(); JsonNode peersNode = object.get(PEERS); if (peersNode == null) { return peers; } peersNode.forEach(jsonNode -> { Optional<String> name; if (jsonNode.get(NAME) == null) { name = Optional.empty(); } else { name = Optional.of(jsonNode.get(NAME).asText()); } peers.add(new PeerConfig(name, IpAddress.valueOf(jsonNode.path(IP).asText()), ConnectPoint.deviceConnectPoint(jsonNode.path(CONN_POINT).asText()), jsonNode.path(INTF_NAME).asText())); }); return peers; }  Set<PeerConfig> bgpPeers(); ConnectPoint getPortForPeer(IpAddress peerAddress); String getInterfaceNameForPeer(IpAddress peerAddress); PeerConfig getPeerForName(Optional<String> peerName); void addPeer(PeerConfig peer); PeerConfig getPeerForIp(IpAddress ip); void removePeer(IpAddress peerIp); static final String PEERS; static final String NAME; static final String IP; static final String CONN_POINT; static final String INTF_NAME; }
@Test public void testBgpPeers() throws Exception { assertEquals(peers, peersConfig.bgpPeers()); }