Skip to content

Commit

Permalink
Fix issues in comments and return values.
Browse files Browse the repository at this point in the history
  • Loading branch information
User253489 committed Aug 8, 2018
1 parent 436d549 commit 5efced2
Showing 1 changed file with 37 additions and 34 deletions.
71 changes: 37 additions & 34 deletions src/main/java/org/testng/FileAssert.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import java.io.IOException;

/**
* Assertion tool for File centric assertions. Conceptually this is an extension of {@link Assert}
* Assertion tool for File centric assertions. Conceptually, this is an extension of {@link Assert}.
* Presents assertion methods with a more natural parameter order. The order is always
* <B>actualValue</B>, <B>expectedValue</B> [, message].
*
Expand All @@ -13,14 +13,14 @@
*/
public class FileAssert {

/** Protect constructor since it is a static only class */
/** Protect this constructor since it is a static only class. */
private FileAssert() {
// hide constructor
// Hide this constructor.
}

/**
* Asserts that a {@code tstvalue} is a proper directory. If it isn't, an AssertionError, with the
* given message, is thrown.
* Asserts that a {@code tstvalue} is a proper directory. If it isn't, an AssertionError with the
* given message is thrown.
*
* @param tstvalue the file to evaluate
* @param message the assertion error message
Expand All @@ -42,8 +42,8 @@ public static void assertDirectory(File tstvalue) {
}

/**
* Asserts that a {@code tstvalue} is a proper file. If it isn't, an AssertionError, with the
* given message, is thrown.
* Asserts that a {@code tstvalue} is a proper file. If it isn't, an AssertionError with the
* given message is thrown.
*
* @param tstvalue the file to evaluate
* @param message the assertion error message
Expand All @@ -67,7 +67,7 @@ public static void assertFile(File tstvalue) {

/**
* Asserts that a {@code tstvalue} is a file of exactly {@code expected} characters or a directory
* of exactly {@code expected} entries. If it isn't, an AssertionError, with the given message, is
* of exactly {@code expected} entries. If it isn't, an AssertionError with the given message is
* thrown.
*
* @param tstvalue the file to evaluate
Expand All @@ -92,8 +92,8 @@ public static void assertLength(File tstvalue, long expected) {

/**
* Asserts that a {@code tstvalue} is a file of at least {@code expected} characters or a
* directory of at least {@code expected} entries. If it isn't, an AssertionError, with the given
* message, is thrown.
* directory of at least {@code expected} entries. If it isn't, an AssertionError with the given
* message is thrown.
*
* @param tstvalue the file to evaluate
* @param message the assertion error message
Expand All @@ -118,7 +118,7 @@ public static void assertMinLength(File tstvalue, long expected) {

/**
* Asserts that a {@code tstvalue} is a file of at most {@code expected} characters or a directory
* of at most {@code expected} entries. If it isn't, an AssertionError, with the given message, is
* of at most {@code expected} entries. If it isn't, an AssertionError with the given message is
* thrown.
*
* @param tstvalue the file to evaluate
Expand All @@ -143,8 +143,8 @@ public static void assertMaxLength(File tstvalue, long expected) {
}

/**
* Asserts that a {@code tstvalue} is readable. If it isn't, an AssertionError, with the given
* message, is thrown.
* Asserts that a {@code tstvalue} is readable. If it isn't, an AssertionError with the given
* message is thrown.
*
* @param tstvalue the file to evaluate
* @param message the assertion error message
Expand All @@ -167,8 +167,8 @@ public static void assertReadable(File tstvalue) {
}

/**
* Asserts that a {@code tstvalue} is writeable. If it isn't, an AssertionError, with the given
* message, is thrown.
* Asserts that a {@code tstvalue} is writeable. If it isn't, an AssertionError with the given
* message is thrown.
*
* @param tstvalue the file to evaluate
* @param message the assertion error message
Expand All @@ -191,8 +191,8 @@ public static void assertWriteable(File tstvalue) {
}

/**
* Asserts that a {@code tstvalue} is readable and writeable. If it isn't, an AssertionError, with
* the given message, is thrown.
* Asserts that a {@code tstvalue} is readable and writeable. If it isn't, an AssertionError with
* the given message is thrown.
*
* @param tstvalue the file to evaluate
* @param message the assertion error message
Expand Down Expand Up @@ -241,7 +241,7 @@ public static void fail() {
fail(null);
}

/** Formats failure for file assertions */
/** Formats failure for file assertions. */
private static void failFile(File path, String actual, String expected, String message) {
String formatted = "";
if (message != null) {
Expand Down Expand Up @@ -287,34 +287,37 @@ private static void failSecurity(
private static String fileType(File path) {
try {
if (!path.exists()) {
return "Non existant";
} else if (path.isDirectory()) {
return "Nonexistent";
}
if (path.isDirectory()) {
return "Directory";
} else if (path.isFile()) {
}
if (path.isFile()) {
return "File";
} else {
return "Special File";
}
return "Special File";
} catch (SecurityException e) {
return "Unauthorized";
}
}

/** String representation of what sort of file {@code path} is. */
/** String representation of read and write permissions of {@code path}. */
private static String fileAccess(File path) {
try {
if (!path.exists()) {
return "Non existant";
} else if (path.canWrite() && path.canRead()) {
return "Read/Write Access";
} else if (path.canRead()) {
return "Read only Access";
} else if (path.canWrite()) {
return "Write only Access";
} else {
return "No Access";
return "Nonexistent";
}
if (path.canRead() && path.canWrite()) {
return "Read and Write Access";
}
if (path.canRead()) {
return "Read but not Write Access";
}
} catch (SecurityException e) {
if (path.canWrite()) {
return "Write but not Read Access";
}
return "Neither Read nor Write Access";
} catch (SecurityException e) {
return "Unauthorized";
}
}
Expand Down

0 comments on commit 5efced2

Please sign in to comment.