import org.mockito.Mockito;
import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeService;
-import org.opendaylight.controller.sal.core.api.model.SchemaService;
import org.opendaylight.mdsal.binding.dom.codec.api.BindingCodecTreeFactory;
import org.opendaylight.mdsal.binding.generator.impl.GeneratedClassLoadingStrategy;
+import org.opendaylight.mdsal.dom.api.DOMSchemaService;
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService;
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
import org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.top.bgp.GlobalBuilder;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV4UNICAST;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.BgpTableType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev160614.AfiSafi2;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev160614.AfiSafi2Builder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.TablesKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.BgpTableType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev171207.AfiSafi2;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev171207.AfiSafi2Builder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv4AddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.UnicastSubsequentAddressFamily;
public class RibImplTest extends AbstractConfig {
private static final List<AfiSafi> AFISAFIS = new ArrayList<>();
private static final Long ALL_PATHS = 0L;
- private static final BgpTableType TABLE_TYPE = new BgpTableTypeImpl(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class);
+ private static final BgpTableType TABLE_TYPE =
+ new BgpTableTypeImpl(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class);
private static final Ipv4Address BGP_ID = new BgpId(new Ipv4Address("127.0.0.1"));
static {
AFISAFIS.add(new AfiSafiBuilder().setAfiSafiName(IPV4UNICAST.class)
- .addAugmentation(AfiSafi2.class, new AfiSafi2Builder().setReceive(true).setSendMax(Shorts.checkedCast(ALL_PATHS)).build()).build());
+ .addAugmentation(AfiSafi2.class, new AfiSafi2Builder().setReceive(true)
+ .setSendMax(Shorts.checkedCast(ALL_PATHS)).build()).build());
}
@Mock
@Mock
private DOMDataBroker domDataBroker;
@Mock
- private SchemaService schemaService;
+ private DOMSchemaService domSchemaService;
@Mock
private ClusterSingletonServiceProvider clusterSingletonServiceProvider;
@Mock
- private ListenerRegistration dataTreeRegistration;
+ private ListenerRegistration<?> dataTreeRegistration;
@Mock
private RIBSupport ribSupport;
@Mock
- private ServiceRegistration serviceRegistration;
+ private ServiceRegistration<?> serviceRegistration;
+
+ private static Global createGlobal() {
+ return new GlobalBuilder()
+ .setAfiSafis(new AfiSafisBuilder().setAfiSafi(AFISAFIS).build())
+ .setConfig(new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.global.base
+ .ConfigBuilder().setAs(AS).setRouterId(BGP_ID).build()).build();
+ }
@Override
@Before
Mockito.doAnswer(invocationOnMock -> {
RibImplTest.this.singletonService = (ClusterSingletonService) invocationOnMock.getArguments()[0];
return RibImplTest.this.singletonServiceRegistration;
- }).when(this.clusterSingletonServiceProvider).registerClusterSingletonService(any(ClusterSingletonService.class));
+ }).when(this.clusterSingletonServiceProvider)
+ .registerClusterSingletonService(any(ClusterSingletonService.class));
Mockito.doReturn(mock(GeneratedClassLoadingStrategy.class)).when(this.extension).getClassLoadingStrategy();
Mockito.doReturn(this.ribSupport).when(this.extension).getRIBSupport(any(TablesKey.class));
Mockito.doReturn(this.domTx).when(this.domDataBroker).createTransactionChain(any());
final DOMDataTreeChangeService dOMDataTreeChangeService = mock(DOMDataTreeChangeService.class);
Mockito.doReturn(Collections.singletonMap(DOMDataTreeChangeService.class, dOMDataTreeChangeService))
- .when(this.domDataBroker).getSupportedExtensions();
- Mockito.doReturn(this.dataTreeRegistration).when(this.schemaService).registerSchemaContextListener(any());
+ .when(this.domDataBroker).getSupportedExtensions();
+ Mockito.doReturn(this.dataTreeRegistration).when(this.domSchemaService).registerSchemaContextListener(any());
Mockito.doNothing().when(this.dataTreeRegistration).close();
- Mockito.doReturn(mock(ListenerRegistration.class)).when(dOMDataTreeChangeService).registerDataTreeChangeListener(any(), any());
+ Mockito.doReturn(mock(ListenerRegistration.class)).when(dOMDataTreeChangeService)
+ .registerDataTreeChangeListener(any(), any());
Mockito.doNothing().when(this.serviceRegistration).unregister();
}
@Test
public void testRibImpl() throws Exception {
final RibImpl ribImpl = new RibImpl(this.clusterSingletonServiceProvider, this.extension, this.dispatcher,
- this.bindingCodecTreeFactory, this.domDataBroker, this.schemaService);
+ this.bindingCodecTreeFactory, this.domDataBroker, this.domSchemaService);
ribImpl.setServiceRegistration(this.serviceRegistration);
- ribImpl.start(createGlobal(), "rib-test", this.tableTypeRegistry, this.configurationWriter);
+ ribImpl.start(createGlobal(), "rib-test", this.tableTypeRegistry);
verify(this.extension).getClassLoadingStrategy();
verify(this.domDataBroker).getSupportedExtensions();
verify(this.clusterSingletonServiceProvider).registerClusterSingletonService(any());
- verify(this.schemaService).registerSchemaContextListener(any(RIBImpl.class));
+ verify(this.domSchemaService).registerSchemaContextListener(any(RIBImpl.class));
this.singletonService.instantiateServiceInstance();
- Mockito.verify(this.configurationWriter).apply();
assertEquals("RIBImpl{}", ribImpl.toString());
assertEquals(ServiceGroupIdentifier.create("rib-test-service-group"), ribImpl.getRibIServiceGroupIdentifier());
- assertEquals(Collections.singleton(new TablesKey(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class)), ribImpl.getLocalTablesKeys());
+ assertEquals(Collections.singleton(new TablesKey(Ipv4AddressFamily.class,
+ UnicastSubsequentAddressFamily.class)), ribImpl.getLocalTablesKeys());
assertNotNull(ribImpl.getImportPolicyPeerTracker());
assertNotNull(ribImpl.getService());
assertNotNull(ribImpl.getInstanceIdentifier());
verify(this.dataTreeRegistration).close();
verify(this.serviceRegistration).unregister();
}
-
- private Global createGlobal() {
- return new GlobalBuilder()
- .setAfiSafis(new AfiSafisBuilder().setAfiSafi(AFISAFIS).build())
- .setConfig(new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.global.base
- .ConfigBuilder().setAs(AS).setRouterId(BGP_ID).build()).build();
- }
}
\ No newline at end of file