Giter VIP home page Giter VIP logo

api-restful-java's Introduction

API-RESTFUL-JAVA

Microservice that use H2 as database to run, JWT as security with email/password for tokens, and all responses in JSON format. It was built between Saturday and Sunday.

Contents

  1. Used versions
  2. What's included
  3. DataModeler images, first models.
  4. How to run and what to expect
  5. Inside the code
  6. Thanks

Used Versions

I must clarify that Spring boot 3.0.0-SNAPSHOT is broken in gradle and not working properly at the time I wrote this project. JDK 17 has compabilities issues with Hibernate, JPA and H2 Database that made me desist and run back to JDK 1.8

  • H2 as Database
  • Gradle to build it
  • Hibernate
  • Spring Framework/Boot 2.6.6
  • Tomcat Embedded
  • Java 8 (Amazon)
  • Github
  • JUnit5
  • io.jsonwebtoken 0.9.1

What's included

In the main path of the project, you are going to find the Postman Collection which contains all the entries and endpoints that are used by this microservice. You can also find the script.sql (it was exported from the H2 database). There's also a PDF with the exercise. That's all the extra files from the project. Other files are from the project itselfs to run and work properly.


DataModeler images, first models.

My first step in this exercise was to do the logical and relational model of the database, but I missunderstand the instructions and figured out later that was not required. Anyway I uploaded the images just to get a better visual of how I saw it: image image


How to run and what to expect

First, download the project. Unzip it to your desired location and then using your gradle tool, run it. After it, you can check the database at:

I recommend to use Postman Desktop (you wont be able to connect over cloud version) to use the Postman collection. Once you are inside Postman and you imported the collection called Ernst & Young Exercise.postman_collection.json then if you try to run any endpoint except token, you will get a forbidden error. Please refer to token endpoint, and use the email & password from the database you already got in the previous step. After using the credentials, you should be able to use token endpoint to get a new object which contains the JWT(Token). Please use it in each endpoint, or just go to your Collection and add it to your Authorization tab.

Now you will be able to use the rest of endpoints.

The available endpoints are:

  • GetAllUsers
  • GetUsersByEmail
  • postUser
  • Token(no auth needed)
  • Error(unuseful, it exist to handle errors)

Inside the code

I'm going to describe only the things that I failed to accomplish, or what I left between 50-99% done. Everything that is not mentioned here is already done over the code.

The code coverage of the full project is 60%. I'm afraid I couldn't handle the Security & Controller classes with JUnit. I tried. but at end I just added @Disabled annotation because it was impossible for me to add test classes on them.

The password regex accepts 1 Uppercase, Lowercases and 2 numbers, in that exactly order. From my point of view this was the right path. but I'm clarifying that maybe I was wrong.

Once again, I have not done any UML or diagram with the solution(except the initial data modeler).


Thanks

I want to thank EY for the opportunity to develop the exercise. At first it seemed easy to me, then I realized that my knowledge was rusty, but thanks to you I was able to refresh several knowledge, and learn some others that I did not know.

Thank you!

api-restful-java's People

Contributors

jomipeca avatar

Stargazers

Hernan Riquelme avatar

Watchers

 avatar

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.