TepCommandHelper { @SuppressWarnings("checkstyle:IllegalCatch") public <T extends DataObject> void deleteOnCommit() { List<InstanceIdentifier<T>> vtepPaths = new ArrayList<>(); List<InstanceIdentifier<T>> subnetPaths = new ArrayList<>(); List<Vteps> vtepDelList = new ArrayList<>(); List<InstanceIdentifier<T>> allPaths = new ArrayList<>(); try { if (vtepDelCommitList != null && !vtepDelCommitList.isEmpty()) { InstanceIdentifier<TransportZones> path = InstanceIdentifier.builder(TransportZones.class).build(); Optional<TransportZones> transportZonesOptional = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, path, dataBroker); if (transportZonesOptional.isPresent()) { List<TransportZone> transportZones = transportZonesOptional.get().nonnullTransportZone(); for (TransportZone tz : transportZones) { if (tz.getVteps() == null || tz.getVteps().isEmpty()) { continue; } vtepDelList.addAll(vtepDelCommitList); for (Vteps vtep : vtepDelList) { InstanceIdentifier<T> vpath = (InstanceIdentifier<T>) InstanceIdentifier .builder(TransportZones.class) .child(TransportZone.class, tz.key()) .child(Vteps.class, vtep.key()).build(); vtepPaths.add(vpath); } } allPaths.addAll(vtepPaths); allPaths.addAll(subnetPaths); Futures.addCallback(txRunner.callWithNewWriteOnlyTransactionAndSubmit(Datastore.CONFIGURATION, tx -> allPaths.forEach(tx::delete)), ItmUtils.DEFAULT_WRITE_CALLBACK, MoreExecutors.directExecutor()); } vtepPaths.clear(); subnetPaths.clear(); allPaths.clear(); vtepDelCommitList.clear(); } } catch (RuntimeException e) { LOG.error("Unexpected error", e); } } @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 testDeleteOnCommit() { transportZoneList.add(transportZone); transportZoneList.add(transportZoneNew); transportZones = new TransportZonesBuilder().setTransportZone(transportZoneList).build(); optionalTransportZones = Optional.of(transportZones); doReturn(FluentFutures.immediateFluentFuture(optionalTransportZones)).when(mockReadTx).read(LogicalDatastoreType .CONFIGURATION,transportZonesIdentifier); try { tepCommandHelper.deleteVtep(dpId1, tepIp1, transportZone1); } catch (TepException e) { LOG.error(e.getMessage()); } tepCommandHelper.deleteOnCommit(); verify(mockReadTx).read(LogicalDatastoreType.CONFIGURATION,vtepsIdentifier); }