Spring Boot service that exposes the seeded contents of viewData.json through a single REST endpoint for my internship test.
- Java 25 (matching
pom.xml'sjava.version) - Maven 3.9+ (the project ships with
mvnwwrappers if Maven is not installed) - PostgreSQL 16 (or compatible) running locally on the default port
- Ensure PostgreSQL is running and reachable at
jdbc:postgresql://localhost:5432/viewdatawith userpostgresand passwordpostgres(as configured insrc/main/resources/application.properties).- Docker option (recommended for local dev):
Stop with
docker run --name pg \ -e POSTGRES_PASSWORD=postgres \ -e POSTGRES_DB=viewdata \ -p 5432:5432 -d postgres:16
docker stop pgand start again usingdocker start pg. - Native install: create the database manually if it does not exist:
createdb -U postgres viewdata
- Docker option (recommended for local dev):
- Adjust credentials/URL in
application.propertiesif your environment differs.
On startup the application seeds data into the database from
src/main/resources/viewData.json. Existing rows are preserved by theddl-auto=updatesetting, but you can drop the schema manually if you want a fresh load.
Use the Maven wrapper (recommended so the correct Maven version is used):
./mvnw spring-boot:runThe app starts on http://localhost:8080.
To stop the server, press Ctrl + C in the terminal.
- GET
/api/view-data- Returns the entire dataset with two arrays:
data(transactions) andstatus(reference data). - Example response (truncated):
{ "data": [ { "id": 1372, "productID": "10001", "productName": "Test 1", "amount": "1000", "customerName": "abc", "status": 0, "transactionDate": "2022-07-10 11:14:52", "createBy": "abc", "createOn": "2022-07-10 11:14:52" } ], "status": [ { "id": 0, "name": "SUCCESS" }, { "id": 1, "name": "FAILED" } ] }
- Returns the entire dataset with two arrays:
curl -s http://localhost:8080/api/view-data | jq- Remove the pipe to
jqif it is not installed. - Add
-vto see request/response headers.
- Start the application so it is listening on
http://localhost:8080. - Open Postman and create a new GET request tab.
- Set the request URL to
http://localhost:8080/api/view-data. - Click Send. The JSON response should appear in the
Bodytab. - (Optional) Save the request to a collection for future use.
./mvnw testThe answer are inside of the folder LogicalTestAnswer