Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mytime
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Narendar Vakiti
mytime
Commits
c85ffaf2
Unverified
Commit
c85ffaf2
authored
May 11, 2018
by
rsayannagari-nisum-com
Committed by
GitHub
May 11, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4 from nisum-inc/MT-44
[MT-44] Mahesh: Search by Name/email id/Emp Id in Employee Details
parents
48a6da9f
a1ce17fd
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
240 additions
and
51 deletions
+240
-51
UserController.java
...main/java/com/nisum/mytime/controller/UserController.java
+15
-0
EmployeeRolesRepo.java
...n/java/com/nisum/mytime/repository/EmployeeRolesRepo.java
+1
-0
UserService.java
src/main/java/com/nisum/mytime/service/UserService.java
+4
-0
UserServiceImpl.java
src/main/java/com/nisum/mytime/service/UserServiceImpl.java
+36
-0
MyTimeUtils.java
src/main/java/com/nisum/mytime/utils/MyTimeUtils.java
+1
-0
LoginController.js
src/main/webapp/WEB-INF/controllers/LoginController.js
+3
-3
ReporteesController.js
src/main/webapp/WEB-INF/controllers/ReporteesController.js
+106
-28
default-styles.css
src/main/webapp/WEB-INF/css/default-styles.css
+13
-0
employees.html
src/main/webapp/WEB-INF/templates/employees.html
+13
-10
ProjectControllerTest.java
...om/nisum/mytime/controllertest/ProjectControllerTest.java
+2
-2
ProjectTeamControllerTest.java
...isum/mytime/controllertest/ProjectTeamControllerTest.java
+3
-3
UserControllerTest.java
...a/com/nisum/mytime/controllertest/UserControllerTest.java
+43
-5
No files found.
src/main/java/com/nisum/mytime/controller/UserController.java
View file @
c85ffaf2
...
...
@@ -161,4 +161,19 @@ public class UserController {
.
collect
(
Collectors
.
toList
());
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
src/main/java/com/nisum/mytime/repository/EmployeeRolesRepo.java
View file @
c85ffaf2
...
...
@@ -10,4 +10,5 @@ public interface EmployeeRolesRepo extends MongoRepository<EmployeeRoles, String
EmployeeRoles
findByEmployeeId
(
String
employeeId
);
EmployeeRoles
findByEmployeeName
(
String
employeeName
);
}
src/main/java/com/nisum/mytime/service/UserService.java
View file @
c85ffaf2
...
...
@@ -47,4 +47,8 @@ public interface UserService {
public
List
<
Account
>
getAccounts
()
throws
MyTimeException
;
List
<
Location
>
getLocations
()
throws
MyTimeException
;
EmployeeRoles
getEmployeeRoleDataForSearchCriteria
(
String
searchId
,
String
searchAttribute
);
List
<
String
>
getEmployeeDetailsForAutocomplete
();
}
src/main/java/com/nisum/mytime/service/UserServiceImpl.java
View file @
c85ffaf2
package
com
.
nisum
.
mytime
.
service
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.mongodb.core.FindAndModifyOptions
;
...
...
@@ -27,6 +29,7 @@ import com.nisum.mytime.repository.LocationRepo;
import
com.nisum.mytime.repository.ProjectTeamMatesRepo
;
import
com.nisum.mytime.repository.ShiftRepo
;
import
com.nisum.mytime.repository.TechnologyRepo
;
import
com.nisum.mytime.utils.MyTimeUtils
;
import
com.nisum.mytime.utils.PdfReportGenerator
;
@Service
(
"userService"
)
...
...
@@ -221,4 +224,37 @@ public class UserServiceImpl implements UserService {
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
;
}
}
src/main/java/com/nisum/mytime/utils/MyTimeUtils.java
View file @
c85ffaf2
...
...
@@ -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_QUERY1
=
") AND STATUS='Working' AND EMPLOYEECODE NOT LIKE 'del%' "
;
public
final
static
String
ABESENT
=
"Absent"
;
public
final
static
String
EMAIL_ID
=
"emailId"
;
}
src/main/webapp/WEB-INF/controllers/LoginController.js
View file @
c85ffaf2
...
...
@@ -255,7 +255,7 @@ myApp.controller("loginController",function($scope, myFactory, $compile, $window
myFactory
.
setEmpRole
(
role
);
if
(
role
==
"HR"
){
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"
:
"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"
});
...
...
@@ -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"
});
}
else
if
(
role
==
"HR Manager"
){
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"
:
"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"
});
...
...
@@ -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"
});
}
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"
:
"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"
:
"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"
});
...
...
src/main/webapp/WEB-INF/controllers/ReporteesController.js
View file @
c85ffaf2
...
...
@@ -7,7 +7,8 @@ myApp.controller("employeesController", function($scope, $http, myFactory, $mdDi
$scope
.
avgLoginHrs
=
""
;
$scope
.
isVisible
=
false
;
$scope
.
searchId
=
""
;
$scope
.
hidethis
=
false
;
// Date picker related code
var
today
=
new
Date
();
var
priorDt
=
today
;
...
...
@@ -43,47 +44,124 @@ myApp.controller("employeesController", function($scope, $http, myFactory, $mdDi
$scope
.
gridOptions
.
data
=
[];
$scope
.
isVisible
=
false
;
$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
.
hidethis
=
true
;
var
searchId
=
$scope
.
searchId
;
var
fromDate
=
getFormattedDate
(
$scope
.
fromDate
);
var
toDate
=
getFormattedDate
(
$scope
.
toDate
);
if
(
type
==
"blur"
){
if
(
searchId
!=
""
&&
isNaN
(
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
==
""
){
var
toDate
=
getFormattedDate
(
$scope
.
toDate
);
if
(
type
==
"click"
)
{
if
(
!
validation
.
isNotEmpty
(
searchId
))
{
getData
(
0
,
fromDate
,
toDate
,
'onclick'
);
}
else
if
(
searchId
!=
""
&&
isNaN
(
searchId
)){
showAlert
(
'Please enter only digits'
);
}
else
if
(
validation
.
isNotEmpty
(
searchId
)
&&
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
();
}
else
if
(
searchId
!=
""
&&
!
checkEmpIdRange
(
searchId
)){
showAlert
(
'Employee ID should be in between '
+
appConfig
.
empStartId
+
' - '
+
appConfig
.
empEndId
);
}
else
if
(
validation
.
isNotEmpty
(
searchId
)
&&
!
validation
.
isEmailAddress
(
searchId
)
&&
(
searchId
.
indexOf
(
'@'
)
>
-
1
||
searchId
.
indexOf
(
'.'
)
>
-
1
))
{
showAlert
(
'Please enter a valid Email ID'
);
setFieldsEmpty
();
}
else
if
(
searchId
!=
""
&&
(
searchId
.
length
<
5
||
searchId
.
length
>
5
)){
showAlert
(
'Employee ID should be 5 digits'
);
}
else
if
(
validation
.
isNotEmpty
(
searchId
)
&&
validation
.
isEmailAddress
(
searchId
)
&&
searchId
.
indexOf
(
"@nisum.com"
,
searchId
.
length
-
"@nisum.com"
.
length
)
==
-
1
)
{
showAlert
(
'Please enter a valid Nisum Email-Id'
);
setFieldsEmpty
();
}
else
{
getData
(
searchId
,
fromDate
,
toDate
,
'onclick'
);
}
else
if
(
validation
.
isNotEmpty
(
searchId
)
&&
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
){
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
){
...
...
src/main/webapp/WEB-INF/css/default-styles.css
View file @
c85ffaf2
...
...
@@ -100,3 +100,16 @@ md-dialog{
box-shadow
:
0
6px
6px
rgba
(
0
,
0
,
0
,
0.175
);
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
;
}
src/main/webapp/WEB-INF/templates/employees.html
View file @
c85ffaf2
<div
class=
"md-padding"
style=
"width: 100%; padding: 3px 0px 0px 0px;"
id=
"popupContainer"
ng-controller=
"employeesController"
ng-init=
"setPageDefaults()"
>
ng-init=
"setPageDefaults()
;getEmployeeDetailsForAutocomplete();
"
>
<div
class=
"container-fluid mainDivHeaderClass"
>
<div
class=
"row"
>
<div
class=
"col-lg-12"
>
...
...
@@ -20,11 +19,14 @@
<br
/>
<div
class=
"form-horizontal"
>
<div
class=
"form-group"
>
<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-inline col-lg-12"
style=
"margin-left: 3%;"
>
<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"
placeholder=
"Employee ID"
class=
"form-control"
min-length=
"5"
ng-blur=
"getEmployeeData('blur');"
/>
placeholder=
"Employee ID/Name/Email ID"
class=
"form-control"
min-length=
"5"
ng-keyup=
"autoComplete(searchId);"
ng-blur=
"hideUlComponent()"
/>
<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
class=
"form-group col-lg-1"
></div>
<div
class=
"form-group col-lg-4"
>
...
...
@@ -41,7 +43,7 @@
onkeydown=
"return false"
ng-change=
"validateDates(toDate, 'ToDate')"
></md-datepicker></label>
</div>
<div
class=
"form-group col-lg-1"
>
<div
class=
"form-group col-lg-1"
>
<label
class=
""
for=
"submitBtn"
><md-button
class=
"md-raised md-primary"
style=
"width:100px;background: cadetblue;"
...
...
@@ -53,7 +55,8 @@
</div>
</div>
<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
hours:
</label>
{{avgLoginHrs}}
</div>
...
...
@@ -61,9 +64,9 @@
<div
class=
"form-group"
>
<div
class=
"form-inline col-lg-12"
>
<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
by Employee ID
</div>
by Employee ID
/Name/Email ID
</div>
</div>
</div>
</div>
...
...
src/test/java/com/nisum/mytime/controllertest/ProjectControllerTest.java
View file @
c85ffaf2
...
...
@@ -56,7 +56,7 @@ public class ProjectControllerTest {
@Test
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
);
mockMvc
.
perform
(
get
(
"/project/employee"
).
param
(
"emailId"
,
"user@nisum.com"
)).
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
verify
(
userService
).
getEmployeesRole
(
"user@nisum.com"
);
...
...
@@ -108,7 +108,7 @@ public class ProjectControllerTest {
@Test
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
,
n
ull
,
n
ew
Date
(
2017
-
11
-
18
),
new
Date
(
2017
-
12
-
18
));
when
(
userService
.
getEmployeesRoleData
(
"16127"
)).
thenReturn
(
employeesRole
);
mockMvc
.
perform
(
get
(
"/project/getEmployeeRoleData"
).
param
(
"empId"
,
"16127"
).
contentType
(
MediaType
.
APPLICATION_JSON_VALUE
)).
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
verify
(
userService
).
getEmployeesRoleData
(
"16127"
);
...
...
src/test/java/com/nisum/mytime/controllertest/ProjectTeamControllerTest.java
View file @
c85ffaf2
...
...
@@ -50,7 +50,7 @@ public class ProjectTeamControllerTest {
@Test
public
void
testgetEmployeeRole
()
throws
Exception
{
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
);
mockMvc
.
perform
(
get
(
"/projectTeam/employee"
).
param
(
"emailId"
,
"user@nisum.com"
))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
...
...
@@ -76,7 +76,7 @@ public class ProjectTeamControllerTest {
public
void
testupdateEmployeeRole
()
throws
Exception
{
EmployeeRoles
employeesRoles2
=
new
EmployeeRoles
(
"1976ef15874c902c98b8a05d"
,
"16111"
,
"Vinay Singh"
,
"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"
,
n
ull
,
n
ew
Date
(
2017
-
11
-
29
),
new
Date
(
2017
-
12
-
20
));
ObjectMapper
mapper
=
new
ObjectMapper
();
String
jsonString
=
mapper
.
writeValueAsString
(
employeesRoles2
);
when
(
userService
.
updateEmployeeRole
(
any
())).
thenReturn
(
employeesRoles2
);
...
...
@@ -95,7 +95,7 @@ public class ProjectTeamControllerTest {
@Test
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
-
20
),
new
Date
(
2107
-
12
-
23
));
null
,
null
,
null
,
null
,
null
,
null
,
n
ull
,
n
ew
Date
(
2017
-
11
-
20
),
new
Date
(
2107
-
12
-
23
));
when
(
userService
.
getEmployeesRoleData
(
"16127"
)).
thenReturn
(
employeesRole
);
mockMvc
.
perform
(
get
(
"/projectTeam/getEmployeeRoleData"
).
param
(
"empId"
,
"16127"
)
.
contentType
(
MediaType
.
APPLICATION_JSON_VALUE
)).
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
...
...
src/test/java/com/nisum/mytime/controllertest/UserControllerTest.java
View file @
c85ffaf2
...
...
@@ -50,7 +50,7 @@ public class UserControllerTest {
@Test
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
-
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
);
mockMvc
.
perform
(
get
(
"/user/employee"
).
param
(
"emailId"
,
"user@nisum.com"
))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
...
...
@@ -61,7 +61,7 @@ public class UserControllerTest {
@Test
public
void
testassigingEmployeeRole
()
throws
Exception
{
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
();
String
jsonString
=
mapper
.
writeValueAsString
(
employeeRole
);
when
(
userService
.
assigingEmployeeRole
(
anyObject
())).
thenReturn
(
employeeRole
);
...
...
@@ -74,7 +74,7 @@ public class UserControllerTest {
@Test
public
void
testupdateEmployeeRole
()
throws
Exception
{
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
();
String
jsonString
=
mapper
.
writeValueAsString
(
employeeRole2
);
when
(
userService
.
updateEmployeeRole
(
anyObject
())).
thenReturn
(
employeeRole2
);
...
...
@@ -103,13 +103,51 @@ public class UserControllerTest {
@Test
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
-
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
);
mockMvc
.
perform
(
get
(
"/user/getEmployeeRoleData"
).
param
(
"empId"
,
"16127"
).
contentType
(
MediaType
.
APPLICATION_JSON_VALUE
))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
()).
andExpect
(
jsonPath
(
"$.employeeId"
,
is
(
"16127"
)))
.
andDo
(
print
());
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
public
void
testgetManagers
()
throws
Exception
{
...
...
@@ -147,7 +185,7 @@ public class UserControllerTest {
@Test
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"
,
n
ull
,
n
ew
Date
(
2017
-
01
-
01
),
new
Date
(
2017
-
03
-
01
));
System
.
out
.
println
(
employeeRole
);
ObjectMapper
mapper
=
new
ObjectMapper
();
String
jsonString
=
mapper
.
writeValueAsString
(
employeeRole
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment