-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor FileFilterTest and add LazySupplierTest
Updated the FileFilterTest.java by revising existing tests and adding new ones for improved code coverage. The refactoring increases the usage of lambda expressions and method references for readability and conciseness. Simultaneously, a new test class LazySupplierTest.java has been added, which includes tests for both eager and lazy suppliers.
- Loading branch information
Showing
2 changed files
with
68 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package lambdas; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.logging.Logger; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
public class LazySupplierTest { | ||
private final Logger logger = Logger.getLogger(LazySupplierTest.class.getName()); | ||
|
||
private String getErrorMessage() { | ||
System.out.println("getErrorMessage() called"); | ||
return "Error message"; | ||
} | ||
|
||
private String getLogMessage() { | ||
System.out.println("getLogMessage() called"); | ||
return "Test passed"; | ||
} | ||
|
||
@Test | ||
void eagerSupplier() { | ||
boolean x = true; | ||
assertTrue(x, getErrorMessage()); | ||
logger.fine(getLogMessage()); | ||
} | ||
|
||
@Test | ||
void lazySupplier() { | ||
boolean x = true; | ||
assertTrue(x, () -> getErrorMessage()); | ||
logger.fine(() -> getLogMessage()); | ||
} | ||
} |