Make AbstractRIBSupportTest type-safe 41/72641/2
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 4 Jun 2018 08:59:52 +0000 (10:59 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Mon, 4 Jun 2018 09:42:19 +0000 (11:42 +0200)
Add generic arguments to bind types which the test needs.

Change-Id: Ie3c874dbcd30a8366ec342edb4e0ff24353e42cb
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
15 files changed:
bgp/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/EvpnRibSupportTest.java
bgp/flowspec/src/test/java/org/opendaylight/protocol/bgp/flowspec/FlowspecIpv4RIBSupportTest.java
bgp/flowspec/src/test/java/org/opendaylight/protocol/bgp/flowspec/FlowspecIpv6RIBSupportTest.java
bgp/flowspec/src/test/java/org/opendaylight/protocol/bgp/flowspec/FlowspecL3vpnIpv4RIBSupportTest.java
bgp/flowspec/src/test/java/org/opendaylight/protocol/bgp/flowspec/FlowspecL3vpnIpv6RIBSupportTest.java
bgp/inet/src/test/java/org/opendaylight/protocol/bgp/inet/IPv4RIBSupportTest.java
bgp/inet/src/test/java/org/opendaylight/protocol/bgp/inet/IPv6RIBSupportTest.java
bgp/l3vpn/src/test/java/org/opendaylight/protocol/bgp/l3vpn/unicast/ipv4/VpnIpv4RIBSupportTest.java
bgp/l3vpn/src/test/java/org/opendaylight/protocol/bgp/l3vpn/unicast/ipv6/VpnIpv6RIBSupportTest.java
bgp/labeled-unicast/src/test/java/org/opendaylight/protocol/bgp/labeled/unicast/LabeledUnicastIpv4RIBSupportTest.java
bgp/labeled-unicast/src/test/java/org/opendaylight/protocol/bgp/labeled/unicast/LabeledUnicastIpv6RIBSupportTest.java
bgp/linkstate/src/test/java/org/opendaylight/protocol/bgp/linkstate/LinkstateRIBSupportTest.java
bgp/mvpn/src/test/java/org/opendaylight/protocol/bgp/mvpn/impl/MvpnIpv4RIBSupportTest.java
bgp/mvpn/src/test/java/org/opendaylight/protocol/bgp/mvpn/impl/MvpnIpv6RIBSupportTest.java
bgp/rib-spi/src/test/java/org/opendaylight/protocol/bgp/rib/spi/AbstractRIBSupportTest.java

index 57b5f2cf004e791e9609bbc5af3073096059c130..d8f3994c3b0e931ecf0c111fc9ce4f594f5adf0a 100644 (file)
@@ -52,7 +52,8 @@ import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidates;
 
-public final class EvpnRibSupportTest extends AbstractRIBSupportTest<EvpnRoute> {
+public final class EvpnRibSupportTest extends AbstractRIBSupportTest<EvpnRoutesCase, EvpnRoutes, EvpnRoute,
+        EvpnRouteKey> {
     private EvpnRibSupport ribSupport;
     private static final EvpnRoute ROUTE;
     private static final EvpnRouteKey ROUTE_KEY;
index 8b162cb72dcecb723ac436d83cc44ae451ba8394..9bb82046667b069de8f1d6d19d2f337f005404b0 100644 (file)
@@ -50,7 +50,8 @@ import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidates;
 
-public class FlowspecIpv4RIBSupportTest extends AbstractRIBSupportTest<FlowspecRoute> {
+public class FlowspecIpv4RIBSupportTest extends AbstractRIBSupportTest<FlowspecRoutesCase, FlowspecRoutes,
+        FlowspecRoute, FlowspecRouteKey> {
 
     private FlowspecIpv4RIBSupport ribSupport;
     private FlowspecRoute route;
@@ -64,7 +65,7 @@ public class FlowspecIpv4RIBSupportTest extends AbstractRIBSupportTest<FlowspecR
             = Collections.singletonList(new FlowspecBuilder().setFlowspecType(DEST_PREFIX).build());
     private static final DestinationFlowspec DEST_FLOW = new DestinationFlowspecBuilder()
             .setFlowspec(FLOW_LIST).setPathId(PATH_ID).build();
-    private static final DestinationFlowspecCase REACH_NLRI 
+    private static final DestinationFlowspecCase REACH_NLRI
             = new DestinationFlowspecCaseBuilder().setDestinationFlowspec(DEST_FLOW).build();
     private static final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.update
         .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationFlowspecCase UNREACH_NLRI
@@ -83,7 +84,7 @@ public class FlowspecIpv4RIBSupportTest extends AbstractRIBSupportTest<FlowspecR
         this.ribSupport = FlowspecIpv4RIBSupport.getInstance(fsContext, this.mappingService);
 
         final SimpleFlowspecIpv4NlriParser parser = new SimpleFlowspecIpv4NlriParser(
-                fsContext.getFlowspecTypeRegistry(SimpleFlowspecExtensionProviderContext.AFI.IPV4, 
+                fsContext.getFlowspecTypeRegistry(SimpleFlowspecExtensionProviderContext.AFI.IPV4,
                         SimpleFlowspecExtensionProviderContext.SAFI.FLOWSPEC));
 
         this.routeKey = new FlowspecRouteKey(PATH_ID, parser.stringNlri(FLOW_LIST));
@@ -179,11 +180,11 @@ public class FlowspecIpv4RIBSupportTest extends AbstractRIBSupportTest<FlowspecR
     @Test
     public void testChangedRoutes() {
         final Routes emptyCase = new FlowspecRoutesCaseBuilder().build();
-        DataTreeCandidateNode tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(), 
+        DataTreeCandidateNode tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(),
                 createRoutes(emptyCase)).getRootNode();
         Assert.assertTrue(this.ribSupport.changedRoutes(tree).isEmpty());
 
-        final Routes emptyRoutes 
+        final Routes emptyRoutes
                 = new FlowspecRoutesCaseBuilder().setFlowspecRoutes(new FlowspecRoutesBuilder().build()).build();
         tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(), createRoutes(emptyRoutes)).getRootNode();
         Assert.assertTrue(this.ribSupport.changedRoutes(tree).isEmpty());
index 9dfd4bed30bec475d6f260eb0d4dbadcaec40de1..8c997f1bd371bf00c037b250bffbf91f45906d2f 100644 (file)
@@ -50,7 +50,8 @@ import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidates;
 
-public class FlowspecIpv6RIBSupportTest extends AbstractRIBSupportTest<FlowspecRoute> {
+public class FlowspecIpv6RIBSupportTest extends AbstractRIBSupportTest<FlowspecIpv6RoutesCase, FlowspecIpv6Routes,
+        FlowspecRoute, FlowspecRouteKey> {
 
     private static final PathId PATH_ID = new PathId(1L);
     private static final DestinationIpv6PrefixCase DEST_PREFIX = new DestinationIpv6PrefixCaseBuilder()
index 17f21666c7fe54174ac2575f0d2d42280144135c..a818f4ba6e2049560a3b5f0309857baafc2e1c23 100644 (file)
@@ -51,7 +51,8 @@ import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidates;
 
-public class FlowspecL3vpnIpv4RIBSupportTest extends AbstractRIBSupportTest<FlowspecL3vpnRoute> {
+public class FlowspecL3vpnIpv4RIBSupportTest extends AbstractRIBSupportTest<FlowspecL3vpnIpv4RoutesCase,
+        FlowspecL3vpnIpv4Routes, FlowspecL3vpnRoute, FlowspecL3vpnRouteKey> {
 
     private static final FlowspecL3vpnRoute ROUTE;
     private static final FlowspecL3vpnRouteKey ROUTE_KEY;
index c2da8610ff23929551ea15311fe684163a6069fe..590f6dcda92bc49bcda25054418b63c958428f4f 100644 (file)
@@ -50,7 +50,8 @@ import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidates;
 
-public class FlowspecL3vpnIpv6RIBSupportTest extends AbstractRIBSupportTest<FlowspecL3vpnRoute> {
+public class FlowspecL3vpnIpv6RIBSupportTest extends AbstractRIBSupportTest<FlowspecL3vpnIpv6RoutesCase,
+        FlowspecL3vpnIpv6Routes, FlowspecL3vpnRoute, FlowspecL3vpnRouteKey> {
 
     private static final FlowspecL3vpnRoute ROUTE;
     private static final FlowspecL3vpnRouteKey ROUTE_KEY;
index 87d7d075941207f6d75a718a84ef030df89446eb..34ed098a730ab546c8d43b3d4fb209d674b7a15c 100644 (file)
@@ -46,7 +46,8 @@ import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidates;
 
-public final class IPv4RIBSupportTest extends AbstractRIBSupportTest<Ipv4Route> {
+public final class IPv4RIBSupportTest extends AbstractRIBSupportTest<Ipv4RoutesCase, Ipv4Routes, Ipv4Route,
+        Ipv4RouteKey> {
     private IPv4RIBSupport ribSupport;
     private static final PathId PATH_ID = new PathId(1L);
     private static final Ipv4Prefix PREFIX = new Ipv4Prefix("1.2.3.4/32");
index 9db3fcb14674594d05e0a678d31000eb51eb0b9e..aa7b0a555221afb2473961e21d97a38feb35d00d 100644 (file)
@@ -45,7 +45,8 @@ import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidates;
 
-public final class IPv6RIBSupportTest extends AbstractRIBSupportTest<Ipv6Route> {
+public final class IPv6RIBSupportTest extends AbstractRIBSupportTest<Ipv6RoutesCase, Ipv6Routes, Ipv6Route,
+        Ipv6RouteKey> {
     private IPv6RIBSupport ribSupport;
     private static final PathId PATH_ID = new PathId(1L);
     private static final Ipv6Prefix PREFIX = new Ipv6Prefix("2001:db8:1:2::/64");
index 4a9a18e3783ea3487810f944d93d6f9d739fa3be..0c42d6b82d83a867ae9f030603c4df7942867ddb 100644 (file)
@@ -47,7 +47,8 @@ import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidates;
 
-public class VpnIpv4RIBSupportTest extends AbstractRIBSupportTest<VpnRoute> {
+public class VpnIpv4RIBSupportTest extends AbstractRIBSupportTest<VpnIpv4RoutesCase, VpnIpv4Routes, VpnRoute,
+        VpnRouteKey> {
     private VpnIpv4RIBSupport ribSupport;
 
     private static final DestinationVpnIpv4Case REACH_NLRI = new DestinationVpnIpv4CaseBuilder().setVpnIpv4Destination(
index 5d2db5668ed440044d742f0b4b9845aa35bb3fe8..d49522411b2ce7050f5f6349ca4762350f3280ef 100644 (file)
@@ -47,7 +47,8 @@ import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidates;
 
-public class VpnIpv6RIBSupportTest extends AbstractRIBSupportTest<VpnRoute> {
+public class VpnIpv6RIBSupportTest extends AbstractRIBSupportTest<VpnIpv6RoutesCase, VpnIpv6Routes, VpnRoute,
+        VpnRouteKey> {
     private VpnIpv6RIBSupport ribSupport;
 
     private static final DestinationVpnIpv6Case REACH_NLRI = new DestinationVpnIpv6CaseBuilder()
index b76a024f6c79c980fb8b7c1e8259ebbcdd470260..abfefa55dcf44652481d80d511f573782083ee2c 100644 (file)
@@ -55,7 +55,8 @@ import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidates;
 
-public class LabeledUnicastIpv4RIBSupportTest extends AbstractRIBSupportTest<LabeledUnicastRoute> {
+public class LabeledUnicastIpv4RIBSupportTest extends AbstractRIBSupportTest<LabeledUnicastRoutesCase,
+        LabeledUnicastRoutes, LabeledUnicastRoute, LabeledUnicastRouteKey> {
 
     private static final IpPrefix IPv4_PREFIX = new IpPrefix(new Ipv4Prefix("34.1.22.0/24"));
     private static final LabeledUnicastRoute ROUTE;
index 7c32e4b62a5d0bd4ee396217c349f1bb53555282..17a11bf9fcebddd71e88776c8a4271298a1c2266 100644 (file)
@@ -55,7 +55,8 @@ import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidates;
 
-public class LabeledUnicastIpv6RIBSupportTest extends AbstractRIBSupportTest<LabeledUnicastRoute> {
+public class LabeledUnicastIpv6RIBSupportTest extends AbstractRIBSupportTest<LabeledUnicastIpv6RoutesCase,
+        LabeledUnicastIpv6Routes, LabeledUnicastRoute, LabeledUnicastRouteKey> {
 
     private static final IpPrefix IPv6_PREFIX = new IpPrefix(new Ipv6Prefix("102:304:500::/40"));
     private static final LabeledUnicastRoute ROUTE;
index a3ea8f8426d8de4102315523e6a1bae5c8015a23..6088cc076b80f170808fc935305711d175ab3395 100644 (file)
@@ -68,7 +68,8 @@ import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidates;
 
-public final class LinkstateRIBSupportTest extends AbstractRIBSupportTest<LinkstateRoute> {
+public final class LinkstateRIBSupportTest extends AbstractRIBSupportTest<LinkstateRoutesCase, LinkstateRoutes,
+        LinkstateRoute, LinkstateRouteKey> {
 
     private LinkstateRIBSupport ribSupport;
     private static final LinkstateRoute ROUTE;
index d60634d61ec028def6a39295bfe3cf2160143993..e4517c8f26c854f5ac0a9818b55ff57e5c0c6fce 100644 (file)
@@ -54,7 +54,8 @@ import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidates;
 
-public class MvpnIpv4RIBSupportTest extends AbstractRIBSupportTest<MvpnRoute> {
+public class MvpnIpv4RIBSupportTest extends AbstractRIBSupportTest<MvpnRoutesIpv4Case, MvpnRoutesIpv4, MvpnRoute,
+        MvpnRouteKey> {
     private static final PathId PATH_ID = new PathId(0L);
     private static final MvpnChoice MVPN = new InterAsIPmsiADCaseBuilder().setInterAsIPmsiAD(
             new InterAsIPmsiADBuilder()
index 6d6ec87c07f3ddfe16266a282e8bf1871b4f2338..ac23ea6a17e69a38ce2fe394398bc524c73c078e 100644 (file)
@@ -55,7 +55,8 @@ import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidates;
 
-public final class MvpnIpv6RIBSupportTest extends AbstractRIBSupportTest<MvpnRoute> {
+public final class MvpnIpv6RIBSupportTest extends AbstractRIBSupportTest<MvpnRoutesIpv6Case, MvpnRoutesIpv6, MvpnRoute,
+        MvpnRouteKey> {
     private static final PathId PATH_ID = new PathId(0L);
     private static final MvpnChoice MVPN = new InterAsIPmsiADCaseBuilder().setInterAsIPmsiAD(
             new InterAsIPmsiADBuilder()
index 69f343880700fc4072be5758a43ab755d96f975e..23e5cbc9595a6357c8e2716cda2b714bea461936 100644 (file)
@@ -49,7 +49,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes;
+import org.opendaylight.yangtools.yang.binding.ChildOf;
+import org.opendaylight.yangtools.yang.binding.ChoiceIn;
 import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.Identifiable;
+import org.opendaylight.yangtools.yang.binding.Identifier;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
 import org.opendaylight.yangtools.yang.common.QName;
@@ -62,7 +66,10 @@ import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 
-public abstract class AbstractRIBSupportTest<R extends Route> extends AbstractConcurrentDataBrokerTest {
+public abstract class AbstractRIBSupportTest<C extends Routes & DataObject & ChoiceIn<Tables>,
+        S extends ChildOf<? super C>,
+        R extends Route & ChildOf<? super S> & Identifiable<I>,
+        I extends Identifier<R>> extends AbstractConcurrentDataBrokerTest {
     protected static final PathId PATH_ID = new PathId(1L);
     protected static final Attributes ATTRIBUTES = new AttributesBuilder().build();
     private static final InstanceIdentifier<LocRib> RIB = InstanceIdentifier.builder(BgpRib.class)
@@ -79,10 +86,10 @@ public abstract class AbstractRIBSupportTest<R extends Route> extends AbstractCo
     protected List<Map.Entry<InstanceIdentifier<?>, DataObject>> insertedRoutes;
 
     protected BindingNormalizedNodeSerializer mappingService;
-    private AbstractRIBSupport abstractRIBSupport;
+    private AbstractRIBSupport<C, S, R, I> abstractRIBSupport;
     private ModuleInfoBackedContext moduleInfoBackedContext;
 
-    protected final void setUpTestCustomizer(final AbstractRIBSupport<?, ?, ?, ?> ribSupport) throws Exception {
+    protected final void setUpTestCustomizer(final AbstractRIBSupport<C, S, R, I> ribSupport) throws Exception {
         this.abstractRIBSupport = ribSupport;
         this.moduleInfoBackedContext
                 .registerModuleInfo(BindingReflections.getModuleInfo(this.abstractRIBSupport.routesContainerClass()));
@@ -147,10 +154,10 @@ public abstract class AbstractRIBSupportTest<R extends Route> extends AbstractCo
             .getChild(new NodeIdentifier(BindingReflections.findQName(Routes.class))).get();
     }
 
-    protected final Collection<MapEntryNode> createRoutes(final DataObject routes) {
+    protected final Collection<MapEntryNode> createRoutes(final S routes) {
         Preconditions.checkArgument(routes.getImplementedInterface()
                 .equals(this.abstractRIBSupport.routesContainerClass()));
-        final InstanceIdentifier<DataObject> routesIId = routesIId();
+        final InstanceIdentifier<S> routesIId = routesIId();
         final Map.Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> normalizedNode = this.mappingService
                 .toNormalizedNode(routesIId, routes);
         final ContainerNode container = (ContainerNode) normalizedNode.getValue();
@@ -166,9 +173,9 @@ public abstract class AbstractRIBSupportTest<R extends Route> extends AbstractCo
         return RIB.child(Tables.class, getTablesKey());
     }
 
-    private InstanceIdentifier<DataObject> routesIId() {
+    private InstanceIdentifier<S> routesIId() {
         final InstanceIdentifier<Tables> tables = tablesIId();
-        return tables.child(this.abstractRIBSupport.routesContainerClass());
+        return tables.child(this.abstractRIBSupport.routesCaseClass(), this.abstractRIBSupport.routesContainerClass());
     }
 
     protected final YangInstanceIdentifier getTablePath() {
@@ -177,7 +184,7 @@ public abstract class AbstractRIBSupportTest<R extends Route> extends AbstractCo
     }
 
     protected final YangInstanceIdentifier getRoutePath() {
-        final InstanceIdentifier<DataObject> routesIId = routesIId();
+        final InstanceIdentifier<S> routesIId = routesIId();
         return this.mappingService.toYangInstanceIdentifier(routesIId).node(getRouteListQname());
     }
 
@@ -186,7 +193,7 @@ public abstract class AbstractRIBSupportTest<R extends Route> extends AbstractCo
                 .withModule(BindingReflections.getQNameModule(this.abstractRIBSupport.routesCaseClass()));
     }
 
-    protected final NodeIdentifierWithPredicates createRouteNIWP(final DataObject routes) {
+    protected final NodeIdentifierWithPredicates createRouteNIWP(final S routes) {
         final Collection<MapEntryNode> map = createRoutes(routes);
         return Iterables.getOnlyElement(map).getIdentifier();
     }