Migrate away from legacy setters
[bgpcep.git] / bgp / rib-impl / src / test / java / org / opendaylight / protocol / bgp / rib / impl / PeerTest.java
index 01d5ca65c66c9b18945d2f6ae9005d3aab75dadd..750e22c6f69458c6de0a505d4bbdf882ebac4284 100644 (file)
@@ -10,8 +10,8 @@ package org.opendaylight.protocol.bgp.rib.impl;
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.doAnswer;
 import static org.mockito.Mockito.doCallRealMethod;
 import static org.mockito.Mockito.doReturn;
@@ -32,7 +32,7 @@ import java.util.concurrent.TimeUnit;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
 import org.opendaylight.protocol.bgp.parser.BGPError;
 import org.opendaylight.protocol.bgp.parser.impl.message.update.LocalPreferenceAttributeParser;
@@ -79,6 +79,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.type
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.next.hop.c.next.hop.Ipv4NextHopCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.next.hop.c.next.hop.ipv4.next.hop._case.Ipv4NextHopBuilder;
 import org.opendaylight.yangtools.yang.binding.Notification;
+import org.opendaylight.yangtools.yang.common.Uint16;
+import org.opendaylight.yangtools.yang.common.Uint32;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.ModificationType;
@@ -137,8 +139,8 @@ public class PeerTest extends AbstractRIBTestSetup {
 
     @Test
     public void testClassicPeer() throws Exception {
-        this.classic = new BGPPeer(this.tableRegistry, this.neighborAddress, getRib(), PeerRole.Ibgp, null,
-                Collections.emptySet(), Collections.emptySet());
+        this.classic = AbstractAddPathTest.configurePeer(this.tableRegistry, this.neighborAddress.getIpv4Address(),
+                getRib(), null, PeerRole.Ibgp, new StrictBGPPeerRegistry());
         this.classic.instantiateServiceInstance();
         this.mockSession();
         assertEquals(this.neighborAddress.getIpv4Address().getValue(), this.classic.getName());
@@ -173,14 +175,14 @@ public class PeerTest extends AbstractRIBTestSetup {
         }
         assertEquals(0, this.routes.size());
 
-        final LocalPref localPref = new LocalPrefBuilder().setPref((long) 100).build();
+        final LocalPref localPref = new LocalPrefBuilder().setPref(Uint32.valueOf(100)).build();
         ub.setAttributes(ab.setLocalPref(localPref).build());
         this.classic.onMessage(this.session, ub.build());
         assertEquals(3, this.routes.size());
 
         //create new peer so that it gets advertized routes from RIB
-        final BGPPeer testingPeer = new BGPPeer(this.tableRegistry, this.neighborAddress, getRib(), PeerRole.Ibgp,
-                null, Collections.emptySet(), Collections.emptySet());
+        final BGPPeer testingPeer = AbstractAddPathTest.configurePeer(this.tableRegistry,
+            this.neighborAddress.getIpv4Address(), getRib(), null, PeerRole.Ibgp, new StrictBGPPeerRegistry());
         testingPeer.instantiateServiceInstance();
         testingPeer.onSessionUp(this.session);
         assertEquals(3, this.routes.size());
@@ -237,8 +239,8 @@ public class PeerTest extends AbstractRIBTestSetup {
                                                 .build()).build()).build()).build())).build());
         final Open openObj = new OpenBuilder()
                 .setBgpIdentifier(new Ipv4Address("1.1.1.1"))
-                .setHoldTimer(50)
-                .setMyAsNumber(72)
+                .setHoldTimer(Uint16.valueOf(50))
+                .setMyAsNumber(Uint16.valueOf(72))
                 .setBgpParameters(params).build();
         this.session = new BGPSessionImpl(this.classic, channel, openObj, 30, null);
         this.session.setChannelExtMsgCoder(openObj);