Search in sources :

Example 1 with BmpMonitor

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;
    });
}
Also used : SimpleBmpExtensionProviderContext(org.opendaylight.protocol.bmp.spi.registry.SimpleBmpExtensionProviderContext) InetSocketAddress(java.net.InetSocketAddress) DOMDataTreeWriteTransaction(org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction) BmpDispatcherImpl(org.opendaylight.protocol.bmp.impl.BmpDispatcherImpl) SimpleBGPExtensionProviderContext(org.opendaylight.protocol.bgp.parser.spi.pojo.SimpleBGPExtensionProviderContext) SimpleBGPExtensionProviderContext(org.opendaylight.protocol.bgp.parser.spi.pojo.SimpleBGPExtensionProviderContext) BGPExtensionProviderContext(org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderContext) BmpMonitor(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.BmpMonitor) Monitor(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.bmp.monitor.Monitor) ClusterSingletonService(org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) DefaultBmpSessionFactory(org.opendaylight.protocol.bmp.impl.session.DefaultBmpSessionFactory) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup) BmpActivator(org.opendaylight.protocol.bmp.parser.BmpActivator) Before(org.junit.Before)

Aggregations

NioEventLoopGroup (io.netty.channel.nio.NioEventLoopGroup)1 InetSocketAddress (java.net.InetSocketAddress)1 Before (org.junit.Before)1 DOMDataTreeWriteTransaction (org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction)1 ClusterSingletonService (org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService)1 BGPExtensionProviderContext (org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderContext)1 SimpleBGPExtensionProviderContext (org.opendaylight.protocol.bgp.parser.spi.pojo.SimpleBGPExtensionProviderContext)1 BmpDispatcherImpl (org.opendaylight.protocol.bmp.impl.BmpDispatcherImpl)1 DefaultBmpSessionFactory (org.opendaylight.protocol.bmp.impl.session.DefaultBmpSessionFactory)1 BmpActivator (org.opendaylight.protocol.bmp.parser.BmpActivator)1 SimpleBmpExtensionProviderContext (org.opendaylight.protocol.bmp.spi.registry.SimpleBmpExtensionProviderContext)1 BmpMonitor (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.BmpMonitor)1 Monitor (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.bmp.monitor.Monitor)1 NodeIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier)1 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)1