This is a simple Java-based file validation utility that checks the structure of filenames based on specific rules, reads their content (if valid), and prints messages accordingly.
Git clone will allows you to download the whole source code of the application. Use this command in your bash/terminal
git clone https://github.com/edneilcabigao444/file-name-validator.git
file-name-validator
src
- com.jp.file.validator
- constants
- CommonConstant.java
- service
- FileNameValidatorImpl.java
- ReadFileImpl.java
- util
- CommonUtil.java
Main.java
test
- com.jp.file.validator
- service
- FileNameValidatorImplTest.java
- ReadFileImplTest.java
- util
- CommonUtilTest.java
MainTest.java
resources
- Hello_A_07121987.csv
- Test.txt
- Test_A_07121987.csv
- Test_A_07121987.txt
- Test_A_31122000_12.csv
- Test_E_07121987.csv
- Testing001.pdf [Other type of file]
pom.xmlThe expected format for filenames is:
- Prefix: Must start with
Test - Portfolio Code: Must be one of
A,B, orC - Date: Must be a valid date in
ddMMyyyyformat - Sequence: Optional, but if present, must be a 2-digit number with sequential digits (like
12or21) - Extension: Must be
.csv
- Add Error handling if the file is not exist in the resource folder
- Add Error handling if the the sequence number is not valid or not found
- Junit Jupiter
- 5.10.0
JUnit Jupiter is the combination of the new programming model and extension model for writing tests and extensions in JUnit 5
- 5.10.0
- Mokito
- 5.12.0
Mockito is an open-source Java mocking framework used for creating test double objects in unit tests
- 5.12.0
- Maven Surefire Plugin
- 3.2.1
The Surefire Plugin is used during the test phase of the build lifecycle to execute the unit tests of an application. It generates reports in two different file formats:
- Plain text files (*.txt)
- XML files (*.xml)
- 3.2.1
- Java 11
- Maven
- JUnit 5
- Mockito
- Java 11 or later
- Maven (for building and running tests)
# Navigate to the project root
cd your-project-root [C:\Users\<user>\Downloads\file-name-validator]
# Compile the code
mvn clean compile package
# Run Code
java -jar ./target/<name-of-project>-1.0-SNAPSHOT.jar
# (Optional) Run Test
mvn test
This is a sample result based on the document and the expectation of the user/consumer.

