@SuppressWarnings({"unchecked", "rawtypes"}) @Test public void testCheckOfOverlayConfig_TunnelTypeEqualsFalse() throws Exception { AbstractTunnelType abstractTunnelType = mock(AbstractTunnelType.class); when(writeTransaction.read(any(LogicalDatastoreType.class), any(InstanceIdentifier.class))) .thenReturn(nodeConfigFuture); when(nodeConfigOptional.isPresent()).thenReturn(true); OfOverlayNodeConfig overlayConfig = mock(OfOverlayNodeConfig.class); when(nodeConfigOptional.get()).thenReturn(overlayConfig); Tunnel tunnel = mock(Tunnel.class); when(overlayConfig.getTunnel()).thenReturn(Collections.singletonList(tunnel)); when(abstractTunnelType.getTunnelType()).thenReturn((Class) TunnelTypeVxlan.class); when(tunnel.getTunnelType()).thenReturn((Class) TunnelTypeBase.class); boolean result = InventoryHelper.checkOfOverlayConfig(nodeIdString, Collections.singletonList(abstractTunnelType), dataBroker); assertFalse(result); }
public static boolean checkOfOverlayConfig(String nodeIdString, List<AbstractTunnelType> requiredTunnelTypes, DataBroker dataBroker) { OfOverlayNodeConfig config = getOfOverlayConfig(nodeIdString, dataBroker); if (config == null || config.getTunnel() == null) { LOG.debug("No OfOverlay config for {}", nodeIdString); return false; } for (AbstractTunnelType tunnelType : requiredTunnelTypes) { boolean tunnelPresent = false; for (Tunnel tunnel : config.getTunnel()) { if (tunnelType.getTunnelType().equals(tunnel.getTunnelType())) { tunnelPresent = true; break; } } if (tunnelPresent == false) { return false; } } return true; }
InventoryHelper { public static boolean checkOfOverlayConfig(String nodeIdString, List<AbstractTunnelType> requiredTunnelTypes, DataBroker dataBroker) { OfOverlayNodeConfig config = getOfOverlayConfig(nodeIdString, dataBroker); if (config == null || config.getTunnel() == null) { LOG.debug("No OfOverlay config for {}", nodeIdString); return false; } for (AbstractTunnelType tunnelType : requiredTunnelTypes) { boolean tunnelPresent = false; for (Tunnel tunnel : config.getTunnel()) { if (tunnelType.getTunnelType().equals(tunnel.getTunnelType())) { tunnelPresent = true; break; } } if (tunnelPresent == false) { return false; } } return true; } }
InventoryHelper { public static boolean checkOfOverlayConfig(String nodeIdString, List<AbstractTunnelType> requiredTunnelTypes, DataBroker dataBroker) { OfOverlayNodeConfig config = getOfOverlayConfig(nodeIdString, dataBroker); if (config == null || config.getTunnel() == null) { LOG.debug("No OfOverlay config for {}", nodeIdString); return false; } for (AbstractTunnelType tunnelType : requiredTunnelTypes) { boolean tunnelPresent = false; for (Tunnel tunnel : config.getTunnel()) { if (tunnelType.getTunnelType().equals(tunnel.getTunnelType())) { tunnelPresent = true; break; } } if (tunnelPresent == false) { return false; } } return true; }  }
InventoryHelper { public static boolean checkOfOverlayConfig(String nodeIdString, List<AbstractTunnelType> requiredTunnelTypes, DataBroker dataBroker) { OfOverlayNodeConfig config = getOfOverlayConfig(nodeIdString, dataBroker); if (config == null || config.getTunnel() == null) { LOG.debug("No OfOverlay config for {}", nodeIdString); return false; } for (AbstractTunnelType tunnelType : requiredTunnelTypes) { boolean tunnelPresent = false; for (Tunnel tunnel : config.getTunnel()) { if (tunnelType.getTunnelType().equals(tunnel.getTunnelType())) { tunnelPresent = true; break; } } if (tunnelPresent == false) { return false; } } return true; }  static Long getLongFromDpid(String dpid); static String getInventoryNodeIdString(OvsdbBridgeAugmentation ovsdbBridge,
            InstanceIdentifier<OvsdbTerminationPointAugmentation> ovsdbTpIid, DataBroker dataBroker); static String getInventoryNodeConnectorIdString(String inventoryNodeId,
            OvsdbTerminationPointAugmentation ovsdbTp, InstanceIdentifier<OvsdbTerminationPointAugmentation> tpIid,
            DataBroker dataBroker); static boolean checkOfOverlayConfig(String nodeIdString, List<AbstractTunnelType> requiredTunnelTypes,
            DataBroker dataBroker); static InstanceIdentifier<ExternalInterfaces> addOfOverlayExternalPort(NodeId nodeId, NodeConnectorId ncId,
        DataBroker dataBroker); static OfOverlayNodeConfig getOfOverlayConfig(String nodeIdString, DataBroker dataBroker); static void updateOfOverlayConfig(IpAddress ip, String nodeIdString, String nodeConnectorIdString,
            AbstractTunnelType tunnelType, DataBroker dataBroker); static void removeTunnelsOfOverlayConfig(String nodeIdString,
                                                    List<AbstractTunnelType> tunnels,
                                                    DataBroker dataBroker); }
InventoryHelper { public static boolean checkOfOverlayConfig(String nodeIdString, List<AbstractTunnelType> requiredTunnelTypes, DataBroker dataBroker) { OfOverlayNodeConfig config = getOfOverlayConfig(nodeIdString, dataBroker); if (config == null || config.getTunnel() == null) { LOG.debug("No OfOverlay config for {}", nodeIdString); return false; } for (AbstractTunnelType tunnelType : requiredTunnelTypes) { boolean tunnelPresent = false; for (Tunnel tunnel : config.getTunnel()) { if (tunnelType.getTunnelType().equals(tunnel.getTunnelType())) { tunnelPresent = true; break; } } if (tunnelPresent == false) { return false; } } return true; }  static Long getLongFromDpid(String dpid); static String getInventoryNodeIdString(OvsdbBridgeAugmentation ovsdbBridge,
            InstanceIdentifier<OvsdbTerminationPointAugmentation> ovsdbTpIid, DataBroker dataBroker); static String getInventoryNodeConnectorIdString(String inventoryNodeId,
            OvsdbTerminationPointAugmentation ovsdbTp, InstanceIdentifier<OvsdbTerminationPointAugmentation> tpIid,
            DataBroker dataBroker); static boolean checkOfOverlayConfig(String nodeIdString, List<AbstractTunnelType> requiredTunnelTypes,
            DataBroker dataBroker); static InstanceIdentifier<ExternalInterfaces> addOfOverlayExternalPort(NodeId nodeId, NodeConnectorId ncId,
        DataBroker dataBroker); static OfOverlayNodeConfig getOfOverlayConfig(String nodeIdString, DataBroker dataBroker); static void updateOfOverlayConfig(IpAddress ip, String nodeIdString, String nodeConnectorIdString,
            AbstractTunnelType tunnelType, DataBroker dataBroker); static void removeTunnelsOfOverlayConfig(String nodeIdString,
                                                    List<AbstractTunnelType> tunnels,
                                                    DataBroker dataBroker);  }