NewsPortal is an Api that enables users to add and retrieve information concerning the employees, department and News relating to the entire organisation and departments.
To use the postgres database run the create.sql script in the src/create.sql
folder in the project directory
or run the following:
CREATE DATABASE news_portal;
\c news_portal
CREATE TABLE workers(
id serial PRIMARY KEY,
workername VARCHAR,
workerposition VARCHAR,
departmentid INTEGER
);
CREATE TABLE departments(
id serial PRIMARY KEY,
name VARCHAR,
description VARCHAR
);
CREATE TABLE news(
id serial PRIMARY KEY,
topic VARCHAR,
description VARCHAR,
departmentid INTEGER
);
Note the database name is news_portal
if using the postgres database
- Basic knowledge of On Git CLI
- Java 11
- Gradle as a built tool
- IntelliJ or any Java based IDE
- postgres SQL sever installed
- Postman desktop client installed
- Java 11
- Gradle
- Spark
- JUnit
- Postgres Sql
- Clone or download repository as an archive
- If archive unzip the archive to get project folder
- Open the application's root folder in an IDE that can execute builds in java using gradle e.g. IntelliJ or Eclipse.
- Navigate to the Main.java file and run the
main
class - Use the link below to access the labeled request collection in Postman web,fork the collection into your personal workspace.
- For testing use Postman desktop client to access the forked collection because their cloud client does not access
local ports like
localhost:4567
. - In postman replace where indicated
:id
the number with the id you want to use in the path variables - Make sure you recreate the database in your local psql by running the psql commands above.
- If you do not fork the already created postman collection make sure to enter and label yours correctly to avoid errors because of extra spaces or missing characters
- Entry
{
"name": "Payments",
"description": "Facilitates monetary services"
}
Response
{
"id": 1,
"name": "Payments",
"description": "Facilitates monetary services"
}
- Entry
{
"topic": "Employee Reduction",
"description": "Department has decided to reduce the number of it employess",
"departmentId": 1
}
- Response if department with id does not exist
{
"errorMessage": "No department with the id exists",
"status": 404
}
- Response if department exists
{
"id": 1,
"topic": "Employee Reduction",
"description": "Department has decided to reduce the number of it employess",
"departmentId": 1
}
- Response
[{
"id": 1,
"name": "Payments",
"description": "Facilitates monetary services"
}
]
- If department with id:3 doesn't exist
{
"errorMessage": "No department with the id: \"3\" exists",
"status": 404
}
- If department with id:1 exists
{
"id": 1,
"name": "Payments",
"description": "Facilitates monetary services"
}
- News retrieval error
{
"errorMessage": "No department with the id: \"3\" exists",
"status": 404
}
- Workers in a department retrieval error
{
"errorMessage": "No department with the id: \"3\" exists",
"status": 404
}
- But with no News assigned
{
"message": "Apologies, there are no available news for this department."
}
- With Worker assigned
[
{
"departmentId": 1,
"workerName": "Charles Muvaka",
"workerPosition" : "Payment Officer"
}
]
- Department with news assigned
[
{
"id": 1,
"departmentId": 1,
"topic": "Employees Reduction",
"description": "The department has decided to reduce its employees due to the ongoing pandemic"
}
]
NOTE: Not all individual response behaviors are covered by the samples but all response types are covered by the samples to provide a correct idea of what responses will look like endpoints are hit
To fix a bug or enhance an existing module, follow these steps:
- Fork the repo
- Create a new branch (
git checkout -b improve-feature
) - Make the appropriate changes in the files
- Add changes to reflect the changes made
- Commit your changes (
git commit -m 'Improve feature'
) - Push to the branch (
git push origin improve-feature
) - Create a Pull Request
If you come across any bug in the project kindly report using the link below
MIT License
Copyright (c) 2022 Charles Muvaka
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
EMAIL: muvakacharles@gmail.com