Modernize codebase a bit
[bgpcep.git] / bgp / rib-impl / src / test / java / org / opendaylight / protocol / bgp / rib / impl / config / RibImplTest.java
index 305b8f8655f83f9543a0745f09ba004ed7f76963..a5a7ff44ddd0b1b86d8842ea9792ddfeb962d122 100644 (file)
@@ -5,18 +5,17 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.protocol.bgp.rib.impl.config;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
-import static org.mockito.Matchers.any;
+import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 
-import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableClassToInstanceMap;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.primitives.Shorts;
 import java.util.ArrayList;
@@ -25,10 +24,10 @@ import java.util.List;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mock;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeService;
 import org.opendaylight.mdsal.binding.dom.codec.api.BindingCodecTreeFactory;
 import org.opendaylight.mdsal.binding.generator.impl.GeneratedClassLoadingStrategy;
+import org.opendaylight.mdsal.dom.api.DOMDataBroker;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeService;
 import org.opendaylight.mdsal.dom.api.DOMSchemaService;
 import org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl;
 import org.opendaylight.protocol.bgp.rib.impl.RIBImpl;
@@ -54,7 +53,6 @@ import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
-import org.osgi.framework.ServiceRegistration;
 
 public class RibImplTest extends AbstractConfig {
     private static final List<AfiSafi> AFISAFIS = new ArrayList<>();
@@ -81,8 +79,6 @@ public class RibImplTest extends AbstractConfig {
     private ListenerRegistration<?> dataTreeRegistration;
     @Mock
     private RIBSupport<?, ?, ?, ?> ribSupport;
-    @Mock
-    private ServiceRegistration<?> serviceRegistration;
 
     @Override
     @Before
@@ -96,19 +92,18 @@ public class RibImplTest extends AbstractConfig {
         doReturn(ImmutableSet.of()).when(this.ribSupport).cacheableAttributeObjects();
         final MapEntryNode emptyTable = mock(MapEntryNode.class);
         doReturn(emptyTable).when(this.ribSupport).emptyTable();
-        final NodeIdentifierWithPredicates niie = new NodeIdentifierWithPredicates(Rib.QNAME,
-                ImmutableMap.of(QName.create("", "test").intern(), "t"));
+        final NodeIdentifierWithPredicates niie = NodeIdentifierWithPredicates.of(Rib.QNAME,
+                QName.create("", "test").intern(), "t");
         doReturn(niie).when(emptyTable).getIdentifier();
         doReturn(QName.create("", "test").intern()).when(emptyTable).getNodeType();
-        doReturn(this.domTx).when(this.domDataBroker).createTransactionChain(any());
+        doReturn(this.domTx).when(this.domDataBroker).createMergingTransactionChain(any());
         final DOMDataTreeChangeService dOMDataTreeChangeService = mock(DOMDataTreeChangeService.class);
-        doReturn(Collections.singletonMap(DOMDataTreeChangeService.class, dOMDataTreeChangeService))
-                .when(this.domDataBroker).getSupportedExtensions();
+        doReturn(ImmutableClassToInstanceMap.of(DOMDataTreeChangeService.class, dOMDataTreeChangeService))
+                .when(this.domDataBroker).getExtensions();
         doReturn(this.dataTreeRegistration).when(this.domSchemaService).registerSchemaContextListener(any());
         doNothing().when(this.dataTreeRegistration).close();
         doReturn(mock(ListenerRegistration.class)).when(dOMDataTreeChangeService)
                 .registerDataTreeChangeListener(any(), any());
-        doNothing().when(this.serviceRegistration).unregister();
     }
 
     @Test
@@ -121,10 +116,9 @@ public class RibImplTest extends AbstractConfig {
                 this.domDataBroker,
                 getDataBroker(),
                 this.domSchemaService);
-        ribImpl.setServiceRegistration(this.serviceRegistration);
         ribImpl.start(createGlobal(), "rib-test", this.tableTypeRegistry);
         verify(this.extension).getClassLoadingStrategy();
-        verify(this.domDataBroker).getSupportedExtensions();
+        verify(this.domDataBroker).getExtensions();
         verify(this.domSchemaService).registerSchemaContextListener(any(RIBImpl.class));
         assertEquals("RIBImpl{bgpId=Ipv4Address{_value=127.0.0.1}, localTables=[BgpTableTypeImpl ["
                 + "getAfi()=interface org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types."
@@ -146,7 +140,6 @@ public class RibImplTest extends AbstractConfig {
         ribImpl.close();
         verify(this.dataTreeRegistration).close();
         verify(this.dataTreeRegistration).close();
-        verify(this.serviceRegistration).unregister();
     }
 
     private static Global createGlobal() {