SdxParticipantsConfig extends Config<ApplicationId> { public void addPeer(PeerConfig peer) { ObjectNode peerNode = JsonNodeFactory.instance.objectNode(); if (peer.name().isPresent()) { peerNode.put(NAME, peer.name().get()); } peerNode.put(IP, peer.ip().toString()); peerNode.put(CONN_POINT, peer.connectPoint().elementId().toString() + "/" + peer.connectPoint().port().toString()); peerNode.put(INTF_NAME, peer.interfaceName()); ArrayNode peersArray = bgpPeers().isEmpty() ? initPeersConfiguration() : (ArrayNode) object.get(PEERS); peersArray.add(peerNode); }  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 testAddPeer() throws Exception { int initialSize = peersConfig.bgpPeers().size(); SdxParticipantsConfig.PeerConfig newPeer = createNewPeer(); peersConfig.addPeer(newPeer); assertEquals(initialSize + 1, peersConfig.bgpPeers().size()); peers.add(newPeer); assertEquals(peers, peersConfig.bgpPeers()); }