Skip to content

Commit 3be5a90

Browse files
committed
Fix bugs
1 parent e7c9e20 commit 3be5a90

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/main/java/com/nordstrom/common/file/PathUtils.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
import java.util.regex.Pattern;
1414
import java.util.stream.Stream;
1515

16-
import org.testng.util.Strings;
17-
1816
public class PathUtils {
1917

2018
private PathUtils() {
@@ -34,15 +32,17 @@ public static Path getNextPath(Path targetPath, String baseName, String extensio
3432
String newName;
3533

3634
Objects.requireNonNull(targetPath, "[targetPath] must be non-null");
35+
Objects.requireNonNull(baseName, "[baseName] must be non-null");
36+
Objects.requireNonNull(extension, "[extension] must be non-null");
3737

3838
File targetFile = targetPath.toFile();
3939
if ( ! (targetFile.exists() && targetFile.isDirectory())) {
4040
throw new IllegalArgumentException("[targetPath] must specify an existing directory");
4141
}
42-
if (Strings.isNullOrEmpty(baseName)) {
42+
if (baseName.isEmpty()) {
4343
throw new IllegalArgumentException("[baseName] must specify a non-empty string");
4444
}
45-
if (Strings.isNullOrEmpty(extension)) {
45+
if (extension.isEmpty()) {
4646
throw new IllegalArgumentException("[extension] must specify a non-empty string");
4747
}
4848

src/test/java/com/nordstrom/common/file/PathUtilsTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public void testNextPath() throws IOException {
2727
file.delete();
2828
}
2929
} else {
30-
Files.createDirectory(targetPath);
30+
Files.createDirectories(targetPath);
3131
}
3232

3333
Path path1 = PathUtils.getNextPath(targetPath, "test", "txt");
@@ -75,7 +75,7 @@ public void testNonExistentPath() throws IOException {
7575
PathUtils.getNextPath(Paths.get("foobar"), "test", "txt");
7676
}
7777

78-
@Test(expectedExceptions = {IllegalArgumentException.class})
78+
@Test(expectedExceptions = {NullPointerException.class})
7979
public void testNullBaseName() throws IOException {
8080
PathUtils.getNextPath(getOutputPath(), null, "txt");
8181
}
@@ -85,7 +85,7 @@ public void testEmptyBaseName() throws IOException {
8585
PathUtils.getNextPath(getOutputPath(), "", "txt");
8686
}
8787

88-
@Test(expectedExceptions = {IllegalArgumentException.class})
88+
@Test(expectedExceptions = {NullPointerException.class})
8989
public void testNullExtenstion() throws IOException {
9090
PathUtils.getNextPath(getOutputPath(), "test", null);
9191
}

0 commit comments

Comments
 (0)