Search in sources :

Example 1 with SpeakerIdListener

use of org.opendaylight.bgpcep.pcep.topology.provider.PCEPStatefulPeerProposal.SpeakerIdListener in project bgpcep by opendaylight.

the class PCEPStatefulPeerProposalTest method testSetPeerProposalWithEntityIdSuccess.

@Test
public void testSetPeerProposalWithEntityIdSuccess() throws Exception {
    updateBuilder(() -> {
        final var listeners = captor.getAllValues();
        assertEquals(2, listeners.size());
        // not entirely accurate, but works well enough
        final var modPath = TOPOLOGY_IID.child(Node.class, new NodeKey(ServerSessionManager.createNodeId(ADDRESS.getAddress())));
        final var dbverRoot = mock(DataObjectModification.class);
        doReturn(LSP_DB_VERSION).when(dbverRoot).getDataAfter();
        final var dbverMod = mock(DataTreeModification.class);
        doReturn(DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL, modPath)).when(dbverMod).getRootPath();
        doReturn(dbverRoot).when(dbverMod).getRootNode();
        final var speakerRoot = mock(DataObjectModification.class);
        doReturn(new PcepNodeSyncConfigBuilder().setSpeakerEntityIdValue(SPEAKER_ID).build()).when(speakerRoot).getDataAfter();
        final var speakerMod = mock(DataTreeModification.class);
        doReturn(DataTreeIdentifier.create(LogicalDatastoreType.CONFIGURATION, modPath)).when(speakerMod).getRootPath();
        doReturn(speakerRoot).when(speakerMod).getRootNode();
        for (DataTreeChangeListener<?> listener : listeners) {
            if (listener instanceof SpeakerIdListener) {
                listener.onDataTreeChanged(List.of(speakerMod));
            } else if (listener instanceof LspDbVersionListener) {
                listener.onDataTreeChanged(List.of(dbverMod));
            }
        }
    });
    final Tlvs3 aug = tlvsBuilder.augmentation(Tlvs3.class);
    assertNotNull(aug);
    assertEquals(LSP_DB_VERSION, aug.getLspDbVersion());
    assertEquals(new SpeakerEntityIdBuilder().setSpeakerEntityIdValue(SPEAKER_ID).build(), aug.getSpeakerEntityId());
}
Also used : PcepNodeSyncConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.sync.optimizations.config.rev181109.PcepNodeSyncConfigBuilder) SpeakerEntityIdBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev200720.speaker.entity.id.tlv.SpeakerEntityIdBuilder) LspDbVersionListener(org.opendaylight.bgpcep.pcep.topology.provider.PCEPStatefulPeerProposal.LspDbVersionListener) Tlvs3(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev200720.Tlvs3) NodeKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey) SpeakerIdListener(org.opendaylight.bgpcep.pcep.topology.provider.PCEPStatefulPeerProposal.SpeakerIdListener) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 LspDbVersionListener (org.opendaylight.bgpcep.pcep.topology.provider.PCEPStatefulPeerProposal.LspDbVersionListener)1 SpeakerIdListener (org.opendaylight.bgpcep.pcep.topology.provider.PCEPStatefulPeerProposal.SpeakerIdListener)1 Tlvs3 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev200720.Tlvs3)1 SpeakerEntityIdBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev200720.speaker.entity.id.tlv.SpeakerEntityIdBuilder)1 PcepNodeSyncConfigBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.sync.optimizations.config.rev181109.PcepNodeSyncConfigBuilder)1 NodeKey (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey)1