Commit a1ce17fd authored by Mahesh Gutam's avatar Mahesh Gutam

[MT-44] Mahesh: Search by Name/email id/Emp Id in Employee Details

screen for HR HR Manager DIrector roles.
parent 48a6da9f
...@@ -161,4 +161,19 @@ public class UserController { ...@@ -161,4 +161,19 @@ public class UserController {
.collect(Collectors.toList()); .collect(Collectors.toList());
return new ResponseEntity<>(technologies, HttpStatus.OK); return new ResponseEntity<>(technologies, HttpStatus.OK);
} }
@RequestMapping(value = "/getEmployeeRoleDataForSearchCriteria", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<EmployeeRoles> getEmployeeRoleDataForSearchCriteria(
@RequestParam("searchId") String searchId, @RequestParam("searchAttribute") String searchAttribute) throws MyTimeException {
EmployeeRoles employeesRole = userService.getEmployeeRoleDataForSearchCriteria(searchId, searchAttribute);
return new ResponseEntity<>(employeesRole, HttpStatus.OK);
}
@RequestMapping(value = "/getEmployeeDetailsForAutocomplete", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<String>> getEmployeeDetailsForAutocomplete() throws MyTimeException {
List<String> details = userService.getEmployeeDetailsForAutocomplete();
return new ResponseEntity<>(details, HttpStatus.OK);
}
} }
\ No newline at end of file
...@@ -10,4 +10,5 @@ public interface EmployeeRolesRepo extends MongoRepository<EmployeeRoles, String ...@@ -10,4 +10,5 @@ public interface EmployeeRolesRepo extends MongoRepository<EmployeeRoles, String
EmployeeRoles findByEmployeeId(String employeeId); EmployeeRoles findByEmployeeId(String employeeId);
EmployeeRoles findByEmployeeName(String employeeName);
} }
...@@ -47,4 +47,8 @@ public interface UserService { ...@@ -47,4 +47,8 @@ public interface UserService {
public List<Account> getAccounts() throws MyTimeException; public List<Account> getAccounts() throws MyTimeException;
List<Location> getLocations() throws MyTimeException; List<Location> getLocations() throws MyTimeException;
EmployeeRoles getEmployeeRoleDataForSearchCriteria(String searchId, String searchAttribute);
List<String> getEmployeeDetailsForAutocomplete();
} }
package com.nisum.mytime.service; package com.nisum.mytime.service;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.FindAndModifyOptions; import org.springframework.data.mongodb.core.FindAndModifyOptions;
...@@ -27,6 +29,7 @@ import com.nisum.mytime.repository.LocationRepo; ...@@ -27,6 +29,7 @@ import com.nisum.mytime.repository.LocationRepo;
import com.nisum.mytime.repository.ProjectTeamMatesRepo; import com.nisum.mytime.repository.ProjectTeamMatesRepo;
import com.nisum.mytime.repository.ShiftRepo; import com.nisum.mytime.repository.ShiftRepo;
import com.nisum.mytime.repository.TechnologyRepo; import com.nisum.mytime.repository.TechnologyRepo;
import com.nisum.mytime.utils.MyTimeUtils;
import com.nisum.mytime.utils.PdfReportGenerator; import com.nisum.mytime.utils.PdfReportGenerator;
@Service("userService") @Service("userService")
...@@ -221,4 +224,37 @@ public class UserServiceImpl implements UserService { ...@@ -221,4 +224,37 @@ public class UserServiceImpl implements UserService {
return employeeRolesDB; return employeeRolesDB;
} }
/* (non-Javadoc)
* @see com.nisum.mytime.service.UserService#getEmployeeRoleDataForSearchCriteria(java.lang.String, java.lang.String)
*/
@Override
public EmployeeRoles getEmployeeRoleDataForSearchCriteria(String searchId, String searchAttribute) {
if(MyTimeUtils.EMPLOYEE_NAME.equals(searchAttribute)){
return employeeRolesRepo.findByEmployeeName(searchId);
}else if(MyTimeUtils.EMAIL_ID.equals(searchAttribute)){
return employeeRolesRepo.findByEmailId(searchId);
}
return null;
}
/* (non-Javadoc)
* @see com.nisum.mytime.service.UserService#getEmployeeDetailsForAutocomplete()
*/
@Override
public List<String> getEmployeeDetailsForAutocomplete() {
List<EmployeeRoles> roles = employeeRolesRepo.findAll();
List<String> details = new ArrayList<>();
roles.stream().sorted(java.util.Comparator.comparing(EmployeeRoles::getEmployeeId)).collect(Collectors.toList()).forEach(role -> {
details.add(role.getEmployeeId());
});
roles.stream().sorted(java.util.Comparator.comparing(EmployeeRoles::getEmployeeName)).collect(Collectors.toList()).forEach(role -> {
details.add(role.getEmployeeName());
});
roles.stream().sorted(java.util.Comparator.comparing(EmployeeRoles::getEmailId)).collect(Collectors.toList()).forEach(role -> {
details.add(role.getEmailId());
});
return details;
}
} }
...@@ -36,5 +36,6 @@ public class MyTimeUtils { ...@@ -36,5 +36,6 @@ public class MyTimeUtils {
public final static String ABESENT_QUERY = "SELECT * FROM EMPLOYEES WHERE EMPLOYEECODE NOT IN("; public final static String ABESENT_QUERY = "SELECT * FROM EMPLOYEES WHERE EMPLOYEECODE NOT IN(";
public final static String ABESENT_QUERY1 = ") AND STATUS='Working' AND EMPLOYEECODE NOT LIKE 'del%' "; public final static String ABESENT_QUERY1 = ") AND STATUS='Working' AND EMPLOYEECODE NOT LIKE 'del%' ";
public final static String ABESENT ="Absent"; public final static String ABESENT ="Absent";
public final static String EMAIL_ID = "emailId";
} }
...@@ -255,7 +255,7 @@ myApp.controller("loginController",function($scope, myFactory, $compile, $window ...@@ -255,7 +255,7 @@ myApp.controller("loginController",function($scope, myFactory, $compile, $window
myFactory.setEmpRole(role); myFactory.setEmpRole(role);
if(role == "HR"){ if(role == "HR"){
menuItems.push({"menu" : "My Details","icon" : "fa fa-indent fa-2x","path" : "templates/employee.html"}); menuItems.push({"menu" : "My Details","icon" : "fa fa-indent fa-2x","path" : "templates/employee.html"});
menuItems.push({"menu" : "Employee Details","icon" : "fa fa-users fa-2x","path" : "templates/employees.html"}); menuItems.push({"menu" : "Employee Login Details","icon" : "fa fa-users fa-2x","path" : "templates/employees.html"});
menuItems.push({"menu" : "Reports","icon" : "fa fa-pie-chart fa-2x","path" : "templates/reports.html"}); menuItems.push({"menu" : "Reports","icon" : "fa fa-pie-chart fa-2x","path" : "templates/reports.html"});
menuItems.push({"menu" : "Manage Employees","icon" : "fa fa-user-plus fa-2x","path" : "templates/roles.html"}); menuItems.push({"menu" : "Manage Employees","icon" : "fa fa-user-plus fa-2x","path" : "templates/roles.html"});
menuItems.push({"menu" : "Manage Projects","icon" : "fa fa-tasks fa-2x","path" : "templates/projects.html"}); menuItems.push({"menu" : "Manage Projects","icon" : "fa fa-tasks fa-2x","path" : "templates/projects.html"});
...@@ -280,7 +280,7 @@ myApp.controller("loginController",function($scope, myFactory, $compile, $window ...@@ -280,7 +280,7 @@ myApp.controller("loginController",function($scope, myFactory, $compile, $window
menuItems.push({"menu" : "My Profile","icon" : "fa fa-address-card-o fa-2x","path" : "templates/profile.html"}); menuItems.push({"menu" : "My Profile","icon" : "fa fa-address-card-o fa-2x","path" : "templates/profile.html"});
}else if(role == "HR Manager"){ }else if(role == "HR Manager"){
menuItems.push({"menu" : "My Details","icon" : "fa fa-indent fa-2x","path" : "templates/employee.html"}); menuItems.push({"menu" : "My Details","icon" : "fa fa-indent fa-2x","path" : "templates/employee.html"});
menuItems.push({"menu" : "Employee Details","icon" : "fa fa-users fa-2x","path" : "templates/employees.html"}); menuItems.push({"menu" : "Employee Login Details","icon" : "fa fa-users fa-2x","path" : "templates/employees.html"});
menuItems.push({"menu" : "Reports","icon" : "fa fa-pie-chart fa-2x","path" : "templates/reports.html"}); menuItems.push({"menu" : "Reports","icon" : "fa fa-pie-chart fa-2x","path" : "templates/reports.html"});
menuItems.push({"menu" : "Manage Employees","icon" : "fa fa-user-plus fa-2x","path" : "templates/roles.html"}); menuItems.push({"menu" : "Manage Employees","icon" : "fa fa-user-plus fa-2x","path" : "templates/roles.html"});
menuItems.push({"menu" : "Manage Team","icon" : "fa fa-sitemap fa-2x","path" : "templates/projectDetails.html"}); menuItems.push({"menu" : "Manage Team","icon" : "fa fa-sitemap fa-2x","path" : "templates/projectDetails.html"});
...@@ -299,7 +299,7 @@ myApp.controller("loginController",function($scope, myFactory, $compile, $window ...@@ -299,7 +299,7 @@ myApp.controller("loginController",function($scope, myFactory, $compile, $window
menuItems.push({"menu" : "My Profile","icon" : "fa fa-address-card-o fa-2x","path" : "templates/profile.html"}); menuItems.push({"menu" : "My Profile","icon" : "fa fa-address-card-o fa-2x","path" : "templates/profile.html"});
}else if(role == "Delivery Manager" || role == "Director"){ }else if(role == "Delivery Manager" || role == "Director"){
menuItems.push({"menu" : "My Details","icon" : "fa fa-indent fa-2x","path" : "templates/employee.html"}); menuItems.push({"menu" : "My Details","icon" : "fa fa-indent fa-2x","path" : "templates/employee.html"});
menuItems.push({"menu" : "Employee Details","icon" : "fa fa-users fa-2x","path" : "templates/employees.html"}); menuItems.push({"menu" : "Employee Login Details","icon" : "fa fa-users fa-2x","path" : "templates/employees.html"});
menuItems.push({"menu" : "Reports","icon" : "fa fa-pie-chart fa-2x","path" : "templates/reports.html"}); menuItems.push({"menu" : "Reports","icon" : "fa fa-pie-chart fa-2x","path" : "templates/reports.html"});
menuItems.push({"menu" : "Manage Employees","icon" : "fa fa-user-plus fa-2x","path" : "templates/roles.html"}); menuItems.push({"menu" : "Manage Employees","icon" : "fa fa-user-plus fa-2x","path" : "templates/roles.html"});
menuItems.push({"menu" : "Manage Team","icon" : "fa fa-sitemap fa-2x","path" : "templates/projectDetails.html"}); menuItems.push({"menu" : "Manage Team","icon" : "fa fa-sitemap fa-2x","path" : "templates/projectDetails.html"});
......
...@@ -7,7 +7,8 @@ myApp.controller("employeesController", function($scope, $http, myFactory, $mdDi ...@@ -7,7 +7,8 @@ myApp.controller("employeesController", function($scope, $http, myFactory, $mdDi
$scope.avgLoginHrs = ""; $scope.avgLoginHrs = "";
$scope.isVisible = false; $scope.isVisible = false;
$scope.searchId=""; $scope.searchId="";
$scope.hidethis = false;
// Date picker related code // Date picker related code
var today = new Date(); var today = new Date();
var priorDt = today; var priorDt = today;
...@@ -43,47 +44,124 @@ myApp.controller("employeesController", function($scope, $http, myFactory, $mdDi ...@@ -43,47 +44,124 @@ myApp.controller("employeesController", function($scope, $http, myFactory, $mdDi
$scope.gridOptions.data = []; $scope.gridOptions.data = [];
$scope.isVisible = false; $scope.isVisible = false;
$scope.setPageDefaults(); $scope.setPageDefaults();
$scope.hidethis = true;
}; };
$scope.employeeDetails = [];
$scope.getEmployeeDetailsForAutocomplete = function(){
$http({
method : "GET",
url : appConfig.appUri + "user/getEmployeeDetailsForAutocomplete"
}).then(function mySuccess(response) {
if(response.data != "" && response.data.length !=0){
$scope.employeeDetails = response.data;
}else{
$scope.employeeDetails = [];
}
}, function myError(response) {
$scope.employeeDetails = [];
});
};
$scope.autoComplete = function(searchId){
var output = [];
$scope.filterEmployees = [];
if(searchId.length > 0){
$scope.hidethis = false;
}else{
$scope.hidethis = true;
}
angular.forEach($scope.employeeDetails, function(searchString){
if(searchString.toLowerCase().indexOf(searchId.toLowerCase()) >=0){
output.push(searchString);
}
});
$scope.filterEmployees = output;
}
$scope.fillTextbox = function(searchString){
$scope.searchId = searchString;
$scope.hidethis = true;
}
var validation = {
isEmailAddress:function(str) {
var pattern =/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
return pattern.test(str); // returns a boolean
},
isNotEmpty:function (str) {
var pattern =/\S+/;
return pattern.test(str); // returns a boolean
},
isNumber:function(str) {
var pattern = /^\d+$/;
return pattern.test(str); // returns a boolean
}
};
$scope.getEmployeeData = function(type){ $scope.getEmployeeData = function(type){
$scope.hidethis = true;
var searchId = $scope.searchId; var searchId = $scope.searchId;
var fromDate = getFormattedDate($scope.fromDate); var fromDate = getFormattedDate($scope.fromDate);
var toDate = getFormattedDate($scope.toDate); var toDate = getFormattedDate($scope.toDate);
if(type == "blur"){ if (type == "click") {
if(searchId != "" && isNaN(searchId)){ if (!validation.isNotEmpty(searchId)) {
showAlert('Please enter only digits');
setFieldsEmpty();
}else if(searchId != "" && ((searchId.length >0 && searchId.length <5) || searchId.length>5)){
showAlert('Employee ID should be 5 digits');
setFieldsEmpty();
}else if(searchId != "" && !checkEmpIdRange(searchId)){
showAlert('Employee ID should be in between '+appConfig.empStartId+' - '+appConfig.empEndId);
setFieldsEmpty();
}else{
if(searchId == "") getData(0, fromDate, toDate, 'onblur');
else getData(searchId, fromDate, toDate, 'onblur');
}
}else if(type == "click"){
if(searchId == ""){
getData(0, fromDate, toDate, 'onclick'); getData(0, fromDate, toDate, 'onclick');
}else if(searchId != "" && isNaN(searchId)){ } else if (validation.isNotEmpty(searchId)
showAlert('Please enter only digits'); && validation.isNumber(searchId)
&& checkEmpIdRange(searchId)) {
getData(searchId, fromDate, toDate, 'onclick');
} else if (validation.isNotEmpty(searchId)
&& validation.isNumber(searchId)
&& !checkEmpIdRange(searchId)) {
showAlert('Please enter a valid Employee ID');
setFieldsEmpty(); setFieldsEmpty();
}else if(searchId != "" && !checkEmpIdRange(searchId)){ } else if (validation.isNotEmpty(searchId)
showAlert('Employee ID should be in between '+appConfig.empStartId+' - '+appConfig.empEndId); && !validation.isEmailAddress(searchId)
&& (searchId.indexOf('@') > -1 || searchId
.indexOf('.') > -1)) {
showAlert('Please enter a valid Email ID');
setFieldsEmpty(); setFieldsEmpty();
}else if(searchId != ""&& (searchId.length < 5 || searchId.length > 5)){ }else if (validation.isNotEmpty(searchId)
showAlert('Employee ID should be 5 digits'); && validation.isEmailAddress(searchId)
&& searchId.indexOf("@nisum.com", searchId.length - "@nisum.com".length) == -1) {
showAlert('Please enter a valid Nisum Email-Id');
setFieldsEmpty(); setFieldsEmpty();
}else{ } else if (validation.isNotEmpty(searchId)
getData(searchId, fromDate, toDate, 'onclick'); && validation.isEmailAddress(searchId)
&& !validation.isNumber(searchId)) {
getEmployeeIdFromRoles(searchId, 'emailId', fromDate, toDate, 'onclick');
} else if (validation.isNotEmpty(searchId)
&& !validation.isEmailAddress(searchId)
&& !validation.isNumber(searchId)) {
getEmployeeIdFromRoles(searchId, 'employeeName', fromDate, toDate, 'onclick');
} }
} }
} }
function checkEmpIdRange(searchId){ function checkEmpIdRange(searchId){
return parseInt(searchId) >= appConfig.empStartId && parseInt(searchId) <= appConfig.empEndId; if(searchId.length < 5 || searchId.length > 5)
return false;
else
return parseInt(searchId) >= appConfig.empStartId && parseInt(searchId) <= appConfig.empEndId;
}
function getEmployeeIdFromRoles(searchId, searchAttribute, fromDate, toDate, type){
$http({
method : "GET",
url : appConfig.appUri + "user/getEmployeeRoleDataForSearchCriteria?searchId=" + searchId + "&searchAttribute=" + searchAttribute
}).then(function mySuccess(response) {
if(response.data != "" && response.data.length !=0){
getData(response.data.employeeId, fromDate, toDate, type);
}else{
showAlert('Please enter a valid Employee ID/Name/Email ID');
setFieldsEmpty();
}
}, function myError(response) {
showAlert("Something went wrong while fetching data!!!");
$scope.gridOptions.data = [];
});
} }
function getData(empId, fromDate, toDate, type){ function getData(empId, fromDate, toDate, type){
......
...@@ -100,3 +100,16 @@ md-dialog{ ...@@ -100,3 +100,16 @@ md-dialog{
box-shadow: 0 6px 6px rgba(0,0,0,0.175); box-shadow: 0 6px 6px rgba(0,0,0,0.175);
background-clip: padding-box; background-clip: padding-box;
} }
.autoComplete-dropdown{
font: inherit;
border-color: #ececec;
border-width: 1px;
width: 206px;
cursor: pointer;
position: absolute;
z-index: 9999;
top: 35px;
overflow-y: auto;
max-height: 206px;
}
<div class="md-padding" style="width: 100%; padding: 3px 0px 0px 0px;" <div class="md-padding" style="width: 100%; padding: 3px 0px 0px 0px;"
id="popupContainer" ng-controller="employeesController" id="popupContainer" ng-controller="employeesController"
ng-init="setPageDefaults()"> ng-init="setPageDefaults();getEmployeeDetailsForAutocomplete();">
<div class="container-fluid mainDivHeaderClass"> <div class="container-fluid mainDivHeaderClass">
<div class="row"> <div class="row">
<div class="col-lg-12"> <div class="col-lg-12">
...@@ -20,11 +19,14 @@ ...@@ -20,11 +19,14 @@
<br /> <br />
<div class="form-horizontal"> <div class="form-horizontal">
<div class="form-group"> <div class="form-group">
<div class="form-inline col-lg-12" style="margin-left:3%;"> <div class="form-inline col-lg-12" style="margin-left: 3%;">
<div class="form-group col-lg-2 col-md-4 col-sm-6 col-xs-12"> <div class="form-group col-lg-2 col-md-4 col-sm-6 col-xs-12"
style="width: 23%;">
<input type="text" ng-model="searchId" id="searchId" <input type="text" ng-model="searchId" id="searchId"
placeholder="Employee ID" class="form-control" min-length="5" placeholder="Employee ID/Name/Email ID" class="form-control" min-length="5" ng-keyup="autoComplete(searchId);" ng-blur="hideUlComponent()"/>
ng-blur="getEmployeeData('blur');" /> <ul class="list-group autoComplete-dropdown" ng-model="hidethis" ng-hide="hidethis">
<li class="list-group-item" ng-repeat="employeeData in filterEmployees" ng-click="fillTextbox(employeeData);">{{employeeData}}</li>
</ul>
</div> </div>
<div class="form-group col-lg-1"></div> <div class="form-group col-lg-1"></div>
<div class="form-group col-lg-4"> <div class="form-group col-lg-4">
...@@ -41,7 +43,7 @@ ...@@ -41,7 +43,7 @@
onkeydown="return false" onkeydown="return false"
ng-change="validateDates(toDate, 'ToDate')"></md-datepicker></label> ng-change="validateDates(toDate, 'ToDate')"></md-datepicker></label>
</div> </div>
<div class="form-group col-lg-1" > <div class="form-group col-lg-1">
<label class="" for="submitBtn"><md-button <label class="" for="submitBtn"><md-button
class="md-raised md-primary" class="md-raised md-primary"
style="width:100px;background: cadetblue;" style="width:100px;background: cadetblue;"
...@@ -53,7 +55,8 @@ ...@@ -53,7 +55,8 @@
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="form-inline col-lg-12" ng-show="isVisible" style="margin-left:3%;"> <div class="form-inline col-lg-12" ng-show="isVisible"
style="margin-left: 3%;">
<label class="control-label" for="avgHrs"> Average Login <label class="control-label" for="avgHrs"> Average Login
hours:&nbsp;&nbsp; </label>{{avgLoginHrs}} hours:&nbsp;&nbsp; </label>{{avgLoginHrs}}
</div> </div>
...@@ -61,9 +64,9 @@ ...@@ -61,9 +64,9 @@
<div class="form-group"> <div class="form-group">
<div class="form-inline col-lg-12"> <div class="form-inline col-lg-12">
<div id="gridTest" ui-grid="gridOptions" ui-grid-pagination <div id="gridTest" ui-grid="gridOptions" ui-grid-pagination
class="grid" style="width: 99%; height: 362px;margin-left:5px;"> class="grid" style="width: 99%; height: 362px; margin-left: 5px;">
<div class="watermark" ng-show="!gridOptions.data.length">Search <div class="watermark" ng-show="!gridOptions.data.length">Search
by Employee ID</div> by Employee ID/Name/Email ID</div>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -56,7 +56,7 @@ public class ProjectControllerTest { ...@@ -56,7 +56,7 @@ public class ProjectControllerTest {
@Test @Test
public void testgetEmployeeRole() throws Exception{ public void testgetEmployeeRole() throws Exception{
EmployeeRoles employeesRole = new EmployeeRoles("5976ef15874c902c98b8a05d",null,null,"user@nisum.com",null, null,null,null,null,null,null,null, new Date(2017-11-12),new Date(2017-12-12)); EmployeeRoles employeesRole = new EmployeeRoles("5976ef15874c902c98b8a05d",null,null,"user@nisum.com",null, null,null,null,null,null,null,null,null, new Date(2017-11-12),new Date(2017-12-12));
when(userService.getEmployeesRole("user@nisum.com")).thenReturn(employeesRole); when(userService.getEmployeesRole("user@nisum.com")).thenReturn(employeesRole);
mockMvc.perform(get("/project/employee").param("emailId", "user@nisum.com")).andExpect(MockMvcResultMatchers.status().isOk()); mockMvc.perform(get("/project/employee").param("emailId", "user@nisum.com")).andExpect(MockMvcResultMatchers.status().isOk());
verify(userService).getEmployeesRole("user@nisum.com"); verify(userService).getEmployeesRole("user@nisum.com");
...@@ -108,7 +108,7 @@ public class ProjectControllerTest { ...@@ -108,7 +108,7 @@ public class ProjectControllerTest {
@Test @Test
public void testgetEmployeeRoleData() throws Exception{ public void testgetEmployeeRoleData() throws Exception{
EmployeeRoles employeesRole = new EmployeeRoles("5976ef15874c902c98b8a05d","16127",null,null,null,null, null,null,null,null,null,null,new Date(2017-11-18),new Date(2017-12-18)); EmployeeRoles employeesRole = new EmployeeRoles("5976ef15874c902c98b8a05d","16127",null,null,null,null, null,null,null,null,null,null,null, new Date(2017-11-18),new Date(2017-12-18));
when(userService.getEmployeesRoleData("16127")).thenReturn(employeesRole); when(userService.getEmployeesRoleData("16127")).thenReturn(employeesRole);
mockMvc.perform(get("/project/getEmployeeRoleData").param("empId", "16127").contentType(MediaType.APPLICATION_JSON_VALUE)).andExpect(MockMvcResultMatchers.status().isOk()); mockMvc.perform(get("/project/getEmployeeRoleData").param("empId", "16127").contentType(MediaType.APPLICATION_JSON_VALUE)).andExpect(MockMvcResultMatchers.status().isOk());
verify(userService).getEmployeesRoleData("16127"); verify(userService).getEmployeesRoleData("16127");
......
...@@ -50,7 +50,7 @@ public class ProjectTeamControllerTest { ...@@ -50,7 +50,7 @@ public class ProjectTeamControllerTest {
@Test @Test
public void testgetEmployeeRole() throws Exception { public void testgetEmployeeRole() throws Exception {
EmployeeRoles employeesRole = new EmployeeRoles("5976ef15874c902c98b8a05d", null, null, null, null, null, null, EmployeeRoles employeesRole = new EmployeeRoles("5976ef15874c902c98b8a05d", null, null, null, null, null, null,
null, null, "user@nisum.com", null, null, new Date(2017 - 11 - 20), new Date(2107 - 12 - 23)); null, null, "user@nisum.com", null, null,null, new Date(2017 - 11 - 20), new Date(2107 - 12 - 23));
when(userService.getEmployeesRole("user@nisum.com")).thenReturn(employeesRole); when(userService.getEmployeesRole("user@nisum.com")).thenReturn(employeesRole);
mockMvc.perform(get("/projectTeam/employee").param("emailId", "user@nisum.com")) mockMvc.perform(get("/projectTeam/employee").param("emailId", "user@nisum.com"))
.andExpect(MockMvcResultMatchers.status().isOk()); .andExpect(MockMvcResultMatchers.status().isOk());
...@@ -76,7 +76,7 @@ public class ProjectTeamControllerTest { ...@@ -76,7 +76,7 @@ public class ProjectTeamControllerTest {
public void testupdateEmployeeRole() throws Exception { public void testupdateEmployeeRole() throws Exception {
EmployeeRoles employeesRoles2 = new EmployeeRoles("1976ef15874c902c98b8a05d", "16111", "Vinay Singh", EmployeeRoles employeesRoles2 = new EmployeeRoles("1976ef15874c902c98b8a05d", "16111", "Vinay Singh",
"vsingh@nisum.com", "Manager", null, "09:00-06:00", "Java/J2EE", "Testing", "8755672341", "8800543678", "vsingh@nisum.com", "Manager", null, "09:00-06:00", "Java/J2EE", "Testing", "8755672341", "8800543678",
"vsingh@gmail.com", new Date(2017 - 11 - 29), new Date(2017 - 12 - 20)); "vsingh@gmail.com", null, new Date(2017 - 11 - 29), new Date(2017 - 12 - 20));
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
String jsonString = mapper.writeValueAsString(employeesRoles2); String jsonString = mapper.writeValueAsString(employeesRoles2);
when(userService.updateEmployeeRole(any())).thenReturn(employeesRoles2); when(userService.updateEmployeeRole(any())).thenReturn(employeesRoles2);
...@@ -95,7 +95,7 @@ public class ProjectTeamControllerTest { ...@@ -95,7 +95,7 @@ public class ProjectTeamControllerTest {
@Test @Test
public void testgetEmployeeRoleData() throws Exception { public void testgetEmployeeRoleData() throws Exception {
EmployeeRoles employeesRole = new EmployeeRoles("5976ef15874c902c98b8a05d", "16127", null, null, null, null, EmployeeRoles employeesRole = new EmployeeRoles("5976ef15874c902c98b8a05d", "16127", null, null, null, null,
null, null, null, null, null, null, new Date(2017 - 11 - 20), new Date(2107 - 12 - 23)); null, null, null, null, null, null, null, new Date(2017 - 11 - 20), new Date(2107 - 12 - 23));
when(userService.getEmployeesRoleData("16127")).thenReturn(employeesRole); when(userService.getEmployeesRoleData("16127")).thenReturn(employeesRole);
mockMvc.perform(get("/projectTeam/getEmployeeRoleData").param("empId", "16127") mockMvc.perform(get("/projectTeam/getEmployeeRoleData").param("empId", "16127")
.contentType(MediaType.APPLICATION_JSON_VALUE)).andExpect(MockMvcResultMatchers.status().isOk()); .contentType(MediaType.APPLICATION_JSON_VALUE)).andExpect(MockMvcResultMatchers.status().isOk());
......
...@@ -50,7 +50,7 @@ public class UserControllerTest { ...@@ -50,7 +50,7 @@ public class UserControllerTest {
@Test @Test
public void testgetEmployeeRole() throws Exception { public void testgetEmployeeRole() throws Exception {
EmployeeRoles employeesRole = new EmployeeRoles("5976ef15874c902c98b8a05d", null, null, EmployeeRoles employeesRole = new EmployeeRoles("5976ef15874c902c98b8a05d", null, null,
"user@nisum.com", null,null,null,null,null,null,null, null,new Date(2017-11-20),new Date(2017-12-23)); "user@nisum.com", null,null,null,null,null,null,null, null, null,new Date(2017-11-20),new Date(2017-12-23));
when(userService.getEmployeesRole("user@nisum.com")).thenReturn(employeesRole); when(userService.getEmployeesRole("user@nisum.com")).thenReturn(employeesRole);
mockMvc.perform(get("/user/employee").param("emailId", "user@nisum.com")) mockMvc.perform(get("/user/employee").param("emailId", "user@nisum.com"))
.andExpect(MockMvcResultMatchers.status().isOk()); .andExpect(MockMvcResultMatchers.status().isOk());
...@@ -61,7 +61,7 @@ public class UserControllerTest { ...@@ -61,7 +61,7 @@ public class UserControllerTest {
@Test @Test
public void testassigingEmployeeRole() throws Exception { public void testassigingEmployeeRole() throws Exception {
EmployeeRoles employeeRole = new EmployeeRoles("5976ef15874c902c98b8a05c", "16135", "Monika", EmployeeRoles employeeRole = new EmployeeRoles("5976ef15874c902c98b8a05c", "16135", "Monika",
"user1@nisum.com", "HR","Human Resource Lead", "06:00-09:00","Java/J2EE","Spring","8767893452","5687234567","user1@gmail.com",new Date(2017-11-20),new Date(2017-12-23)); "user1@nisum.com", "HR","Human Resource Lead", "06:00-09:00","Java/J2EE","Spring","8767893452","5687234567","user1@gmail.com", null,new Date(2017-11-20),new Date(2017-12-23));
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
String jsonString = mapper.writeValueAsString(employeeRole); String jsonString = mapper.writeValueAsString(employeeRole);
when(userService.assigingEmployeeRole(anyObject())).thenReturn(employeeRole); when(userService.assigingEmployeeRole(anyObject())).thenReturn(employeeRole);
...@@ -74,7 +74,7 @@ public class UserControllerTest { ...@@ -74,7 +74,7 @@ public class UserControllerTest {
@Test @Test
public void testupdateEmployeeRole() throws Exception { public void testupdateEmployeeRole() throws Exception {
EmployeeRoles employeeRole2 = new EmployeeRoles("5976ef15874c902c98b8a05d", "67890", "Sonika", EmployeeRoles employeeRole2 = new EmployeeRoles("5976ef15874c902c98b8a05d", "67890", "Sonika",
"user2@nisum.com", "Manager","Senior Software Engineer", "09:00am-06:00am","php","Hibernate","9878678956","9989782210","user2@gmail.com",new Date(2017-11-20),new Date(2017-12-23)); "user2@nisum.com", "Manager","Senior Software Engineer", "09:00am-06:00am","php","Hibernate","9878678956","9989782210","user2@gmail.com", null,new Date(2017-11-20),new Date(2017-12-23));
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
String jsonString = mapper.writeValueAsString(employeeRole2); String jsonString = mapper.writeValueAsString(employeeRole2);
when(userService.updateEmployeeRole(anyObject())).thenReturn(employeeRole2); when(userService.updateEmployeeRole(anyObject())).thenReturn(employeeRole2);
...@@ -103,13 +103,51 @@ public class UserControllerTest { ...@@ -103,13 +103,51 @@ public class UserControllerTest {
@Test @Test
public void testgetEmployeeRoleData() throws Exception { public void testgetEmployeeRoleData() throws Exception {
EmployeeRoles employeesRole = new EmployeeRoles("5976ef15874c902c98b8a05d", "16127",null, null, null, EmployeeRoles employeesRole = new EmployeeRoles("5976ef15874c902c98b8a05d", "16127",null, null, null,
null, null,null,null,null,null,null,new Date(2017-11-13),new Date(2017-12-20)); null, null,null,null,null,null,null, null,new Date(2017-11-13),new Date(2017-12-20));
when(userService.getEmployeesRoleData("16127")).thenReturn(employeesRole); when(userService.getEmployeesRoleData("16127")).thenReturn(employeesRole);
mockMvc.perform(get("/user/getEmployeeRoleData").param("empId", "16127").contentType(MediaType.APPLICATION_JSON_VALUE)) mockMvc.perform(get("/user/getEmployeeRoleData").param("empId", "16127").contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(MockMvcResultMatchers.status().isOk()).andExpect(jsonPath("$.employeeId", is("16127"))) .andExpect(MockMvcResultMatchers.status().isOk()).andExpect(jsonPath("$.employeeId", is("16127")))
.andDo(print()); .andDo(print());
verify(userService).getEmployeesRoleData("16127"); verify(userService).getEmployeesRoleData("16127");
} }
@Test
public void testgetEmployeeRoleDataForEmailIdSearch() throws Exception {
EmployeeRoles employeesRole = new EmployeeRoles("5976ef15874c902c98b8a05d", "16209", null, null, null, null,
null, null, null, null, null, null, null, new Date(2017 - 11 - 13), new Date(2017 - 12 - 20));
when(userService.getEmployeeRoleDataForSearchCriteria("dummy@nisum.com", "emailId")).thenReturn(employeesRole);
mockMvc.perform(get("/user/getEmployeeRoleDataForSearchCriteria").param("searchId", "dummy@nisum.com")
.param("searchAttribute", "emailId").contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(MockMvcResultMatchers.status().isOk()).andExpect(jsonPath("$.employeeId", is("16209")))
.andDo(print());
verify(userService).getEmployeeRoleDataForSearchCriteria("dummy@nisum.com", "emailId");
}
@Test
public void testgetEmployeeRoleDataForEmployeeNameSearch() throws Exception {
EmployeeRoles employeesRole = new EmployeeRoles("5976ef15874c902c98b8a05d", "16209", null, null, null, null,
null, null, null, null, null, null, null, new Date(2017 - 11 - 13), new Date(2017 - 12 - 20));
when(userService.getEmployeeRoleDataForSearchCriteria("Mahesh Kumar Gutam", "employeeName")).thenReturn(employeesRole);
mockMvc.perform(get("/user/getEmployeeRoleDataForSearchCriteria").param("searchId", "Mahesh Kumar Gutam")
.param("searchAttribute", "employeeName").contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(MockMvcResultMatchers.status().isOk()).andExpect(jsonPath("$.employeeId", is("16209")))
.andDo(print());
verify(userService).getEmployeeRoleDataForSearchCriteria("Mahesh Kumar Gutam", "employeeName");
}
@Test
public void testGetEmployeeDetailsForAutocomplete() throws Exception {
List<String> details = new ArrayList<>();
details.add("16294");details.add("Ashwin Kumar"); details.add("kashwin@nisum.com");
details.add("16209");details.add("Mahesh Kumar Gutam");details.add("mgutam@nisum.com");
details.add("16143");details.add("Ajay");details.add("ajayS@nisum.com");
details.add("16207");details.add("Sumith Kumar Lambu");details.add("slambu@nisum.com");
details.add("16111");details.add("Mahesh Mudrakolu");details.add("mmahesh@nisum.com");
when(userService.getEmployeeDetailsForAutocomplete()).thenReturn(details);
mockMvc.perform(get("/user/getEmployeeDetailsForAutocomplete").contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(MockMvcResultMatchers.status().isOk()).andDo(print());
verify(userService).getEmployeeDetailsForAutocomplete();
}
@Test @Test
public void testgetManagers() throws Exception { public void testgetManagers() throws Exception {
...@@ -147,7 +185,7 @@ public class UserControllerTest { ...@@ -147,7 +185,7 @@ public class UserControllerTest {
@Test @Test
public void testupdateProfile() throws Exception{ public void testupdateProfile() throws Exception{
EmployeeRoles employeeRole = new EmployeeRoles("5996ef15874c902c98b8a05d", "16127", "Monika Srivastava", "msrivastava@nisum.com", "Employee", "Software Engineer", "09:00-06:00", "Java/J2EE", "Spring", "8765588388", "9978567723", "msrivastava@gmail.com", new Date(2017-01-01), new Date(2017-03-01)); EmployeeRoles employeeRole = new EmployeeRoles("5996ef15874c902c98b8a05d", "16127", "Monika Srivastava", "msrivastava@nisum.com", "Employee", "Software Engineer", "09:00-06:00", "Java/J2EE", "Spring", "8765588388", "9978567723", "msrivastava@gmail.com", null, new Date(2017-01-01), new Date(2017-03-01));
System.out.println(employeeRole); System.out.println(employeeRole);
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
String jsonString = mapper.writeValueAsString(employeeRole); String jsonString = mapper.writeValueAsString(employeeRole);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment