- Open project in IntelliJ IDEA or another IDE
- In file application properties write your mysql login and password.(usually by default it is root)
You can download MySQL here https://www.mysql.com/downloads/
- Go to the MySQL Workbench
-
- Launch MySQL Workbench and click the + button to open the Setup New Connection wizard
-
- Enter the name for the connection and username, then click Test Connection. Enter the password in the dialog asking for the password
-
- In the MySQL Workbench window that opens, click the Create a new schema in the connected server button on the main toolbar. Then enter the schema name (adcash), and click Apply
-
- In the Apply SQL Script to Database window that opens, click Apply. Then click Finish
You can test api using Postman. You can download it here https://www.postman.com/downloads/postman-agent/
NB! For a more beautiful output of the JSON, you can install this extension https://chrome.google.com/webstore/detail/json-viewer/gbmdgpbipfallnflgajpaliibnhdgobh?hl=ru
In Postman go to Workspaces -> My Workspace -> press + .
Firstly, you should create a category.
- Use http://localhost:8080/categories and choose a POST method
- For creating a new category, you should write the category’s name. Press “Body” then choose “raw” and choose ‘“JSON”.
-
Write category’s name like this
{ “categoryName”: “wanted category name” }
-
Press “Send”
If you try to create the category with the existing name you will get the error “Category already exists!”
- For this, use http://localhost:8080/products and choose a POST method
- Repeat all steps from “create a category”, write parameters for a new product like that:
{ “productName”: “wanted product name”, “productDescription”: “wanted product description” }
- As every product has a category, you should give a category id the product belongs to. Choose “Params”, write under the key categoryId and tick this key. As a value write needed category Id
- Use http://localhost:8080/categories and choose a GET method
- Press “Send”
- Or just type http://localhost:8080/categories in the search box and you will get something similar to this
- Use http://localhost:8080/products and choose a GET method
- Press “Send”
- Or just type http://localhost:8080/products in the search box
- Use http://localhost:8080/categories/{id} and choose a PUT method
- Instead of {id} in the URL, write the id of the category to be updated
- In params under the “Key” write the “name”(field to be changed) and under the “Value” wanted new name value
- Press “Send”
You will get a product with a changed name
- Use http://localhost:8080/products/{id} and choose a PUT method
- Instead of {id} in the URL, write the id of the product to be updated
- In params under the “Key” write the “name”(field to be changed) and under the “Value” wanted new name value
- Press “Send”
You will get a product with a changed name
- Use http://localhost:8080/categories/{id} and choose a DELETE method
- Instead of {id} in the URL, write the id of the category to be deleted
- Press “Send” You will get deleted category’s Id
- Use http://localhost:8080/products/{id} and choose a DELETE method
- Instead of {id} in the URL, write the id of the product to be deleted
- Press “Send” You will get deleted category’s Id
- Use http://localhost:8080/products/category/{category} and choose a GET method
- Instead of {category} in the URL, write the category of the products you want to get