Fix sonar complains
[bgpcep.git] / bgp / path-selection-mode / src / test / java / org / opendaylight / protocol / bgp / mode / impl / base / BaseBestPathTest.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.mode.impl.base;
10
11 import static org.junit.Assert.assertEquals;
12 import static org.junit.Assert.assertFalse;
13 import static org.junit.Assert.assertTrue;
14
15 import com.google.common.primitives.UnsignedInteger;
16 import org.junit.Before;
17 import org.junit.Test;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.PeerId;
19
20 public class BaseBestPathTest {
21     private static final long PATH_ID = 0;
22     private BaseBestPath baseBestPath;
23     private static final UnsignedInteger ROUTER_ID = UnsignedInteger.valueOf(2130706433);
24     private static final PeerId PEER_ID = new PeerId("bgp://127.0.0.1");
25     private BaseBestPath baseBestPathCopy;
26
27     @Before
28     public void setUp() throws Exception {
29         final BasePathSelector selector = new BasePathSelector(20L);
30         selector.processPath(BasePathSelectorTest.ROUTER_ID2, BasePathSelectorTest.createStateFromPrefMedOriginASPath().build());
31         this.baseBestPath = selector.result();
32         this.baseBestPathCopy = selector.result();
33     }
34
35     @Test
36     public void testGetRouterId() throws Exception {
37         assertEquals(ROUTER_ID, this.baseBestPath.getRouterId());
38     }
39
40     @Test
41     public void testGetPeerId() throws Exception {
42         assertEquals(PEER_ID, this.baseBestPath.getPeerId());
43     }
44
45     @Test
46     public void testGetPathId() throws Exception {
47         assertEquals(PATH_ID, this.baseBestPath.getPathId());
48     }
49
50     @Test
51     public void testHashCodeAndEqual() throws Exception {
52         assertTrue(this.baseBestPath.equals(this.baseBestPathCopy) && this.baseBestPathCopy.equals(this.baseBestPath));
53         assertTrue(this.baseBestPath.hashCode() == this.baseBestPathCopy.hashCode());
54         assertTrue(this.baseBestPath.getPathId() == PATH_ID);
55     }
56
57     @Test
58     public void testToString() throws Exception {
59         assertTrue(this.baseBestPath.toString().equals(this.baseBestPathCopy.toString()));
60     }
61 }