use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.BmpMonitor in project bgpcep by opendaylight.
the class BmpMonitorImplTest method setUp.
@Before
public void setUp() throws Exception {
super.setup();
doAnswer(invocationOnMock -> {
BmpMonitorImplTest.this.singletonService = (ClusterSingletonService) invocationOnMock.getArguments()[0];
singletonService.instantiateServiceInstance();
return BmpMonitorImplTest.this.singletonServiceRegistration;
}).when(clusterSSProv).registerClusterSingletonService(any(ClusterSingletonService.class));
doAnswer(invocationOnMock -> BmpMonitorImplTest.this.singletonService.closeServiceInstance()).when(singletonServiceRegistration).close();
doAnswer(invocationOnMock -> {
singletonService2 = (ClusterSingletonService) invocationOnMock.getArguments()[0];
singletonService2.instantiateServiceInstance();
return BmpMonitorImplTest.this.singletonServiceRegistration2;
}).when(clusterSSProv2).registerClusterSingletonService(any(ClusterSingletonService.class));
doAnswer(invocationOnMock -> BmpMonitorImplTest.this.singletonService2.closeServiceInstance()).when(singletonServiceRegistration2).close();
ribActivator.startRIBExtensionProvider(ribExtension, mappingService.currentSerializer());
final BGPExtensionProviderContext context = new SimpleBGPExtensionProviderContext();
bgpActivator.start(context);
final SimpleBmpExtensionProviderContext ctx = new SimpleBmpExtensionProviderContext();
bmpActivator = new BmpActivator(context);
bmpActivator.start(ctx);
msgRegistry = ctx.getBmpMessageRegistry();
dispatcher = new BmpDispatcherImpl(new NioEventLoopGroup(), new NioEventLoopGroup(), ctx, new DefaultBmpSessionFactory());
final InetSocketAddress inetAddress = new InetSocketAddress(InetAddresses.forString(MONITOR_LOCAL_ADDRESS), MONITOR_LOCAL_PORT);
final DOMDataTreeWriteTransaction wTx = getDomBroker().newWriteOnlyTransaction();
final ContainerNode parentNode = Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(BmpMonitor.QNAME)).addChild(ImmutableNodes.mapNodeBuilder(Monitor.QNAME).build()).build();
wTx.merge(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.of(BmpMonitor.QNAME), parentNode);
wTx.commit().get();
bmpApp = new BmpMonitoringStationImpl(getDomBroker(), dispatcher, ribExtension, mappingService.currentSerializer(), clusterSSProv, MONITOR_ID, inetAddress, null);
readDataOperational(getDataBroker(), BMP_II, monitor -> {
assertEquals(1, monitor.nonnullMonitor().size());
final Monitor bmpMonitor = monitor.nonnullMonitor().values().iterator().next();
assertEquals(MONITOR_ID, bmpMonitor.getMonitorId());
assertEquals(0, bmpMonitor.nonnullRouter().size());
assertEquals(MONITOR_ID, bmpMonitor.getMonitorId());
assertEquals(0, bmpMonitor.nonnullRouter().size());
return monitor;
});
}
Aggregations