The project is to build a Rest-API for solving knacksnack problem. The job is carried out in an asynchronous communication. It means that a client may post its task in the sever, and get back its solution later on.
I slightly changed Java Program to Implement Knapsack Algorithm, so that it fits into the project.
User post its task via API. System feedback a http accepted status, meanwhile spawning a new thread to do the heavy job. As the job done, the solution is inserted in to database, waiting for user to retrieve it.
Cloud: https://knapsacksolver.herokuapp.com/ Project jar file is deployed on the Cloud via Heroku CLI using git command.
The cloud server is totally free, so it will very often fall in idle. You need to wait a while until it wakes up.
or Local: http://localhost:8080 running on Tomcat sever
API is secured by the Spring Security, with user: "test" and password: "test"
Unit test: Spring Integration test with Mocked MVC. It includes an embedded memory database, and a mocked application server. It is presented in the code, test package. And/OR: Real life test: using Postman to invoke APIs.
URI: https://knapsacksolver.herokuapp.com/knapsack/tasks
Request body: {"capacity":60,"weights":[50,10,20,40,30],"prices":[300,60,90,100,240]}
Basic Auth.: user: "test"; password: "test"
URI https://knapsacksolver.herokuapp.com/knapsack/tasks/id
id : Long ; task id.
URI https://knapsacksolver.herokuapp.com/knapsack/solutions/task
task: JAVA util UUID String ; achieved when posting a task
for instance: https://knapsacksolver.herokuapp.com/knapsack/solutions/0964614d-b8fb-450e-9abd-fcace74dabe9
URI https://knapsacksolver.herokuapp.com/knapsack/admin/tasks
return all tasks classified by their status.
for instance