Skip to content

Latest commit

 

History

History
47 lines (37 loc) · 1.56 KB

readme.md

File metadata and controls

47 lines (37 loc) · 1.56 KB

Constraints

Exposing static method

public static String pack(String filePath) throws APIException

Plugins and Technologies Used

  • Java 18
  • Maven
  • TDD
  • Integration Testing
  • JUnit5, Mockito
  • Lombok
  • Jacoco
  • log4J

Assumption

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

Expected Input/Output

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

Data Structure & Implementation Details

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.

Entry point

call static method pack(fileName) with reference to Packer class Packer.pack("some_file_name")

Build And Test

  • mvn clean install
  • mvn clean test The detailed test coverage can be seen in target->jacoco->site->index.html

NFR

Added CodeQL workflow to scan code for security vulnerabilities