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());
}
Aggregations