@Test public void testAbstractRoutesRowDiff() { RouteRowAttribute.Builder routeRowAttrBuilder = RouteRowAttribute.builder().setAdminDistance(200).setMetric(2L).setNextHop("node1"); List<List<RouteRowAttribute>> diffMatrix = new ArrayList<>(); diffMatrix.add(Lists.newArrayList(routeRowAttrBuilder.build(), routeRowAttrBuilder.build())); List<DiffRoutesOutput> diff = ImmutableList.of( new DiffRoutesOutput( new RouteRowKey("node", "vrf", Prefix.parse("1.1.1.1/24")), new RouteRowSecondaryKey(Ip.parse("1.1.1.2"), "bgp"), KeyPresenceStatus.IN_BOTH, diffMatrix, KeyPresenceStatus.IN_BOTH)); Multiset<Row> rows = getAbstractRouteRowsDiff(diff); assertThat( rows, containsInAnyOrder( ImmutableList.of( hasColumn( COL_ROUTE_ENTRY_PRESENCE, equalTo(RouteEntryPresenceStatus.UNCHANGED.routeEntryPresenceName()), Schema.STRING)))); }
static Multiset<Row> getAbstractRouteRowsDiff(List<DiffRoutesOutput> diffRoutesList) { Map<String, ColumnMetadata> columnMetadataMap = getDiffTableMetadata(RibProtocol.MAIN).toColumnMap(); Multiset<Row> rows = HashMultiset.create(); for (DiffRoutesOutput diffRoutesOutput : diffRoutesList) { RouteRowKey routeRowKey = diffRoutesOutput.getRouteRowKey(); String hostName = routeRowKey.getHostName(); String vrfName = routeRowKey.getVrfName(); Prefix network = routeRowKey.getPrefix(); RouteRowSecondaryKey routeRowSecondaryKey = diffRoutesOutput.getRouteRowSecondaryKey(); KeyPresenceStatus secondaryKeyPresenceStatus = diffRoutesOutput.getRouteRowSecondaryKeyStatus(); for (List<RouteRowAttribute> routeRowAttributeInBaseAndRef : diffRoutesOutput.getDiffInAttributes()) { Row.RowBuilder rowBuilder = Row.builder(columnMetadataMap); rowBuilder .put(COL_NODE, new Node(hostName)) .put(COL_VRF_NAME, vrfName) .put(COL_NETWORK, network); RouteRowAttribute routeRowAttributeBase = routeRowAttributeInBaseAndRef.get(0); RouteRowAttribute routeRowAttributeRef = routeRowAttributeInBaseAndRef.get(1); rowBuilder.put( COL_ROUTE_ENTRY_PRESENCE, getRouteEntryPresence( secondaryKeyPresenceStatus, routeRowAttributeBase, routeRowAttributeRef)); populateSecondaryKeyAttrs(routeRowSecondaryKey, secondaryKeyPresenceStatus, rowBuilder); populateRouteAttributes(rowBuilder, routeRowAttributeBase, true); populateRouteAttributes(rowBuilder, routeRowAttributeRef, false); rows.add(rowBuilder.build()); } } return rows; }
RoutesAnswererUtil { static Multiset<Row> getAbstractRouteRowsDiff(List<DiffRoutesOutput> diffRoutesList) { Map<String, ColumnMetadata> columnMetadataMap = getDiffTableMetadata(RibProtocol.MAIN).toColumnMap(); Multiset<Row> rows = HashMultiset.create(); for (DiffRoutesOutput diffRoutesOutput : diffRoutesList) { RouteRowKey routeRowKey = diffRoutesOutput.getRouteRowKey(); String hostName = routeRowKey.getHostName(); String vrfName = routeRowKey.getVrfName(); Prefix network = routeRowKey.getPrefix(); RouteRowSecondaryKey routeRowSecondaryKey = diffRoutesOutput.getRouteRowSecondaryKey(); KeyPresenceStatus secondaryKeyPresenceStatus = diffRoutesOutput.getRouteRowSecondaryKeyStatus(); for (List<RouteRowAttribute> routeRowAttributeInBaseAndRef : diffRoutesOutput.getDiffInAttributes()) { Row.RowBuilder rowBuilder = Row.builder(columnMetadataMap); rowBuilder .put(COL_NODE, new Node(hostName)) .put(COL_VRF_NAME, vrfName) .put(COL_NETWORK, network); RouteRowAttribute routeRowAttributeBase = routeRowAttributeInBaseAndRef.get(0); RouteRowAttribute routeRowAttributeRef = routeRowAttributeInBaseAndRef.get(1); rowBuilder.put( COL_ROUTE_ENTRY_PRESENCE, getRouteEntryPresence( secondaryKeyPresenceStatus, routeRowAttributeBase, routeRowAttributeRef)); populateSecondaryKeyAttrs(routeRowSecondaryKey, secondaryKeyPresenceStatus, rowBuilder); populateRouteAttributes(rowBuilder, routeRowAttributeBase, true); populateRouteAttributes(rowBuilder, routeRowAttributeRef, false); rows.add(rowBuilder.build()); } } return rows; } }
RoutesAnswererUtil { static Multiset<Row> getAbstractRouteRowsDiff(List<DiffRoutesOutput> diffRoutesList) { Map<String, ColumnMetadata> columnMetadataMap = getDiffTableMetadata(RibProtocol.MAIN).toColumnMap(); Multiset<Row> rows = HashMultiset.create(); for (DiffRoutesOutput diffRoutesOutput : diffRoutesList) { RouteRowKey routeRowKey = diffRoutesOutput.getRouteRowKey(); String hostName = routeRowKey.getHostName(); String vrfName = routeRowKey.getVrfName(); Prefix network = routeRowKey.getPrefix(); RouteRowSecondaryKey routeRowSecondaryKey = diffRoutesOutput.getRouteRowSecondaryKey(); KeyPresenceStatus secondaryKeyPresenceStatus = diffRoutesOutput.getRouteRowSecondaryKeyStatus(); for (List<RouteRowAttribute> routeRowAttributeInBaseAndRef : diffRoutesOutput.getDiffInAttributes()) { Row.RowBuilder rowBuilder = Row.builder(columnMetadataMap); rowBuilder .put(COL_NODE, new Node(hostName)) .put(COL_VRF_NAME, vrfName) .put(COL_NETWORK, network); RouteRowAttribute routeRowAttributeBase = routeRowAttributeInBaseAndRef.get(0); RouteRowAttribute routeRowAttributeRef = routeRowAttributeInBaseAndRef.get(1); rowBuilder.put( COL_ROUTE_ENTRY_PRESENCE, getRouteEntryPresence( secondaryKeyPresenceStatus, routeRowAttributeBase, routeRowAttributeRef)); populateSecondaryKeyAttrs(routeRowSecondaryKey, secondaryKeyPresenceStatus, rowBuilder); populateRouteAttributes(rowBuilder, routeRowAttributeBase, true); populateRouteAttributes(rowBuilder, routeRowAttributeRef, false); rows.add(rowBuilder.build()); } } return rows; }  }
RoutesAnswererUtil { static Multiset<Row> getAbstractRouteRowsDiff(List<DiffRoutesOutput> diffRoutesList) { Map<String, ColumnMetadata> columnMetadataMap = getDiffTableMetadata(RibProtocol.MAIN).toColumnMap(); Multiset<Row> rows = HashMultiset.create(); for (DiffRoutesOutput diffRoutesOutput : diffRoutesList) { RouteRowKey routeRowKey = diffRoutesOutput.getRouteRowKey(); String hostName = routeRowKey.getHostName(); String vrfName = routeRowKey.getVrfName(); Prefix network = routeRowKey.getPrefix(); RouteRowSecondaryKey routeRowSecondaryKey = diffRoutesOutput.getRouteRowSecondaryKey(); KeyPresenceStatus secondaryKeyPresenceStatus = diffRoutesOutput.getRouteRowSecondaryKeyStatus(); for (List<RouteRowAttribute> routeRowAttributeInBaseAndRef : diffRoutesOutput.getDiffInAttributes()) { Row.RowBuilder rowBuilder = Row.builder(columnMetadataMap); rowBuilder .put(COL_NODE, new Node(hostName)) .put(COL_VRF_NAME, vrfName) .put(COL_NETWORK, network); RouteRowAttribute routeRowAttributeBase = routeRowAttributeInBaseAndRef.get(0); RouteRowAttribute routeRowAttributeRef = routeRowAttributeInBaseAndRef.get(1); rowBuilder.put( COL_ROUTE_ENTRY_PRESENCE, getRouteEntryPresence( secondaryKeyPresenceStatus, routeRowAttributeBase, routeRowAttributeRef)); populateSecondaryKeyAttrs(routeRowSecondaryKey, secondaryKeyPresenceStatus, rowBuilder); populateRouteAttributes(rowBuilder, routeRowAttributeBase, true); populateRouteAttributes(rowBuilder, routeRowAttributeRef, false); rows.add(rowBuilder.build()); } } return rows; }  static Map<RouteRowKey, Map<RouteRowSecondaryKey, SortedSet<RouteRowAttribute>>> groupRoutes(
          SortedMap<String, SortedMap<String, GenericRib<T>>> ribs,
          Set<String> matchingNodes,
          @Nullable Prefix network,
          String vrfRegex,
          RoutingProtocolSpecifier protocolSpec,
          @Nullable Map<Ip, Set<String>> ipOwners); static List<DiffRoutesOutput> getRoutesDiff(
      Map<RouteRowKey, Map<RouteRowSecondaryKey, SortedSet<RouteRowAttribute>>> routesInBase,
      Map<RouteRowKey, Map<RouteRowSecondaryKey, SortedSet<RouteRowAttribute>>> routesInRef); }
RoutesAnswererUtil { static Multiset<Row> getAbstractRouteRowsDiff(List<DiffRoutesOutput> diffRoutesList) { Map<String, ColumnMetadata> columnMetadataMap = getDiffTableMetadata(RibProtocol.MAIN).toColumnMap(); Multiset<Row> rows = HashMultiset.create(); for (DiffRoutesOutput diffRoutesOutput : diffRoutesList) { RouteRowKey routeRowKey = diffRoutesOutput.getRouteRowKey(); String hostName = routeRowKey.getHostName(); String vrfName = routeRowKey.getVrfName(); Prefix network = routeRowKey.getPrefix(); RouteRowSecondaryKey routeRowSecondaryKey = diffRoutesOutput.getRouteRowSecondaryKey(); KeyPresenceStatus secondaryKeyPresenceStatus = diffRoutesOutput.getRouteRowSecondaryKeyStatus(); for (List<RouteRowAttribute> routeRowAttributeInBaseAndRef : diffRoutesOutput.getDiffInAttributes()) { Row.RowBuilder rowBuilder = Row.builder(columnMetadataMap); rowBuilder .put(COL_NODE, new Node(hostName)) .put(COL_VRF_NAME, vrfName) .put(COL_NETWORK, network); RouteRowAttribute routeRowAttributeBase = routeRowAttributeInBaseAndRef.get(0); RouteRowAttribute routeRowAttributeRef = routeRowAttributeInBaseAndRef.get(1); rowBuilder.put( COL_ROUTE_ENTRY_PRESENCE, getRouteEntryPresence( secondaryKeyPresenceStatus, routeRowAttributeBase, routeRowAttributeRef)); populateSecondaryKeyAttrs(routeRowSecondaryKey, secondaryKeyPresenceStatus, rowBuilder); populateRouteAttributes(rowBuilder, routeRowAttributeBase, true); populateRouteAttributes(rowBuilder, routeRowAttributeRef, false); rows.add(rowBuilder.build()); } } return rows; }  static Map<RouteRowKey, Map<RouteRowSecondaryKey, SortedSet<RouteRowAttribute>>> groupRoutes(
          SortedMap<String, SortedMap<String, GenericRib<T>>> ribs,
          Set<String> matchingNodes,
          @Nullable Prefix network,
          String vrfRegex,
          RoutingProtocolSpecifier protocolSpec,
          @Nullable Map<Ip, Set<String>> ipOwners); static List<DiffRoutesOutput> getRoutesDiff(
      Map<RouteRowKey, Map<RouteRowSecondaryKey, SortedSet<RouteRowAttribute>>> routesInBase,
      Map<RouteRowKey, Map<RouteRowSecondaryKey, SortedSet<RouteRowAttribute>>> routesInRef);  }