A fictional client has an existing Micro Service to fetch order and product information. This simple code contains a Search REST API
to display a list of potential matches.
The following areas were addressed: Configuration, Architecture, Logic, Exception Handling, Logs, Spring, Persistence, REST, Tests, Documentation, and JAVA.
I've been using spring-boot to make the server up, runnable and ready to receive HTTP requests. The server is started on port 8088.
Besides the Micro Service to fetch order and product information, I've also added a new generic Search REST API
to retrieve all relevant information matching the following criteria:
- This search criteria is applied on the
status
column of theorders
table. - The value of the
status
should beSHIPPED
.
- This search criteria is applied on the
discount
column of theorders
table.
eg:
{
"orderNumber": "RTL_1003",
"discount": 19.99,
"taxPercent": 8.5,
"total": 139.97,
"totalTax": 11.89,
"grandTotal": 131.87,
"status": "SHIPPED",
"products": [
{
"upc": "1358743283",
"sku": "7394650110003",
"description": "Polo Shirt",
"price": 19.99
},
{
"upc": "1458843283",
"sku": "7394750120000",
"description": "Floral Swing Skirt",
"price": 69.99
},
{
"upc": "1258793283",
"sku": "7394950140000",
"description": "True Skinny Jeans",
"price": 49.99
}
]
}
- This search criteria is applied on the
price
column of theproducts
table.
- I've added unit tests for all the existing classes in the workspace.
- I've added Spring Integration Tests for all the
API endpoints
.
-
List Orders: [GET]
http://localhost:8088/orders
-
Fetch Order Details: [GET]
http://localhost:8088/orders/{order_id}
-
List Products: [GET]
http://localhost:8088/products
-
Fetch Product Details: [GET]
http://localhost:8088/products/{product_id}
- To test, you should have Java 8, Maven and Git installed.
- The sample data has been pre-loaded so that the new
Search API
can be tested. Please refer todata-h2.sql
.
- Java 8.x
- Maven 3.x
- Spring Framework 4.x
- Spring Boot 1.5.6
- Hibernate
- JPA
- H2 database
- JUnit 4.x
- Mockito 2.x
- Hamcrest
- Spring Integration Tests