Skip to content

NafeesMn/coding-exercise

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Coding Exercise: Spring Boot REST API

A Java application built using the Spring Boot framework. It serves as a REST API that interacts with the JSONPlaceholder API, retrieving and processing data about posts.

The application fetches a list of posts from the JSONPlaceholder API, analyzes them, and provides various functionalities, including displaying all posts, finding the post with the longest title, and modifying the JSON response format to include the length of each post's title.

Additionally, the application is equipped with unit tests to ensure the reliability and correctness of its features. Overall, the Coding Exercise demonstrates the implementation of a Spring Boot REST API for data retrieval and manipulation.

Prerequisite

Java JDK (version 17 or higher) Maven (version 3.2.4 or higher)

Build Instructions

  1. Clone the repository

  2. Navigate to the project directory

  3. Build and Run the project using:

    ./mvnw spring-boot:run
    

    Alternatively you can use

    ./mvnw clean package
    

**After the server has started, you may access the following endpoints: **

  1. To get all posts:
    http://localhost:8080/posts
    
  2. To get the post with the longest title:
    http://localhost:8080/longestTitle
    
  3. To get all post with a new field titleLength:
    http://localhost:8080/postsTitleLength
    

Output Screenshots

  1. Display all posts

displayAllPosts

  1. Display the post with the longest title

findLongestTitle

  1. Display all post with a new field titleLength

displayAllTitleLength

  1. Unit test result for the API Controller

testApiControllerTest

  1. Unit test result for the main class testMainClass

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages