operational state of LLGR procedures
[bgpcep.git] / bgp / openconfig-state / src / test / java / org / opendaylight / protocol / bgp / state / StateProviderImplTest.java
index 8b5f75538feeb4f2bf297dffa924a56e0a1dc7bb..b30e9e00015ff04531c46412210e1a7d46f5357f 100644 (file)
@@ -36,6 +36,7 @@ import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 import java.util.Optional;
+import java.util.Set;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
@@ -56,6 +57,7 @@ import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain;
 import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
 import org.opendaylight.infrautils.testutils.LogCapture;
 import org.opendaylight.infrautils.testutils.internal.RememberingLogger;
+import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections;
 import org.opendaylight.protocol.bgp.openconfig.spi.BGPTableTypeRegistryConsumer;
 import org.opendaylight.protocol.bgp.rib.spi.State;
 import org.opendaylight.protocol.bgp.rib.spi.state.BGPAfiSafiState;
@@ -72,6 +74,7 @@ import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.r
 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafiBuilder;
 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.GracefulRestartBuilder;
 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.graceful.restart.StateBuilder;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.operational.rev151009.BgpAfiSafiGracefulRestartState;
 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.operational.rev151009.BgpNeighborState;
 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.operational.rev151009.bgp.neighbor.prefix.counters_state.PrefixesBuilder;
 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.graceful.restart.GracefulRestart;
@@ -144,7 +147,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.type
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
-import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
 import org.slf4j.LoggerFactory;
 
 public class StateProviderImplTest extends ConstantSchemaAbstractDataBrokerTest {
@@ -244,7 +246,7 @@ public class StateProviderImplTest extends ConstantSchemaAbstractDataBrokerTest
 
         doReturn(this.timersState).when(this.bgpPeerState).getBGPTimersState();
         doReturn(10L).when(this.timersState).getNegotiatedHoldTime();
-        doReturn(1L).when(this.timersState).getUpTime();
+        doReturn(10L).when(this.timersState).getUpTime();
 
         doReturn(this.bgpTransportState).when(this.bgpPeerState).getBGPTransportState();
         doReturn(this.localPort).when(this.bgpTransportState).getLocalPort();
@@ -260,6 +262,7 @@ public class StateProviderImplTest extends ConstantSchemaAbstractDataBrokerTest
         doReturn(true).when(this.bgpGracelfulRestartState).isLocalRestarting();
         doReturn(true).when(this.bgpGracelfulRestartState).isPeerRestarting();
         doReturn(this.restartTime).when(this.bgpGracelfulRestartState).getPeerRestartTime();
+        doReturn(BgpAfiSafiGracefulRestartState.Mode.BILATERAL).when(this.bgpGracelfulRestartState).getMode();
 
         doReturn(this.bgpAfiSafiState).when(this.bgpPeerState).getBGPAfiSafiState();
         doReturn(Collections.singleton(TABLES_KEY)).when(this.bgpAfiSafiState).getAfiSafisAdvertized();
@@ -270,10 +273,13 @@ public class StateProviderImplTest extends ConstantSchemaAbstractDataBrokerTest
         doReturn(true).when(this.bgpAfiSafiState).isAfiSafiSupported(any());
         doReturn(true).when(this.bgpAfiSafiState).isGracefulRestartAdvertized(any());
         doReturn(true).when(this.bgpAfiSafiState).isGracefulRestartReceived(any());
+        doReturn(true).when(this.bgpAfiSafiState).isLlGracefulRestartAdvertised(any());
+        doReturn(true).when(this.bgpAfiSafiState).isLlGracefulRestartReceived(any());
+        doReturn(60).when(this.bgpAfiSafiState).getLlGracefulRestartTimer(any());
     }
 
     @Override
-    protected Iterable<YangModuleInfo> getModuleInfos() throws Exception {
+    protected Set<YangModuleInfo> getModuleInfos() throws Exception {
         return ImmutableSet.of(BindingReflections.getModuleInfo(NetworkInstances.class),
                 BindingReflections.getModuleInfo(NetworkInstanceProtocol.class));
     }
@@ -482,7 +488,12 @@ public class StateProviderImplTest extends ConstantSchemaAbstractDataBrokerTest
                 .setGracefulRestart(new GracefulRestartBuilder().setState(new StateBuilder().setEnabled(false)
                         .addAugmentation(NeighborAfiSafiGracefulRestartStateAugmentation.class,
                                 new NeighborAfiSafiGracefulRestartStateAugmentationBuilder()
-                                        .setAdvertised(true).setReceived(true).build())
+                                        .setAdvertised(true)
+                                        .setReceived(true)
+                                        .setLlStaleTimer(60L)
+                                        .setLlAdvertised(true)
+                                        .setLlReceived(true)
+                                        .build())
                         .build()).build())
                 .setState(new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp
                         .common.afi.safi.list.afi.safi.StateBuilder().setEnabled(false).addAugmentation(
@@ -536,7 +547,9 @@ public class StateProviderImplTest extends ConstantSchemaAbstractDataBrokerTest
         gracefulAugmentation.setLocalRestarting(false);
         gracefulAugmentation.setPeerRestartTime(0);
         gracefulAugmentation.setLocalRestarting(true)
-                .setPeerRestarting(true).setPeerRestartTime(this.restartTime);
+                .setPeerRestarting(true)
+                .setPeerRestartTime(this.restartTime)
+                .setMode(BgpAfiSafiGracefulRestartState.Mode.BILATERAL);
         final GracefulRestart gracefulRestart = new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp
                 .rev151009.bgp.graceful.restart.GracefulRestartBuilder().setState(new org.opendaylight.yang.gen.v1.http
                 .openconfig.net.yang.bgp.rev151009.bgp.graceful.restart.graceful.restart.StateBuilder()