Exposing static method
public static String pack(String filePath) throws APIException
- Java 18
- Maven
- TDD
- Integration Testing
- JUnit5, Mockito
- Lombok
- Jacoco
- log4J
This project could be used as external library or mvn plugin.
The API only process List of items in the given format in src/main/test/resources/example_input
Input: Absolute File Path Name, UTF-8 format
Output: String as mentioned in path src/main/test/resources
file data is empty or invalid, the API call throws FileNotFound Exception If anything else goes wrong, the API call throws APIException
There can be many ways to solve this problem like using dynamic programming and priority queue. I chose to solve this problem by priority queue keeping in mind of lightweight solution. I am using the mix of Heap (PriorityQueue) of java and Map I created in this customized data structures into a class name KnapSackQueue, which is a class that collects and sort products keeping in mind of knapsack algorithm. Since this problem can be solved in multiple ways, I created an interface KnapSack which can have multiple implementations.
call static method pack(fileName) with reference to Packer class
Packer.pack("some_file_name")
- mvn clean install
- mvn clean test
The detailed test coverage can be seen in
target->jacoco->site->index.html
Added CodeQL workflow to scan code for security vulnerabilities