]> git.basschouten.com Git - openhab-addons.git/blob
b290072ff259c7dbe67aab093964c8dadac8857d
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
7  * This program and the accompanying materials are made available under the
8  * terms of the Eclipse Public License 2.0 which is available at
9  * http://www.eclipse.org/legal/epl-2.0
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.lametrictime.internal.api.test;
14
15 import java.nio.file.Path;
16 import java.nio.file.Paths;
17 import java.util.ArrayList;
18 import java.util.Arrays;
19 import java.util.List;
20
21 import org.eclipse.jdt.annotation.NonNullByDefault;
22
23 /**
24  * Test utility class.
25  *
26  * @author Gregory Moyer - Initial contribution
27  */
28 @NonNullByDefault
29 public class TestUtil {
30     private static final String RESOURCES_PATH = "src/test/resources/";
31
32     public static Path getTestDataPath(Class<?> clazz, String name) {
33         String packageName = clazz.getPackage().getName();
34
35         List<String> paths = new ArrayList<>();
36         paths.addAll(Arrays.asList(packageName.split("\\.")));
37         paths.add(name);
38
39         return Paths.get(RESOURCES_PATH, paths.toArray(new String[paths.size()]));
40     }
41
42     // @formatter:off
43     private TestUtil() {}
44     // @formatter:on
45 }