GithubHelp home page GithubHelp logo

waes's Introduction

WAES Assessment Application

Candidate: Daniel Chiuratto Seabra

Running the Application

The application is implemented using the Java 8, but it works for more recent versions of Java without any issues, and also you are going to need to have Maven installed as well, since that the project has been built as a Maven project to manage the dependencies and help with the building process.

Maven Download Link: https://maven.apache.org/download.cgi

Java Download Link: https://www.oracle.com/technetwork/pt/java/javase/downloads/index.html

So, to run the application:

  • Clone the application using git clone with the address:
git clone https://github.com/daniel-chiuratto-seabra/waes.git
  • Once cloned, access the project root folder and to execute the application you can choose two approaches: using the package goal from Maven to run the tests, pack it as a JAR and run it through the Java command or using the Spring Boot plugin which executes the application directly without executing the tests:

Without tests:

mvn spring-boot:run

With tests:

mvn package

And then execute:

java -jar target/assessment-0.0.1-SNAPSHOT.jar

Application Context Name

The application does not contain a defined context name, so to reach it through Rest requests, running it locally, you can do like the example below with the id 10:

POST: http://localhost:8080/v1/diff/10/left
POST: http://localhost:8080/v1/diff/10/right
GET: http://localhost:8080/v1/diff/10

Testing the Application

According to the requirement, the application should accept Base64 encoded binary data, for the testing you can check it through the Spring Boot Test, executing it through the JUnit Test class AssessmentApplicationTests class executing it through the IDE of your preference or executing it via command line with the mvn test command through the root folder of the project which will start the application and doing the requests where you can follow-up through logging and results on the tests itself, or through a Rest client like Postman for instance, together with any utilitary that helps to translate a String into Base64 encoded String.

Using an external client you can do POST and GET calls through the endpoints defined on the requirement, sending raw data with Base64 encoded data as String. To have this encoded data you can use online solutions like the website https://www.base64encode.org, or if you are on Mac, you can use the terminal entering the following command:

echo "{\"field\":\"this is a sample\"}" | base64

And copy the result of this process to the body of the Rest client to be sent to the application and then processed by it.

Application Structure

The application is divided in:

  • Controller class
  • Service class
  • Utility class
  • Exception Handler class

The Controller class (AssessmentApplicationController) is the interface with the outside world and has the function to receive the payload from the outside, sending it to the Service.

The Service class (AssessmentApplicationService and MessageService) is where the business logic are, also consuming other Services and the Utilitary classes to do the work, returning the result to the Controller.

The Utility class (JsonUtil) is focused in giving support for certain functionalities in the application that is complex enough to justify to have it in another class.

The Exception Handler class is where all exceptions thrown during the application goes if they happen, because they are handled to have a more standarized way to be returned to requestor with a friendly message.

Integration Tests

You can run the integration tests on the Spring Boot Test JUnit test through the AssessmentApplicationTests class.

Unit Tests

You are going to see that the application is not 100% covered by JUnit tests, but this is because I avoided to do dummy tests in classes that does not have enough logic to be tested such DTO classes and Builders.

Improvements

Caching

It was implemented a Map which caches the result of the process (when we do a GET) in a manner that when we repeat such call without setting anything to the same id (doing a POST to the same id with some value), instead of the application re-run all the processes, it gets the result that was cached on a prior execution. This approach optimizes the performance.

Diff Result

To attend the scenario of having two payloads with the same id, having the same size but different values, it was implemented an utilitary class (JsonUtil) which finds the difference between the two payloads returning with a certain amount of detail what fields and their values to allow the requestor to know exactly what is the difference between them, despite their equality in size.

waes's People

Watchers

Daniel Chiuratto Seabra 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.