Application to search words in a given data and find top occurrence words
Steps to run the project:
- Import the project in your local IDE
- Run commands: a) mvn clean b) mvn compile
- Run the project using CounterAppApplication.java (currently supported for JDK 8 or JDK 11)
Assumptions
- Used Spring Security in-memory authentication to demonstrate authentication.
- The API's will work only with username:diway and password:pass1234 as hard coded in the app.
- The sample paragraph has been kept at path: src/main/resources/data.txt
- If it's location is changed, then changes need to be done in CounterAppResourceLoader.java file.
- As per the Task 2 requirement, path variable top listing can only be 5, 10, 20, 30.
REST API Endpoints
-
POST /counter-api/search
- Description: Search the entered texts, which will return the counts respectively. If the request body is not passed, API will give 400 (Bad Request) error.
-
GET /counter-api/top/{value}
- Description: Provide the top texts which has the highest counts. If the path variable is not passed or incorrect value is passed, API will give 400 (Bad Request) error.
Error Handling
- Counter App handles all major Exceptions including Runtime Exception’s. We have a customized ErrorResponse object which we return to the consumers of the APIs.