TepCommandHelper { public void configureTunnelType(String transportZoneName, String tunnelType) throws ExecutionException, InterruptedException { LOG.debug("configureTunnelType {} for transportZone {}", tunnelType, transportZoneName); TransportZone transportZoneFromConfigDS = ItmUtils.getTransportZoneFromConfigDS(transportZoneName, dataBroker); Class<? extends TunnelTypeBase> tunType; if (transportZoneFromConfigDS != null) { if (!transportZoneName.equals(ITMConstants.DEFAULT_TRANSPORT_ZONE)) { LOG.debug("Transport zone {} with tunnel type {} already exists. No action required.", transportZoneName, tunnelType); return; } else { tunnelType = StringUtils.upperCase(tunnelType); tunType = ItmUtils.TUNNEL_TYPE_MAP.get(tunnelType); if (Objects.equals(transportZoneFromConfigDS.getTunnelType(), tunType)) { return; } } } tunnelType = StringUtils.upperCase(tunnelType); tunType = ItmUtils.TUNNEL_TYPE_MAP.get(tunnelType); InstanceIdentifier<TransportZones> path = InstanceIdentifier.create(TransportZones.class); Optional<TransportZones> tzones = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, path, dataBroker); TransportZone tzone = new TransportZoneBuilder().withKey(new TransportZoneKey(transportZoneName)) .setTunnelType(tunType).build(); List<TransportZone> tzList = new ArrayList<>(); if (tzones.isPresent()) { final List<TransportZone> lst = tzones.get().getTransportZone(); if (lst != null) { tzList.addAll(lst); } } tzList.add(tzone); TransportZones transportZones = new TransportZonesBuilder().setTransportZone(tzList).build(); txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> tx.put(path, transportZones)).get(); } @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 testConfigureTunnelType() throws ExecutionException, InterruptedException { doReturn(FluentFutures.immediateFluentFuture(Optional.empty())).when(mockReadTx).read(LogicalDatastoreType .CONFIGURATION,transportZoneIdentifier); tepCommandHelper.configureTunnelType(transportZone1, "VXLAN"); verify(mockReadTx).read(LogicalDatastoreType.CONFIGURATION, transportZoneIdentifier); final List<TransportZone> newList = new ArrayList<>(transportZoneList); newList.add(new TransportZoneBuilder().withKey(new TransportZoneKey(transportZone1)) .setTunnelType(TunnelTypeVxlan.class).build()); verify(mockWriteTx).put(LogicalDatastoreType.CONFIGURATION, transportZonesIdentifier, new TransportZonesBuilder().setTransportZone(newList).build()); }