TepCommandHelper { public void configureTunnelMonitorParams(boolean monitorEnabled, String monitorProtocol) { InstanceIdentifier<TunnelMonitorParams> path = InstanceIdentifier.create(TunnelMonitorParams.class); Optional<TunnelMonitorParams> storedTunnelMonitor = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, path, dataBroker); Class<? extends TunnelMonitoringTypeBase> monitorType ; if (storedTunnelMonitor.isPresent() && storedTunnelMonitor.get().getMonitorProtocol() != null) { monitorType = storedTunnelMonitor.get().getMonitorProtocol(); } else { if (monitorProtocol != null && monitorProtocol.equalsIgnoreCase(ITMConstants.MONITOR_TYPE_LLDP)) { monitorType = TunnelMonitoringTypeLldp.class; } else { monitorType = TunnelMonitoringTypeBfd.class; } } if (!storedTunnelMonitor.isPresent() || storedTunnelMonitor.get().isEnabled() != monitorEnabled) { TunnelMonitorParams tunnelMonitor = new TunnelMonitorParamsBuilder().setEnabled(monitorEnabled) .setMonitorProtocol(monitorType).build(); Futures.addCallback(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> tx.merge(path, tunnelMonitor)), ItmUtils.DEFAULT_WRITE_CALLBACK, MoreExecutors.directExecutor()); } } @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 testConfigureTunnelMonitorParams() { TunnelMonitorParams tunnelMonitor = new TunnelMonitorParamsBuilder().setEnabled(enabled) .setMonitorProtocol(monitorProtocol).build(); tepCommandHelper.configureTunnelMonitorParams(enabled, "BFD"); verify(mockReadTx).read(LogicalDatastoreType.CONFIGURATION,tunnelMonitorParamsIdentifier); verify(mockWriteTx).merge(LogicalDatastoreType.CONFIGURATION,tunnelMonitorParamsIdentifier, tunnelMonitor); }