TepCommandHelper { public List<String> showTeps(boolean monitorEnabled, int monitorInterval) throws TepException { boolean flag = false; InstanceIdentifier<TransportZones> path = InstanceIdentifier.builder(TransportZones.class).build(); Optional<TransportZones> transportZonesOptional = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, path, dataBroker); if (transportZonesOptional.isPresent()) { List<String> result = new ArrayList<>(); TransportZones transportZones = transportZonesOptional.get(); if (transportZones.getTransportZone() == null || transportZones.getTransportZone().isEmpty()) { handleError("No teps configured"); return result; } result.add(String.format("Tunnel Monitoring (for VXLAN tunnels): %s", monitorEnabled ? "On" : "Off")); result.add(String.format("Tunnel Monitoring Interval (for VXLAN tunnels): %d", monitorInterval)); result.add(System.lineSeparator()); result.add(String.format("%-16s %-16s %-12s %-16s", "TransportZone", "TunnelType", "DpnID", "IPAddress")); result.add("---------------------------------------------------------------------------------------------" + "---------------------------------"); for (TransportZone tz : transportZones.getTransportZone()) { if (tz.getVteps() == null || tz.getVteps().isEmpty()) { continue; } for (Vteps vtep : tz.getVteps().values()) { flag = true; String strTunnelType ; if (TunnelTypeGre.class.equals(tz.getTunnelType())) { strTunnelType = ITMConstants.TUNNEL_TYPE_GRE; } else { strTunnelType = ITMConstants.TUNNEL_TYPE_VXLAN; } result.add(String.format("%-16s %-16s %-12s %-16s", tz.getZoneName(), strTunnelType, vtep.getDpnId().toString(), vtep.getIpAddress().stringValue())); } } if (flag) { return result; } else { return Collections.singletonList("No teps to display"); } } else { return Collections.singletonList("No teps configured"); } } @Inject  TepCommandHelper(final DataBroker dataBroker, final ItmConfig itmConfig,
                            final UnprocessedTunnelsStateCache unprocessedTunnelsStateCache); @PostConstruct void start(); @PreDestroy void close(); @SuppressWarnings("checkstyle:IllegalCatch") void createLocalCache(Uint64 dpnId, String ipAddress,
                                 String transportZone); TransportZone getTransportZone(String transportZoneName); TransportZones getAllTransportZones(); boolean checkTepPerTzPerDpn(String tzone, Uint64 dpnId); @SuppressWarnings("checkstyle:IllegalCatch") void buildTeps(); List<String> showTeps(boolean monitorEnabled, int monitorInterval); @SuppressWarnings("checkstyle:RegexpSinglelineJava") void showCache(String cacheName); @SuppressWarnings("checkstyle:IllegalCatch") void deleteVtep(Uint64 dpnId, String ipAddress,
                           String transportZone); @SuppressWarnings("checkstyle:IllegalCatch") void deleteOnCommit(); @SuppressWarnings("checkstyle:RegexpSinglelineJava") void showState(Collection<StateTunnelList> tunnelLists, boolean tunnelMonitorEnabled); void showBridges(Map<Uint64, OvsdbBridgeRef> dpnIdBridgeRefMap); boolean isInCache(Uint64 dpnId, String ipAddress,
                             String transportZone); void configureTunnelType(String transportZoneName, String tunnelType); void configureTunnelMonitorParams(boolean monitorEnabled, String monitorProtocol); void configureTunnelMonitorInterval(int interval); void handleError(String errorMessage); @SuppressWarnings("checkstyle:RegexpSinglelineJava") void showOfPorts(Collection<OfTep> ofTeps);  }
@Test public void testShowTepsWithTransportZone() { try { tepCommandHelper.showTeps(enabled, interval); } catch (TepException e) { LOG.error(e.getMessage()); } verify(mockReadTx).read(LogicalDatastoreType.CONFIGURATION,transportZonesIdentifier); }
@Test public void testShowTepsWithoutTransportZone() { optionalTransportZones = Optional.of(transportZonesNew); doReturn(FluentFutures.immediateFluentFuture(optionalTransportZones)).when(mockReadTx).read(LogicalDatastoreType .CONFIGURATION,transportZonesIdentifier); String output = null; try { tepCommandHelper.showTeps(enabled, interval); } catch (TepException e) { output = e.getMessage(); } verify(mockReadTx).read(LogicalDatastoreType.CONFIGURATION,transportZonesIdentifier); assertEquals("No teps configured",output); }