project: Intro to spring boot project - Part 1

Tags spring-boot data-structures annotations
Hard Prerequisites
IMPORTANT: Please review these prerequisites, they include important information that will help you with this content.
  • TOPICS: Intro to spring boot - Part 1

  • We covered a very large part of the Spring Boot framework at a high level on the reading material but I hope you went through the resource as well. This project will be very simple but focusing on all the building blocks. HAVE FUN!!

    Step 1 - Create a java application and import ‘org.springframework.boot:spring-boot-starter-web’ into your build.gradle file to convert it to a Web Spring Boot application

    Step 2 - Ensure that your Main class is configured correctly for a Spring Boot application.

    Step 3 - Create a Model called User

    class User {
        private long Id;
        private String name;
        private String surname;
    
        // add constructor, getter and setter
    }
    

    Step 4 Create an interface called FakeRepoInterface with the following methods

    insertUser(id, name, surname)
    
    findUserById(id)
    
    deleteUser(id)
    

    Step 5 - Create a class called FakeRepo and implement the FakeRepoInterface, in this class you will mimic an actual repository by provide implementation for the following methods

    Create an object array of type User
    
    insertUser(id, name, surname) // should store the name, surname and id in the 'User' Object Array, return the name added
    
    findUserById(id) // returns name and surname of the specified id from the 'User' Object Array, return the name
    
    deleteUser(id) // remove the object with id from the User Object Array, return deleted user name
    

    Step 6 - Create an Interface called (UserService) with the following methods

    addUser(name, surname)
    
    removeUser(Id)
    
    getUser(Id)
    

    Step 7 - Create a class called UserServiceImpl which implements the interface in [step 6] and must do the following

    DO NOT USE THE NEW KEYWORD when instantiating your fake repo

    addUser(name, surname) // should call insertUser(id, name, surname), from FakeRepo and print to console '[name] added', (generate/hardcode the id)
    
    removeUser(Id) // should call deleteUser(id) from FakeRepo and print to console '[name] removed'
    
    getUser(Id) // should call findUserById(id) from FakeRepo and print to console 'hello [name]'
    
    [name] - replaced with actual name return from the FakeRepo
    

    Step 8 - Write tests for

    • addUser(name, surname)
    • removeUser(Id)
    • getUser(Id)

    RAW CONTENT URL