Key Information

Register
Submit
Status: ‌Cancelled client request

Challenge Overview



Childhood Dream

This is the EASY LEVEL Level Competition

As a new employee, he needs to complete the onboarding process which involves familiarizing himself with the list of trains & services being provided - Steve is required to quickly go through the list of available trains/ services and their details.

Your task in this challenge is to create an initial application using Java, Spring & PostgreSQL. You are given a starter application and in this task, you have to modify and extend that starter application to create the Restful API to help Steve manage the trains.

Solving this problem you learn:
  • How to configure Spring Data, JPA, Hibernate to work with PostgreSQL Database
  • How to define Data Models and Repository interfaces
  • Way to create Spring Rest Controller to process HTTP requests
  • Way to use Spring Data JPA to interact with PostgreSQL Database
  • Use sql to load initial database table and content
  • Create new endpoint to retrieve all trains data
Learning Resource: https://bezkoder.com/spring-boot-postgresql-example/


What do you need to do?

IMPORTANT:
  • Follow the exact base API endpoint, automated testers will check the exact same address: http://localhost:8080/api/trains
  • Match the exact code status & wording (lowercase) for the returned message.
  • Match the exact data model and type

Technology Stack
  • Java 8
  • Spring Boot 2 (with Spring Web MVC, Spring Data JPA)
  • PostgreSQL
  • Maven

Project Structure:
  • Train data model class corresponds to entity and table tutorials.
  • TrainRepository is an interface that extends JpaRepository for CRUD methods and custom finder methods. It will be autowired in TrainController.
  • TrainController is a RestController which has request mapping methods for RESTful requests.
  • Configuration for Spring Datasource, JPA & Hibernate in application.properties.
  • pom.xml contains dependencies for Spring Boot and PostgreSQL.

Data Model for Train
  • id: long
  • name: String
  • description: String
  • distance-between-stop: String
  • max-speed: String
  • sharing-tracks: Boolean
  • grade-crossing: Boolean
  • train-frequency: String
  • amenities: String

Task:

1. Fix data init on db/sql
  • Copy and move data of all 5 trains from this JSON to SQL format inside /db folder on sample submission: https://drive.google.com/file/d/1o9qernfxutJpc6x2TAY2ExF9YJLywmmr/view?usp=sharing

2. Create new endpoint to view all train
  • Method : GET
  • Url : /api/trains/
  • Response:
    • Success:
      • Need return 200 code and
      • Need load all with trains with all keys and values
    • Error:
      • When use other endpoint need return 405 code and
      • {message: "invalid endpoint"}
3. Create new endpoint to view train detail by id
  • Method : GET
  • Url : /api/trains/:id
  • Response:
    • Success:
      • Need return 200 code and
      • Return details of selected train details by id
    • Error:
      • When view train that id not exist
        • need return 404 code and
        • {message: “train not found”}

Sample Submission: https://drive.google.com/drive/folders/1h_PDXHKdd9TC-eshxydMjUyRUtcx-JQz?usp=sharing

Final Submission Guidelines

Topcoder Skill Builder | Java + Springboot + PostgreSQL Levels

Host Challenge & Submission Guideline | Challenge Link: http://www.topcoder.com/challenges/30168990
Easy | Challenge Link: http://www.topcoder.com/challenges/30168991
Medium | Challenge Link: http://www.topcoder.com/challenges/30168980
Hard |  Challenge Link: http://www.topcoder.com/challenges/30168986

ELIGIBLE EVENTS:

2021 Topcoder(R) Open

REVIEW STYLE:

Final Review:

Community Review Board

Approval:

User Sign-Off

SHARE:

ID: 30168991