<file_sep>package com.neosoft.app.employeeportal1.main.exceptionhandling;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {

	@Autowired
	ExceptionResponse response;

	@ExceptionHandler(EmployeeNotFoundException.class)
	public ExceptionResponse customHandlerException(EmployeeNotFoundException exception) {
		System.out.println("Custom Exception Handle");
		response.setMessage(exception.getMessage());
		response.setStatusCode(HttpStatus.BAD_REQUEST.value());
		response.setDescription("Invalid Id User not exist For such id");
		response.setStringStatusCode(HttpStatus.BAD_REQUEST.toString());
		return response;
	}
}<file_sep>package com.neosoft.app.employeeportal1.main.exceptionhandling;

import org.springframework.stereotype.Component;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
@Component
public class ExceptionResponse {
 
	private String message ;
	private int statusCode;
	private String description;
	private String stringStatusCode;
}
<file_sep>package com.neosoft.app.employeeportal1.main.dto;

import lombok.Data;

@Data
public class Response {

	private String msg;
}
<file_sep>package com.neosoft.app.employeeportal1.main.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import com.neosoft.app.employeeportal1.main.entity.Employee;
@Repository
public interface IEmployeeRepository extends JpaRepository<Employee, Short>{

	Employee findByFirstName(String name);

	void save(short id);

}
<file_sep>#Mon Jul 19 17:51:13 IST 2021
org.eclipse.core.runtime=2
org.eclipse.platform=4.19.0.v20210303-1800
<file_sep>package com.neosoft.app.employeeportal1.main;

import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest
class Vehicleservice1ApplicationTests {

	@Test
	void contextLoads() {
	}

}
<file_sep>package com.neosoft.app.employeeportal1.main.utility;

import java.util.Comparator;

import com.neosoft.app.employeeportal1.main.entity.Employee;

public class SortByJoining implements Comparator<Employee>{

	@Override
	public int compare(Employee o1, Employee o2) {
		return o1.getDateOfJoining().compareTo(o2.getDateOfJoining());
	}

}
