Please make sure you have the following installed on your machine:
For database, you can use any DBMS you want, but I'd used MySQL for this project.
For IDE, you can use any IDE you want, but I'd used IntelliJ IDEA for this project (Community Edition is enough).
API Testing Tool:
- Postman (recommended)
-
Open your terminal/CMD and go to the directory where you want to clone this project by using
cd
command. -
Clone this repository to your local machine.
git clone https://github.com/Esh07/Module-Timetable-Management-System-RESTful-API.git
- Open the project in your IDE.
-
Open MySQL Workbench and connect to your local MySQL server. (If you don't have any server, you can create one by clicking on the
+
icon on the MySQL Connections tab.) -
Create a new schema and name it
module_timetable_api
. (You can name it whatever you want, but you have to change the name in theapplication.properties
file in the project. - See below) -
Create a new user and name it
co2103
with passwordco2103
. (You can name it whatever you want, but you have to change the name in theapplication.properties
file in the project. - See below) -
Grant all privileges to the user you just created. (You can do this by clicking on the
Users and Privileges
tab and double-clicking on the user you just created. Then, go to theAdministrative Roles
tab and check all the privileges.) -
Click on the
Apply
button and then click on theFinish
button. -
Now, you can connect to the database using the user you just created.
-
Open the project in your IDE.
-
Go to the
src/main/resources
directory and open theapplication.properties
file. -
Change the
spring.datasource.url
property tojdbc:mysql://localhost:3306/module_timetable_api
.Note: If you have changed the schema name, you have to change it here as well. For example:
- Keep protocol, hostname and port as it is.
- Change the schema name to the name you have given to the schema (database) you created. (keep the same,
module_timetable_api
if you haven't changed it in the Database section above)
-
Change the
spring.datasource.username
property toco2103
.Note: If you have changed the username, you have to change it here as well.
-
Change the
spring.datasource.password
property toco2103
.Note: If you have changed the password, you have to change it here as well.
-
Save the file.
-
Go to the
src/main/java/edu/leicester/co2103/
directory and open thePart1Application.java
file. -
Right-click on the
Part1Application.java
file and selectRun 'Part1Application'
. -
Go to the
Run
tab and click on theEdit Configurations...
option. -
Click on the
+
icon and selectGradle
. -
Change the
Name
toRun Part1Application
. -
Change the
Gradle project
toModule-Timetable-Management-System-RESTful-API
. -
Change the
Tasks
tobootRun
. -
Click on the
Apply
button and then click on theOK
button. -
Now, you can run the project by clicking on the
Run Part1Application
option in theRun
tab.
Note: Before testing the API, ensure that the project is running.
-
Open Postman.
-
Click on the
Collection
tab and create a new collection namedModule Timetable API
. -
Now, click on the
File
tab and selectImport...
. -
Go to the
src/main/resources
directory and select thepart1.postman_collection.json
file.or
you can drag and drop the
part1.postman_collection.json
file to the Postman window.
If you have done everything correctly, you should see the Timetable - REST API
collection in the Collections
tab.
You can now call the API endpoints by clicking on the endpoints in the Collections
tab.
Each endpoint has a test script that tests the endpoint and returns the result.
To run collection tests:
-
Click on the
Runner
tab and follow instructions shown on the new window. -
Once you've imported the collection, click on the
Start Run
button. -
It will run all the tests and show the results.
If you have any issues or need any help, please create an issue and I'll try to help you as soon as possible.