@Test public void testRemoveIfExists_NotExisting() throws Exception { Optional<?> optional = mock(Optional.class); when(optional.isPresent()).thenReturn(false); when(readFuture.checkedGet()).thenReturn((Optional) optional); DataStoreHelper.removeIfExists(LogicalDatastoreType.OPERATIONAL, mock(InstanceIdentifier.class), readWriteTransaction); verify(readWriteTransaction, never()).delete(any(LogicalDatastoreType.class), any(InstanceIdentifier.class)); }
public static <T extends DataObject> Optional<T> removeIfExists(LogicalDatastoreType store, InstanceIdentifier<T> path, ReadWriteTransaction rwTx) { Optional<T> potentialResult = readFromDs(store, path, rwTx); if (potentialResult.isPresent()) { rwTx.delete(store, path); } return potentialResult; }
DataStoreHelper { public static <T extends DataObject> Optional<T> removeIfExists(LogicalDatastoreType store, InstanceIdentifier<T> path, ReadWriteTransaction rwTx) { Optional<T> potentialResult = readFromDs(store, path, rwTx); if (potentialResult.isPresent()) { rwTx.delete(store, path); } return potentialResult; } }
DataStoreHelper { public static <T extends DataObject> Optional<T> removeIfExists(LogicalDatastoreType store, InstanceIdentifier<T> path, ReadWriteTransaction rwTx) { Optional<T> potentialResult = readFromDs(store, path, rwTx); if (potentialResult.isPresent()) { rwTx.delete(store, path); } return potentialResult; }  }
DataStoreHelper { public static <T extends DataObject> Optional<T> removeIfExists(LogicalDatastoreType store, InstanceIdentifier<T> path, ReadWriteTransaction rwTx) { Optional<T> potentialResult = readFromDs(store, path, rwTx); if (potentialResult.isPresent()) { rwTx.delete(store, path); } return potentialResult; }  static Optional<T> readFromDs(LogicalDatastoreType store, InstanceIdentifier<T> path, ReadTransaction rTx); static boolean submitToDs(WriteTransaction wTx); static Optional<T> removeIfExists(LogicalDatastoreType store, InstanceIdentifier<T> path,
            ReadWriteTransaction rwTx); }
DataStoreHelper { public static <T extends DataObject> Optional<T> removeIfExists(LogicalDatastoreType store, InstanceIdentifier<T> path, ReadWriteTransaction rwTx) { Optional<T> potentialResult = readFromDs(store, path, rwTx); if (potentialResult.isPresent()) { rwTx.delete(store, path); } return potentialResult; }  static Optional<T> readFromDs(LogicalDatastoreType store, InstanceIdentifier<T> path, ReadTransaction rTx); static boolean submitToDs(WriteTransaction wTx); static Optional<T> removeIfExists(LogicalDatastoreType store, InstanceIdentifier<T> path,
            ReadWriteTransaction rwTx);  }