BUG-7215: Fix App Peer ModifiedNodeDoesNotExistException
[bgpcep.git] / bgp / rib-impl / src / test / java / org / opendaylight / protocol / bgp / rib / impl / config / AppPeerTest.java
index 666481a53567ad1d6c113d0f17aabd13a8c5df24..7c278fc3bc95df9ba283c7b2565b54eb5334722b 100644 (file)
@@ -24,8 +24,10 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.
 
 public class AppPeerTest extends AbstractConfig {
     private static final AppPeer APP_PEER = new AppPeer();
+    private final Neighbor neighbor = new NeighborBuilder()
+        .setNeighborAddress(new IpAddress(new Ipv4Address("127.0.0.1"))).build();
 
-
+    @Override
     @Before
     public void setUp() throws Exception {
         super.setUp();
@@ -34,19 +36,22 @@ public class AppPeerTest extends AbstractConfig {
 
     @Test
     public void testAppPeer() throws Exception {
-        final Neighbor neighbor = new NeighborBuilder().setNeighborAddress(new IpAddress(new Ipv4Address("127.0.0.1"))).build();
-        APP_PEER.start(this.rib, neighbor, this.mappingService, this.configurationWriter);
+        APP_PEER.start(this.rib, this.neighbor, this.mappingService, this.configurationWriter);
         Mockito.verify(this.rib).getYangRibId();
         Mockito.verify(this.rib).getService();
         Mockito.verify(this.rib).getRibIServiceGroupIdentifier();
         Mockito.verify(this.rib).registerClusterSingletonService(any(ClusterSingletonService.class));
 
         this.singletonService.instantiateServiceInstance();
+        Mockito.verify(this.rib, times(2)).getYangRibId();
         Mockito.verify(this.configurationWriter).apply();
         Mockito.verify(this.rib).getRibSupportContext();
         Mockito.verify(this.rib).getLocalTablesKeys();
         Mockito.verify(this.domTx).newWriteOnlyTransaction();
 
+        APP_PEER.close();
+        Mockito.verify(this.singletonServiceRegistration).close();
+
         APP_PEER.restart(this.rib, this.mappingService);
         this.singletonService.instantiateServiceInstance();
         Mockito.verify(this.rib, times(4)).getYangRibId();
@@ -57,9 +62,10 @@ public class AppPeerTest extends AbstractConfig {
         this.singletonService.closeServiceInstance();
         Mockito.verify(this.listener, times(2)).close();
 
-        assertTrue(APP_PEER.containsEqualConfiguration(new NeighborBuilder().setNeighborAddress(new IpAddress(new Ipv4Address("127.0.0.1"))).build()));
-        assertFalse(APP_PEER.containsEqualConfiguration(new NeighborBuilder().setNeighborAddress(new IpAddress(new Ipv4Address("127.0.0.2"))).build()));
+        assertTrue(APP_PEER.containsEqualConfiguration(this.neighbor));
+        assertFalse(APP_PEER.containsEqualConfiguration(new NeighborBuilder()
+            .setNeighborAddress(new IpAddress(new Ipv4Address("127.0.0.2"))).build()));
         APP_PEER.close();
-        Mockito.verify(this.singletonServiceRegistration).close();
+        Mockito.verify(this.singletonServiceRegistration, times(2)).close();
     }
 }
\ No newline at end of file