ee505561078c5d3fea2dd360de9dd6e5168ca167
[bgpcep.git] / bgp / rib-impl / src / test / java / org / opendaylight / protocol / bgp / rib / impl / stats / rib / impl / BGPRenderStatsImplTest.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.protocol.bgp.rib.impl.stats.rib.impl;
10
11 import static org.junit.Assert.assertEquals;
12
13 import java.util.ArrayList;
14 import java.util.List;
15 import org.junit.Test;
16 import org.opendaylight.controller.config.yang.bgp.rib.impl.BgpRenderState;
17 import org.opendaylight.controller.config.yang.bgp.rib.impl.LocRibRouteTable;
18 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
19 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.ZeroBasedCounter32;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.RibId;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.TablesKey;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpId;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.ClusterIdentifier;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv4AddressFamily;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.UnicastSubsequentAddressFamily;
26
27 public class BGPRenderStatsImplTest {
28     private final static BgpId BGP_ID = new BgpId("127.0.0.1");
29     private static final RibId RIB_ID = new RibId("test-rib");
30     private static final ClusterIdentifier CLUSTER_ID = new ClusterIdentifier("192.168.1.2");
31     private static final AsNumber AS = new AsNumber(0x10L);
32     private static final ZeroBasedCounter32 COUTER = new ZeroBasedCounter32(0L);
33
34     @Test
35     public void getBgpRenderState() throws Exception {
36         final BGPRenderStatsImpl render = new BGPRenderStatsImpl(BGP_ID, RIB_ID, AS, CLUSTER_ID);
37
38         final BgpRenderState renderStateExpected = new BgpRenderState();
39         renderStateExpected.setRibId(RIB_ID);
40         renderStateExpected.setBgpRibId(BGP_ID);
41         renderStateExpected.setClusterId(CLUSTER_ID);
42         renderStateExpected.setLocalAs(AS);
43         renderStateExpected.setConfiguredPeerCount(COUTER);
44         renderStateExpected.setConnectedPeerCount(COUTER);
45         final List<LocRibRouteTable> locRibRouteTableList = new ArrayList<>();
46         renderStateExpected.setLocRibRouteTable(locRibRouteTableList);
47         renderStateExpected.setLocRibRoutesCount(COUTER);
48
49         assertEquals(renderStateExpected, render.getBgpRenderState());
50         assertEquals(1L, render.getLocRibRouteCounter().init(new TablesKey(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class)).increaseCount());
51         assertEquals(1L, render.getConfiguredPeerCounter().increaseCount());
52         assertEquals(1L, render.getConnectedPeerCounter().increaseCount());
53     }
54 }