Git Product home page Git Product logo

lf-code-challenge's Introduction

Labforward Code Challenge for Backend Engineer Candidate

This is a simple Hello World API for recruiting purposes. You, as a candidate, should work on the challenge on your own account. Please clone the repo to your account and create a PR with your solution.

Task

You need to add a new endpoint to the API to allow users to update the greetings they created.

Solution

I have listed all the changes and enhancements below. I spent 10-12 hours analyzing and implementing the solution.

API Changes

  • Added a new endpoint Patch /hello/{id} to patch the existing greeting in the system.
    • It will update the entity, only if it is present in the system.
    • If there is no entity in system for the provided Id, then system shall send a resource not found response.
  • Updated Post /hello - endpoint.
    • This endpoint was returning the newly created entity in response.
    • Updated code shall return the newly created entity as well as the location of entity in response header.
    • It is achieved by using EntityCreatedResponse.class, which has location field.

DI Change

  • Dependency injection strategy changed. Removed constructor injection of HelloService.class in HelloController.class and used setter injection instead.

API Documentation

  • Added Swagger dependency in project. It will enable the audience to visualize all the available API operations.
  • Added GlobalConfiguration.class - This is used for adding project configuration, included swagger configuration bean for API documentation.
    Documentation path: http://localhost:8080/swagger-ui.html#/

Test

  • Fixed returnsBadRequestWhenUnexpectedAttributeProvided() and createOKWhenRequiredGreetingProvided() test in HelloControllerTest.class.
  • Added integration test case for Patch /hello{id} endpoint.
  • Added unit test case for update greeting in HelloWorldServiceTest.class

Note

I found logger and datasource missing in the application. I assume it was avoided, for convenience sake.
Thank you for sending this coding challenge. I have tried my best to provide a feasible solution.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.