## Summary

Below are the List of Features available in Code

1. Reading payload from JSON File and using it as mocked Response
2. Object creation from JSON File
---

## Things Newly Implemented

1. JSON Payload files are found in src/test/resources/json-data
2. In the Code Converstion to Employee Object after reading Employee JSON and Stringify of JSON Object are both done  
3. MockMvc Testing is implemented for Controllers	
	- For AddEmployee Endpoint - Request from JSON file, Response from mocked response  
	- For GetEmployee Endpoint - Request by URL, Response from mocked Employee object constructed from JSON File
	- For GetAllEmployees Endpoint - Request by URL, Response from method returning Employee Object
	- For DeleteEmployee Endpoint - Request by URL, Response from mocked method	 	  
---

## Changes in pom.xml 
```xml
<build>
    <testResources>
        <testResource>
            <directory>${project.basedir}/src/test/resources</directory>
        </testResource>			
    </testResources>
    .
    .
    .
</build>
```
---

# API endpoints
## GET
`Get All Employees Detail` [/empmgmt/employees](#getallemployee) <br/>
`Get Employee Details` [/empmgmt/employees/{empId}](#getemployeesempid) <br/>

## POST
`Add Employee Details` [/empmgmt/employees](#addemployee) <br/>

## DELETE
`Delete EmpDetails` [/empmgmt/employees/{empId}](#deleteemployee) <br/>
___

<a name="getemployeesempid"></a>
### GET /empmgmt/employees/{empId}
Get Employee Detail

**Parameters**

|          Name | Required |  Type   | Description                                                                                                                                                           |
| -------------:|:--------:|:-------:| --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|     `empId` | required | string  | Employee Id

**Response**

```
// Employee Details added Succesfully
[
    {
        "empID": 1,
        "empName": "Mugil",
        "empAge": "36"
    }
]
```
___

<a name="getallemployee"></a>
### GET /empmgmt/employees

**Response**
```
// Employee Details added Succesfully
[
    {
        "empID": 1,
        "empName": "Mugil",
        "empAge": "36"
    }
]
```
___

<a name="addemployee"></a>
### POST /empmgmt/employees
Add Employee Details

**Parameters**

|          Name | Required |  Type   | Description                                                                                                                                                           |
| -------------:|:--------:|:-------:| --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|     `empName` | required | string  | Name of Employee
|     `empAge` | required | string  | Age of Employee

**Request**
```
// Employee Details 
{
    "empName" : "Mugil",
    "empAge" : "36"
}
```


**Response**

```
// Employee Details added Succesfully
[
    {
        "empID": 1,
        "empName": "Mugil",
        "empAge": "36"
    }
]
```
___

<a name="deleteemployee"></a>
### DELETE /empmgmt/employees/{empId}

**Parameters**

|          Name | Required |  Type   | Description                                                                                                                                                           |
| -------------:|:--------:|:-------:| --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|     `empId` | required | string  | Employee Id


**Response**

```
Employee Deleted Successfully
```
___



## Note

* While reading file from resources folder I continously got error telling the file doesnot exists. 
  The Same problem is faced while working in office project. After adding above lines in pom.xml it started 
  working. It kept working, even after removing above lines
* The URL returned in _Link in add employee wont have a port number. The test keeps failing if you copy and paste
  URL from postman and try to asset the _links in mockMVC

___    

Copy paste the code in URL to see in action : https://markdownlivepreview.com/

Readme file screen shot for above code

Comments are closed.