2 * Copyright (c) 2020 Pantheon Technologies, s.r.o. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.mdsal.binding.java.api.generator.test;
11 import java.io.FileNotFoundException;
12 import java.util.HashMap;
14 import java.util.Scanner;
16 final class FileSearchUtil {
17 private FileSearchUtil() {
21 static void assertFileContains(final File file, final String searchText) throws FileNotFoundException {
22 try (Scanner scanner = new Scanner(file)) {
23 while (scanner.hasNextLine()) {
24 if (scanner.nextLine().contains(searchText)) {
29 throw new AssertionError("File " + file + " does not contain '" + searchText + "'");
32 static Map<String, File> getFiles(final File path) {
33 final Map<String, File> ret = new HashMap<>();
38 private static void getFiles(final File path, final Map<String, File> files) {
39 final File [] dirFiles = path.listFiles();
40 for (File file : dirFiles) {
41 if (file.isDirectory()) {
42 getFiles(file, files);
45 files.put(file.getName(), file);