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
65c9aaa9
Commit
65c9aaa9
authored
Sep 17, 2018
by
Vijay Akula
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added request format for domain controller. Refactored the code in
DomainController, DomainService, DomainRepo
parent
35c50907
Changes
25
Show whitespace changes
Inline
Side-by-side
Showing
25 changed files
with
1493 additions
and
1426 deletions
+1493
-1426
DomainController.java
...in/java/com/nisum/mytime/controller/DomainController.java
+43
-23
ProjectController.java
...n/java/com/nisum/mytime/controller/ProjectController.java
+5
-5
ProjectTeamController.java
...va/com/nisum/mytime/controller/ProjectTeamController.java
+15
-15
ReportsController.java
...n/java/com/nisum/mytime/controller/ReportsController.java
+6
-6
UserController.java
...main/java/com/nisum/mytime/controller/UserController.java
+27
-27
Domain.java
src/main/java/com/nisum/mytime/model/Domain.java
+42
-0
Employee.java
src/main/java/com/nisum/mytime/model/Employee.java
+130
-6
EmployeeRoles.java
src/main/java/com/nisum/mytime/model/EmployeeRoles.java
+0
-139
DomainRepo.java
src/main/java/com/nisum/mytime/repository/DomainRepo.java
+7
-5
EmployeeRolesRepo.java
...n/java/com/nisum/mytime/repository/EmployeeRolesRepo.java
+9
-9
AccountService.java
src/main/java/com/nisum/mytime/service/AccountService.java
+6
-6
DomainService.java
src/main/java/com/nisum/mytime/service/DomainService.java
+219
-12
DomainServiceImpl.java
...main/java/com/nisum/mytime/service/DomainServiceImpl.java
+0
-227
IDomainService.java
src/main/java/com/nisum/mytime/service/IDomainService.java
+33
-0
ProjectService.java
src/main/java/com/nisum/mytime/service/ProjectService.java
+4
-4
ProjectServiceImpl.java
...ain/java/com/nisum/mytime/service/ProjectServiceImpl.java
+23
-23
UserService.java
src/main/java/com/nisum/mytime/service/UserService.java
+14
-14
UserServiceImpl.java
src/main/java/com/nisum/mytime/service/UserServiceImpl.java
+44
-44
CommomUtil.java
src/main/java/com/nisum/mytime/utils/CommomUtil.java
+11
-0
login.html
src/main/webapp/WEB-INF/templates/login.html
+3
-2
DomainControllerTest.java
...com/nisum/mytime/controllertest/DomainControllerTest.java
+21
-19
EmployeeBillingControllerTest.java
.../mytime/controllertest/EmployeeBillingControllerTest.java
+137
-137
ProjectControllerTest.java
...om/nisum/mytime/controllertest/ProjectControllerTest.java
+191
-200
ProjectTeamControllerTest.java
...isum/mytime/controllertest/ProjectTeamControllerTest.java
+478
-478
UserControllerTest.java
...a/com/nisum/mytime/controllertest/UserControllerTest.java
+25
-25
No files found.
src/main/java/com/nisum/mytime/controller/DomainController.java
View file @
65c9aaa9
...
@@ -6,6 +6,8 @@ import java.util.List;
...
@@ -6,6 +6,8 @@ import java.util.List;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.MediaType
;
...
@@ -22,8 +24,8 @@ import org.springframework.web.bind.annotation.RestController;
...
@@ -22,8 +24,8 @@ import org.springframework.web.bind.annotation.RestController;
import
com.nisum.mytime.exception.handler.MyTimeException
;
import
com.nisum.mytime.exception.handler.MyTimeException
;
import
com.nisum.mytime.exception.handler.ResponseDetails
;
import
com.nisum.mytime.exception.handler.ResponseDetails
;
import
com.nisum.mytime.model.Domain
s
;
import
com.nisum.mytime.model.Domain
;
import
com.nisum.mytime.service.DomainService
;
import
com.nisum.mytime.service.
I
DomainService
;
import
com.nisum.mytime.utils.MyTimeUtils
;
import
com.nisum.mytime.utils.MyTimeUtils
;
...
@@ -35,48 +37,66 @@ import com.nisum.mytime.utils.MyTimeUtils;
...
@@ -35,48 +37,66 @@ import com.nisum.mytime.utils.MyTimeUtils;
public
class
DomainController
{
public
class
DomainController
{
@Autowired
@Autowired
private
DomainService
domainService
;
private
I
DomainService
domainService
;
@RequestMapping
(
value
=
"/domains"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
TEXT_PLAIN_VALUE
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
DomainController
.
class
);
public
ResponseEntity
<?>
addDomain
(
@RequestBody
Domains
domain
,
HttpServletRequest
request
)
throws
MyTimeException
{
String
response
=
null
;
@RequestMapping
(
value
=
"/domains"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
response
=
domainService
.
addDomains
(
domain
);
public
ResponseEntity
<?>
createDomain
(
@RequestBody
Domain
domain
,
HttpServletRequest
request
)
throws
MyTimeException
{
logger
.
info
(
"Domain Creation"
);
if
(!
domainService
.
isDomainExists
(
domain
))
{
Domain
domainPeristed
=
domainService
.
create
(
domain
);
ResponseDetails
createRespDetails
=
new
ResponseDetails
(
new
Date
(),
801
,
"Domain has been created"
,
ResponseDetails
createRespDetails
=
new
ResponseDetails
(
new
Date
(),
801
,
"Domain has been created"
,
"Domain Creation"
,
null
,
request
.
getContextPath
(),
"details"
,
domain
);
"Domain Creation"
,
null
,
""
,
"details"
,
domainPeristed
);
return
new
ResponseEntity
<
ResponseDetails
>(
createRespDetails
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<
ResponseDetails
>(
createRespDetails
,
HttpStatus
.
OK
);
}
logger
.
info
(
"A domain is already existed with the requested name"
+
domain
.
getDomainName
());
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
802
,
"Domain is already existed"
,
"Choose the different domain name"
,
null
,
request
.
getRequestURI
(),
"Domain details"
,
domain
);
return
new
ResponseEntity
<
ResponseDetails
>(
responseDetails
,
HttpStatus
.
OK
);
}
}
@RequestMapping
(
value
=
"/domains"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
@RequestMapping
(
value
=
"/domains"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
get
Account
s
(
HttpServletRequest
request
)
throws
MyTimeException
{
public
ResponseEntity
<?>
get
Domain
s
(
HttpServletRequest
request
)
throws
MyTimeException
{
ResponseDetails
getRespDetails
=
new
ResponseDetails
(
new
Date
(),
804
,
"Retrieved the domains successfully"
,
ResponseDetails
getRespDetails
=
new
ResponseDetails
(
new
Date
(),
804
,
"Retrieved the domains successfully"
,
"Domains list"
,
domainService
.
get
AllDomains
(),
request
.
getContextPath
(),
"details"
,
null
);
"Domains list"
,
domainService
.
get
DomainsList
(),
request
.
getRequestURI
(),
"details"
,
null
);
return
new
ResponseEntity
<
ResponseDetails
>(
getRespDetails
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<
ResponseDetails
>(
getRespDetails
,
HttpStatus
.
OK
);
}
}
@RequestMapping
(
value
=
"/domains"
,
method
=
RequestMethod
.
PUT
,
produces
=
MediaType
.
TEXT_PLAI
N_VALUE
)
@RequestMapping
(
value
=
"/domains"
,
method
=
RequestMethod
.
PUT
,
produces
=
MediaType
.
APPLICATION_JSO
N_VALUE
)
public
ResponseEntity
<?>
updateDomain
(
@RequestBody
Domain
s
domains
,
HttpServletRequest
request
)
public
ResponseEntity
<?>
updateDomain
(
@RequestBody
Domain
domain
,
HttpServletRequest
request
)
throws
MyTimeException
{
throws
MyTimeException
{
String
response
=
null
;
response
=
domainService
.
updateDomain
(
domains
);
boolean
isDomainExists
=
domainService
.
isDomainExists
(
domain
);
if
(
isDomainExists
==
true
)
{
Domain
domainPersisted
=
domainService
.
update
(
domain
);
ResponseDetails
updateRespDetails
=
new
ResponseDetails
(
new
Date
(),
802
,
"Domain has been updated"
,
ResponseDetails
updateRespDetails
=
new
ResponseDetails
(
new
Date
(),
802
,
"Domain has been updated"
,
"Domain Updation"
,
null
,
request
.
getContextPath
(),
"Updation Domain details"
,
domains
);
"Domain Updation"
,
null
,
request
.
getRequestURI
(),
"Updation Domain details"
,
domainPersisted
);
return
new
ResponseEntity
<
ResponseDetails
>(
updateRespDetails
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<
ResponseDetails
>(
updateRespDetails
,
HttpStatus
.
OK
);
}
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
803
,
"Domain is Not found"
,
"Choose the correct updating domain name"
,
null
,
request
.
getRequestURI
(),
"details"
,
domain
);
return
new
ResponseEntity
<
ResponseDetails
>(
responseDetails
,
HttpStatus
.
OK
);
}
}
@RequestMapping
(
value
=
"/domains
"
,
method
=
RequestMethod
.
DELETE
,
produces
=
MediaType
.
TEXT_PLAI
N_VALUE
)
@RequestMapping
(
value
=
"/domains
/{domainId}"
,
method
=
RequestMethod
.
DELETE
,
produces
=
MediaType
.
APPLICATION_JSO
N_VALUE
)
public
ResponseEntity
<?>
deleteDomain
(
@
RequestParam
String
domainId
,
HttpServletRequest
request
)
public
ResponseEntity
<?>
deleteDomain
(
@
PathVariable
String
domainId
,
HttpServletRequest
request
)
throws
MyTimeException
{
throws
MyTimeException
{
domainService
.
delete
Domain
(
domainId
);
domainService
.
delete
(
domainId
);
ResponseDetails
deleteRespDetails
=
new
ResponseDetails
(
new
Date
(),
804
,
"Domain has been deleted"
,
ResponseDetails
deleteRespDetails
=
new
ResponseDetails
(
new
Date
(),
804
,
"Domain has been deleted"
,
"Domain Deletion"
,
null
,
request
.
get
ContextPath
(),
"Deletion Domain details"
,
domainId
);
"Domain Deletion"
,
null
,
request
.
get
RequestURI
(),
"Deletion Domain details"
,
domainId
);
return
new
ResponseEntity
<
ResponseDetails
>(
deleteRespDetails
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<
ResponseDetails
>(
deleteRespDetails
,
HttpStatus
.
OK
);
...
...
src/main/java/com/nisum/mytime/controller/ProjectController.java
View file @
65c9aaa9
...
@@ -15,7 +15,7 @@ import org.springframework.web.bind.annotation.RestController;
...
@@ -15,7 +15,7 @@ import org.springframework.web.bind.annotation.RestController;
import
com.nisum.mytime.exception.handler.MyTimeException
;
import
com.nisum.mytime.exception.handler.MyTimeException
;
import
com.nisum.mytime.model.Account
;
import
com.nisum.mytime.model.Account
;
import
com.nisum.mytime.model.Employee
Roles
;
import
com.nisum.mytime.model.Employee
;
import
com.nisum.mytime.model.Project
;
import
com.nisum.mytime.model.Project
;
import
com.nisum.mytime.repository.AccountRepo
;
import
com.nisum.mytime.repository.AccountRepo
;
import
com.nisum.mytime.repository.ProjectRepo
;
import
com.nisum.mytime.repository.ProjectRepo
;
...
@@ -40,9 +40,9 @@ public class ProjectController {
...
@@ -40,9 +40,9 @@ public class ProjectController {
private
ProjectRepo
projectRepo
;
private
ProjectRepo
projectRepo
;
@RequestMapping
(
value
=
"/employee"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
@RequestMapping
(
value
=
"/employee"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
Employee
Roles
>
getEmployeeRole
(
@RequestParam
(
"emailId"
)
String
emailId
)
public
ResponseEntity
<
Employee
>
getEmployeeRole
(
@RequestParam
(
"emailId"
)
String
emailId
)
throws
MyTimeException
{
throws
MyTimeException
{
Employee
Roles
employeesRole
=
userService
.
getEmployeesRole
(
emailId
);
Employee
employeesRole
=
userService
.
getEmployeesRole
(
emailId
);
return
new
ResponseEntity
<>(
employeesRole
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
employeesRole
,
HttpStatus
.
OK
);
}
}
...
@@ -124,9 +124,9 @@ public class ProjectController {
...
@@ -124,9 +124,9 @@ public class ProjectController {
}
}
@RequestMapping
(
value
=
"/getEmployeeRoleData"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
@RequestMapping
(
value
=
"/getEmployeeRoleData"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
Employee
Roles
>
getEmployeeRoleData
(
@RequestParam
(
"empId"
)
String
empId
)
public
ResponseEntity
<
Employee
>
getEmployeeRoleData
(
@RequestParam
(
"empId"
)
String
empId
)
throws
MyTimeException
{
throws
MyTimeException
{
Employee
Roles
employeesRole
=
userService
.
getEmployeesRoleData
(
empId
);
Employee
employeesRole
=
userService
.
getEmployeesRoleData
(
empId
);
return
new
ResponseEntity
<>(
employeesRole
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
employeesRole
,
HttpStatus
.
OK
);
}
}
...
...
src/main/java/com/nisum/mytime/controller/ProjectTeamController.java
View file @
65c9aaa9
...
@@ -18,7 +18,7 @@ import org.springframework.web.bind.annotation.RestController;
...
@@ -18,7 +18,7 @@ import org.springframework.web.bind.annotation.RestController;
import
com.nisum.mytime.exception.handler.MyTimeException
;
import
com.nisum.mytime.exception.handler.MyTimeException
;
import
com.nisum.mytime.model.BillingDetails
;
import
com.nisum.mytime.model.BillingDetails
;
import
com.nisum.mytime.model.EmployeeDashboardVO
;
import
com.nisum.mytime.model.EmployeeDashboardVO
;
import
com.nisum.mytime.model.Employee
Roles
;
import
com.nisum.mytime.model.Employee
;
import
com.nisum.mytime.model.EmployeeVisa
;
import
com.nisum.mytime.model.EmployeeVisa
;
import
com.nisum.mytime.model.Project
;
import
com.nisum.mytime.model.Project
;
import
com.nisum.mytime.model.ProjectTeamMate
;
import
com.nisum.mytime.model.ProjectTeamMate
;
...
@@ -42,9 +42,9 @@ public class ProjectTeamController {
...
@@ -42,9 +42,9 @@ public class ProjectTeamController {
@RequestMapping
(
value
=
"/employee"
,
method
=
RequestMethod
.
GET
,
@RequestMapping
(
value
=
"/employee"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
Employee
Roles
>
getEmployeeRole
(
public
ResponseEntity
<
Employee
>
getEmployeeRole
(
@RequestParam
(
"emailId"
)
String
emailId
)
throws
MyTimeException
{
@RequestParam
(
"emailId"
)
String
emailId
)
throws
MyTimeException
{
Employee
Roles
employeesRole
=
userService
.
getEmployeesRole
(
emailId
);
Employee
employeesRole
=
userService
.
getEmployeesRole
(
emailId
);
return
new
ResponseEntity
<>(
employeesRole
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
employeesRole
,
HttpStatus
.
OK
);
}
}
...
@@ -60,9 +60,9 @@ public class ProjectTeamController {
...
@@ -60,9 +60,9 @@ public class ProjectTeamController {
@RequestMapping
(
value
=
"/updateEmployeeRole"
,
method
=
RequestMethod
.
POST
,
@RequestMapping
(
value
=
"/updateEmployeeRole"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
Employee
Roles
>
updateEmployeeRole
(
@RequestBody
EmployeeRoles
emp
,
public
ResponseEntity
<
Employee
>
updateEmployeeRole
(
@RequestBody
Employee
emp
,
@RequestParam
(
value
=
"empId"
)
String
loginEmpId
)
throws
MyTimeException
{
@RequestParam
(
value
=
"empId"
)
String
loginEmpId
)
throws
MyTimeException
{
Employee
Roles
employeeRole
=
userService
.
updateEmployeeRole
(
emp
,
loginEmpId
);
Employee
employeeRole
=
userService
.
updateEmployeeRole
(
emp
,
loginEmpId
);
return
new
ResponseEntity
<>(
employeeRole
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
employeeRole
,
HttpStatus
.
OK
);
}
}
...
@@ -76,9 +76,9 @@ public class ProjectTeamController {
...
@@ -76,9 +76,9 @@ public class ProjectTeamController {
@RequestMapping
(
value
=
"/getEmployeeRoleData"
,
method
=
RequestMethod
.
GET
,
@RequestMapping
(
value
=
"/getEmployeeRoleData"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
Employee
Roles
>
getEmployeeRoleData
(
public
ResponseEntity
<
Employee
>
getEmployeeRoleData
(
@RequestParam
(
"empId"
)
String
empId
)
throws
MyTimeException
{
@RequestParam
(
"empId"
)
String
empId
)
throws
MyTimeException
{
Employee
Roles
employeesRole
=
userService
.
getEmployeesRoleData
(
empId
);
Employee
employeesRole
=
userService
.
getEmployeesRoleData
(
empId
);
return
new
ResponseEntity
<>(
employeesRole
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
employeesRole
,
HttpStatus
.
OK
);
}
}
...
@@ -95,9 +95,9 @@ public class ProjectTeamController {
...
@@ -95,9 +95,9 @@ public class ProjectTeamController {
@RequestMapping
(
value
=
"/getEmployeesToTeam"
,
method
=
RequestMethod
.
GET
,
@RequestMapping
(
value
=
"/getEmployeesToTeam"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
Employee
Roles
>>
getManagers
()
public
ResponseEntity
<
List
<
Employee
>>
getManagers
()
throws
MyTimeException
{
throws
MyTimeException
{
List
<
Employee
Roles
>
employeesRoles
=
new
ArrayList
<>();
List
<
Employee
>
employeesRoles
=
new
ArrayList
<>();
if
(
userService
.
getEmployeeRoles
()
!=
null
)
{
if
(
userService
.
getEmployeeRoles
()
!=
null
)
{
employeesRoles
=
userService
.
getEmployeeRoles
().
stream
()
employeesRoles
=
userService
.
getEmployeeRoles
().
stream
()
.
sorted
((
o1
,
o2
)
->
o1
.
getEmployeeName
()
.
sorted
((
o1
,
o2
)
->
o1
.
getEmployeeName
()
...
@@ -171,9 +171,9 @@ public class ProjectTeamController {
...
@@ -171,9 +171,9 @@ public class ProjectTeamController {
@RequestMapping
(
value
=
"/getUnAssignedEmployees"
,
@RequestMapping
(
value
=
"/getUnAssignedEmployees"
,
method
=
RequestMethod
.
GET
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
Employee
Roles
>>
getUnAssignedEmployees
()
public
ResponseEntity
<
List
<
Employee
>>
getUnAssignedEmployees
()
throws
MyTimeException
{
throws
MyTimeException
{
List
<
Employee
Roles
>
employeesRoles
=
projectService
List
<
Employee
>
employeesRoles
=
projectService
.
getUnAssignedEmployees
();
.
getUnAssignedEmployees
();
return
new
ResponseEntity
<>(
employeesRoles
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
employeesRoles
,
HttpStatus
.
OK
);
}
}
...
@@ -288,9 +288,9 @@ public class ProjectTeamController {
...
@@ -288,9 +288,9 @@ public class ProjectTeamController {
@RequestMapping
(
value
=
"/getEmployeesHavingVisa"
,
@RequestMapping
(
value
=
"/getEmployeesHavingVisa"
,
method
=
RequestMethod
.
GET
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
Employee
Roles
>>
getEmployeesHavingVisa
(
public
ResponseEntity
<
List
<
Employee
>>
getEmployeesHavingVisa
(
@RequestParam
(
"visa"
)
String
passport
)
throws
MyTimeException
{
@RequestParam
(
"visa"
)
String
passport
)
throws
MyTimeException
{
List
<
Employee
Roles
>
employees
=
new
ArrayList
<>();
List
<
Employee
>
employees
=
new
ArrayList
<>();
if
(
passport
!=
null
&&
!
"passport"
.
equalsIgnoreCase
(
passport
))
{
if
(
passport
!=
null
&&
!
"passport"
.
equalsIgnoreCase
(
passport
))
{
List
<
EmployeeVisa
>
employeeVisas
=
employeeVisaRepo
List
<
EmployeeVisa
>
employeeVisas
=
employeeVisaRepo
.
findByVisaName
(
passport
);
.
findByVisaName
(
passport
);
...
@@ -301,8 +301,8 @@ public class ProjectTeamController {
...
@@ -301,8 +301,8 @@ public class ProjectTeamController {
.
collect
(
Collectors
.
toList
());
.
collect
(
Collectors
.
toList
());
}
}
if
(
employeeIds
!=
null
&&
!
employeeIds
.
isEmpty
())
{
if
(
employeeIds
!=
null
&&
!
employeeIds
.
isEmpty
())
{
List
<
Employee
Roles
>
emps
=
userService
.
getEmployeeRoles
();
List
<
Employee
>
emps
=
userService
.
getEmployeeRoles
();
for
(
Employee
Roles
emp
:
emps
)
{
for
(
Employee
emp
:
emps
)
{
if
(
employeeIds
.
contains
(
emp
.
getEmployeeId
()))
{
if
(
employeeIds
.
contains
(
emp
.
getEmployeeId
()))
{
employees
.
add
(
emp
);
employees
.
add
(
emp
);
}
}
...
...
src/main/java/com/nisum/mytime/controller/ReportsController.java
View file @
65c9aaa9
...
@@ -35,7 +35,7 @@ import com.nisum.mytime.exception.handler.MyTimeException;
...
@@ -35,7 +35,7 @@ import com.nisum.mytime.exception.handler.MyTimeException;
import
com.nisum.mytime.model.Account
;
import
com.nisum.mytime.model.Account
;
import
com.nisum.mytime.model.BillingDetails
;
import
com.nisum.mytime.model.BillingDetails
;
import
com.nisum.mytime.model.ColumnChartData
;
import
com.nisum.mytime.model.ColumnChartData
;
import
com.nisum.mytime.model.Employee
Roles
;
import
com.nisum.mytime.model.Employee
;
import
com.nisum.mytime.model.GroupByCount
;
import
com.nisum.mytime.model.GroupByCount
;
import
com.nisum.mytime.model.ProjectTeamMate
;
import
com.nisum.mytime.model.ProjectTeamMate
;
import
com.nisum.mytime.model.ReportSeriesRecord
;
import
com.nisum.mytime.model.ReportSeriesRecord
;
...
@@ -83,7 +83,7 @@ public class ReportsController {
...
@@ -83,7 +83,7 @@ public class ReportsController {
// Convert the aggregation result into a List
// Convert the aggregation result into a List
AggregationResults
<
GroupByCount
>
groupResults
=
mongoTemplate
AggregationResults
<
GroupByCount
>
groupResults
=
mongoTemplate
.
aggregate
(
agg
,
Employee
Roles
.
class
,
GroupByCount
.
class
);
.
aggregate
(
agg
,
Employee
.
class
,
GroupByCount
.
class
);
List
<
GroupByCount
>
result
=
groupResults
.
getMappedResults
();
List
<
GroupByCount
>
result
=
groupResults
.
getMappedResults
();
return
new
ResponseEntity
<>(
result
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
result
,
HttpStatus
.
OK
);
...
@@ -111,7 +111,7 @@ public class ReportsController {
...
@@ -111,7 +111,7 @@ public class ReportsController {
// Convert the aggregation result into a List
// Convert the aggregation result into a List
AggregationResults
<
GroupByCount
>
groupResults
=
mongoTemplate
AggregationResults
<
GroupByCount
>
groupResults
=
mongoTemplate
.
aggregate
(
agg
,
Employee
Roles
.
class
,
GroupByCount
.
class
);
.
aggregate
(
agg
,
Employee
.
class
,
GroupByCount
.
class
);
List
<
GroupByCount
>
result
=
groupResults
.
getMappedResults
();
List
<
GroupByCount
>
result
=
groupResults
.
getMappedResults
();
ColumnChartData
reportData
=
new
ColumnChartData
();
ColumnChartData
reportData
=
new
ColumnChartData
();
reportData
.
setCategories
(
"data"
);
reportData
.
setCategories
(
"data"
);
...
@@ -302,7 +302,7 @@ public class ReportsController {
...
@@ -302,7 +302,7 @@ public class ReportsController {
// Convert the aggregation result into a List
// Convert the aggregation result into a List
AggregationResults
<
GroupByCount
>
groupResults
=
mongoTemplate
AggregationResults
<
GroupByCount
>
groupResults
=
mongoTemplate
.
aggregate
(
agg
,
Employee
Roles
.
class
,
GroupByCount
.
class
);
.
aggregate
(
agg
,
Employee
.
class
,
GroupByCount
.
class
);
List
<
GroupByCount
>
result
=
groupResults
.
getMappedResults
();
List
<
GroupByCount
>
result
=
groupResults
.
getMappedResults
();
Map
<
String
,
List
<
GroupByCount
>>
map
=
new
HashMap
<
String
,
List
<
GroupByCount
>>();
Map
<
String
,
List
<
GroupByCount
>>
map
=
new
HashMap
<
String
,
List
<
GroupByCount
>>();
map
.
put
(
"data"
,
result
);
map
.
put
(
"data"
,
result
);
...
@@ -315,9 +315,9 @@ public class ReportsController {
...
@@ -315,9 +315,9 @@ public class ReportsController {
@RequestMapping
(
value
=
"/fetchEmployeeDetailsByFG"
,
@RequestMapping
(
value
=
"/fetchEmployeeDetailsByFG"
,
method
=
RequestMethod
.
GET
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
Employee
Roles
>>
getEmployeesByFG
(
public
ResponseEntity
<
List
<
Employee
>>
getEmployeesByFG
(
@RequestParam
(
"fGroup"
)
String
fGroup
)
throws
MyTimeException
{
@RequestParam
(
"fGroup"
)
String
fGroup
)
throws
MyTimeException
{
List
<
Employee
Roles
>
empList
=
new
ArrayList
<>();
List
<
Employee
>
empList
=
new
ArrayList
<>();
empList
=
userService
.
getEmployeesByFunctionalGrp
(
fGroup
);
empList
=
userService
.
getEmployeesByFunctionalGrp
(
fGroup
);
return
new
ResponseEntity
<>(
empList
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
empList
,
HttpStatus
.
OK
);
...
...
src/main/java/com/nisum/mytime/controller/UserController.java
View file @
65c9aaa9
...
@@ -21,9 +21,9 @@ import com.nisum.mytime.exception.handler.MyTimeException;
...
@@ -21,9 +21,9 @@ import com.nisum.mytime.exception.handler.MyTimeException;
import
com.nisum.mytime.model.Account
;
import
com.nisum.mytime.model.Account
;
import
com.nisum.mytime.model.AccountInfo
;
import
com.nisum.mytime.model.AccountInfo
;
import
com.nisum.mytime.model.Designation
;
import
com.nisum.mytime.model.Designation
;
import
com.nisum.mytime.model.Domain
s
;
import
com.nisum.mytime.model.Domain
;
import
com.nisum.mytime.model.EmployeeLocationDetails
;
import
com.nisum.mytime.model.EmployeeLocationDetails
;
import
com.nisum.mytime.model.Employee
Roles
;
import
com.nisum.mytime.model.Employee
;
import
com.nisum.mytime.model.Location
;
import
com.nisum.mytime.model.Location
;
import
com.nisum.mytime.model.MasterData
;
import
com.nisum.mytime.model.MasterData
;
import
com.nisum.mytime.model.Shift
;
import
com.nisum.mytime.model.Shift
;
...
@@ -46,9 +46,9 @@ public class UserController {
...
@@ -46,9 +46,9 @@ public class UserController {
@RequestMapping
(
value
=
"/employee"
,
method
=
RequestMethod
.
GET
,
@RequestMapping
(
value
=
"/employee"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
Employee
Roles
>
getEmployeeRole
(
public
ResponseEntity
<
Employee
>
getEmployeeRole
(
@RequestParam
(
"emailId"
)
String
emailId
)
throws
MyTimeException
{
@RequestParam
(
"emailId"
)
String
emailId
)
throws
MyTimeException
{
Employee
Roles
employeesRole
=
userService
.
getEmployeesRole
(
emailId
);
Employee
employeesRole
=
userService
.
getEmployeesRole
(
emailId
);
if
(
employeesRole
!=
null
)
{
if
(
employeesRole
!=
null
)
{
if
(
employeesRole
.
getRole
()
!=
null
if
(
employeesRole
.
getRole
()
!=
null
&&
employeesRole
.
getRole
().
equalsIgnoreCase
(
"Admin"
))
{
&&
employeesRole
.
getRole
().
equalsIgnoreCase
(
"Admin"
))
{
...
@@ -68,9 +68,9 @@ public class UserController {
...
@@ -68,9 +68,9 @@ public class UserController {
@RequestMapping
(
value
=
"/assignEmployeeRole"
,
method
=
RequestMethod
.
POST
,
@RequestMapping
(
value
=
"/assignEmployeeRole"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
Employee
Roles
>
assigingEmployeeRole
(
public
ResponseEntity
<
Employee
>
assigingEmployeeRole
(
@RequestBody
Employee
Roles
employeeRoles
,
@RequestParam
(
value
=
"empId"
)
String
loginEmpId
)
throws
MyTimeException
{
@RequestBody
Employee
employeeRoles
,
@RequestParam
(
value
=
"empId"
)
String
loginEmpId
)
throws
MyTimeException
{
Employee
Roles
employeeRole
=
userService
Employee
employeeRole
=
userService
.
assigingEmployeeRole
(
employeeRoles
,
loginEmpId
);
.
assigingEmployeeRole
(
employeeRoles
,
loginEmpId
);
return
new
ResponseEntity
<>(
employeeRole
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
employeeRole
,
HttpStatus
.
OK
);
}
}
...
@@ -78,10 +78,10 @@ public class UserController {
...
@@ -78,10 +78,10 @@ public class UserController {
@RequestMapping
(
value
=
"/updateEmployeeRole"
,
method
=
RequestMethod
.
POST
,
@RequestMapping
(
value
=
"/updateEmployeeRole"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
Employee
Roles
>
updateEmployeeRole
(
public
ResponseEntity
<
Employee
>
updateEmployeeRole
(
@RequestBody
Employee
Roles
employeeRoles
,
@RequestBody
Employee
employeeRoles
,
@RequestParam
(
value
=
"empId"
)
String
loginEmpId
)
throws
MyTimeException
{
@RequestParam
(
value
=
"empId"
)
String
loginEmpId
)
throws
MyTimeException
{
Employee
Roles
employeeRole
=
userService
Employee
employeeRole
=
userService
.
updateEmployeeRole
(
employeeRoles
,
loginEmpId
);
.
updateEmployeeRole
(
employeeRoles
,
loginEmpId
);
return
new
ResponseEntity
<>(
employeeRole
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
employeeRole
,
HttpStatus
.
OK
);
}
}
...
@@ -96,17 +96,17 @@ public class UserController {
...
@@ -96,17 +96,17 @@ public class UserController {
@RequestMapping
(
value
=
"/getUserRoles"
,
method
=
RequestMethod
.
GET
,
@RequestMapping
(
value
=
"/getUserRoles"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
Employee
Roles
>>
getUserRoles
()
public
ResponseEntity
<
List
<
Employee
>>
getUserRoles
()
throws
MyTimeException
{
throws
MyTimeException
{
List
<
Employee
Roles
>
employeesRoles
=
userService
.
getEmployeeRoles
();
List
<
Employee
>
employeesRoles
=
userService
.
getEmployeeRoles
();
return
new
ResponseEntity
<>(
employeesRoles
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
employeesRoles
,
HttpStatus
.
OK
);
}
}
@RequestMapping
(
value
=
"/getEmployeeRoleData"
,
method
=
RequestMethod
.
GET
,
@RequestMapping
(
value
=
"/getEmployeeRoleData"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
Employee
Roles
>
getEmployeeRoleData
(
public
ResponseEntity
<
Employee
>
getEmployeeRoleData
(
@RequestParam
(
"empId"
)
String
empId
)
throws
MyTimeException
{
@RequestParam
(
"empId"
)
String
empId
)
throws
MyTimeException
{
Employee
Roles
employeesRole
=
userService
.
getEmployeesRoleData
(
empId
);
Employee
employeesRole
=
userService
.
getEmployeesRoleData
(
empId
);
return
new
ResponseEntity
<>(
employeesRole
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
employeesRole
,
HttpStatus
.
OK
);
}
}
...
@@ -121,16 +121,16 @@ public class UserController {
...
@@ -121,16 +121,16 @@ public class UserController {
@RequestMapping
(
value
=
"/getManagers"
,
method
=
RequestMethod
.
GET
,
@RequestMapping
(
value
=
"/getManagers"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
Employee
Roles
>>
getManagers
()
public
ResponseEntity
<
List
<
Employee
>>
getManagers
()
throws
MyTimeException
{
throws
MyTimeException
{
List
<
Employee
Roles
>
employeesRoles
=
userService
.
getEmployeeRoles
();
List
<
Employee
>
employeesRoles
=
userService
.
getEmployeeRoles
();
List
<
Employee
Roles
>
managers
=
employeesRoles
.
stream
()
List
<
Employee
>
managers
=
employeesRoles
.
stream
()
.
filter
(
e
->
(
"Director"
.
equalsIgnoreCase
(
e
.
getRole
())
.
filter
(
e
->
(
"Director"
.
equalsIgnoreCase
(
e
.
getRole
())
||
"Delivery Manager"
.
equalsIgnoreCase
(
e
.
getRole
())
||
"Delivery Manager"
.
equalsIgnoreCase
(
e
.
getRole
())
||
"Manager"
.
equalsIgnoreCase
(
e
.
getRole
())
||
"Manager"
.
equalsIgnoreCase
(
e
.
getRole
())
||
"HR Manager"
.
equalsIgnoreCase
(
e
.
getRole
())
||
"HR Manager"
.
equalsIgnoreCase
(
e
.
getRole
())
||
"Lead"
.
equalsIgnoreCase
(
e
.
getRole
())))
||
"Lead"
.
equalsIgnoreCase
(
e
.
getRole
())))
.
sorted
(
Comparator
.
comparing
(
Employee
Roles
:
:
getEmployeeName
))
.
sorted
(
Comparator
.
comparing
(
Employee:
:
getEmployeeName
))
.
collect
(
Collectors
.
toList
());
.
collect
(
Collectors
.
toList
());
return
new
ResponseEntity
<>(
managers
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
managers
,
HttpStatus
.
OK
);
}
}
...
@@ -183,9 +183,9 @@ public class UserController {
...
@@ -183,9 +183,9 @@ public class UserController {
@RequestMapping
(
value
=
"/updateProfile"
,
method
=
RequestMethod
.
POST
,
@RequestMapping
(
value
=
"/updateProfile"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
Employee
Roles
>
updateProfile
(
public
ResponseEntity
<
Employee
>
updateProfile
(
@RequestBody
Employee
Roles
employeeRoles
)
throws
MyTimeException
{
@RequestBody
Employee
employeeRoles
)
throws
MyTimeException
{
Employee
Roles
employeeRole
=
userService
.
updateProfile
(
employeeRoles
);
Employee
employeeRole
=
userService
.
updateProfile
(
employeeRoles
);
return
new
ResponseEntity
<>(
employeeRole
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
employeeRole
,
HttpStatus
.
OK
);
}
}
...
@@ -203,11 +203,11 @@ public class UserController {
...
@@ -203,11 +203,11 @@ public class UserController {
@RequestMapping
(
value
=
"/getEmployeeRoleDataForSearchCriteria"
,
@RequestMapping
(
value
=
"/getEmployeeRoleDataForSearchCriteria"
,
method
=
RequestMethod
.
GET
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
Employee
Roles
>
getEmployeeRoleDataForSearchCriteria
(
public
ResponseEntity
<
Employee
>
getEmployeeRoleDataForSearchCriteria
(
@RequestParam
(
"searchId"
)
String
searchId
,
@RequestParam
(
"searchId"
)
String
searchId
,
@RequestParam
(
"searchAttribute"
)
String
searchAttribute
)
@RequestParam
(
"searchAttribute"
)
String
searchAttribute
)
throws
MyTimeException
{
throws
MyTimeException
{
Employee
Roles
employeesRole
=
userService
Employee
employeesRole
=
userService
.
getEmployeeRoleDataForSearchCriteria
(
searchId
,
.
getEmployeeRoleDataForSearchCriteria
(
searchId
,
searchAttribute
);
searchAttribute
);
return
new
ResponseEntity
<>(
employeesRole
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
employeesRole
,
HttpStatus
.
OK
);
...
@@ -243,10 +243,10 @@ public class UserController {
...
@@ -243,10 +243,10 @@ public class UserController {
@RequestMapping
(
value
=
"/getEmployeeByStatus"
,
method
=
RequestMethod
.
GET
,
@RequestMapping
(
value
=
"/getEmployeeByStatus"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
Employee
Roles
>>
getEmployeeByStatus
(
public
ResponseEntity
<
List
<
Employee
>>
getEmployeeByStatus
(
@RequestParam
(
"status"
)
String
status
)
{
@RequestParam
(
"status"
)
String
status
)
{
List
<
Employee
Roles
>
employeesRoles
=
userService
List
<
Employee
>
employeesRoles
=
userService
.
getEmployeesByStatus
(
status
);
.
getEmployeesByStatus
(
status
);
return
new
ResponseEntity
<>(
employeesRoles
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
employeesRoles
,
HttpStatus
.
OK
);
}
}
...
@@ -272,10 +272,10 @@ public class UserController {
...
@@ -272,10 +272,10 @@ public class UserController {
@RequestMapping
(
value
=
"/getDomains"
,
method
=
RequestMethod
.
GET
,
@RequestMapping
(
value
=
"/getDomains"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
Domain
s
>>
getDomains
(
public
ResponseEntity
<
List
<
Domain
>>
getDomains
(
@RequestParam
(
"accountId"
)
String
accountId
)
@RequestParam
(
"accountId"
)
String
accountId
)
throws
MyTimeException
{
throws
MyTimeException
{
List
<
Domain
s
>
domains
=
userService
.
getDomains
(
accountId
).
stream
()
List
<
Domain
>
domains
=
userService
.
getDomains
(
accountId
).
stream
()
.
filter
(
e
->
"Active"
.
equalsIgnoreCase
(
e
.
getStatus
()))
.
filter
(
e
->
"Active"
.
equalsIgnoreCase
(
e
.
getStatus
()))
.
collect
(
Collectors
.
toList
());
.
collect
(
Collectors
.
toList
());
return
new
ResponseEntity
<>(
domains
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
domains
,
HttpStatus
.
OK
);
...
...
src/main/java/com/nisum/mytime/model/Domain
s
.java
→
src/main/java/com/nisum/mytime/model/Domain.java
View file @
65c9aaa9
...
@@ -3,7 +3,11 @@ package com.nisum.mytime.model;
...
@@ -3,7 +3,11 @@ package com.nisum.mytime.model;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
java.util.List
;
import
java.util.List
;
import
javax.validation.constraints.NotNull
;
import
javax.validation.constraints.Size
;
import
org.bson.types.ObjectId
;
import
org.bson.types.ObjectId
;
import
org.hibernate.validator.constraints.NotBlank
;
import
org.springframework.data.annotation.Id
;
import
org.springframework.data.annotation.Id
;
import
org.springframework.data.mongodb.core.mapping.Document
;
import
org.springframework.data.mongodb.core.mapping.Document
;
...
@@ -19,15 +23,20 @@ import lombok.ToString;
...
@@ -19,15 +23,20 @@ import lombok.ToString;
@NoArgsConstructor
@NoArgsConstructor
@ToString
@ToString
@Document
(
collection
=
"Domains"
)
@Document
(
collection
=
"Domains"
)
public
class
Domain
s
implements
Serializable
{
public
class
Domain
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
long
serialVersionUID
=
1L
;
// private ObjectId id;
@Id
@Id
private
ObjectId
id
;
private
String
domainId
;
private
String
domainId
;
@NotNull
@Size
(
min
=
2
,
max
=
80
,
message
=
"Domain Name should have atlast 2 and less than 80 characters"
)
private
String
domainName
;
private
String
domainName
;
@NotBlank
private
String
accountId
;
private
String
accountId
;
@NotBlank
private
String
status
;
private
String
status
;
List
<
String
>
deliveryManagers
;
@NotNull
List
<?>
deliveryManagers
;
}
}
src/main/java/com/nisum/mytime/model/Employee.java
View file @
65c9aaa9
package
com
.
nisum
.
mytime
.
model
;
package
com
.
nisum
.
mytime
.
model
;
import
java.io.Serializable
;
import
java.util.Date
;
import
org.springframework.data.annotation.Id
;
import
org.springframework.data.mongodb.core.mapping.Document
;
import
com.poiji.annotation.ExcelCellName
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
import
lombok.Setter
;
import
lombok.ToString
;
@Setter
@Setter
@Getter
@Getter
public
class
Employee
{
@AllArgsConstructor
@NoArgsConstructor
@ToString
@Document
(
collection
=
"EmployeeDetails"
)
public
class
Employee
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
@Id
private
String
id
;
@ExcelCellName
(
"Employee ID"
)
private
String
employeeId
;
@ExcelCellName
(
"Employee Name"
)
private
String
employeeName
;
@ExcelCellName
(
"Email ID"
)
private
String
emailId
;
@ExcelCellName
(
"Role"
)
private
String
role
;
@ExcelCellName
(
"Designation"
)
private
String
designation
;
@ExcelCellName
(
"Shift"
)
private
String
shift
;
@ExcelCellName
(
"Primary Skill"
)
private
String
baseTechnology
;
@ExcelCellName
(
"Domain"
)
private
String
domain
;
@ExcelCellName
(
"Location"
)
private
String
empLocation
;
@ExcelCellName
(
"Skills"
)
private
String
technologyKnown
;
@ExcelCellName
(
"Primary Mobile"
)
private
String
mobileNumber
;
@ExcelCellName
(
"Alternate Mobile"
)
private
String
alternateMobileNumber
;
@ExcelCellName
(
"Personal Email"
)
private
String
personalEmailId
;
@ExcelCellName
(
"Functional Group"
)
private
String
functionalGroup
;
@ExcelCellName
(
"Employment Status"
)
private
String
empStatus
;
@ExcelCellName
(
"Employment Type"
)
private
String
employmentType
;
@ExcelCellName
(
"Date Of Joining"
)
private
Date
dateOfJoining
;
@ExcelCellName
(
"Date Of Birth"
)
private
Date
dateOfBirth
;
@ExcelCellName
(
"Gender"
)
private
String
gender
;
@ExcelCellName
(
"Has Passport"
)
private
String
hasPassort
;
@ExcelCellName
(
"Passport Expiry Date"
)
private
Date
passportExpiryDate
;
@ExcelCellName
(
"Has B1"
)
private
String
hasB1
;
@ExcelCellName
(
"B1 Expiry Date"
)
private
Date
b1ExpiryDate
;
@ExcelCellName
(
"Created"
)
private
Date
createdOn
;
@ExcelCellName
(
"Last Modified"
)
private
Date
lastModifiedOn
;
@ExcelCellName
(
"Exit Date"
)
private
Date
endDate
;
private
String
createdBy
;
private
String
modifiedBy
;
@Override
public
int
hashCode
()
{
final
int
prime
=
31
;
int
result
=
1
;
result
=
prime
*
result
+
((
employeeId
==
null
)
?
0
:
employeeId
.
hashCode
());
return
result
;
}
@Override
public
boolean
equals
(
Object
obj
)
{
if
(
this
==
obj
)
return
true
;
if
(
obj
==
null
)
return
false
;
if
(
getClass
()
!=
obj
.
getClass
())
return
false
;
Employee
other
=
(
Employee
)
obj
;
if
(
employeeId
==
null
)
{
if
(
other
.
employeeId
!=
null
)
return
false
;
}
else
if
(!
employeeId
.
equals
(
other
.
employeeId
))
return
false
;
return
true
;
}
private
String
email
;
private
String
name
;
private
String
givenName
;
private
String
familyName
;
}
}
src/main/java/com/nisum/mytime/model/EmployeeRoles.java
deleted
100644 → 0
View file @
35c50907
package
com
.
nisum
.
mytime
.
model
;
import
java.io.Serializable
;
import
java.util.Date
;
import
org.springframework.data.annotation.Id
;
import
org.springframework.data.mongodb.core.mapping.Document
;
import
com.poiji.annotation.ExcelCellName
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
import
lombok.ToString
;
@Setter
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ToString
@Document
(
collection
=
"EmployeeDetails"
)
public
class
EmployeeRoles
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
@Id
private
String
id
;
@ExcelCellName
(
"Employee ID"
)
private
String
employeeId
;
@ExcelCellName
(
"Employee Name"
)
private
String
employeeName
;
@ExcelCellName
(
"Email ID"
)
private
String
emailId
;
@ExcelCellName
(
"Role"
)
private
String
role
;
@ExcelCellName
(
"Designation"
)
private
String
designation
;
@ExcelCellName
(
"Shift"
)
private
String
shift
;
@ExcelCellName
(
"Primary Skill"
)
private
String
baseTechnology
;
@ExcelCellName
(
"Domain"
)
private
String
domain
;
@ExcelCellName
(
"Location"
)
private
String
empLocation
;
@ExcelCellName
(
"Skills"
)
private
String
technologyKnown
;
@ExcelCellName
(
"Primary Mobile"
)
private
String
mobileNumber
;
@ExcelCellName
(
"Alternate Mobile"
)
private
String
alternateMobileNumber
;
@ExcelCellName
(
"Personal Email"
)
private
String
personalEmailId
;
@ExcelCellName
(
"Functional Group"
)
private
String
functionalGroup
;
@ExcelCellName
(
"Employment Status"
)
private
String
empStatus
;
@ExcelCellName
(
"Employment Type"
)
private
String
employmentType
;
@ExcelCellName
(
"Date Of Joining"
)
private
Date
dateOfJoining
;
@ExcelCellName
(
"Date Of Birth"
)
private
Date
dateOfBirth
;
@ExcelCellName
(
"Gender"
)
private
String
gender
;
@ExcelCellName
(
"Has Passport"
)
private
String
hasPassort
;
@ExcelCellName
(
"Passport Expiry Date"
)
private
Date
passportExpiryDate
;
@ExcelCellName
(
"Has B1"
)
private
String
hasB1
;
@ExcelCellName
(
"B1 Expiry Date"
)
private
Date
b1ExpiryDate
;
@ExcelCellName
(
"Created"
)
private
Date
createdOn
;
@ExcelCellName
(
"Last Modified"
)
private
Date
lastModifiedOn
;
@ExcelCellName
(
"Exit Date"
)
private
Date
endDate
;
private
String
createdBy
;
private
String
modifiedBy
;
@Override
public
int
hashCode
()
{
final
int
prime
=
31
;
int
result
=
1
;
result
=
prime
*
result
+
((
employeeId
==
null
)
?
0
:
employeeId
.
hashCode
());
return
result
;
}
@Override
public
boolean
equals
(
Object
obj
)
{
if
(
this
==
obj
)
return
true
;
if
(
obj
==
null
)
return
false
;
if
(
getClass
()
!=
obj
.
getClass
())
return
false
;
EmployeeRoles
other
=
(
EmployeeRoles
)
obj
;
if
(
employeeId
==
null
)
{
if
(
other
.
employeeId
!=
null
)
return
false
;
}
else
if
(!
employeeId
.
equals
(
other
.
employeeId
))
return
false
;
return
true
;
}
}
src/main/java/com/nisum/mytime/repository/DomainRepo.java
View file @
65c9aaa9
package
com
.
nisum
.
mytime
.
repository
;
package
com
.
nisum
.
mytime
.
repository
;
import
java.util.List
;
import
java.util.List
;
import
org.springframework.data.mongodb.repository.MongoRepository
;
import
org.springframework.data.mongodb.repository.MongoRepository
;
import
com.nisum.mytime.model.Domain
s
;
import
com.nisum.mytime.model.Domain
;
public
interface
DomainRepo
extends
MongoRepository
<
Domain
s
,
String
>
{
public
interface
DomainRepo
extends
MongoRepository
<
Domain
,
String
>
{
List
<
Domain
s
>
findByDomainNameAndAccountId
(
String
domianName
,
String
accountId
);
List
<
Domain
>
findByDomainNameAndAccountId
(
String
domianName
,
String
accountId
);
List
<
Domain
s
>
findByAccountId
(
String
accountId
);
List
<
Domain
>
findByAccountId
(
String
accountId
);
Domains
findByDomainId
(
String
domainId
);
Domain
findByDomainId
(
String
domainId
);
List
<
Domain
>
findByDeliveryManagers
(
String
empId
);
}
}
\ No newline at end of file
src/main/java/com/nisum/mytime/repository/EmployeeRolesRepo.java
View file @
65c9aaa9
...
@@ -5,24 +5,24 @@ import java.util.Set;
...
@@ -5,24 +5,24 @@ import java.util.Set;
import
org.springframework.data.mongodb.repository.MongoRepository
;
import
org.springframework.data.mongodb.repository.MongoRepository
;
import
com.nisum.mytime.model.Employee
Roles
;
import
com.nisum.mytime.model.Employee
;
public
interface
EmployeeRolesRepo
public
interface
EmployeeRolesRepo
extends
MongoRepository
<
Employee
Roles
,
String
>
{
extends
MongoRepository
<
Employee
,
String
>
{
Employee
Roles
findByEmailId
(
String
emailId
);
Employee
findByEmailId
(
String
emailId
);
Employee
Roles
findByEmployeeId
(
String
employeeId
);
Employee
findByEmployeeId
(
String
employeeId
);
Employee
Roles
findByEmployeeName
(
String
employeeName
);
Employee
findByEmployeeName
(
String
employeeName
);
List
<
Employee
Roles
>
findByEmpStatusAndFunctionalGroup
(
String
empStatus
,
List
<
Employee
>
findByEmpStatusAndFunctionalGroup
(
String
empStatus
,
String
functionalGroup
);
String
functionalGroup
);
List
<
Employee
Roles
>
findByEmpStatusOrderByEmployeeNameAsc
(
String
empStatus
);
List
<
Employee
>
findByEmpStatusOrderByEmployeeNameAsc
(
String
empStatus
);
List
<
Employee
Roles
>
findByEmpStatus
(
String
status
);
List
<
Employee
>
findByEmpStatus
(
String
status
);
List
<
Employee
Roles
>
findByEmployeeIdIn
(
Set
<
String
>
empIdsSet
);
List
<
Employee
>
findByEmployeeIdIn
(
Set
<
String
>
empIdsSet
);
}
}
\ No newline at end of file
src/main/java/com/nisum/mytime/service/AccountService.java
View file @
65c9aaa9
...
@@ -19,7 +19,7 @@ import org.springframework.stereotype.Service;
...
@@ -19,7 +19,7 @@ import org.springframework.stereotype.Service;
import
com.nisum.mytime.controller.AccountController
;
import
com.nisum.mytime.controller.AccountController
;
import
com.nisum.mytime.exception.handler.MyTimeException
;
import
com.nisum.mytime.exception.handler.MyTimeException
;
import
com.nisum.mytime.model.Account
;
import
com.nisum.mytime.model.Account
;
import
com.nisum.mytime.model.Employee
Roles
;
import
com.nisum.mytime.model.Employee
;
import
com.nisum.mytime.repository.AccountRepo
;
import
com.nisum.mytime.repository.AccountRepo
;
import
com.nisum.mytime.utils.CommomUtil
;
import
com.nisum.mytime.utils.CommomUtil
;
import
com.nisum.mytime.utils.MyTimeUtils
;
import
com.nisum.mytime.utils.MyTimeUtils
;
...
@@ -102,7 +102,7 @@ public class AccountService implements IAccountService {
...
@@ -102,7 +102,7 @@ public class AccountService implements IAccountService {
List
<
Map
<
String
,
String
>>
updatedEmployeeList
=
null
;
List
<
Map
<
String
,
String
>>
updatedEmployeeList
=
null
;
for
(
Account
account
:
accountRepo
.
findAll
())
{
for
(
Account
account
:
accountRepo
.
findAll
())
{
updatedEmployeeList
=
new
ArrayList
<>();
updatedEmployeeList
=
new
ArrayList
<>();
for
(
Employee
Roles
employeesRole
:
getEmployeeDetails
(
account
))
{
for
(
Employee
employeesRole
:
getEmployeeDetails
(
account
))
{
updatedEmployeeList
.
add
(
getEmployeeDetails
(
employeesRole
));
updatedEmployeeList
.
add
(
getEmployeeDetails
(
employeesRole
));
}
}
updatedAccountList
.
add
(
getAccuntDetails
(
account
,
updatedEmployeeList
));
updatedAccountList
.
add
(
getAccuntDetails
(
account
,
updatedEmployeeList
));
...
@@ -179,14 +179,14 @@ public class AccountService implements IAccountService {
...
@@ -179,14 +179,14 @@ public class AccountService implements IAccountService {
}
}
// fetching the employee details using employeeId.
// fetching the employee details using employeeId.
private
List
<
Employee
Roles
>
getEmployeeDetails
(
Account
account
)
{
private
List
<
Employee
>
getEmployeeDetails
(
Account
account
)
{
List
<
Employee
Roles
>
employeeRoles
=
mongoTemplate
.
find
(
List
<
Employee
>
employeeRoles
=
mongoTemplate
.
find
(
new
Query
(
Criteria
.
where
(
MyTimeUtils
.
EMPLOYEE_ID
).
in
(
account
.
getDeliveryManagers
())),
new
Query
(
Criteria
.
where
(
MyTimeUtils
.
EMPLOYEE_ID
).
in
(
account
.
getDeliveryManagers
())),
Employee
Roles
.
class
);
Employee
.
class
);
return
employeeRoles
;
return
employeeRoles
;
}
}
private
HashMap
<
String
,
String
>
getEmployeeDetails
(
Employee
Roles
employeesRole
)
{
private
HashMap
<
String
,
String
>
getEmployeeDetails
(
Employee
employeesRole
)
{
HashMap
<
String
,
String
>
employeeDetails
=
new
HashMap
<>();
HashMap
<
String
,
String
>
employeeDetails
=
new
HashMap
<>();
employeeDetails
.
put
(
MyTimeUtils
.
EMPLOYEE_ID
,
employeesRole
.
getEmployeeId
());
employeeDetails
.
put
(
MyTimeUtils
.
EMPLOYEE_ID
,
employeesRole
.
getEmployeeId
());
employeeDetails
.
put
(
MyTimeUtils
.
EMPLOYEE_NAME
,
employeesRole
.
getEmployeeName
());
employeeDetails
.
put
(
MyTimeUtils
.
EMPLOYEE_NAME
,
employeesRole
.
getEmployeeName
());
...
...
src/main/java/com/nisum/mytime/service/DomainService.java
View file @
65c9aaa9
package
com
.
nisum
.
mytime
.
service
;
package
com
.
nisum
.
mytime
.
service
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.mongodb.core.MongoTemplate
;
import
org.springframework.data.mongodb.core.query.Criteria
;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.data.mongodb.core.query.Update
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.StringUtils
;
import
com.mongodb.WriteResult
;
import
com.mongodb.WriteResult
;
import
com.nisum.mytime.exception.handler.MyTimeException
;
import
com.nisum.mytime.exception.handler.MyTimeException
;
import
com.nisum.mytime.model.Domains
;
import
com.nisum.mytime.model.Domain
;
import
com.nisum.mytime.model.Employee
;
import
com.nisum.mytime.repository.DomainRepo
;
import
com.nisum.mytime.utils.CommomUtil
;
import
com.nisum.mytime.utils.MyTimeUtils
;
/**
/**
* @author Vijay
* @author Vijay
*
*
*/
*/
public
interface
DomainService
{
@Service
public
class
DomainService
implements
IDomainService
{
@Autowired
private
DomainRepo
domainRepo
;
@Autowired
private
MongoTemplate
mongoTemplate
;
@Autowired
private
RoleInfoService
roleInfoService
;
@Autowired
private
RoleMappingService
roleMappingService
;
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
DomainService
.
class
);
public
boolean
isDomainExists
(
Domain
domainReq
)
{
boolean
isDomainExists
=
false
;
int
count
=
0
;
List
<
Domain
>
domainListByName
=
domainRepo
.
findByDomainNameAndAccountId
(
domainReq
.
getDomainName
(),
domainReq
.
getAccountId
());
List
<
Domain
>
domainListbyAccountId
=
domainRepo
.
findByAccountId
(
domainReq
.
getAccountId
());
// Case sensitive logic
for
(
Domain
domainItr
:
domainListbyAccountId
)
{
if
(
domainItr
.
getDomainName
().
equalsIgnoreCase
(
domainReq
.
getDomainName
()))
count
++;
}
if
(
count
>
0
||
domainListByName
.
size
()
>
0
)
{
isDomainExists
=
true
;
}
return
isDomainExists
;
}
@Override
public
Domain
create
(
Domain
domainReq
)
throws
MyTimeException
{
if
(
StringUtils
.
isEmpty
(
domainReq
.
getDomainId
()))
{
domainReq
.
setDomainId
((
MyTimeUtils
.
DOM
+
MyTimeUtils
.
ZERO_
)
+
(
getDomainsList
().
size
()
+
1
));
}
domainReq
.
setStatus
(
MyTimeUtils
.
ACTIVE
);
Domain
domainPersisted
=
domainRepo
.
save
(
domainReq
);
if
(
domainPersisted
!=
null
)
{
saveEmployeeRole
(
domainReq
);
}
return
domainPersisted
;
}
@Override
public
Domain
update
(
Domain
domainReq
)
throws
MyTimeException
{
logger
.
info
(
"updating the roles for DeliveryManager in EmployeeRoleMapping collection"
);
final
String
roleId
=
roleInfoService
.
getRole
(
MyTimeUtils
.
DOMAIN
);
updateRoleIdsForDMs
(
domainReq
,
roleId
);
logger
.
info
(
"deleting roleids for DeliveryManagers in EmployeeRoleMapping collection"
);
deleteRoleIdsForDMs
(
domainReq
,
roleId
);
logger
.
info
(
"updating the domain details"
);
domainReq
.
setStatus
(
MyTimeUtils
.
ACTIVE
);
Domain
domainPersisted
=
domainRepo
.
save
(
domainReq
);
logger
.
info
(
"After update the domain details::"
+
domainPersisted
);
return
domainPersisted
;
}
private
void
updateRoleIdsForDMs
(
Domain
domainReq
,
String
roleId
)
throws
MyTimeException
{
Domain
domainDAO
=
getDomainById
(
domainReq
.
getDomainId
());
List
dmssListDAO
=
domainDAO
.
getDeliveryManagers
();
List
dmsListReq
=
domainReq
.
getDeliveryManagers
();
List
<
String
>
managersAddedByUser
=
managersAddedByUser
=
CommomUtil
.
getAddedManagersListForDM
(
dmssListDAO
,
dmsListReq
);
roleMappingService
.
saveUniqueEmployeeAndRole
(
managersAddedByUser
,
roleId
);
}
private
void
deleteRoleIdsForDMs
(
Domain
domainUpdating
,
String
roleId
)
throws
MyTimeException
{
Map
<
String
,
Integer
>
managersDomainCount
=
new
HashMap
<
String
,
Integer
>();
Domain
domainDAO
=
getDomainById
(
domainUpdating
.
getDomainId
());
List
dmsListDAO
=
domainDAO
.
getDeliveryManagers
();
List
dmsListReq
=
domainUpdating
.
getDeliveryManagers
();
List
<
String
>
managersDeletedByUser
=
CommomUtil
.
getDeletedManagersList
(
dmsListDAO
,
dmsListReq
);
List
<
Domain
>
domainsPersistedList
=
domainRepo
.
findAll
();
for
(
Domain
domain
:
domainsPersistedList
)
{
List
employeeIds
=
domain
.
getDeliveryManagers
();
for
(
Object
eId
:
employeeIds
)
{
if
(
managersDomainCount
.
get
(
eId
)
!=
null
)
managersDomainCount
.
put
(
eId
.
toString
(),
managersDomainCount
.
get
(
eId
)
+
1
);
else
managersDomainCount
.
put
(
eId
.
toString
(),
1
);
}
}
for
(
String
managerId
:
managersDeletedByUser
)
{
if
(
managersDomainCount
.
get
(
managerId
)
==
1
)
{
// Call service to delete manager
roleMappingService
.
deleteRole
(
managerId
,
roleId
);
}
}
}
@Override
public
List
<
Domain
>
getDomainsList
()
throws
MyTimeException
{
List
<
Domain
>
domainsPersistedList
=
domainRepo
.
findAll
();
for
(
Domain
domainPersisted
:
domainsPersistedList
)
{
domainPersisted
.
setDeliveryManagers
(
prepareEmployeeList
(
domainPersisted
));
}
return
domainsPersistedList
;
}
@Override
public
WriteResult
delete
(
String
domainId
)
throws
MyTimeException
{
List
<
String
>
domEmpIds
=
new
ArrayList
<
String
>();
String
roleId
=
roleInfoService
.
getRole
(
MyTimeUtils
.
DOMAIN
);
List
<
Domain
>
domainsPersistedList
=
domainRepo
.
findAll
();
Query
selectedDomainQuery
=
new
Query
(
Criteria
.
where
(
MyTimeUtils
.
DOMAIN_ID
).
in
(
domainId
).
and
(
MyTimeUtils
.
STATUS
).
in
(
MyTimeUtils
.
ACTIVE
));
List
<
Domain
>
selectedDomain
=
mongoTemplate
.
find
(
selectedDomainQuery
,
Domain
.
class
);
for
(
Domain
domain
:
domainsPersistedList
)
{
List
employeeIds
=
domain
.
getDeliveryManagers
();
for
(
Object
eIds
:
employeeIds
)
domEmpIds
.
add
(
eIds
.
toString
());
}
for
(
Object
empId
:
selectedDomain
.
get
(
0
).
getDeliveryManagers
())
{
int
occurrences
=
Collections
.
frequency
(
domEmpIds
,
empId
.
toString
());
if
(
occurrences
==
1
)
{
// Service call for RoleMapping
roleMappingService
.
deleteRole
(
empId
.
toString
(),
roleId
);
}
}
Update
update
=
new
Update
();
update
.
set
(
MyTimeUtils
.
STATUS
,
MyTimeUtils
.
IN_ACTIVE
);
return
mongoTemplate
.
upsert
(
selectedDomainQuery
,
update
,
Domain
.
class
);
}
private
void
saveEmployeeRole
(
Domain
domainReq
)
throws
MyTimeException
{
String
roleId
=
roleInfoService
.
getRole
(
MyTimeUtils
.
DOMAIN
);
List
dmsList
=
domainReq
.
getDeliveryManagers
();
roleMappingService
.
saveUniqueEmployeeAndRole
(
dmsList
,
roleId
);
}
private
List
<
HashMap
<
String
,
String
>>
prepareEmployeeList
(
Domain
domainPersisted
)
{
ArrayList
<
HashMap
<
String
,
String
>>
empList
=
new
ArrayList
<
HashMap
<
String
,
String
>>();
Query
query
=
new
Query
(
Criteria
.
where
(
MyTimeUtils
.
EMPLOYEE_ID
).
in
(
domainPersisted
.
getDeliveryManagers
()));
List
<
Employee
>
employeeList
=
mongoTemplate
.
find
(
query
,
Employee
.
class
);
for
(
Employee
employee
:
employeeList
)
{
HashMap
<
String
,
String
>
employeeMap
=
new
HashMap
<>();
employeeMap
.
put
(
MyTimeUtils
.
EMPLOYEE_ID
,
employee
.
getEmployeeId
());
employeeMap
.
put
(
MyTimeUtils
.
EMPLOYEE_NAME
,
employee
.
getEmployeeName
());
empList
.
add
(
employeeMap
);
}
return
empList
;
}
String
addDomains
(
Domains
d
)
throws
MyTimeException
;
// Custom methods
private
Domain
getDomainById
(
String
domainId
)
{
Query
selectedDomainQuery
=
new
Query
(
Criteria
.
where
(
MyTimeUtils
.
DOMAIN_ID
).
in
(
domainId
).
and
(
MyTimeUtils
.
STATUS
).
in
(
MyTimeUtils
.
ACTIVE
));
List
<
Domain
>
selectedDomain
=
mongoTemplate
.
find
(
selectedDomainQuery
,
Domain
.
class
);
if
(
selectedDomain
.
size
()
==
1
)
return
selectedDomain
.
get
(
0
);
return
null
;
}
List
<
HashMap
<
Object
,
Object
>>
getAllDomains
()
throws
MyTimeException
;
private
boolean
duplicateCheck
(
String
domainName
,
String
accountId
,
List
<
String
>
fromDB
,
List
fromUser
)
{
boolean
check
=
false
;
int
count
=
0
;
List
<
Domain
>
domainListbyAccountId
=
domainRepo
.
findByAccountId
(
accountId
);
boolean
deleveryManagersCheck
=
fromDB
.
toString
().
contentEquals
(
fromUser
.
toString
());
List
<
Domain
>
domainList
=
domainRepo
.
findByDomainNameAndAccountId
(
domainName
,
accountId
);
for
(
Domain
domains
:
domainListbyAccountId
)
{
if
(
domains
.
getDomainName
().
equalsIgnoreCase
(
domainName
))
count
++;
}
if
((
domainList
.
size
()
>
0
&&
deleveryManagersCheck
)
||
count
>
1
)
check
=
true
;
return
check
;
}
String
updateDomain
(
Domains
d
)
throws
MyTimeException
;
@Override
public
Set
<
String
>
accountsAssignedToDeliveryLead
(
String
empId
)
{
Set
<
String
>
accIdsSet
=
new
HashSet
<
String
>();
List
<
Domain
>
domainList
=
domainRepo
.
findByDeliveryManagers
(
empId
);
if
(
null
!=
domainList
&&
!
domainList
.
isEmpty
()
&&
domainList
.
size
()
>
MyTimeUtils
.
INT_ZERO
)
{
for
(
Domain
domain
:
domainList
)
{
accIdsSet
.
add
(
domain
.
getAccountId
());
}
}
return
accIdsSet
;
}
WriteResult
deleteDomain
(
String
id
)
throws
MyTimeException
;
}
}
\ No newline at end of file
src/main/java/com/nisum/mytime/service/DomainServiceImpl.java
deleted
100644 → 0
View file @
35c50907
package
com
.
nisum
.
mytime
.
service
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.mongodb.core.MongoTemplate
;
import
org.springframework.data.mongodb.core.query.Criteria
;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.data.mongodb.core.query.Update
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.StringUtils
;
import
com.mongodb.WriteResult
;
import
com.nisum.mytime.exception.handler.MyTimeException
;
import
com.nisum.mytime.model.Account
;
import
com.nisum.mytime.model.Domains
;
import
com.nisum.mytime.model.EmployeeRoles
;
import
com.nisum.mytime.repository.DomainRepo
;
import
com.nisum.mytime.utils.CommomUtil
;
import
com.nisum.mytime.utils.MyTimeUtils
;
/**
* @author Vijay
*
*/
@Service
public
class
DomainServiceImpl
implements
DomainService
{
List
<
Domains
>
domainList
=
null
;
List
<
HashMap
<
Object
,
Object
>>
updatedDomainList
=
null
;
List
<
HashMap
<
String
,
String
>>
updatedEmployeeList
=
null
;
@Autowired
private
DomainRepo
domainRepo
;
@Autowired
private
MongoTemplate
mongoTemplate
;
@Autowired
private
RoleInfoService
roleInfoService
;
@Autowired
private
RoleMappingService
roleMappingService
;
@Override
public
String
addDomains
(
Domains
d
)
throws
MyTimeException
{
String
response
=
null
;
int
count
=
0
;
List
<
Domains
>
domainList
=
domainRepo
.
findByDomainNameAndAccountId
(
d
.
getDomainName
(),
d
.
getAccountId
());
List
<
Domains
>
domainListbyAccountId
=
domainRepo
.
findByAccountId
(
d
.
getAccountId
());
//Case sensitive logic
for
(
Domains
domains:
domainListbyAccountId
)
{
if
(
domains
.
getDomainName
().
equalsIgnoreCase
(
d
.
getDomainName
()))
count
++;
}
if
(
count
>
0
||
domainList
.
size
()>
0
)
{
return
response
=
"Domain already exists"
;
}
if
(
StringUtils
.
isEmpty
(
d
.
getDomainId
())
&&
d
.
getId
()==
null
)
{
d
.
setDomainId
((
MyTimeUtils
.
DOM
+
MyTimeUtils
.
ZERO_
)
+
(
getAllDomains
().
size
()
+
1
));
}
d
.
setStatus
(
MyTimeUtils
.
ACTIVE
);
if
(
d
.
getId
()==
null
){
response
=
"Domain saved successfully"
;
}
else
{
response
=
"Domain updated successfully"
;
}
domainRepo
.
save
(
d
);
String
roleId
=
roleInfoService
.
getRole
(
MyTimeUtils
.
DOMAIN
);
roleMappingService
.
saveUniqueEmployeeAndRole
(
d
.
getDeliveryManagers
(),
roleId
);
return
response
;
}
@Override
public
List
<
HashMap
<
Object
,
Object
>>
getAllDomains
()
throws
MyTimeException
{
domainList
=
domainRepo
.
findAll
();
updatedDomainList
=
new
ArrayList
<>();
for
(
Domains
domain
:
domainList
)
{
HashMap
<
Object
,
Object
>
domainMap
=
new
HashMap
<>();
domainMap
.
put
(
MyTimeUtils
.
ID_
,
domain
.
getId
());
domainMap
.
put
(
MyTimeUtils
.
DOMAIN_ID
,
domain
.
getDomainId
());
domainMap
.
put
(
MyTimeUtils
.
DOMAIN_NAME
,
domain
.
getDomainName
());
domainMap
.
put
(
MyTimeUtils
.
STATUS
,
domain
.
getStatus
());
domainMap
.
put
(
MyTimeUtils
.
ACCOUNT_ID
,
domain
.
getAccountId
());
Query
accountInfoQuery
=
new
Query
(
Criteria
.
where
(
MyTimeUtils
.
ACCOUNT_ID
).
in
(
domain
.
getAccountId
()));
List
<
Account
>
accountList
=
mongoTemplate
.
find
(
accountInfoQuery
,
Account
.
class
);
if
(
accountList
!=
null
&&
accountList
.
size
()>
0
)
domainMap
.
put
(
MyTimeUtils
.
ACCOUNT_NAME
,
accountList
.
get
(
0
).
getAccountName
());
updatedEmployeeList
=
new
ArrayList
<>();
List
<
String
>
employeeIds
=
domain
.
getDeliveryManagers
();
Query
query
=
new
Query
(
Criteria
.
where
(
MyTimeUtils
.
EMPLOYEE_ID
).
in
(
employeeIds
));
List
<
EmployeeRoles
>
employeeRoles
=
mongoTemplate
.
find
(
query
,
EmployeeRoles
.
class
);
for
(
EmployeeRoles
employeesRole
:
employeeRoles
){
HashMap
<
String
,
String
>
employeeMap
=
new
HashMap
<>();
employeeMap
.
put
(
MyTimeUtils
.
EMPLOYEE_ID
,
employeesRole
.
getEmployeeId
());
employeeMap
.
put
(
MyTimeUtils
.
EMPLOYEE_NAME
,
employeesRole
.
getEmployeeName
());
updatedEmployeeList
.
add
(
employeeMap
);
}
domainMap
.
put
(
MyTimeUtils
.
DELIVERY_MANAGERS
,
updatedEmployeeList
);
updatedDomainList
.
add
(
domainMap
);
}
return
updatedDomainList
;
}
@Override
public
String
updateDomain
(
Domains
d
)
throws
MyTimeException
{
String
response
=
null
;
List
<
String
>
deliveryManagersListFromUser
=
null
;
List
<
String
>
deliveryManagersListFromDb
=
null
;
List
<
String
>
managersAddedByUser
=
null
;
List
<
String
>
managersDeletedByUser
=
null
;
Map
<
String
,
Integer
>
managersDomainCount
=
new
HashMap
<
String
,
Integer
>();
Domains
domainDetailsFromDb
=
getDomainById
(
d
.
getDomainId
());
deliveryManagersListFromUser
=
d
.
getDeliveryManagers
();
if
(
null
!=
domainDetailsFromDb
)
deliveryManagersListFromDb
=
domainDetailsFromDb
.
getDeliveryManagers
();
boolean
isDuplicate
=
duplicateCheck
(
d
.
getDomainName
(),
d
.
getAccountId
(),
deliveryManagersListFromDb
,
d
.
getDeliveryManagers
());
if
(
isDuplicate
)
{
return
response
=
"Domain already exists"
;
}
else
{
response
=
"Domain updated successfully"
;
}
managersAddedByUser
=
CommomUtil
.
getAddedManagersList
(
deliveryManagersListFromDb
,
deliveryManagersListFromUser
);
managersDeletedByUser
=
CommomUtil
.
getDeletedManagersList
(
deliveryManagersListFromDb
,
deliveryManagersListFromUser
);
domainList
=
domainRepo
.
findAll
();
String
roleId
=
roleInfoService
.
getRole
(
MyTimeUtils
.
DOMAIN
);
for
(
Domains
domain
:
domainList
)
{
List
<
String
>
employeeIds
=
domain
.
getDeliveryManagers
();
for
(
String
eId
:
employeeIds
)
{
if
(
managersDomainCount
.
get
(
eId
)!=
null
)
managersDomainCount
.
put
(
eId
,
managersDomainCount
.
get
(
eId
)+
1
);
else
managersDomainCount
.
put
(
eId
,
1
);
}
}
for
(
String
managerId
:
managersDeletedByUser
)
{
if
(
managersDomainCount
.
get
(
managerId
)==
1
)
{
// Call service to delete manager
roleMappingService
.
deleteRole
(
managerId
,
roleId
);
}
}
d
.
setStatus
(
MyTimeUtils
.
ACTIVE
);
domainRepo
.
save
(
d
);
roleMappingService
.
saveUniqueEmployeeAndRole
(
managersAddedByUser
,
roleId
);
return
response
;
}
@Override
public
WriteResult
deleteDomain
(
String
id
)
throws
MyTimeException
{
List
<
String
>
domEmpIds
=
new
ArrayList
<
String
>();
String
roleId
=
roleInfoService
.
getRole
(
MyTimeUtils
.
DOMAIN
);
domainList
=
domainRepo
.
findAll
();
Query
selectedDomainQuery
=
new
Query
(
Criteria
.
where
(
MyTimeUtils
.
DOMAIN_ID
).
in
(
id
).
and
(
MyTimeUtils
.
STATUS
).
in
(
MyTimeUtils
.
ACTIVE
)
);
List
<
Domains
>
selectedDomain
=
mongoTemplate
.
find
(
selectedDomainQuery
,
Domains
.
class
);
for
(
Domains
domain
:
domainList
)
{
List
<
String
>
employeeIds
=
domain
.
getDeliveryManagers
();
for
(
String
eIds:
employeeIds
)
domEmpIds
.
add
(
eIds
);
}
for
(
String
empId
:
selectedDomain
.
get
(
0
).
getDeliveryManagers
())
{
int
occurrences
=
Collections
.
frequency
(
domEmpIds
,
empId
);
if
(
occurrences
==
1
)
{
//Service call for RoleMapping
roleMappingService
.
deleteRole
(
empId
,
roleId
);
}
}
Update
update
=
new
Update
();
update
.
set
(
MyTimeUtils
.
STATUS
,
MyTimeUtils
.
IN_ACTIVE
);
return
mongoTemplate
.
upsert
(
selectedDomainQuery
,
update
,
Domains
.
class
);
}
//Custom methods
private
Domains
getDomainById
(
String
id
)
{
Query
selectedDomainQuery
=
new
Query
(
Criteria
.
where
(
MyTimeUtils
.
DOMAIN_ID
).
in
(
id
).
and
(
MyTimeUtils
.
STATUS
).
in
(
MyTimeUtils
.
ACTIVE
)
);
List
<
Domains
>
selectedDomain
=
mongoTemplate
.
find
(
selectedDomainQuery
,
Domains
.
class
);
if
(
selectedDomain
.
size
()==
1
)
return
selectedDomain
.
get
(
0
);
return
null
;
}
private
boolean
duplicateCheck
(
String
domainName
,
String
accountId
,
List
<
String
>
fromDB
,
List
<
String
>
fromUser
)
{
boolean
check
=
false
;
int
count
=
0
;
List
<
Domains
>
domainListbyAccountId
=
domainRepo
.
findByAccountId
(
accountId
);
boolean
deleveryManagersCheck
=
fromDB
.
toString
().
contentEquals
(
fromUser
.
toString
());
List
<
Domains
>
domainList
=
domainRepo
.
findByDomainNameAndAccountId
(
domainName
,
accountId
);
for
(
Domains
domains:
domainListbyAccountId
)
{
if
(
domains
.
getDomainName
().
equalsIgnoreCase
(
domainName
))
count
++;
}
if
((
domainList
.
size
()>
0
&&
deleveryManagersCheck
)
||
count
>
1
)
check
=
true
;
return
check
;
}
}
\ No newline at end of file
src/main/java/com/nisum/mytime/service/IDomainService.java
0 → 100644
View file @
65c9aaa9
package
com
.
nisum
.
mytime
.
service
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Set
;
import
org.springframework.stereotype.Service
;
import
com.mongodb.WriteResult
;
import
com.nisum.mytime.exception.handler.MyTimeException
;
import
com.nisum.mytime.model.Domain
;
/**
* @author Vijay
*
*/
@Service
public
interface
IDomainService
{
boolean
isDomainExists
(
Domain
domainReq
);
Domain
create
(
Domain
domain
)
throws
MyTimeException
;
// List<HashMap<Object,Object>> getAllDomains() throws MyTimeException;
Domain
update
(
Domain
domain
)
throws
MyTimeException
;
WriteResult
delete
(
String
id
)
throws
MyTimeException
;
List
<
Domain
>
getDomainsList
()
throws
MyTimeException
;
Set
<
String
>
accountsAssignedToDeliveryLead
(
String
empId
)
throws
MyTimeException
;
}
src/main/java/com/nisum/mytime/service/ProjectService.java
View file @
65c9aaa9
...
@@ -10,7 +10,7 @@ import com.nisum.mytime.exception.handler.MyTimeException;
...
@@ -10,7 +10,7 @@ import com.nisum.mytime.exception.handler.MyTimeException;
import
com.nisum.mytime.model.BillingDetails
;
import
com.nisum.mytime.model.BillingDetails
;
import
com.nisum.mytime.model.EmpLoginData
;
import
com.nisum.mytime.model.EmpLoginData
;
import
com.nisum.mytime.model.EmployeeDashboardVO
;
import
com.nisum.mytime.model.EmployeeDashboardVO
;
import
com.nisum.mytime.model.Employee
Roles
;
import
com.nisum.mytime.model.Employee
;
import
com.nisum.mytime.model.Project
;
import
com.nisum.mytime.model.Project
;
import
com.nisum.mytime.model.ProjectTeamMate
;
import
com.nisum.mytime.model.ProjectTeamMate
;
...
@@ -26,13 +26,13 @@ public interface ProjectService {
...
@@ -26,13 +26,13 @@ public interface ProjectService {
String
generatePdfReport
(
long
id
,
String
fromDate
,
String
toDate
)
String
generatePdfReport
(
long
id
,
String
fromDate
,
String
toDate
)
throws
MyTimeException
;
throws
MyTimeException
;
Employee
Roles
getEmployeesRole
(
String
emailId
);
Employee
getEmployeesRole
(
String
emailId
);
void
deleteProject
(
String
projectId
);
void
deleteProject
(
String
projectId
);
Project
updateProject
(
Project
project
,
String
loginEmpId
)
throws
MyTimeException
;
Project
updateProject
(
Project
project
,
String
loginEmpId
)
throws
MyTimeException
;
Employee
Roles
getEmployeesRoleData
(
String
empId
);
Employee
getEmployeesRoleData
(
String
empId
);
List
<
ProjectTeamMate
>
getTeamDetails
(
String
empId
);
List
<
ProjectTeamMate
>
getTeamDetails
(
String
empId
);
...
@@ -50,7 +50,7 @@ public interface ProjectService {
...
@@ -50,7 +50,7 @@ public interface ProjectService {
List
<
ProjectTeamMate
>
getMyTeamDetails
(
String
empId
);
List
<
ProjectTeamMate
>
getMyTeamDetails
(
String
empId
);
List
<
Employee
Roles
>
getUnAssignedEmployees
();
List
<
Employee
>
getUnAssignedEmployees
();
List
<
ProjectTeamMate
>
getShiftDetails
(
String
shift
);
List
<
ProjectTeamMate
>
getShiftDetails
(
String
shift
);
...
...
src/main/java/com/nisum/mytime/service/ProjectServiceImpl.java
View file @
65c9aaa9
...
@@ -29,11 +29,11 @@ import com.nisum.mytime.controller.DomainController;
...
@@ -29,11 +29,11 @@ import com.nisum.mytime.controller.DomainController;
import
com.nisum.mytime.exception.handler.MyTimeException
;
import
com.nisum.mytime.exception.handler.MyTimeException
;
import
com.nisum.mytime.model.Account
;
import
com.nisum.mytime.model.Account
;
import
com.nisum.mytime.model.BillingDetails
;
import
com.nisum.mytime.model.BillingDetails
;
import
com.nisum.mytime.model.Domain
s
;
import
com.nisum.mytime.model.Domain
;
import
com.nisum.mytime.model.EmpLoginData
;
import
com.nisum.mytime.model.EmpLoginData
;
import
com.nisum.mytime.model.EmpShiftDetails
;
import
com.nisum.mytime.model.EmpShiftDetails
;
import
com.nisum.mytime.model.EmployeeDashboardVO
;
import
com.nisum.mytime.model.EmployeeDashboardVO
;
import
com.nisum.mytime.model.Employee
Roles
;
import
com.nisum.mytime.model.Employee
;
import
com.nisum.mytime.model.Project
;
import
com.nisum.mytime.model.Project
;
import
com.nisum.mytime.model.ProjectTeamMate
;
import
com.nisum.mytime.model.ProjectTeamMate
;
import
com.nisum.mytime.repository.AccountRepo
;
import
com.nisum.mytime.repository.AccountRepo
;
...
@@ -90,7 +90,7 @@ public class ProjectServiceImpl implements ProjectService {
...
@@ -90,7 +90,7 @@ public class ProjectServiceImpl implements ProjectService {
private
DomainRepo
domainRepo
;
private
DomainRepo
domainRepo
;
@Autowired
@Autowired
private
ProjectService
project
Service
;
private
IDomainService
domain
Service
;
@Override
@Override
public
List
<
EmpLoginData
>
employeeLoginsBasedOnDate
(
long
id
,
public
List
<
EmpLoginData
>
employeeLoginsBasedOnDate
(
long
id
,
...
@@ -120,7 +120,7 @@ public class ProjectServiceImpl implements ProjectService {
...
@@ -120,7 +120,7 @@ public class ProjectServiceImpl implements ProjectService {
projectMap
.
put
(
"projectId"
,
p
.
getProjectId
());
projectMap
.
put
(
"projectId"
,
p
.
getProjectId
());
projectMap
.
put
(
"projectName"
,
p
.
getProjectName
());
projectMap
.
put
(
"projectName"
,
p
.
getProjectName
());
Account
account
=
accountRepo
.
findByAccountId
(
p
.
getAccountId
());
Account
account
=
accountRepo
.
findByAccountId
(
p
.
getAccountId
());
Domain
s
domain
=
domainRepo
.
findByDomainId
(
p
.
getDomainId
());
Domain
domain
=
domainRepo
.
findByDomainId
(
p
.
getDomainId
());
if
(
domain
!=
null
)
if
(
domain
!=
null
)
projectMap
.
put
(
"domain"
,
domain
.
getDomainName
());
projectMap
.
put
(
"domain"
,
domain
.
getDomainName
());
if
(
account
!=
null
)
if
(
account
!=
null
)
...
@@ -157,15 +157,15 @@ public class ProjectServiceImpl implements ProjectService {
...
@@ -157,15 +157,15 @@ public class ProjectServiceImpl implements ProjectService {
@Override
@Override
public
Project
addProject
(
Project
project
,
String
loginEmpId
)
throws
MyTimeException
{
public
Project
addProject
(
Project
project
,
String
loginEmpId
)
throws
MyTimeException
{
if
(
project
.
getDomainId
()
==
null
)
{
if
(
project
.
getDomainId
()
==
null
)
{
Domain
s
domain
=
new
Domains
();
Domain
domain
=
new
Domain
();
domain
.
setAccountId
(
project
.
getAccountId
());
domain
.
setAccountId
(
project
.
getAccountId
());
domain
.
setDomainName
(
project
.
getDomain
());
domain
.
setDomainName
(
project
.
getDomain
());
domain
.
setDeliveryManagers
(
project
.
getManagerIds
());
domain
.
setDeliveryManagers
(
project
.
getManagerIds
());
domain
.
setStatus
(
project
.
getStatus
());
domain
.
setStatus
(
project
.
getStatus
());
domainController
.
addDomain
(
domain
);
domainController
.
createDomain
(
domain
,
null
);
List
<
Domain
s
>
domainsList
=
domainRepo
List
<
Domain
>
domainsList
=
domainRepo
.
findByAccountId
(
project
.
getAccountId
());
.
findByAccountId
(
project
.
getAccountId
());
Domain
s
savedDomain
=
domainsList
.
get
(
0
);
Domain
savedDomain
=
domainsList
.
get
(
0
);
project
.
setDomainId
(
savedDomain
.
getDomainId
());
project
.
setDomainId
(
savedDomain
.
getDomainId
());
project
.
setDomain
(
savedDomain
.
getDomainName
());
project
.
setDomain
(
savedDomain
.
getDomainName
());
}
}
...
@@ -174,7 +174,7 @@ public class ProjectServiceImpl implements ProjectService {
...
@@ -174,7 +174,7 @@ public class ProjectServiceImpl implements ProjectService {
}
}
@Override
@Override
public
Employee
Roles
getEmployeesRole
(
String
emailId
)
{
public
Employee
getEmployeesRole
(
String
emailId
)
{
return
employeeRolesRepo
.
findByEmailId
(
emailId
);
return
employeeRolesRepo
.
findByEmailId
(
emailId
);
}
}
...
@@ -305,7 +305,7 @@ public class ProjectServiceImpl implements ProjectService {
...
@@ -305,7 +305,7 @@ public class ProjectServiceImpl implements ProjectService {
}
}
@Override
@Override
public
Employee
Roles
getEmployeesRoleData
(
String
employeeId
)
{
public
Employee
getEmployeesRoleData
(
String
employeeId
)
{
return
employeeRolesRepo
.
findByEmployeeId
(
employeeId
);
return
employeeRolesRepo
.
findByEmployeeId
(
employeeId
);
}
}
...
@@ -555,7 +555,7 @@ public class ProjectServiceImpl implements ProjectService {
...
@@ -555,7 +555,7 @@ public class ProjectServiceImpl implements ProjectService {
||
(
projectTeamMate
.
getShift
()
!=
null
)
&&
!
projectTeamMate
.
getShift
().
equalsIgnoreCase
(
existingTeammate
.
getShift
()))
{
||
(
projectTeamMate
.
getShift
()
!=
null
)
&&
!
projectTeamMate
.
getShift
().
equalsIgnoreCase
(
existingTeammate
.
getShift
()))
{
updateShiftDetails
(
existingTeammate
,
loginEmpId
);
updateShiftDetails
(
existingTeammate
,
loginEmpId
);
existingTeammate
.
setShift
(
projectTeamMate
.
getShift
());
existingTeammate
.
setShift
(
projectTeamMate
.
getShift
());
Employee
Roles
employeeDB
=
employeeRolesRepo
.
findByEmployeeId
(
projectTeamMate
.
getEmployeeId
());
Employee
employeeDB
=
employeeRolesRepo
.
findByEmployeeId
(
projectTeamMate
.
getEmployeeId
());
employeeDB
.
setShift
(
projectTeamMate
.
getShift
());
employeeDB
.
setShift
(
projectTeamMate
.
getShift
());
employeeDB
.
setModifiedBy
(
loginEmpId
);
employeeDB
.
setModifiedBy
(
loginEmpId
);
employeeDB
.
setLastModifiedOn
(
new
Date
());
employeeDB
.
setLastModifiedOn
(
new
Date
());
...
@@ -691,9 +691,9 @@ public class ProjectServiceImpl implements ProjectService {
...
@@ -691,9 +691,9 @@ public class ProjectServiceImpl implements ProjectService {
}
}
@Override
@Override
public
List
<
Employee
Roles
>
getUnAssignedEmployees
()
{
public
List
<
Employee
>
getUnAssignedEmployees
()
{
List
<
Employee
Roles
>
allEmployees
=
employeeRolesRepo
.
findAll
();
List
<
Employee
>
allEmployees
=
employeeRolesRepo
.
findAll
();
List
<
Employee
Roles
>
notAssignedEmployees
=
new
ArrayList
<>();
List
<
Employee
>
notAssignedEmployees
=
new
ArrayList
<>();
List
<
String
>
teamMates
=
new
ArrayList
<>();
List
<
String
>
teamMates
=
new
ArrayList
<>();
List
<
ProjectTeamMate
>
empRecords
=
projectTeamMatesRepo
.
findAll
();
List
<
ProjectTeamMate
>
empRecords
=
projectTeamMatesRepo
.
findAll
();
for
(
ProjectTeamMate
pt
:
empRecords
)
{
for
(
ProjectTeamMate
pt
:
empRecords
)
{
...
@@ -703,7 +703,7 @@ public class ProjectServiceImpl implements ProjectService {
...
@@ -703,7 +703,7 @@ public class ProjectServiceImpl implements ProjectService {
teamMates
.
add
(
pt
.
getEmployeeId
());
teamMates
.
add
(
pt
.
getEmployeeId
());
}
}
}
}
for
(
Employee
Roles
emp
:
allEmployees
)
{
for
(
Employee
emp
:
allEmployees
)
{
if
(!
teamMates
.
contains
(
emp
.
getEmployeeId
()))
{
if
(!
teamMates
.
contains
(
emp
.
getEmployeeId
()))
{
notAssignedEmployees
.
add
(
emp
);
notAssignedEmployees
.
add
(
emp
);
...
@@ -912,7 +912,7 @@ public class ProjectServiceImpl implements ProjectService {
...
@@ -912,7 +912,7 @@ public class ProjectServiceImpl implements ProjectService {
@Override
@Override
public
List
<
EmployeeDashboardVO
>
getEmployeesDashBoard
()
{
public
List
<
EmployeeDashboardVO
>
getEmployeesDashBoard
()
{
List
<
Employee
Roles
>
allEmployees
=
employeeRolesRepo
.
findAll
();
List
<
Employee
>
allEmployees
=
employeeRolesRepo
.
findAll
();
List
<
EmployeeDashboardVO
>
employeeDashboard
=
new
ArrayList
<>();
List
<
EmployeeDashboardVO
>
employeeDashboard
=
new
ArrayList
<>();
Map
<
String
,
Object
>
teamMatesMap
=
new
HashMap
();
Map
<
String
,
Object
>
teamMatesMap
=
new
HashMap
();
Map
<
String
,
Object
>
teamMatesStatusMap
=
new
HashMap
();
Map
<
String
,
Object
>
teamMatesStatusMap
=
new
HashMap
();
...
@@ -944,7 +944,7 @@ public class ProjectServiceImpl implements ProjectService {
...
@@ -944,7 +944,7 @@ public class ProjectServiceImpl implements ProjectService {
}
}
}
}
}
}
for
(
Employee
Roles
emp
:
allEmployees
)
{
for
(
Employee
emp
:
allEmployees
)
{
if
(
teamMatesMap
.
containsKey
(
emp
.
getEmployeeId
()))
{
if
(
teamMatesMap
.
containsKey
(
emp
.
getEmployeeId
()))
{
Object
value
=
teamMatesMap
.
get
(
emp
.
getEmployeeId
());
Object
value
=
teamMatesMap
.
get
(
emp
.
getEmployeeId
());
if
(
value
instanceof
List
)
{
if
(
value
instanceof
List
)
{
...
@@ -986,9 +986,9 @@ public class ProjectServiceImpl implements ProjectService {
...
@@ -986,9 +986,9 @@ public class ProjectServiceImpl implements ProjectService {
List
<
HashMap
<
String
,
String
>>
EmployeeList
=
new
ArrayList
<>();
List
<
HashMap
<
String
,
String
>>
EmployeeList
=
new
ArrayList
<>();
Query
query
=
new
Query
(
Criteria
.
where
(
"employeeId"
).
in
(
ids
));
Query
query
=
new
Query
(
Criteria
.
where
(
"employeeId"
).
in
(
ids
));
List
<
Employee
Roles
>
employeeRoles
=
mongoTemplate
.
find
(
query
,
List
<
Employee
>
employeeRoles
=
mongoTemplate
.
find
(
query
,
Employee
Roles
.
class
);
Employee
.
class
);
for
(
Employee
Roles
employeesRole
:
employeeRoles
)
{
for
(
Employee
employeesRole
:
employeeRoles
)
{
HashMap
<
String
,
String
>
managerMap
=
new
HashMap
<>();
HashMap
<
String
,
String
>
managerMap
=
new
HashMap
<>();
managerMap
.
put
(
"employeeId"
,
employeesRole
.
getEmployeeId
());
managerMap
.
put
(
"employeeId"
,
employeesRole
.
getEmployeeId
());
managerMap
.
put
(
"employeeName"
,
employeesRole
.
getEmployeeName
());
managerMap
.
put
(
"employeeName"
,
employeesRole
.
getEmployeeName
());
...
@@ -1063,7 +1063,7 @@ public class ProjectServiceImpl implements ProjectService {
...
@@ -1063,7 +1063,7 @@ public class ProjectServiceImpl implements ProjectService {
Project
project
=
null
;
Project
project
=
null
;
Account
account
=
null
;
Account
account
=
null
;
Domain
s
domain
=
null
;
Domain
domain
=
null
;
List
<
ProjectTeamMate
>
projectAllocations
=
getMyProjectAllocations
(
empId
);
List
<
ProjectTeamMate
>
projectAllocations
=
getMyProjectAllocations
(
empId
);
...
@@ -1128,12 +1128,12 @@ public class ProjectServiceImpl implements ProjectService {
...
@@ -1128,12 +1128,12 @@ public class ProjectServiceImpl implements ProjectService {
public
List
<
HashMap
<
Object
,
Object
>>
deliveryLeadProjects
(
String
empId
)
throws
MyTimeException
{
public
List
<
HashMap
<
Object
,
Object
>>
deliveryLeadProjects
(
String
empId
)
throws
MyTimeException
{
List
<
HashMap
<
Object
,
Object
>>
projectsList
=
new
ArrayList
<
HashMap
<
Object
,
Object
>>
();
List
<
HashMap
<
Object
,
Object
>>
projectsList
=
new
ArrayList
<
HashMap
<
Object
,
Object
>>
();
Set
<
String
>
accIdsSet
=
projectService
.
accountsAssignedToDl
(
empId
);
Set
<
String
>
accIdsSet
=
domainService
.
accountsAssignedToDeliveryLead
(
empId
);
List
<
Project
>
prjts
=
projectRepo
.
findByAccountIdIn
(
accIdsSet
);
List
<
Project
>
prjts
=
projectRepo
.
findByAccountIdIn
(
accIdsSet
);
if
(
null
!=
prjts
&&
!
prjts
.
isEmpty
()
&&
MyTimeUtils
.
INT_ZERO
<
prjts
.
size
())
{
if
(
null
!=
prjts
&&
!
prjts
.
isEmpty
()
&&
MyTimeUtils
.
INT_ZERO
<
prjts
.
size
())
{
Account
account
=
null
;
Account
account
=
null
;
Domain
s
domain
=
null
;
Domain
domain
=
null
;
HashMap
<
Object
,
Object
>
projectMap
=
null
;
HashMap
<
Object
,
Object
>
projectMap
=
null
;
...
...
src/main/java/com/nisum/mytime/service/UserService.java
View file @
65c9aaa9
...
@@ -10,10 +10,10 @@ import com.nisum.mytime.exception.handler.MyTimeException;
...
@@ -10,10 +10,10 @@ import com.nisum.mytime.exception.handler.MyTimeException;
import
com.nisum.mytime.model.Account
;
import
com.nisum.mytime.model.Account
;
import
com.nisum.mytime.model.AccountInfo
;
import
com.nisum.mytime.model.AccountInfo
;
import
com.nisum.mytime.model.Designation
;
import
com.nisum.mytime.model.Designation
;
import
com.nisum.mytime.model.Domain
s
;
import
com.nisum.mytime.model.Domain
;
import
com.nisum.mytime.model.EmpLoginData
;
import
com.nisum.mytime.model.EmpLoginData
;
import
com.nisum.mytime.model.EmployeeLocationDetails
;
import
com.nisum.mytime.model.EmployeeLocationDetails
;
import
com.nisum.mytime.model.Employee
Roles
;
import
com.nisum.mytime.model.Employee
;
import
com.nisum.mytime.model.Location
;
import
com.nisum.mytime.model.Location
;
import
com.nisum.mytime.model.MasterData
;
import
com.nisum.mytime.model.MasterData
;
import
com.nisum.mytime.model.Shift
;
import
com.nisum.mytime.model.Shift
;
...
@@ -27,9 +27,9 @@ public interface UserService {
...
@@ -27,9 +27,9 @@ public interface UserService {
List
<
EmpLoginData
>
employeeLoginsBasedOnDate
(
long
id
,
String
fromDate
,
List
<
EmpLoginData
>
employeeLoginsBasedOnDate
(
long
id
,
String
fromDate
,
String
toDate
)
throws
MyTimeException
;
String
toDate
)
throws
MyTimeException
;
List
<
Employee
Roles
>
getEmployeeRoles
()
throws
MyTimeException
;
List
<
Employee
>
getEmployeeRoles
()
throws
MyTimeException
;
Employee
Roles
assigingEmployeeRole
(
EmployeeRoles
employeeRoles
,
String
empId
)
Employee
assigingEmployeeRole
(
Employee
employeeRoles
,
String
empId
)
throws
MyTimeException
;
throws
MyTimeException
;
List
generatePdfReport
(
long
id
,
String
fromDate
,
String
toDate
)
List
generatePdfReport
(
long
id
,
String
fromDate
,
String
toDate
)
...
@@ -38,18 +38,18 @@ public interface UserService {
...
@@ -38,18 +38,18 @@ public interface UserService {
List
generatePdfReport
(
long
id
,
String
fromDate
,
String
toDate
,
String
fromTime
,
String
toTime
)
List
generatePdfReport
(
long
id
,
String
fromDate
,
String
toDate
,
String
fromTime
,
String
toTime
)
throws
MyTimeException
,
ParseException
;
throws
MyTimeException
,
ParseException
;
Employee
Roles
getEmployeesRole
(
String
emailId
);
Employee
getEmployeesRole
(
String
emailId
);
void
deleteEmployee
(
String
empId
);
void
deleteEmployee
(
String
empId
);
Employee
Roles
updateEmployeeRole
(
EmployeeRoles
employeeRoles
,
String
empId
);
Employee
updateEmployeeRole
(
Employee
employeeRoles
,
String
empId
);
void
updateEmployeeLocationDetails
(
Employee
Roles
employeeRoles
,
void
updateEmployeeLocationDetails
(
Employee
employeeRoles
,
boolean
delete
);
boolean
delete
);
void
saveEmployeeLocationDetails
(
Employee
Roles
employeeRoles
);
void
saveEmployeeLocationDetails
(
Employee
employeeRoles
);
Employee
Roles
getEmployeesRoleData
(
String
empId
);
Employee
getEmployeesRoleData
(
String
empId
);
List
<
EmployeeLocationDetails
>
getEmployeeLocationDetails
(
String
empId
);
List
<
EmployeeLocationDetails
>
getEmployeeLocationDetails
(
String
empId
);
...
@@ -59,29 +59,29 @@ public interface UserService {
...
@@ -59,29 +59,29 @@ public interface UserService {
List
<
Skill
>
getTechnologies
()
throws
MyTimeException
;
List
<
Skill
>
getTechnologies
()
throws
MyTimeException
;
public
Employee
Roles
updateProfile
(
EmployeeRoles
employeeRoles
)
public
Employee
updateProfile
(
Employee
employeeRoles
)
throws
MyTimeException
;
throws
MyTimeException
;
public
List
<
Account
>
getAccounts
()
throws
MyTimeException
;
public
List
<
Account
>
getAccounts
()
throws
MyTimeException
;
List
<
Location
>
getLocations
()
throws
MyTimeException
;
List
<
Location
>
getLocations
()
throws
MyTimeException
;
Employee
Roles
getEmployeeRoleDataForSearchCriteria
(
String
searchId
,
Employee
getEmployeeRoleDataForSearchCriteria
(
String
searchId
,
String
searchAttribute
);
String
searchAttribute
);
List
<
String
>
getEmployeeDetailsForAutocomplete
();
List
<
String
>
getEmployeeDetailsForAutocomplete
();
List
<
MasterData
>
getMasterData
()
throws
MyTimeException
;
List
<
MasterData
>
getMasterData
()
throws
MyTimeException
;
List
<
Employee
Roles
>
getEmployeesByFunctionalGrp
(
String
functionalGrp
);
List
<
Employee
>
getEmployeesByFunctionalGrp
(
String
functionalGrp
);
List
<
Employee
Roles
>
getEmployeesByStatus
(
String
status
);
List
<
Employee
>
getEmployeesByStatus
(
String
status
);
List
<
HashMap
<
String
,
String
>>
getDeliveryLeads
(
String
domainId
);
List
<
HashMap
<
String
,
String
>>
getDeliveryLeads
(
String
domainId
);
public
List
<
AccountInfo
>
getAccountsInfo
()
throws
MyTimeException
;
public
List
<
AccountInfo
>
getAccountsInfo
()
throws
MyTimeException
;
public
List
<
Domain
s
>
getDomains
(
String
accountId
)
throws
MyTimeException
;
public
List
<
Domain
>
getDomains
(
String
accountId
)
throws
MyTimeException
;
public
boolean
verifyRole
(
String
empId
,
String
roleName
);
public
boolean
verifyRole
(
String
empId
,
String
roleName
);
...
...
src/main/java/com/nisum/mytime/service/UserServiceImpl.java
View file @
65c9aaa9
...
@@ -27,11 +27,11 @@ import com.nisum.mytime.model.Account;
...
@@ -27,11 +27,11 @@ import com.nisum.mytime.model.Account;
import
com.nisum.mytime.model.AccountInfo
;
import
com.nisum.mytime.model.AccountInfo
;
import
com.nisum.mytime.model.BillingDetails
;
import
com.nisum.mytime.model.BillingDetails
;
import
com.nisum.mytime.model.Designation
;
import
com.nisum.mytime.model.Designation
;
import
com.nisum.mytime.model.Domain
s
;
import
com.nisum.mytime.model.Domain
;
import
com.nisum.mytime.model.EmpLoginData
;
import
com.nisum.mytime.model.EmpLoginData
;
import
com.nisum.mytime.model.EmpShiftDetails
;
import
com.nisum.mytime.model.EmpShiftDetails
;
import
com.nisum.mytime.model.EmployeeLocationDetails
;
import
com.nisum.mytime.model.EmployeeLocationDetails
;
import
com.nisum.mytime.model.Employee
Roles
;
import
com.nisum.mytime.model.Employee
;
import
com.nisum.mytime.model.Location
;
import
com.nisum.mytime.model.Location
;
import
com.nisum.mytime.model.MasterData
;
import
com.nisum.mytime.model.MasterData
;
import
com.nisum.mytime.model.Project
;
import
com.nisum.mytime.model.Project
;
...
@@ -140,13 +140,13 @@ public class UserServiceImpl implements UserService {
...
@@ -140,13 +140,13 @@ public class UserServiceImpl implements UserService {
}
}
@Override
@Override
public
List
<
Employee
Roles
>
getEmployeeRoles
()
throws
MyTimeException
{
public
List
<
Employee
>
getEmployeeRoles
()
throws
MyTimeException
{
//return employeeRolesRepo.findAll();
//return employeeRolesRepo.findAll();
return
employeeRolesRepo
.
findByEmpStatus
(
MyTimeUtils
.
ACTIVE
);
return
employeeRolesRepo
.
findByEmpStatus
(
MyTimeUtils
.
ACTIVE
);
}
}
@Override
@Override
public
Employee
Roles
assigingEmployeeRole
(
EmployeeRoles
employeeRoles
,
String
loginEmpId
)
public
Employee
assigingEmployeeRole
(
Employee
employeeRoles
,
String
loginEmpId
)
throws
MyTimeException
{
throws
MyTimeException
{
employeeRoles
.
setCreatedOn
(
new
Date
());
employeeRoles
.
setCreatedOn
(
new
Date
());
employeeRoles
.
setCreatedBy
(
loginEmpId
);
employeeRoles
.
setCreatedBy
(
loginEmpId
);
...
@@ -189,19 +189,19 @@ public class UserServiceImpl implements UserService {
...
@@ -189,19 +189,19 @@ public class UserServiceImpl implements UserService {
}
}
@Override
@Override
public
Employee
Roles
getEmployeesRole
(
String
emailId
)
{
public
Employee
getEmployeesRole
(
String
emailId
)
{
return
employeeRolesRepo
.
findByEmailId
(
emailId
);
return
employeeRolesRepo
.
findByEmailId
(
emailId
);
}
}
@Override
@Override
public
void
deleteEmployee
(
String
employeeId
)
{
public
void
deleteEmployee
(
String
employeeId
)
{
Employee
Roles
role
=
employeeRolesRepo
.
findByEmployeeId
(
employeeId
);
Employee
role
=
employeeRolesRepo
.
findByEmployeeId
(
employeeId
);
employeeRolesRepo
.
delete
(
role
);
employeeRolesRepo
.
delete
(
role
);
}
}
@Override
@Override
public
Employee
Roles
updateEmployeeRole
(
EmployeeRoles
employeeRoles
,
String
loginEmpId
)
{
public
Employee
updateEmployeeRole
(
Employee
employeeRoles
,
String
loginEmpId
)
{
// update all emp details to inactive if employee is inactive
// update all emp details to inactive if employee is inactive
Query
query
=
new
Query
(
Criteria
.
where
(
"employeeId"
).
is
(
employeeRoles
.
getEmployeeId
()));
Query
query
=
new
Query
(
Criteria
.
where
(
"employeeId"
).
is
(
employeeRoles
.
getEmployeeId
()));
Update
update
=
new
Update
();
Update
update
=
new
Update
();
...
@@ -230,7 +230,7 @@ public class UserServiceImpl implements UserService {
...
@@ -230,7 +230,7 @@ public class UserServiceImpl implements UserService {
}
}
// update employee location
// update employee location
if
(
employeeRoles
.
getEmpLocation
()
!=
null
&&
!
employeeRoles
.
getEmpLocation
().
equals
(
""
))
{
if
(
employeeRoles
.
getEmpLocation
()
!=
null
&&
!
employeeRoles
.
getEmpLocation
().
equals
(
""
))
{
Employee
Roles
existingEmployee
=
employeeRolesRepo
.
findByEmployeeId
(
employeeRoles
.
getEmployeeId
());
Employee
existingEmployee
=
employeeRolesRepo
.
findByEmployeeId
(
employeeRoles
.
getEmployeeId
());
if
(!
existingEmployee
.
getEmpLocation
().
equals
(
employeeRoles
.
getEmpLocation
()))
{
if
(!
existingEmployee
.
getEmpLocation
().
equals
(
employeeRoles
.
getEmpLocation
()))
{
updateEmployeeLocationDetails
(
employeeRoles
,
false
);
updateEmployeeLocationDetails
(
employeeRoles
,
false
);
}
}
...
@@ -241,11 +241,11 @@ public class UserServiceImpl implements UserService {
...
@@ -241,11 +241,11 @@ public class UserServiceImpl implements UserService {
FindAndModifyOptions
options
=
new
FindAndModifyOptions
();
FindAndModifyOptions
options
=
new
FindAndModifyOptions
();
options
.
returnNew
(
true
);
options
.
returnNew
(
true
);
options
.
upsert
(
true
);
options
.
upsert
(
true
);
Employee
Roles
emp
=
mongoTemplate
.
findAndModify
(
query
,
update
,
options
,
EmployeeRoles
.
class
);
Employee
emp
=
mongoTemplate
.
findAndModify
(
query
,
update
,
options
,
Employee
.
class
);
try
{
try
{
// update employee location
// update employee location
if
(
employeeRoles
.
getEmpLocation
()
!=
null
&&
!
employeeRoles
.
getEmpLocation
().
equals
(
""
))
{
if
(
employeeRoles
.
getEmpLocation
()
!=
null
&&
!
employeeRoles
.
getEmpLocation
().
equals
(
""
))
{
Employee
Roles
existingEmployee
=
employeeRolesRepo
.
findByEmployeeId
(
employeeRoles
.
getEmployeeId
());
Employee
existingEmployee
=
employeeRolesRepo
.
findByEmployeeId
(
employeeRoles
.
getEmployeeId
());
if
(!
existingEmployee
.
getEmpLocation
().
equals
(
employeeRoles
.
getEmpLocation
()))
{
if
(!
existingEmployee
.
getEmpLocation
().
equals
(
employeeRoles
.
getEmpLocation
()))
{
updateEmployeeLocationDetails
(
employeeRoles
,
false
);
updateEmployeeLocationDetails
(
employeeRoles
,
false
);
}
}
...
@@ -290,7 +290,7 @@ public class UserServiceImpl implements UserService {
...
@@ -290,7 +290,7 @@ public class UserServiceImpl implements UserService {
}
}
@Override
@Override
public
Employee
Roles
getEmployeesRoleData
(
String
employeeId
)
{
public
Employee
getEmployeesRoleData
(
String
employeeId
)
{
return
employeeRolesRepo
.
findByEmployeeId
(
employeeId
);
return
employeeRolesRepo
.
findByEmployeeId
(
employeeId
);
}
}
...
@@ -320,11 +320,11 @@ public class UserServiceImpl implements UserService {
...
@@ -320,11 +320,11 @@ public class UserServiceImpl implements UserService {
}
}
@Override
@Override
public
Employee
Roles
updateProfile
(
EmployeeRoles
employeeRoles
)
public
Employee
updateProfile
(
Employee
employeeRoles
)
throws
MyTimeException
{
throws
MyTimeException
{
boolean
mobileNumberChanged
=
false
;
boolean
mobileNumberChanged
=
false
;
employeeRoles
.
setLastModifiedOn
(
new
Date
());
employeeRoles
.
setLastModifiedOn
(
new
Date
());
Employee
Roles
existingEmployee
=
employeeRolesRepo
Employee
existingEmployee
=
employeeRolesRepo
.
findByEmployeeId
(
employeeRoles
.
getEmployeeId
());
.
findByEmployeeId
(
employeeRoles
.
getEmployeeId
());
String
newMobileNumber
=
employeeRoles
.
getMobileNumber
();
String
newMobileNumber
=
employeeRoles
.
getMobileNumber
();
if
(
newMobileNumber
!=
null
&&
!
newMobileNumber
.
equalsIgnoreCase
(
""
))
{
if
(
newMobileNumber
!=
null
&&
!
newMobileNumber
.
equalsIgnoreCase
(
""
))
{
...
@@ -341,7 +341,7 @@ public class UserServiceImpl implements UserService {
...
@@ -341,7 +341,7 @@ public class UserServiceImpl implements UserService {
existingEmployee
.
setPersonalEmailId
(
employeeRoles
.
getPersonalEmailId
());
existingEmployee
.
setPersonalEmailId
(
employeeRoles
.
getPersonalEmailId
());
existingEmployee
.
setBaseTechnology
(
employeeRoles
.
getBaseTechnology
());
existingEmployee
.
setBaseTechnology
(
employeeRoles
.
getBaseTechnology
());
existingEmployee
.
setTechnologyKnown
(
employeeRoles
.
getTechnologyKnown
());
existingEmployee
.
setTechnologyKnown
(
employeeRoles
.
getTechnologyKnown
());
Employee
Roles
employeeRolesDB
=
employeeRolesRepo
.
save
(
existingEmployee
);
Employee
employeeRolesDB
=
employeeRolesRepo
.
save
(
existingEmployee
);
if
(
mobileNumberChanged
)
{
if
(
mobileNumberChanged
)
{
try
{
try
{
List
<
ProjectTeamMate
>
employeeProfiles
=
projectTeamMatesRepo
List
<
ProjectTeamMate
>
employeeProfiles
=
projectTeamMatesRepo
...
@@ -367,7 +367,7 @@ public class UserServiceImpl implements UserService {
...
@@ -367,7 +367,7 @@ public class UserServiceImpl implements UserService {
* (java.lang.String, java.lang.String)
* (java.lang.String, java.lang.String)
*/
*/
@Override
@Override
public
Employee
Roles
getEmployeeRoleDataForSearchCriteria
(
String
searchId
,
public
Employee
getEmployeeRoleDataForSearchCriteria
(
String
searchId
,
String
searchAttribute
)
{
String
searchAttribute
)
{
if
(
MyTimeUtils
.
EMPLOYEE_NAME
.
equals
(
searchAttribute
))
{
if
(
MyTimeUtils
.
EMPLOYEE_NAME
.
equals
(
searchAttribute
))
{
return
employeeRolesRepo
.
findByEmployeeName
(
searchId
);
return
employeeRolesRepo
.
findByEmployeeName
(
searchId
);
...
@@ -386,23 +386,23 @@ public class UserServiceImpl implements UserService {
...
@@ -386,23 +386,23 @@ public class UserServiceImpl implements UserService {
*/
*/
@Override
@Override
public
List
<
String
>
getEmployeeDetailsForAutocomplete
()
{
public
List
<
String
>
getEmployeeDetailsForAutocomplete
()
{
List
<
Employee
Roles
>
roles
=
employeeRolesRepo
.
findAll
();
List
<
Employee
>
roles
=
employeeRolesRepo
.
findAll
();
List
<
String
>
details
=
new
ArrayList
<>();
List
<
String
>
details
=
new
ArrayList
<>();
roles
.
stream
()
roles
.
stream
()
.
sorted
(
java
.
util
.
Comparator
.
sorted
(
java
.
util
.
Comparator
.
comparing
(
Employee
Roles
:
:
getEmployeeId
))
.
comparing
(
Employee:
:
getEmployeeId
))
.
collect
(
Collectors
.
toList
()).
forEach
(
role
->
{
.
collect
(
Collectors
.
toList
()).
forEach
(
role
->
{
details
.
add
(
role
.
getEmployeeId
());
details
.
add
(
role
.
getEmployeeId
());
});
});
roles
.
stream
()
roles
.
stream
()
.
sorted
(
java
.
util
.
Comparator
.
sorted
(
java
.
util
.
Comparator
.
comparing
(
Employee
Roles
:
:
getEmployeeName
))
.
comparing
(
Employee:
:
getEmployeeName
))
.
collect
(
Collectors
.
toList
()).
forEach
(
role
->
{
.
collect
(
Collectors
.
toList
()).
forEach
(
role
->
{
details
.
add
(
role
.
getEmployeeName
());
details
.
add
(
role
.
getEmployeeName
());
});
});
roles
.
stream
()
roles
.
stream
()
.
sorted
(
java
.
util
.
Comparator
.
sorted
(
java
.
util
.
Comparator
.
comparing
(
Employee
Roles
:
:
getEmailId
))
.
comparing
(
Employee:
:
getEmailId
))
.
collect
(
Collectors
.
toList
()).
forEach
(
role
->
{
.
collect
(
Collectors
.
toList
()).
forEach
(
role
->
{
details
.
add
(
role
.
getEmailId
());
details
.
add
(
role
.
getEmailId
());
});
});
...
@@ -415,7 +415,7 @@ public class UserServiceImpl implements UserService {
...
@@ -415,7 +415,7 @@ public class UserServiceImpl implements UserService {
}
}
@Override
@Override
public
void
updateEmployeeLocationDetails
(
Employee
Roles
employeeRoles
,
public
void
updateEmployeeLocationDetails
(
Employee
employeeRoles
,
boolean
delete
)
{
boolean
delete
)
{
try
{
try
{
Query
getQuery
=
new
Query
();
Query
getQuery
=
new
Query
();
...
@@ -441,7 +441,7 @@ public class UserServiceImpl implements UserService {
...
@@ -441,7 +441,7 @@ public class UserServiceImpl implements UserService {
}
}
@Override
@Override
public
void
saveEmployeeLocationDetails
(
Employee
Roles
employeeRoles
)
{
public
void
saveEmployeeLocationDetails
(
Employee
employeeRoles
)
{
EmployeeLocationDetails
employeeLocationDetails
=
new
EmployeeLocationDetails
();
EmployeeLocationDetails
employeeLocationDetails
=
new
EmployeeLocationDetails
();
employeeLocationDetails
.
setActive
(
employeeRoles
.
getEmpStatus
().
equalsIgnoreCase
(
"Active"
));
employeeLocationDetails
.
setActive
(
employeeRoles
.
getEmpStatus
().
equalsIgnoreCase
(
"Active"
));
employeeLocationDetails
.
setEmployeeId
(
employeeRoles
.
getEmployeeId
());
employeeLocationDetails
.
setEmployeeId
(
employeeRoles
.
getEmployeeId
());
...
@@ -460,14 +460,14 @@ public class UserServiceImpl implements UserService {
...
@@ -460,14 +460,14 @@ public class UserServiceImpl implements UserService {
}
}
@Override
@Override
public
List
<
Employee
Roles
>
getEmployeesByFunctionalGrp
(
public
List
<
Employee
>
getEmployeesByFunctionalGrp
(
String
functionalGrp
)
{
String
functionalGrp
)
{
return
employeeRolesRepo
.
findByEmpStatusAndFunctionalGroup
(
"Active"
,
functionalGrp
);
return
employeeRolesRepo
.
findByEmpStatusAndFunctionalGroup
(
"Active"
,
functionalGrp
);
}
}
@Override
@Override
public
List
<
Employee
Roles
>
getEmployeesByStatus
(
String
status
)
{
public
List
<
Employee
>
getEmployeesByStatus
(
String
status
)
{
if
(
status
.
equals
(
"both"
))
{
if
(
status
.
equals
(
"both"
))
{
return
employeeRolesRepo
.
findAll
(
new
Sort
(
Sort
.
Direction
.
ASC
,
"employeeName"
));
return
employeeRolesRepo
.
findAll
(
new
Sort
(
Sort
.
Direction
.
ASC
,
"employeeName"
));
}
else
{
}
else
{
...
@@ -478,16 +478,16 @@ public class UserServiceImpl implements UserService {
...
@@ -478,16 +478,16 @@ public class UserServiceImpl implements UserService {
@Override
@Override
public
List
<
HashMap
<
String
,
String
>>
getDeliveryLeads
(
String
domainId
)
{
public
List
<
HashMap
<
String
,
String
>>
getDeliveryLeads
(
String
domainId
)
{
List
<
HashMap
<
String
,
String
>>
EmployeeList
=
null
;
List
<
HashMap
<
String
,
String
>>
EmployeeList
=
null
;
Domain
s
domains
=
domainRepo
.
findByDomainId
(
domainId
);
Domain
domains
=
domainRepo
.
findByDomainId
(
domainId
);
EmployeeList
=
getEmployeeData
(
domains
.
getDeliveryManagers
());
EmployeeList
=
getEmployeeData
(
domains
.
getDeliveryManagers
());
return
EmployeeList
;
return
EmployeeList
;
}
}
public
List
<
HashMap
<
String
,
String
>>
getEmployeeData
(
List
<
String
>
ids
)
{
public
List
<
HashMap
<
String
,
String
>>
getEmployeeData
(
List
ids
)
{
List
<
HashMap
<
String
,
String
>>
EmployeeList
=
new
ArrayList
<>();
List
<
HashMap
<
String
,
String
>>
EmployeeList
=
new
ArrayList
<>();
Query
query
=
new
Query
(
Criteria
.
where
(
"employeeId"
).
in
(
ids
));
Query
query
=
new
Query
(
Criteria
.
where
(
"employeeId"
).
in
(
ids
));
List
<
Employee
Roles
>
employeeRoles
=
mongoTemplate
.
find
(
query
,
EmployeeRoles
.
class
);
List
<
Employee
>
employeeRoles
=
mongoTemplate
.
find
(
query
,
Employee
.
class
);
for
(
Employee
Roles
employeesRole
:
employeeRoles
)
{
for
(
Employee
employeesRole
:
employeeRoles
)
{
HashMap
<
String
,
String
>
managerMap
=
new
HashMap
<>();
HashMap
<
String
,
String
>
managerMap
=
new
HashMap
<>();
managerMap
.
put
(
"employeeId"
,
employeesRole
.
getEmployeeId
());
managerMap
.
put
(
"employeeId"
,
employeesRole
.
getEmployeeId
());
managerMap
.
put
(
"employeeName"
,
employeesRole
.
getEmployeeName
());
managerMap
.
put
(
"employeeName"
,
employeesRole
.
getEmployeeName
());
...
@@ -501,8 +501,8 @@ public class UserServiceImpl implements UserService {
...
@@ -501,8 +501,8 @@ public class UserServiceImpl implements UserService {
}
}
@Override
@Override
public
List
<
Domain
s
>
getDomains
(
String
accountId
)
throws
MyTimeException
{
public
List
<
Domain
>
getDomains
(
String
accountId
)
throws
MyTimeException
{
List
<
Domain
s
>
domains
=
domainRepo
.
findByAccountId
(
accountId
);
List
<
Domain
>
domains
=
domainRepo
.
findByAccountId
(
accountId
);
return
domains
;
return
domains
;
}
}
...
@@ -560,7 +560,7 @@ public class UserServiceImpl implements UserService {
...
@@ -560,7 +560,7 @@ public class UserServiceImpl implements UserService {
String
result
=
""
;
String
result
=
""
;
try
{
try
{
PoijiOptions
options
=
PoijiOptions
.
PoijiOptionsBuilder
.
settings
().
preferNullOverDefault
(
true
).
datePattern
(
"dd-MMM-yyyy"
).
build
();
PoijiOptions
options
=
PoijiOptions
.
PoijiOptionsBuilder
.
settings
().
preferNullOverDefault
(
true
).
datePattern
(
"dd-MMM-yyyy"
).
build
();
List
<
Employee
Roles
>
employees
=
Poiji
.
fromExcel
(
file
.
getInputStream
(),
PoijiExcelType
.
XLS
,
EmployeeRoles
.
class
,
options
);
List
<
Employee
>
employees
=
Poiji
.
fromExcel
(
file
.
getInputStream
(),
PoijiExcelType
.
XLS
,
Employee
.
class
,
options
);
if
(!
employees
.
isEmpty
())
{
if
(!
employees
.
isEmpty
())
{
result
=
allColumnsExistCheckInExcel
(
employees
.
get
(
MyTimeUtils
.
INT_ZERO
));
result
=
allColumnsExistCheckInExcel
(
employees
.
get
(
MyTimeUtils
.
INT_ZERO
));
if
(!
result
.
isEmpty
())
{
if
(!
result
.
isEmpty
())
{
...
@@ -570,7 +570,7 @@ public class UserServiceImpl implements UserService {
...
@@ -570,7 +570,7 @@ public class UserServiceImpl implements UserService {
result
=
duplicateEmpIAndEmptyEmpIdsCheckInImportedExcel
(
employees
);
result
=
duplicateEmpIAndEmptyEmpIdsCheckInImportedExcel
(
employees
);
result
+=
validateExcelRecords
(
employees
);
result
+=
validateExcelRecords
(
employees
);
log
.
info
(
"Partial Import :: Imported {} employee records from file: {}"
,
employees
.
size
(),
file
.
getOriginalFilename
());
log
.
info
(
"Partial Import :: Imported {} employee records from file: {}"
,
employees
.
size
(),
file
.
getOriginalFilename
());
for
(
Employee
Roles
employee
:
employees
)
{
for
(
Employee
employee
:
employees
)
{
addEmployee
(
employee
,
logInEmpId
);
addEmployee
(
employee
,
logInEmpId
);
}
}
}
else
{
}
else
{
...
@@ -588,7 +588,7 @@ public class UserServiceImpl implements UserService {
...
@@ -588,7 +588,7 @@ public class UserServiceImpl implements UserService {
return
result
;
return
result
;
}
}
private
void
addEmployee
(
Employee
Roles
employee
,
String
empId
)
{
private
void
addEmployee
(
Employee
employee
,
String
empId
)
{
try
{
try
{
if
(
employee
.
getRole
().
trim
().
isEmpty
())
{
if
(
employee
.
getRole
().
trim
().
isEmpty
())
{
employee
.
setRole
(
MyTimeUtils
.
EMPLOYEE
);
employee
.
setRole
(
MyTimeUtils
.
EMPLOYEE
);
...
@@ -620,21 +620,21 @@ public class UserServiceImpl implements UserService {
...
@@ -620,21 +620,21 @@ public class UserServiceImpl implements UserService {
}
}
}
}
private
String
validateExcelRecords
(
List
<
Employee
Roles
>
employees
)
{
private
String
validateExcelRecords
(
List
<
Employee
>
employees
)
{
List
<
String
>
inValidEmpRecList
=
new
ArrayList
<
String
>();
List
<
String
>
inValidEmpRecList
=
new
ArrayList
<
String
>();
String
result
=
""
;
String
result
=
""
;
boolean
mandatoryFlag
=
true
;
boolean
mandatoryFlag
=
true
;
int
rowNumber
=
1
;
int
rowNumber
=
1
;
List
<
Employee
Roles
>
invalidEmpRecs
=
new
ArrayList
<
EmployeeRoles
>();
List
<
Employee
>
invalidEmpRecs
=
new
ArrayList
<
Employee
>();
Set
<
String
>
empIdsSet
=
employees
.
stream
().
map
(
Employee
Roles
::
getEmployeeId
).
collect
(
Collectors
.
toSet
());
Set
<
String
>
empIdsSet
=
employees
.
stream
().
map
(
Employee
::
getEmployeeId
).
collect
(
Collectors
.
toSet
());
List
<
Employee
Roles
>
existingEmployess
=
employeeRolesRepo
.
findByEmployeeIdIn
(
empIdsSet
);
List
<
Employee
>
existingEmployess
=
employeeRolesRepo
.
findByEmployeeIdIn
(
empIdsSet
);
if
(
existingEmployess
.
size
()
>
MyTimeUtils
.
INT_ZERO
)
{
if
(
existingEmployess
.
size
()
>
MyTimeUtils
.
INT_ZERO
)
{
result
=
"Below employee records already existed : \n"
+
existingEmployess
.
stream
().
map
(
Employee
Roles
::
getEmployeeId
).
collect
(
Collectors
.
toSet
()).
toString
();
result
=
"Below employee records already existed : \n"
+
existingEmployess
.
stream
().
map
(
Employee
::
getEmployeeId
).
collect
(
Collectors
.
toSet
()).
toString
();
employees
.
removeAll
(
existingEmployess
);
employees
.
removeAll
(
existingEmployess
);
}
}
for
(
Employee
Roles
emp
:
employees
)
{
for
(
Employee
emp
:
employees
)
{
rowNumber
+=
1
;
rowNumber
+=
1
;
mandatoryFlag
=
importExcelMandatoryColumnsValidation
(
emp
);
mandatoryFlag
=
importExcelMandatoryColumnsValidation
(
emp
);
...
@@ -651,13 +651,13 @@ public class UserServiceImpl implements UserService {
...
@@ -651,13 +651,13 @@ public class UserServiceImpl implements UserService {
return
result
;
return
result
;
}
}
private
void
addInValidRecord
(
List
<
String
>
inValidEmpRecList
,
List
<
Employee
Roles
>
invalidEmpRecs
,
EmployeeRoles
emp
,
int
rowNumber
)
{
private
void
addInValidRecord
(
List
<
String
>
inValidEmpRecList
,
List
<
Employee
>
invalidEmpRecs
,
Employee
emp
,
int
rowNumber
)
{
inValidEmpRecList
.
add
(
Integer
.
toString
(
rowNumber
));
inValidEmpRecList
.
add
(
Integer
.
toString
(
rowNumber
));
invalidEmpRecs
.
add
(
emp
);
invalidEmpRecs
.
add
(
emp
);
}
}
private
String
allColumnsExistCheckInExcel
(
Employee
Roles
emp
)
{
private
String
allColumnsExistCheckInExcel
(
Employee
emp
)
{
String
resultString
=
"In excel sheet following coloumns are missing::"
;
String
resultString
=
"In excel sheet following coloumns are missing::"
;
StringBuffer
result
=
new
StringBuffer
(
resultString
);
StringBuffer
result
=
new
StringBuffer
(
resultString
);
Method
[]
empMethodList
=
emp
.
getClass
().
getMethods
();
Method
[]
empMethodList
=
emp
.
getClass
().
getMethods
();
...
@@ -717,7 +717,7 @@ public class UserServiceImpl implements UserService {
...
@@ -717,7 +717,7 @@ public class UserServiceImpl implements UserService {
return
isRequired
;
return
isRequired
;
}
}
private
boolean
importExcelMandatoryColumnsValidation
(
Employee
Roles
emp
)
{
private
boolean
importExcelMandatoryColumnsValidation
(
Employee
emp
)
{
boolean
mandatoryFlag
=
true
;
boolean
mandatoryFlag
=
true
;
if
(!
DataValidations
.
validateNumber
(
emp
.
getEmployeeId
()))
{
if
(!
DataValidations
.
validateNumber
(
emp
.
getEmployeeId
()))
{
...
@@ -749,7 +749,7 @@ public class UserServiceImpl implements UserService {
...
@@ -749,7 +749,7 @@ public class UserServiceImpl implements UserService {
}
}
private
void
importExcelAdditionalColumnVAlidation
(
Employee
Roles
emp
,
List
<
String
>
inValidEmpRecList
,
List
<
EmployeeRoles
>
invalidEmpRecs
,
int
rowNumber
)
{
private
void
importExcelAdditionalColumnVAlidation
(
Employee
emp
,
List
<
String
>
inValidEmpRecList
,
List
<
Employee
>
invalidEmpRecs
,
int
rowNumber
)
{
if
(!
DataValidations
.
isAgeGreaterThanTwenty
(
emp
.
getDateOfBirth
(),
emp
.
getDateOfJoining
()))
{
if
(!
DataValidations
.
isAgeGreaterThanTwenty
(
emp
.
getDateOfBirth
(),
emp
.
getDateOfJoining
()))
{
addInValidRecord
(
inValidEmpRecList
,
invalidEmpRecs
,
emp
,
rowNumber
);
addInValidRecord
(
inValidEmpRecList
,
invalidEmpRecs
,
emp
,
rowNumber
);
return
;
return
;
...
@@ -785,13 +785,13 @@ public class UserServiceImpl implements UserService {
...
@@ -785,13 +785,13 @@ public class UserServiceImpl implements UserService {
}
}
}
}
private
String
duplicateEmpIAndEmptyEmpIdsCheckInImportedExcel
(
List
<
Employee
Roles
>
employees
)
{
private
String
duplicateEmpIAndEmptyEmpIdsCheckInImportedExcel
(
List
<
Employee
>
employees
)
{
int
rowNum
=
MyTimeUtils
.
INT_TWO
;
int
rowNum
=
MyTimeUtils
.
INT_TWO
;
StringBuffer
emptyEmpIds
=
new
StringBuffer
();
StringBuffer
emptyEmpIds
=
new
StringBuffer
();
StringBuffer
duplicteEmpIds
=
new
StringBuffer
();
StringBuffer
duplicteEmpIds
=
new
StringBuffer
();
List
<
String
>
empIdsList
=
new
ArrayList
<
String
>();
List
<
String
>
empIdsList
=
new
ArrayList
<
String
>();
String
result
=
""
;
String
result
=
""
;
for
(
Employee
Roles
emp
:
employees
)
{
for
(
Employee
emp
:
employees
)
{
String
empId
=
emp
.
getEmployeeId
().
trim
();
String
empId
=
emp
.
getEmployeeId
().
trim
();
if
(
empId
.
isEmpty
())
{
if
(
empId
.
isEmpty
())
{
employees
.
remove
(
emp
);
employees
.
remove
(
emp
);
...
...
src/main/java/com/nisum/mytime/utils/CommomUtil.java
View file @
65c9aaa9
...
@@ -19,6 +19,17 @@ public class CommomUtil {
...
@@ -19,6 +19,17 @@ public class CommomUtil {
return
addedManagers
;
return
addedManagers
;
}
}
public
static
List
<
String
>
getAddedManagersListForDM
(
List
<
Object
>
fromDb
,
List
<
Object
>
fromUser
)
{
List
<
String
>
addedManagers
=
new
ArrayList
<
String
>();
if
(
fromDb
!=
null
)
for
(
Object
managerFromUser
:
fromUser
)
{
if
(!
fromDb
.
contains
(
managerFromUser
.
toString
()))
addedManagers
.
add
(
managerFromUser
.
toString
());
}
return
addedManagers
;
}
public
static
List
<
String
>
getDeletedManagersList
(
List
<
String
>
fromDb
,
List
<
String
>
fromUser
)
{
public
static
List
<
String
>
getDeletedManagersList
(
List
<
String
>
fromDb
,
List
<
String
>
fromUser
)
{
List
<
String
>
deletedManager
=
new
ArrayList
<
String
>();
List
<
String
>
deletedManager
=
new
ArrayList
<
String
>();
if
(
fromDb
!=
null
)
if
(
fromDb
!=
null
)
...
...
src/main/webapp/WEB-INF/templates/login.html
View file @
65c9aaa9
...
@@ -16,7 +16,8 @@
...
@@ -16,7 +16,8 @@
function
renderButton
()
{
function
renderButton
()
{
gapi
.
load
(
'auth2'
,
function
()
{
gapi
.
load
(
'auth2'
,
function
()
{
gapi
.
auth2
.
init
({
gapi
.
auth2
.
init
({
client_id
:
"685521475239-ujm7l2hkgrltk7loi8efl0ed702asm2r.apps.googleusercontent.com"
,
//client_id: "685521475239-ujm7l2hkgrltk7loi8efl0ed702asm2r.apps.googleusercontent.com",
client_id
:
"10230597574-gv1bg8nehm0a63n9hh5mu9um563uqaq1.apps.googleusercontent.com"
,
hosted_domain
:
'nisum.com'
hosted_domain
:
'nisum.com'
});
});
});
});
...
@@ -32,7 +33,7 @@
...
@@ -32,7 +33,7 @@
}
}
</script>
</script>
<script
src=
"https://apis.google.com/js/platform.js?onload=renderButton"
></script>
<script
src=
"https://apis.google.com/js/platform.js?onload=renderButton"
></script>
<meta
name=
"google-signin-client_id"
content=
"
685521475239-ujm7l2hkgrltk7loi8efl0ed702asm2r
.apps.googleusercontent.com"
>
<meta
name=
"google-signin-client_id"
content=
"
10230597574-gv1bg8nehm0a63n9hh5mu9um563uqaq1
.apps.googleusercontent.com"
>
<link
rel=
"stylesheet"
href=
"css/login.css"
/>
<link
rel=
"stylesheet"
href=
"css/login.css"
/>
</head>
</head>
<div
class=
"myteam-login"
ng-controller=
"loginController"
id=
"popupContainer"
>
<div
class=
"myteam-login"
ng-controller=
"loginController"
id=
"popupContainer"
>
...
...
src/test/java/com/nisum/mytime/controllertest/DomainControllerTest.java
View file @
65c9aaa9
...
@@ -25,15 +25,15 @@ import org.springframework.test.web.servlet.setup.MockMvcBuilders;
...
@@ -25,15 +25,15 @@ import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.nisum.mytime.controller.DomainController
;
import
com.nisum.mytime.controller.DomainController
;
import
com.nisum.mytime.model.Domain
s
;
import
com.nisum.mytime.model.Domain
;
import
com.nisum.mytime.service.DomainService
;
import
com.nisum.mytime.service.
I
DomainService
;
public
class
DomainControllerTest
{
public
class
DomainControllerTest
{
@Mock
@Mock
DomainService
domainService
;
I
DomainService
domainService
;
@InjectMocks
@InjectMocks
DomainController
domainController
;
DomainController
domainController
;
...
@@ -52,11 +52,12 @@ public class DomainControllerTest {
...
@@ -52,11 +52,12 @@ public class DomainControllerTest {
list
.
add
(
"16620"
);
list
.
add
(
"16620"
);
list
.
add
(
"16632"
);
list
.
add
(
"16632"
);
String
responce
=
null
;
String
responce
=
null
;
Domains
domains
=
new
Domains
(
Domain
domainPeristed
=
null
;
new
ObjectId
(
"9976ef15874c902c98b8a05d"
),
"DOM002"
,
"Marketing"
,
"Acc002"
,
Domain
domains
=
new
Domain
(
"DOM002"
,
"Marketing"
,
"Acc002"
,
"Active"
,
list
);
"Active"
,
list
);
when
(
domainService
.
addDomains
(
domains
))
when
(
domainService
.
create
(
domains
))
.
thenReturn
(
responce
);
.
thenReturn
(
domainPeristed
);
String
jsonvalue
=
(
new
ObjectMapper
())
String
jsonvalue
=
(
new
ObjectMapper
())
.
writeValueAsString
(
domains
).
toString
();
.
writeValueAsString
(
domains
).
toString
();
mockMvc
.
perform
(
post
(
"/domains"
)
mockMvc
.
perform
(
post
(
"/domains"
)
...
@@ -67,12 +68,13 @@ public class DomainControllerTest {
...
@@ -67,12 +68,13 @@ public class DomainControllerTest {
@Test
@Test
public
void
testgetDomains
()
throws
Exception
{
public
void
testgetDomains
()
throws
Exception
{
List
<
HashMap
<
Object
,
Object
>>
domains
=
CreateDomainDetails
();
//List<HashMap<Object,Object>> domains = CreateDomainDetails();
when
(
domainService
.
getAllDomains
()).
thenReturn
(
domains
);
List
domains
=
CreateDomainDetails
();
when
(
domainService
.
getDomainsList
()).
thenReturn
(
domains
);
mockMvc
.
perform
(
get
(
"/domains"
)
mockMvc
.
perform
(
get
(
"/domains"
)
.
contentType
(
MediaType
.
APPLICATION_JSON_VALUE
))
.
contentType
(
MediaType
.
APPLICATION_JSON_VALUE
))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
verify
(
domainService
).
get
AllDomains
();
verify
(
domainService
).
get
DomainsList
();
}
}
@Test
@Test
...
@@ -82,16 +84,16 @@ public class DomainControllerTest {
...
@@ -82,16 +84,16 @@ public class DomainControllerTest {
employeeIds
.
add
(
"16650"
);
employeeIds
.
add
(
"16650"
);
employeeIds
.
add
(
"16651"
);
employeeIds
.
add
(
"16651"
);
String
responce
=
null
;
String
responce
=
null
;
Domain
s
Domain
=
new
Domains
(
new
ObjectId
(
"9976ef15874c902c98b8a05d"
),
"DOM002"
,
"Marketing"
,
"Acc002"
,
Domain
domain
=
new
Domain
(
"DOM002"
,
"Marketing"
,
"Acc002"
,
"Active"
,
employeeIds
);
"Active"
,
employeeIds
);
ObjectMapper
mapper
=
new
ObjectMapper
();
ObjectMapper
mapper
=
new
ObjectMapper
();
String
jsonString
=
mapper
.
writeValueAsString
(
D
omain
);
String
jsonString
=
mapper
.
writeValueAsString
(
d
omain
);
when
(
domainService
.
update
Domain
(
any
())).
thenReturn
(
responce
);
when
(
domainService
.
update
(
any
())).
thenReturn
(
domain
);
mockMvc
.
perform
(
put
(
"/domains"
)
mockMvc
.
perform
(
put
(
"/domains"
)
.
contentType
(
MediaType
.
APPLICATION_JSON_VALUE
)
.
contentType
(
MediaType
.
APPLICATION_JSON_VALUE
)
.
content
(
jsonString
))
.
content
(
jsonString
))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
verify
(
domainService
).
update
Domain
(
any
());
verify
(
domainService
).
update
(
any
());
}
}
@Test
@Test
...
@@ -99,7 +101,7 @@ public class DomainControllerTest {
...
@@ -99,7 +101,7 @@ public class DomainControllerTest {
mockMvc
.
perform
(
mockMvc
.
perform
(
delete
(
"/domains"
).
param
(
"domainId"
,
"DOM001"
))
delete
(
"/domains"
).
param
(
"domainId"
,
"DOM001"
))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
verify
(
domainService
).
delete
Domain
(
"DOM001"
);
verify
(
domainService
).
delete
(
"DOM001"
);
}
}
...
@@ -108,8 +110,8 @@ public class DomainControllerTest {
...
@@ -108,8 +110,8 @@ public class DomainControllerTest {
HashMap
<
Object
,
Object
>
map1
=
new
HashMap
<
Object
,
Object
>();
HashMap
<
Object
,
Object
>
map1
=
new
HashMap
<
Object
,
Object
>();
HashMap
<
Object
,
Object
>
map2
=
new
HashMap
<
Object
,
Object
>();
HashMap
<
Object
,
Object
>
map2
=
new
HashMap
<
Object
,
Object
>();
Domain
s
data1
=
new
Domains
();
Domain
data1
=
new
Domain
();
data1
.
setId
(
new
ObjectId
(
"5976ef15874c902c98b8a05d"
));
//
data1.setId(new ObjectId("5976ef15874c902c98b8a05d"));
data1
.
setDomainId
(
"DOM003"
);
data1
.
setDomainId
(
"DOM003"
);
data1
.
setDomainName
(
"MOC"
);
data1
.
setDomainName
(
"MOC"
);
data1
.
setAccountId
(
"ACC001"
);
data1
.
setAccountId
(
"ACC001"
);
...
@@ -123,8 +125,8 @@ public class DomainControllerTest {
...
@@ -123,8 +125,8 @@ public class DomainControllerTest {
map1
.
put
(
new
ObjectId
(
"5976ef15874c902c98b8a05d"
),
data1
);
map1
.
put
(
new
ObjectId
(
"5976ef15874c902c98b8a05d"
),
data1
);
Domain
s
data2
=
new
Domains
();
Domain
data2
=
new
Domain
();
data2
.
setId
(
new
ObjectId
(
"9976ef15874c902c98b8a05d"
));
//
data2.setId(new ObjectId("9976ef15874c902c98b8a05d"));
data2
.
setDomainId
(
"DOM004"
);
data2
.
setDomainId
(
"DOM004"
);
data2
.
setDomainName
(
"BIGTICKET"
);
data2
.
setDomainName
(
"BIGTICKET"
);
data2
.
setAccountId
(
"ACC001"
);
data2
.
setAccountId
(
"ACC001"
);
...
...
src/test/java/com/nisum/mytime/controllertest/EmployeeBillingControllerTest.java
View file @
65c9aaa9
package
com
.
nisum
.
mytime
.
controllertest
;
//package com.nisum.mytime.controllertest;
//
import
static
org
.
mockito
.
Mockito
.
verify
;
//import static org.mockito.Mockito.verify;
import
static
org
.
mockito
.
Mockito
.
when
;
//import static org.mockito.Mockito.when;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
request
.
MockMvcRequestBuilders
.
get
;
//import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
request
.
MockMvcRequestBuilders
.
post
;
//import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
//
import
java.util.ArrayList
;
//import java.util.ArrayList;
import
java.util.Date
;
//import java.util.Date;
import
java.util.List
;
//import java.util.List;
//
import
org.bson.types.ObjectId
;
//import org.bson.types.ObjectId;
import
org.junit.Test
;
//import org.junit.Test;
import
org.mockito.InjectMocks
;
//import org.mockito.InjectMocks;
import
org.mockito.Mock
;
//import org.mockito.Mock;
import
org.springframework.http.MediaType
;
//import org.springframework.http.MediaType;
import
org.springframework.test.web.servlet.MockMvc
;
//import org.springframework.test.web.servlet.MockMvc;
import
org.springframework.test.web.servlet.result.MockMvcResultMatchers
;
//import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
//
import
com.fasterxml.jackson.databind.ObjectMapper
;
//import com.fasterxml.jackson.databind.ObjectMapper;
import
com.nisum.mytime.controller.ProjectTeamController
;
//import com.nisum.mytime.controller.ProjectTeamController;
import
com.nisum.mytime.model.BillingDetails
;
//import com.nisum.mytime.model.BillingDetails;
import
com.nisum.mytime.model.EmployeeDashboardVO
;
//import com.nisum.mytime.model.EmployeeDashboardVO;
import
com.nisum.mytime.repository.EmployeeVisaRepo
;
//import com.nisum.mytime.repository.EmployeeVisaRepo;
import
com.nisum.mytime.service.ProjectService
;
//import com.nisum.mytime.service.ProjectService;
import
com.nisum.mytime.service.UserService
;
//import com.nisum.mytime.service.UserService;
//
public
class
EmployeeBillingControllerTest
{
//public class EmployeeBillingControllerTest {
//
@Mock
// @Mock
UserService
userService
;
// UserService userService;
//
@Mock
// @Mock
ProjectService
projectService
;
// ProjectService projectService;
//
@Mock
// @Mock
EmployeeVisaRepo
employeeVisaRepo
;
// EmployeeVisaRepo employeeVisaRepo;
//
@InjectMocks
// @InjectMocks
ProjectTeamController
projectTeamController
;
// ProjectTeamController projectTeamController;
//
private
MockMvc
mockMvc
;
// private MockMvc mockMvc;
//
@Test
// @Test
public
void
testgetEmployeeBillingDetails
()
throws
Exception
{
// public void testgetEmployeeBillingDetails() throws Exception {
List
<
BillingDetails
>
billings
=
CreateTeamMateBilling
();
// List<BillingDetails> billings = CreateTeamMateBilling();
when
(
projectService
.
getEmployeeBillingDetailsAll
(
"16167"
)).
thenReturn
(
billings
);
// when(projectService.getEmployeeBillingDetailsAll("16167")).thenReturn(billings);
mockMvc
.
perform
(
get
(
"/projectTeam/getProjectAllocations"
).
param
(
"employeeId"
,
"16167"
))
// mockMvc.perform(get("/projectTeam/getProjectAllocations").param("employeeId", "16167"))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
// .andExpect(MockMvcResultMatchers.status().isOk());
verify
(
projectService
).
getEmployeeBillingDetailsAll
(
"16167"
);
// verify(projectService).getEmployeeBillingDetailsAll("16167");
}
// }
//
@Test
// @Test
public
void
testaddEmployeeBilling
()
throws
Exception
{
// public void testaddEmployeeBilling() throws Exception {
BillingDetails
billingDetails
=
new
BillingDetails
(
// BillingDetails billingDetails = new BillingDetails(
new
ObjectId
(
"9976ef15874c902c98b8a05d"
),
"16389"
,
"Mahesh Mudrakola"
,
"Acc001"
,
"Pro001"
,
"Macys"
,
// new ObjectId("9976ef15874c902c98b8a05d"), "16389","Mahesh Mudrakola", "Acc001","Pro001","Macys",
"Y"
,
new
Date
(
2017
-
11
-
29
),
// "Y", new Date(2017 - 11 - 29),
new
Date
(
2017
-
12
-
20
),
"Comments"
,
true
,
new
Date
(
2017
-
11
-
29
));
// new Date(2017 - 12 - 20),"Comments",true,new Date(2017 - 11 - 29));
String
jsonvalue
=
(
new
ObjectMapper
())
// String jsonvalue = (new ObjectMapper())
.
writeValueAsString
(
billingDetails
).
toString
();
// .writeValueAsString(billingDetails).toString();
when
(
projectService
.
addEmployeeBillingDetails
(
billingDetails
))
// when(projectService.addEmployeeBillingDetails(billingDetails))
.
thenReturn
(
billingDetails
);
// .thenReturn(billingDetails);
mockMvc
.
perform
(
post
(
"/projectTeam/addEmployeeBilling"
)
// mockMvc.perform(post("/projectTeam/addEmployeeBilling")
.
contentType
(
MediaType
.
APPLICATION_JSON_VALUE
)
// .contentType(MediaType.APPLICATION_JSON_VALUE)
.
content
(
jsonvalue
))
// .content(jsonvalue))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
// .andExpect(MockMvcResultMatchers.status().isOk());
}
// }
//
@Test
// @Test
public
void
testupdateEmployeeBilling
()
throws
Exception
{
// public void testupdateEmployeeBilling() throws Exception {
BillingDetails
billingDetails
=
new
BillingDetails
(
// BillingDetails billingDetails = new BillingDetails(
new
ObjectId
(
"9976ef15874c902c98b8a05d"
),
"16389"
,
"Mahesh Mudrakola"
,
"Acc001"
,
"Pro001"
,
"Macys"
,
// new ObjectId("9976ef15874c902c98b8a05d"), "16389","Mahesh Mudrakola", "Acc001","Pro001","Macys",
"Y"
,
new
Date
(
2017
-
11
-
29
),
// "Y", new Date(2017 - 11 - 29),
new
Date
(
2017
-
12
-
20
),
"Comments"
,
true
,
new
Date
(
2017
-
11
-
29
));
// new Date(2017 - 12 - 20),"Comments",true,new Date(2017 - 11 - 29));
String
jsonvalue
=
(
new
ObjectMapper
())
// String jsonvalue = (new ObjectMapper())
.
writeValueAsString
(
billingDetails
).
toString
();
// .writeValueAsString(billingDetails).toString();
when
(
projectService
.
updateEmployeeBilling
(
billingDetails
))
// when(projectService.updateEmployeeBilling(billingDetails))
.
thenReturn
(
billingDetails
);
// .thenReturn(billingDetails);
mockMvc
.
perform
(
post
(
"/projectTeam/updateEmployeeBilling"
)
// mockMvc.perform(post("/projectTeam/updateEmployeeBilling")
.
contentType
(
MediaType
.
APPLICATION_JSON_VALUE
)
// .contentType(MediaType.APPLICATION_JSON_VALUE)
.
content
(
jsonvalue
))
// .content(jsonvalue))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
// .andExpect(MockMvcResultMatchers.status().isOk());
}
// }
//
@Test
// @Test
public
void
testdeleteTeammate
()
throws
Exception
{
// public void testdeleteTeammate() throws Exception {
BillingDetails
billingDetails
=
new
BillingDetails
(
// BillingDetails billingDetails = new BillingDetails(
new
ObjectId
(
"9976ef15874c902c98b8a05d"
),
"16389"
,
"Mahesh Mudrakola"
,
"Acc001"
,
"Pro001"
,
"Macys"
,
// new ObjectId("9976ef15874c902c98b8a05d"), "16389","Mahesh Mudrakola", "Acc001","Pro001","Macys",
"Y"
,
new
Date
(
2017
-
11
-
29
),
// "Y", new Date(2017 - 11 - 29),
new
Date
(
2017
-
12
-
20
),
"Comments"
,
true
,
new
Date
(
2017
-
11
-
29
));
// new Date(2017 - 12 - 20),"Comments",true,new Date(2017 - 11 - 29));
String
jsonvalue
=
(
new
ObjectMapper
())
// String jsonvalue = (new ObjectMapper())
.
writeValueAsString
(
billingDetails
).
toString
();
// .writeValueAsString(billingDetails).toString();
mockMvc
.
perform
(
post
(
"/projectTeam/deleteEmployeeBilling"
)
// mockMvc.perform(post("/projectTeam/deleteEmployeeBilling")
.
contentType
(
MediaType
.
APPLICATION_JSON_VALUE
)
// .contentType(MediaType.APPLICATION_JSON_VALUE)
.
content
(
jsonvalue
))
// .content(jsonvalue))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
// .andExpect(MockMvcResultMatchers.status().isOk());
verify
(
projectService
).
deleteEmployeeBilling
(
billingDetails
);
// verify(projectService).deleteEmployeeBilling(billingDetails);
}
// }
//
@Test
// @Test
public
void
testgetEmployeesDashBoard
()
throws
Exception
{
// public void testgetEmployeesDashBoard() throws Exception {
List
<
EmployeeDashboardVO
>
dashboard
=
null
;
// List<EmployeeDashboardVO> dashboard = null;
when
(
projectService
.
getEmployeesDashBoard
()).
thenReturn
(
dashboard
);
// when(projectService.getEmployeesDashBoard()).thenReturn(dashboard);
mockMvc
.
perform
(
get
(
"/projectTeam/getEmployeesDashBoard"
))
// mockMvc.perform(get("/projectTeam/getEmployeesDashBoard"))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
// .andExpect(MockMvcResultMatchers.status().isOk());
verify
(
projectService
).
getEmployeesDashBoard
();
// verify(projectService).getEmployeesDashBoard();
}
// }
//
private
List
<
BillingDetails
>
CreateTeamMateBilling
()
{
// private List<BillingDetails> CreateTeamMateBilling() {
List
<
BillingDetails
>
data
=
new
ArrayList
<>();
// List<BillingDetails> data = new ArrayList<>();
//
BillingDetails
team1
=
new
BillingDetails
();
// BillingDetails team1 = new BillingDetails();
team1
.
setId
(
new
ObjectId
(
"5b307d7d708ef705c4ca59cc"
));
// team1.setId(new ObjectId("5b307d7d708ef705c4ca59cc"));
team1
.
setEmployeeId
(
"16167"
);
// team1.setEmployeeId("16167");
team1
.
setEmployeeName
(
"Mogana Kurmaran"
);
// team1.setEmployeeName("Mogana Kurmaran");
team1
.
setProjectId
(
"Nisum0000"
);
// team1.setProjectId("Nisum0000");
team1
.
setProjectName
(
"Free Pool"
);
// team1.setProjectName("Free Pool");
team1
.
setBillingStartDate
(
new
Date
(
2017
-
01
-
10
));
// team1.setBillingStartDate(new Date(2017 - 01 - 10));
team1
.
setBillingEndDate
(
new
Date
(
2017
-
02
-
10
));
// team1.setBillingEndDate(new Date(2017 - 02 - 10));
team1
.
setActive
(
true
);
// team1.setActive(true);
data
.
add
(
team1
);
// data.add(team1);
//
BillingDetails
team2
=
new
BillingDetails
();
// BillingDetails team2 = new BillingDetails();
team2
.
setId
(
new
ObjectId
(
"5b2f4a969ed316fef01adcce"
));
// team2.setId(new ObjectId("5b2f4a969ed316fef01adcce"));
team2
.
setEmployeeId
(
"16050"
);
// team2.setEmployeeId("16050");
team2
.
setEmployeeName
(
"Rajeshekar Sayannagari"
);
// team2.setEmployeeName("Rajeshekar Sayannagari");
team2
.
setProjectId
(
"Nisum0000"
);
// team2.setProjectId("Nisum0000");
team2
.
setProjectName
(
"Free Pool"
);
// team2.setProjectName("Free Pool");
team2
.
setBillingStartDate
(
new
Date
(
2017
-
01
-
15
));
// team2.setBillingStartDate(new Date(2017 - 01 - 15));
team2
.
setBillingEndDate
(
new
Date
(
2017
-
02
-
15
));
// team2.setBillingEndDate(new Date(2017 - 02 - 15));
team2
.
setActive
(
false
);
// team2.setActive(false);
data
.
add
(
team2
);
// data.add(team2);
//
return
data
;
// return data;
//
}
// }
}
//}
\ No newline at end of file
\ No newline at end of file
src/test/java/com/nisum/mytime/controllertest/ProjectControllerTest.java
View file @
65c9aaa9
package
com
.
nisum
.
mytime
.
controllertest
;
//package com.nisum.mytime.controllertest;
//
import
static
org
.
mockito
.
Matchers
.
any
;
//import static org.mockito.Matchers.any;
import
static
org
.
mockito
.
Mockito
.
verify
;
//import static org.mockito.Mockito.verify;
import
static
org
.
mockito
.
Mockito
.
when
;
//import static org.mockito.Mockito.when;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
request
.
MockMvcRequestBuilders
.
delete
;
//import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
request
.
MockMvcRequestBuilders
.
get
;
//import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
request
.
MockMvcRequestBuilders
.
post
;
//import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
//
import
java.util.ArrayList
;
//import java.util.ArrayList;
import
java.util.Date
;
//import java.util.Date;
import
java.util.HashMap
;
//import java.util.HashMap;
import
java.util.List
;
//import java.util.List;
//
import
org.bson.types.ObjectId
;
//import org.bson.types.ObjectId;
import
org.junit.Before
;
//import org.junit.Before;
import
org.junit.Test
;
//import org.junit.Test;
import
org.mockito.InjectMocks
;
//import org.mockito.InjectMocks;
import
org.mockito.Mock
;
//import org.mockito.Mock;
import
org.mockito.MockitoAnnotations
;
//import org.mockito.MockitoAnnotations;
import
org.springframework.http.MediaType
;
//import org.springframework.http.MediaType;
import
org.springframework.test.web.servlet.MockMvc
;
//import org.springframework.test.web.servlet.MockMvc;
import
org.springframework.test.web.servlet.result.MockMvcResultMatchers
;
//import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import
org.springframework.test.web.servlet.setup.MockMvcBuilders
;
//import org.springframework.test.web.servlet.setup.MockMvcBuilders;
//
import
com.fasterxml.jackson.databind.ObjectMapper
;
//import com.fasterxml.jackson.databind.ObjectMapper;
import
com.nisum.mytime.controller.ProjectController
;
//import com.nisum.mytime.controller.ProjectController;
import
com.nisum.mytime.model.Account
;
//import com.nisum.mytime.model.Account;
import
com.nisum.mytime.model.EmployeeRoles
;
//import com.nisum.mytime.model.EmployeeRoles;
import
com.nisum.mytime.model.Project
;
//import com.nisum.mytime.model.Project;
import
com.nisum.mytime.repository.AccountRepo
;
//import com.nisum.mytime.repository.AccountRepo;
import
com.nisum.mytime.service.ProjectService
;
//import com.nisum.mytime.service.ProjectService;
import
com.nisum.mytime.service.UserService
;
//import com.nisum.mytime.service.UserService;
//
public
class
ProjectControllerTest
{
//public class ProjectControllerTest {
//
@Mock
// @Mock
UserService
userService
;
// UserService userService;
//
@Mock
// @Mock
ProjectService
projectService
;
// ProjectService projectService;
//
@Mock
// @Mock
AccountRepo
accountRepo
;
// AccountRepo accountRepo;
//
@InjectMocks
// @InjectMocks
ProjectController
projectController
;
// ProjectController projectController;
//
private
MockMvc
mockMvc
;
// private MockMvc mockMvc;
//
@Before
// @Before
public
void
setup
()
{
// public void setup() {
MockitoAnnotations
.
initMocks
(
this
);
// MockitoAnnotations.initMocks(this);
mockMvc
=
MockMvcBuilders
.
standaloneSetup
(
projectController
).
build
();
// mockMvc = MockMvcBuilders.standaloneSetup(projectController).build();
}
// }
//
@Test
// @Test
public
void
testgetEmployeeRole
()
throws
Exception
{
// public void testgetEmployeeRole() throws Exception {
EmployeeRoles
employeesRole
=
new
EmployeeRoles
(
// EmployeeRoles employeesRole = new EmployeeRoles(
"5976ef15874c902c98b8a05d"
,
null
,
null
,
"user@nisum.com"
,
null
,
// "5976ef15874c902c98b8a05d", null, null, "user@nisum.com", null,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
// null, null, null, null, null, null, null, null, null, null,
null
,
null
,
new
Date
(
2017
-
11
-
12
),
new
Date
(
2017
-
12
-
12
),
// null, null, new Date(2017 - 11 - 12), new Date(2017 - 12 - 12),
null
,
// null,
null
,
null
,
null
,
new
Date
(
2020
-
01
-
01
),
new
Date
(
2018
-
01
-
01
),
new
Date
(
2018
-
02
-
15
),
new
Date
(
2018
-
02
-
15
),
"Mahesh"
,
"Mahesh"
);
// null, null,null,new Date(2020 - 01 - 01),new Date(2018 - 01 - 01),new Date(2018 - 02 - 15),new Date(2018 - 02 - 15),"Mahesh","Mahesh");
when
(
userService
.
getEmployeesRole
(
"user@nisum.com"
))
// when(userService.getEmployeesRole("user@nisum.com"))
.
thenReturn
(
employeesRole
);
// .thenReturn(employeesRole);
mockMvc
.
perform
(
// mockMvc.perform(
get
(
"/project/employee"
).
param
(
"emailId"
,
"user@nisum.com"
))
// get("/project/employee").param("emailId", "user@nisum.com"))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
// .andExpect(MockMvcResultMatchers.status().isOk());
verify
(
userService
).
getEmployeesRole
(
"user@nisum.com"
);
// verify(userService).getEmployeesRole("user@nisum.com");
}
// }
//
@Test
// @Test
public
void
testaddProject
()
throws
Exception
{
// public void testaddProject() throws Exception {
List
<
String
>
list
=
new
ArrayList
<>();
// List<String> list = new ArrayList<>();
list
.
add
(
"16620"
);
// list.add("16620");
<<<<<<<
HEAD
//
list
.
add
(
"16632"
);
// Project employeeRole1 = new Project(
=======
// new ObjectId("9976ef15874c902c98b8a05d"), "102","Macys", "NisumIndia","Active",list,
list
.
add
(
"16632"
);
// list, "Acc001", "DOM001",new Date(2018 - 06 - 29),
>>>>>>>
branch
'
master
'
of
https:
//github.com/nisum-inc/mytime
// new Date(2018 - 12 - 20), list);
//
Project
employeeRole1
=
new
Project
(
// Account account = new Account( "Acc001", "Macys", 3, "Y","Macys","Retail",list);
new
ObjectId
(
"9976ef15874c902c98b8a05d"
),
"102"
,
"Macys"
,
"NisumIndia"
,
"Active"
,
list
,
//
list
,
"Acc001"
,
"DOM001"
,
new
Date
(
2018
-
06
-
29
),
// when(projectService.addProject(employeeRole1))
new
Date
(
2018
-
12
-
20
),
list
);
// .thenReturn(employeeRole1);
// when(accountRepo.findByAccountId("Acc001")).thenReturn(account);
<<<<<<<
HEAD
// String jsonvalue = (new ObjectMapper())
Account
account
=
new
Account
(
"Acc001"
,
"Macys"
,
3
,
"Y"
,
"Macys"
,
"Retail"
,
list
);
// .writeValueAsString(employeeRole1).toString();
=======
// mockMvc.perform(post("/project/addProject")
Account
account
=
new
Account
(
new
ObjectId
(
"5b62cca250e71a6eecc8c682"
),
// .contentType(MediaType.APPLICATION_JSON_VALUE)
"Acc001"
,
"Macys"
,
3
,
"Y"
,
"Macys"
,
"Retail"
,
list
);
// .content(jsonvalue))
>>>>>>>
branch
'
master
'
of
https:
//github.com/nisum-inc/mytime
// .andExpect(MockMvcResultMatchers.status().isOk());
when
(
projectService
.
addProject
(
employeeRole1
))
// }
.
thenReturn
(
employeeRole1
);
//
when
(
accountRepo
.
findByAccountId
(
"Acc001"
)).
thenReturn
(
account
);
// @Test
String
jsonvalue
=
(
new
ObjectMapper
())
// public void testupdateEmployeeRole() throws Exception {
.
writeValueAsString
(
employeeRole1
).
toString
();
// List<String> employeeIds = new ArrayList<>();
mockMvc
.
perform
(
post
(
"/project/addProject"
)
// List<String> managerIds = new ArrayList<>();
.
contentType
(
MediaType
.
APPLICATION_JSON_VALUE
)
// List<String> deliveryLeadIds = new ArrayList<>();
.
content
(
jsonvalue
))
//
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
// employeeIds.add("16649");
}
// employeeIds.add("16650");
// employeeIds.add("16651");
@Test
//
public
void
testupdateEmployeeRole
()
throws
Exception
{
//
List
<
String
>
employeeIds
=
new
ArrayList
<>();
// managerIds.add("16652");
List
<
String
>
managerIds
=
new
ArrayList
<>();
//
List
<
String
>
deliveryLeadIds
=
new
ArrayList
<>();
// deliveryLeadIds.add("16653");
// deliveryLeadIds.add("16654");
employeeIds
.
add
(
"16649"
);
//
employeeIds
.
add
(
"16650"
);
//
employeeIds
.
add
(
"16651"
);
// Project project = new Project(new ObjectId("5976ef15874c902c98b8a05d"),"Gap0026",
// "Mosaic", "Move", "Active", employeeIds, managerIds,"Acc002","DOM002"
// ,new Date(2017 - 11 - 29),
managerIds
.
add
(
"16652"
);
// new Date(2017 - 12 - 20),deliveryLeadIds);
// ObjectMapper mapper = new ObjectMapper();
deliveryLeadIds
.
add
(
"16653"
);
// String jsonString = mapper.writeValueAsString(project);
deliveryLeadIds
.
add
(
"16654"
);
// when(projectService.updateProject(any())).thenReturn(project);
// }
//
Project
project
=
new
Project
(
new
ObjectId
(
"5976ef15874c902c98b8a05d"
),
"Gap0026"
,
// @Test
"Mosaic"
,
"Move"
,
"Active"
,
employeeIds
,
managerIds
,
"Acc002"
,
"DOM002"
// public void testdeleteProject() throws Exception {
,
new
Date
(
2017
-
11
-
29
),
// mockMvc.perform(
new
Date
(
2017
-
12
-
20
),
deliveryLeadIds
);
// delete("/project/deleteProject").param("projectId", "101"))
ObjectMapper
mapper
=
new
ObjectMapper
();
// .andExpect(MockMvcResultMatchers.status().isOk());
String
jsonString
=
mapper
.
writeValueAsString
(
project
);
// verify(projectService).deleteProject("101");
when
(
projectService
.
updateProject
(
any
())).
thenReturn
(
project
);
// }
}
//
// @Test
@Test
// public void testgetProjects() throws Exception {
public
void
testdeleteProject
()
throws
Exception
{
// List<HashMap<Object,Object>> projects = CreateProjectDetails();
mockMvc
.
perform
(
// when(projectService.getProjects()).thenReturn(projects);
delete
(
"/project/deleteProject"
).
param
(
"projectId"
,
"101"
))
// mockMvc.perform(get("/project/getProjects")
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
// .contentType(MediaType.APPLICATION_JSON_VALUE))
verify
(
projectService
).
deleteProject
(
"101"
);
// .andExpect(MockMvcResultMatchers.status().isOk());
}
// }
//
@Test
// @Test
public
void
testgetProjects
()
throws
Exception
{
// public void testgetEmployeeRoleData() throws Exception {
List
<
HashMap
<
Object
,
Object
>>
projects
=
CreateProjectDetails
();
// EmployeeRoles employeesRole = new EmployeeRoles(
when
(
projectService
.
getProjects
()).
thenReturn
(
projects
);
// "5976ef15874c902c98b8a05d", null, null, null, null, null, null,
mockMvc
.
perform
(
get
(
"/project/getProjects"
)
// null, null, null, null, null, null, "user@nisum.com", null,
.
contentType
(
MediaType
.
APPLICATION_JSON_VALUE
))
// null, null, new Date(2017 - 11 - 20), new Date(2107 - 12 - 23),
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
// null,
}
// null, null,null,new Date(2020 - 01 - 01),new Date(2018 - 01 - 01),new Date(2018 - 02 - 15),new Date(2018 - 02 - 15),"Mahesh","Mahesh");
// when(userService.getEmployeesRoleData("16127")) .thenReturn(employeesRole);
@Test
// mockMvc.perform(
public
void
testgetEmployeeRoleData
()
throws
Exception
{
// get("/project/getEmployeeRoleData").param("empId", "16127")
EmployeeRoles
employeesRole
=
new
EmployeeRoles
(
// .contentType(MediaType.APPLICATION_JSON_VALUE))
"5976ef15874c902c98b8a05d"
,
null
,
null
,
null
,
null
,
null
,
null
,
// .andExpect(MockMvcResultMatchers.status().isOk());
null
,
null
,
null
,
null
,
null
,
null
,
"user@nisum.com"
,
null
,
// verify(userService).getEmployeesRoleData("16127");
null
,
null
,
new
Date
(
2017
-
11
-
20
),
new
Date
(
2107
-
12
-
23
),
// }
null
,
//
null
,
null
,
null
,
new
Date
(
2020
-
01
-
01
),
new
Date
(
2018
-
01
-
01
),
new
Date
(
2018
-
02
-
15
),
new
Date
(
2018
-
02
-
15
),
"Mahesh"
,
"Mahesh"
);
// private List<HashMap<Object,Object>>CreateProjectDetails() {
when
(
userService
.
getEmployeesRoleData
(
"16127"
))
.
thenReturn
(
employeesRole
);
// List<HashMap<Object,Object>> data = new ArrayList<HashMap<Object,Object>> ();
mockMvc
.
perform
(
// HashMap<Object,Object> map1 = new HashMap<Object,Object>();
get
(
"/project/getEmployeeRoleData"
).
param
(
"empId"
,
"16127"
)
// HashMap<Object,Object> map2 = new HashMap<Object,Object>();
.
contentType
(
MediaType
.
APPLICATION_JSON_VALUE
))
//
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
// Project data1 = new Project();
verify
(
userService
).
getEmployeesRoleData
(
"16127"
);
// data1.setId(new ObjectId("5976ef15874c902c98b8a05d"));
}
// data1.setProjectId("101");
// data1.setProjectName("MOSAIC");
private
List
<
HashMap
<
Object
,
Object
>>
CreateProjectDetails
()
{
// data1.setStatus("Billable");
List
<
HashMap
<
Object
,
Object
>>
data
=
new
ArrayList
<
HashMap
<
Object
,
Object
>>
();
//
HashMap
<
Object
,
Object
>
map1
=
new
HashMap
<
Object
,
Object
>();
// List<String> list = new ArrayList<>();
HashMap
<
Object
,
Object
>
map2
=
new
HashMap
<
Object
,
Object
>();
// list.add("16101");
// list.add("16102");
Project
data1
=
new
Project
();
// list.add("16103");
data1
.
setId
(
new
ObjectId
(
"5976ef15874c902c98b8a05d"
));
//
data1
.
setProjectId
(
"101"
);
// data1.setEmployeeIds(list);
data1
.
setProjectName
(
"MOSAIC"
);
// map1.put(new ObjectId("5976ef15874c902c98b8a05d"), data1);
data1
.
setStatus
(
"Billable"
);
//
// Project data2 = new Project();
List
<
String
>
list
=
new
ArrayList
<>();
// data2.setId(new ObjectId("9976ef15874c902c98b8a05d"));
list
.
add
(
"16101"
);
// data2.setProjectId("102");
list
.
add
(
"16102"
);
// data2.setProjectName("OMS");
list
.
add
(
"16103"
);
// data2.setStatus("Non-Billable");
// List<String> lists = new ArrayList<>();
data1
.
setEmployeeIds
(
list
);
// lists.add("16104");
map1
.
put
(
new
ObjectId
(
"5976ef15874c902c98b8a05d"
),
data1
);
// lists.add("16105");
// lists.add("16106");
Project
data2
=
new
Project
();
// data2.setEmployeeIds(lists);
data2
.
setId
(
new
ObjectId
(
"9976ef15874c902c98b8a05d"
));
// map2.put(new ObjectId("9976ef15874c902c98b8a05d"), data2);
data2
.
setProjectId
(
"102"
);
//
data2
.
setProjectName
(
"OMS"
);
// data.add(map1);
data2
.
setStatus
(
"Non-Billable"
);
// data.add(map2);
List
<
String
>
lists
=
new
ArrayList
<>();
//
lists
.
add
(
"16104"
);
// return data;
lists
.
add
(
"16105"
);
// }
lists
.
add
(
"16106"
);
//}
data2
.
setEmployeeIds
(
lists
);
map2
.
put
(
new
ObjectId
(
"9976ef15874c902c98b8a05d"
),
data2
);
data
.
add
(
map1
);
data
.
add
(
map2
);
return
data
;
}
}
src/test/java/com/nisum/mytime/controllertest/ProjectTeamControllerTest.java
View file @
65c9aaa9
package
com
.
nisum
.
mytime
.
controllertest
;
//
package com.nisum.mytime.controllertest;
//
import
static
org
.
mockito
.
Matchers
.
anyObject
;
//
import static org.mockito.Matchers.anyObject;
import
static
org
.
mockito
.
Mockito
.
verify
;
//
import static org.mockito.Mockito.verify;
import
static
org
.
mockito
.
Mockito
.
when
;
//
import static org.mockito.Mockito.when;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
request
.
MockMvcRequestBuilders
.
delete
;
//
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
request
.
MockMvcRequestBuilders
.
get
;
//
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
request
.
MockMvcRequestBuilders
.
post
;
//
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
//
import
java.util.ArrayList
;
//
import java.util.ArrayList;
import
java.util.Date
;
//
import java.util.Date;
import
java.util.List
;
//
import java.util.List;
//
import
org.bson.types.ObjectId
;
//
import org.bson.types.ObjectId;
import
org.junit.Before
;
//
import org.junit.Before;
import
org.junit.Test
;
//
import org.junit.Test;
import
org.mockito.InjectMocks
;
//
import org.mockito.InjectMocks;
import
org.mockito.Mock
;
//
import org.mockito.Mock;
import
org.mockito.MockitoAnnotations
;
//
import org.mockito.MockitoAnnotations;
import
org.springframework.http.MediaType
;
//
import org.springframework.http.MediaType;
import
org.springframework.test.web.servlet.MockMvc
;
//
import org.springframework.test.web.servlet.MockMvc;
import
org.springframework.test.web.servlet.result.MockMvcResultMatchers
;
//
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import
org.springframework.test.web.servlet.setup.MockMvcBuilders
;
//
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
//
import
com.fasterxml.jackson.databind.ObjectMapper
;
//
import com.fasterxml.jackson.databind.ObjectMapper;
import
com.nisum.mytime.controller.ProjectTeamController
;
//
import com.nisum.mytime.controller.ProjectTeamController;
import
com.nisum.mytime.model.BillingDetails
;
//
import com.nisum.mytime.model.BillingDetails;
import
com.nisum.mytime.model.EmployeeDashboardVO
;
//
import com.nisum.mytime.model.EmployeeDashboardVO;
import
com.nisum.mytime.model.EmployeeRoles
;
//
import com.nisum.mytime.model.EmployeeRoles;
import
com.nisum.mytime.model.Project
;
//
import com.nisum.mytime.model.Project;
import
com.nisum.mytime.model.ProjectTeamMate
;
//
import com.nisum.mytime.model.ProjectTeamMate;
import
com.nisum.mytime.service.ProjectService
;
//
import com.nisum.mytime.service.ProjectService;
import
com.nisum.mytime.service.UserService
;
//
import com.nisum.mytime.service.UserService;
//
public
class
ProjectTeamControllerTest
{
//
public class ProjectTeamControllerTest {
//
@Mock
//
@Mock
UserService
userService
;
//
UserService userService;
//
@Mock
//
@Mock
ProjectService
projectService
;
//
ProjectService projectService;
//
@InjectMocks
//
@InjectMocks
ProjectTeamController
projectTeamController
;
//
ProjectTeamController projectTeamController;
//
private
MockMvc
mockMvc
;
//
private MockMvc mockMvc;
//
@Before
//
@Before
public
void
setup
()
{
//
public void setup() {
MockitoAnnotations
.
initMocks
(
this
);
//
MockitoAnnotations.initMocks(this);
mockMvc
=
MockMvcBuilders
.
standaloneSetup
(
projectTeamController
)
//
mockMvc = MockMvcBuilders.standaloneSetup(projectTeamController)
.
build
();
//
.build();
}
//
}
//
@Test
//
@Test
public
void
testgetEmployeeRole
()
throws
Exception
{
//
public void testgetEmployeeRole() throws Exception {
EmployeeRoles
employeesRole
=
new
EmployeeRoles
(
//
EmployeeRoles employeesRole = new EmployeeRoles(
"5976ef15874c902c98b8a05d"
,
null
,
null
,
null
,
null
,
null
,
null
,
//
"5976ef15874c902c98b8a05d", null, null, null, null, null, null,
null
,
null
,
null
,
null
,
null
,
null
,
"user@nisum.com"
,
null
,
//
null, null, null, null, null, null, "user@nisum.com", null,
null
,
null
,
new
Date
(
2017
-
11
-
20
),
new
Date
(
2107
-
12
-
23
),
//
null, null, new Date(2017 - 11 - 20), new Date(2107 - 12 - 23),
null
,
//
null,
null
,
null
,
null
,
new
Date
(
2020
-
01
-
01
),
new
Date
(
2018
-
01
-
01
),
new
Date
(
2018
-
02
-
15
),
new
Date
(
2018
-
02
-
15
),
"Mahesh"
,
"Mahesh"
);
//
null, null,null,new Date(2020 - 01 - 01),new Date(2018 - 01 - 01),new Date(2018 - 02 - 15),new Date(2018 - 02 - 15),"Mahesh","Mahesh");
//
when
(
userService
.
getEmployeesRole
(
"user@nisum.com"
))
//
when(userService.getEmployeesRole("user@nisum.com"))
.
thenReturn
(
employeesRole
);
//
.thenReturn(employeesRole);
mockMvc
.
perform
(
//
mockMvc.perform(
get
(
"/projectTeam/employee"
).
param
(
"emailId"
,
"user@nisum.com"
))
//
get("/projectTeam/employee").param("emailId", "user@nisum.com"))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
//
.andExpect(MockMvcResultMatchers.status().isOk());
verify
(
userService
).
getEmployeesRole
(
"user@nisum.com"
);
//
verify(userService).getEmployeesRole("user@nisum.com");
}
//
}
//
@Test
//
@Test
public
void
testaddProject
()
throws
Exception
{
//
public void testaddProject() throws Exception {
List
<
String
>
list
=
new
ArrayList
<>();
//
List<String> list = new ArrayList<>();
list
.
add
(
"16101"
);
//
list.add("16101");
list
.
add
(
"16102"
);
//
list.add("16102");
list
.
add
(
"16103"
);
//
list.add("16103");
Project
employeeRole1
=
new
Project
(
//
Project employeeRole1 = new Project(
new
ObjectId
(
"9976ef15874c902c98b8a05d"
),
"102"
,
"Macys"
,
"OMS"
,
"Active"
,
list
,
//
new ObjectId("9976ef15874c902c98b8a05d"), "102","Macys", "OMS","Active",list,
list
,
"Gap"
,
"Billable"
,
new
Date
(
2017
-
11
-
29
),
//
list, "Gap", "Billable",new Date(2017 - 11 - 29),
new
Date
(
2017
-
12
-
20
),
list
);
//
new Date(2017 - 12 - 20), list);
String
jsonvalue
=
(
new
ObjectMapper
())
//
String jsonvalue = (new ObjectMapper())
.
writeValueAsString
(
employeeRole1
).
toString
();
//
.writeValueAsString(employeeRole1).toString();
when
(
projectService
.
addProject
(
employeeRole1
))
//
when(projectService.addProject(employeeRole1))
.
thenReturn
(
employeeRole1
);
//
.thenReturn(employeeRole1);
mockMvc
.
perform
(
post
(
"/projectTeam/addProject"
)
//
mockMvc.perform(post("/projectTeam/addProject")
.
contentType
(
MediaType
.
APPLICATION_JSON_VALUE
)
//
.contentType(MediaType.APPLICATION_JSON_VALUE)
.
content
(
jsonvalue
))
//
.content(jsonvalue))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
//
.andExpect(MockMvcResultMatchers.status().isOk());
}
//
}
//
@Test
//
@Test
public
void
testupdateEmployeeRole
()
throws
Exception
{
//
public void testupdateEmployeeRole() throws Exception {
EmployeeRoles
employeesRoles2
=
new
EmployeeRoles
(
//
EmployeeRoles employeesRoles2 = new EmployeeRoles(
"1976ef15874c902c98b8a05d"
,
"16111"
,
"Vinay Singh"
,
//
"1976ef15874c902c98b8a05d", "16111", "Vinay Singh",
"vsingh@nisum.com"
,
"Manager"
,
null
,
"09:00-06:00"
,
"Java/J2EE"
,
//
"vsingh@nisum.com", "Manager", null, "09:00-06:00", "Java/J2EE",
"Testing"
,
"8755672341"
,
"8800543678"
,
"vsingh@gmail.com"
,
null
,
//
"Testing", "8755672341", "8800543678", "vsingh@gmail.com", null,
null
,
null
,
null
,
null
,
new
Date
(
2017
-
11
-
29
),
//
null, null, null, null, new Date(2017 - 11 - 29),
new
Date
(
2017
-
12
-
20
),
null
,
//
new Date(2017 - 12 - 20),null,
null
,
null
,
null
,
new
Date
(
2020
-
01
-
01
),
new
Date
(
2018
-
01
-
01
),
new
Date
(
2018
-
02
-
15
),
new
Date
(
2018
-
02
-
15
),
"Mahesh"
,
"Mahesh"
);
//
null, null,null,new Date(2020 - 01 - 01),new Date(2018 - 01 - 01),new Date(2018 - 02 - 15),new Date(2018 - 02 - 15),"Mahesh","Mahesh");
ObjectMapper
mapper
=
new
ObjectMapper
();
//
ObjectMapper mapper = new ObjectMapper();
String
jsonString
=
mapper
.
writeValueAsString
(
employeesRoles2
);
//
String jsonString = mapper.writeValueAsString(employeesRoles2);
when
(
userService
.
updateEmployeeRole
(
anyObject
(),
anyObject
())).
thenReturn
(
employeesRoles2
);
//
when(userService.updateEmployeeRole(anyObject(),anyObject())).thenReturn(employeesRoles2);
mockMvc
.
perform
(
post
(
"/projectTeam/updateEmployeeRole"
).
param
(
"empId"
,
"166999"
)
//
mockMvc.perform(post("/projectTeam/updateEmployeeRole").param("empId", "166999")
.
contentType
(
MediaType
.
APPLICATION_JSON_VALUE
)
//
.contentType(MediaType.APPLICATION_JSON_VALUE)
.
content
(
jsonString
))
//
.content(jsonString))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
//
.andExpect(MockMvcResultMatchers.status().isOk());
verify
(
userService
).
updateEmployeeRole
(
anyObject
(),
anyObject
());
//
verify(userService).updateEmployeeRole(anyObject(),anyObject());
}
//
}
//
@Test
//
@Test
public
void
testdeleteEmployee
()
throws
Exception
{
//
public void testdeleteEmployee() throws Exception {
mockMvc
.
perform
(
//
mockMvc.perform(
delete
(
"/projectTeam/deleteEmployee"
).
param
(
"empId"
,
"16157"
))
//
delete("/projectTeam/deleteEmployee").param("empId", "16157"))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
//
.andExpect(MockMvcResultMatchers.status().isOk());
verify
(
userService
).
deleteEmployee
(
"16157"
);
//
verify(userService).deleteEmployee("16157");
}
//
}
//
@Test
//
@Test
public
void
testgetEmployeeRoleData
()
throws
Exception
{
//
public void testgetEmployeeRoleData() throws Exception {
EmployeeRoles
employeesRole
=
new
EmployeeRoles
(
//
EmployeeRoles employeesRole = new EmployeeRoles(
"5976ef15874c902c98b8a05d"
,
"16127"
,
null
,
null
,
null
,
null
,
//
"5976ef15874c902c98b8a05d", "16127", null, null, null, null,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
//
null, null, null, null, null, null, null, null, null, null,
null
,
new
Date
(
2017
-
11
-
20
),
new
Date
(
2107
-
12
-
23
),
null
,
//
null, new Date(2017 - 11 - 20), new Date(2107 - 12 - 23), null,
null
,
null
,
null
,
new
Date
(
2020
-
01
-
01
),
new
Date
(
2018
-
01
-
01
),
new
Date
(
2018
-
02
-
15
),
new
Date
(
2018
-
02
-
15
),
"Mahesh"
,
"Mahesh"
);
//
null, null,null,new Date(2020 - 01 - 01),new Date(2018 - 01 - 01),new Date(2018 - 02 - 15),new Date(2018 - 02 - 15),"Mahesh","Mahesh");
when
(
userService
.
getEmployeesRoleData
(
"16127"
))
//
when(userService.getEmployeesRoleData("16127"))
.
thenReturn
(
employeesRole
);
//
.thenReturn(employeesRole);
mockMvc
.
perform
(
//
mockMvc.perform(
get
(
"/projectTeam/getEmployeeRoleData"
).
param
(
"empId"
,
"16127"
)
//
get("/projectTeam/getEmployeeRoleData").param("empId", "16127")
.
contentType
(
MediaType
.
APPLICATION_JSON_VALUE
))
//
.contentType(MediaType.APPLICATION_JSON_VALUE))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
//
.andExpect(MockMvcResultMatchers.status().isOk());
verify
(
userService
).
getEmployeesRoleData
(
"16127"
);
//
verify(userService).getEmployeesRoleData("16127");
}
//
}
//
@Test
//
@Test
public
void
testgetManagers
()
throws
Exception
{
//
public void testgetManagers() throws Exception {
List
<
EmployeeRoles
>
employeesRoles
=
createEmployeeRoles
();
//
List<EmployeeRoles> employeesRoles = createEmployeeRoles();
when
(
userService
.
getEmployeeRoles
()).
thenReturn
(
employeesRoles
);
//
when(userService.getEmployeeRoles()).thenReturn(employeesRoles);
mockMvc
.
perform
(
get
(
"/projectTeam/getEmployeesToTeam"
))
//
mockMvc.perform(get("/projectTeam/getEmployeesToTeam"))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
//
.andExpect(MockMvcResultMatchers.status().isOk());
//
}
//
}
//
@Test
//
@Test
public
void
testgetTeamDetails
()
throws
Exception
{
//
public void testgetTeamDetails() throws Exception {
List
<
ProjectTeamMate
>
employeesRoles
=
createProjectTeamMate
();
//
List<ProjectTeamMate> employeesRoles = createProjectTeamMate();
when
(
projectService
.
getTeamDetails
(
"16127"
)).
thenReturn
(
employeesRoles
);
//
when(projectService.getTeamDetails("16127")).thenReturn(employeesRoles);
mockMvc
.
perform
(
//
mockMvc.perform(
get
(
"/projectTeam/getTeamDetails"
).
param
(
"employeeId"
,
"16127"
))
//
get("/projectTeam/getTeamDetails").param("employeeId", "16127"))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
//
.andExpect(MockMvcResultMatchers.status().isOk());
verify
(
projectService
).
getTeamDetails
(
"16127"
);
//
verify(projectService).getTeamDetails("16127");
}
//
}
//
@Test
//
@Test
public
void
testaddEmployeeToTeam
()
throws
Exception
{
//
public void testaddEmployeeToTeam() throws Exception {
ProjectTeamMate
projectTeamMate
=
new
ProjectTeamMate
(
//
ProjectTeamMate projectTeamMate = new ProjectTeamMate(
new
ObjectId
(
"1976ef15874c902c98b8a05d"
),
"16127"
,
//
new ObjectId("1976ef15874c902c98b8a05d"), "16127",
"Monika Srivastava"
,
"msrivastava@nisum.com"
,
"Employee"
,
//
"Monika Srivastava", "msrivastava@nisum.com", "Employee",
"09:00-06:00"
,
"101"
,
"MOSAIC"
,
"GAP"
,
"04"
,
"Software Engineer"
,
"Non-Billable"
,
"8765588388"
,
//
"09:00-06:00", "101", "MOSAIC", "GAP", "04", "Software Engineer", "Non-Billable", "8765588388",
new
Date
(),
new
Date
(),
new
Date
(),
true
,
null
,
null
);
//
new Date(), new Date(),new Date(), true,null,null);
String
jsonvalue
=
(
new
ObjectMapper
())
//
String jsonvalue = (new ObjectMapper())
.
writeValueAsString
(
projectTeamMate
).
toString
();
//
.writeValueAsString(projectTeamMate).toString();
when
(
projectService
.
addProjectTeamMate
(
projectTeamMate
))
//
when(projectService.addProjectTeamMate(projectTeamMate))
.
thenReturn
(
projectTeamMate
);
//
.thenReturn(projectTeamMate);
mockMvc
.
perform
(
post
(
"/projectTeam/addEmployeeToTeam"
)
//
mockMvc.perform(post("/projectTeam/addEmployeeToTeam")
.
contentType
(
MediaType
.
APPLICATION_JSON_VALUE
)
//
.contentType(MediaType.APPLICATION_JSON_VALUE)
.
content
(
jsonvalue
))
//
.content(jsonvalue))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
//
.andExpect(MockMvcResultMatchers.status().isOk());
}
//
}
//
@Test
//
@Test
public
void
testupdateTeammate
()
throws
Exception
{
//
public void testupdateTeammate() throws Exception {
ProjectTeamMate
updatedTeammate
=
new
ProjectTeamMate
(
//
ProjectTeamMate updatedTeammate = new ProjectTeamMate(
new
ObjectId
(
"1976ef15874c902c98b8a05d"
),
"16127"
,
//
new ObjectId("1976ef15874c902c98b8a05d"), "16127",
"Monika Srivastava"
,
"msrivastava@nisum.com"
,
"Employee"
,
//
"Monika Srivastava", "msrivastava@nisum.com", "Employee",
"09:00-06:00"
,
"101"
,
"MOSAIC"
,
"GAP"
,
"04"
,
"Software Engineer"
,
"Non-Billable"
,
"8765588388"
,
//
"09:00-06:00", "101", "MOSAIC", "GAP", "04", "Software Engineer", "Non-Billable", "8765588388",
new
Date
(),
new
Date
(),
new
Date
(),
true
,
null
,
null
);
//
new Date(), new Date(),new Date(), true,null,null);
String
jsonvalue
=
(
new
ObjectMapper
())
//
String jsonvalue = (new ObjectMapper())
.
writeValueAsString
(
updatedTeammate
).
toString
();
//
.writeValueAsString(updatedTeammate).toString();
when
(
projectService
.
updateTeammate
(
updatedTeammate
))
//
when(projectService.updateTeammate(updatedTeammate))
.
thenReturn
(
jsonvalue
);
//
.thenReturn(jsonvalue);
mockMvc
.
perform
(
post
(
"/projectTeam/updateTeammate"
)
//
mockMvc.perform(post("/projectTeam/updateTeammate")
.
contentType
(
MediaType
.
APPLICATION_JSON_VALUE
)
//
.contentType(MediaType.APPLICATION_JSON_VALUE)
.
content
(
jsonvalue
))
//
.content(jsonvalue))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
//
.andExpect(MockMvcResultMatchers.status().isOk());
}
//
}
//
@Test
//
@Test
public
void
testdeleteTeammate
()
throws
Exception
{
//
public void testdeleteTeammate() throws Exception {
ProjectTeamMate
deleteTeamMate
=
new
ProjectTeamMate
(
//
ProjectTeamMate deleteTeamMate = new ProjectTeamMate(
new
ObjectId
(
"1976ef15874c902c98b8a05d"
),
"16127"
,
//
new ObjectId("1976ef15874c902c98b8a05d"), "16127",
"Monika Srivastava"
,
"msrivastava@nisum.com"
,
"Employee"
,
//
"Monika Srivastava", "msrivastava@nisum.com", "Employee",
"09:00-06:00"
,
"101"
,
"MOSAIC"
,
"GAP"
,
"04"
,
"Software Engineer"
,
"Non-Billable"
,
"8765588388"
,
//
"09:00-06:00", "101", "MOSAIC", "GAP", "04", "Software Engineer", "Non-Billable", "8765588388",
new
Date
(),
new
Date
(),
new
Date
(),
true
,
null
,
null
);
//
new Date(), new Date(),new Date(), true,null,null);
String
jsonvalue
=
(
new
ObjectMapper
())
//
String jsonvalue = (new ObjectMapper())
.
writeValueAsString
(
deleteTeamMate
).
toString
();
//
.writeValueAsString(deleteTeamMate).toString();
mockMvc
.
perform
(
post
(
"/projectTeam/deleteTeammate"
)
//
mockMvc.perform(post("/projectTeam/deleteTeammate")
.
contentType
(
MediaType
.
APPLICATION_JSON_VALUE
)
//
.contentType(MediaType.APPLICATION_JSON_VALUE)
.
content
(
jsonvalue
))
//
.content(jsonvalue))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
//
.andExpect(MockMvcResultMatchers.status().isOk());
verify
(
projectService
).
deleteTeammate
(
"16127"
,
"101"
,
//
verify(projectService).deleteTeammate("16127", "101",
new
ObjectId
(
"1976ef15874c902c98b8a05d"
));
//
new ObjectId("1976ef15874c902c98b8a05d"));
}
//
}
//
@Test
//
@Test
public
void
testgetProjects
()
throws
Exception
{
//
public void testgetProjects() throws Exception {
List
<
Project
>
projects
=
CreateProjectDetails
();
//
List<Project> projects = CreateProjectDetails();
when
(
projectService
.
getProjects
(
"16127"
)).
thenReturn
(
projects
);
//
when(projectService.getProjects("16127")).thenReturn(projects);
mockMvc
.
perform
(
//
mockMvc.perform(
get
(
"/projectTeam/getProjects"
).
param
(
"employeeId"
,
"16127"
))
//
get("/projectTeam/getProjects").param("employeeId", "16127"))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
//
.andExpect(MockMvcResultMatchers.status().isOk());
verify
(
projectService
).
getProjects
(
"16127"
);
//
verify(projectService).getProjects("16127");
}
//
}
//
@Test
//
@Test
public
void
testgetMyTeamDetails
()
throws
Exception
{
//
public void testgetMyTeamDetails() throws Exception {
List
<
ProjectTeamMate
>
employeesRoles
=
createProjectTeamMate
();
//
List<ProjectTeamMate> employeesRoles = createProjectTeamMate();
when
(
projectService
.
getMyTeamDetails
(
"16127"
))
//
when(projectService.getMyTeamDetails("16127"))
.
thenReturn
(
employeesRoles
);
//
.thenReturn(employeesRoles);
mockMvc
.
perform
(
get
(
"/projectTeam/getMyTeamDetails"
).
param
(
"employeeId"
,
//
mockMvc.perform(get("/projectTeam/getMyTeamDetails").param("employeeId",
"16127"
)).
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
//
"16127")).andExpect(MockMvcResultMatchers.status().isOk());
verify
(
projectService
).
getMyTeamDetails
(
"16127"
);
//
verify(projectService).getMyTeamDetails("16127");
}
//
}
//
@Test
//
@Test
public
void
testgetUnAssignedEmployees
()
throws
Exception
{
//
public void testgetUnAssignedEmployees() throws Exception {
List
<
EmployeeRoles
>
employeesRoles
=
createEmployeeRoles
();
//
List<EmployeeRoles> employeesRoles = createEmployeeRoles();
when
(
projectService
.
getUnAssignedEmployees
())
//
when(projectService.getUnAssignedEmployees())
.
thenReturn
(
employeesRoles
);
//
.thenReturn(employeesRoles);
mockMvc
.
perform
(
get
(
"/projectTeam/getUnAssignedEmployees"
))
//
mockMvc.perform(get("/projectTeam/getUnAssignedEmployees"))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
//
.andExpect(MockMvcResultMatchers.status().isOk());
verify
(
projectService
).
getUnAssignedEmployees
();
//
verify(projectService).getUnAssignedEmployees();
}
//
}
//
@Test
//
@Test
public
void
testgetShiftDetails
()
throws
Exception
{
//
public void testgetShiftDetails() throws Exception {
List
<
ProjectTeamMate
>
employeesRoles
=
createProjectTeamMate
();
//
List<ProjectTeamMate> employeesRoles = createProjectTeamMate();
when
(
projectService
.
getShiftDetails
(
"09:00-06:00"
))
//
when(projectService.getShiftDetails("09:00-06:00"))
.
thenReturn
(
employeesRoles
);
//
.thenReturn(employeesRoles);
mockMvc
.
perform
(
get
(
"/projectTeam/getShiftDetails"
).
param
(
"shift"
,
//
mockMvc.perform(get("/projectTeam/getShiftDetails").param("shift",
"09:00-06:00"
))
//
"09:00-06:00"))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
//
.andExpect(MockMvcResultMatchers.status().isOk());
verify
(
projectService
).
getShiftDetails
(
"09:00-06:00"
);
//
verify(projectService).getShiftDetails("09:00-06:00");
}
//
}
//
@Test
//
@Test
public
void
testgetProjectAllocations
()
throws
Exception
{
//
public void testgetProjectAllocations() throws Exception {
List
<
ProjectTeamMate
>
employeesRoles
=
createProjectTeamMate
();
//
List<ProjectTeamMate> employeesRoles = createProjectTeamMate();
when
(
projectService
.
getAllProjectDetails
()).
thenReturn
(
employeesRoles
);
//
when(projectService.getAllProjectDetails()).thenReturn(employeesRoles);
mockMvc
.
perform
(
get
(
"/projectTeam/getProjectAllocations"
))
//
mockMvc.perform(get("/projectTeam/getProjectAllocations"))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
//
.andExpect(MockMvcResultMatchers.status().isOk());
verify
(
projectService
).
getAllProjectDetails
();
//
verify(projectService).getAllProjectDetails();
}
//
}
//
@Test
//
@Test
public
void
testgetProjectDetails
()
throws
Exception
{
//
public void testgetProjectDetails() throws Exception {
List
<
ProjectTeamMate
>
employeesRoles
=
createProjectTeamMate
();
//
List<ProjectTeamMate> employeesRoles = createProjectTeamMate();
when
(
projectService
.
getProjectDetails
(
"101"
,
null
))
//
when(projectService.getProjectDetails("101", null))
.
thenReturn
(
employeesRoles
);
//
.thenReturn(employeesRoles);
mockMvc
.
perform
(
//
mockMvc.perform(
get
(
"/projectTeam/getProjectDetails"
).
param
(
"projectId"
,
"101"
).
param
(
"status"
,
"Active"
))
//
get("/projectTeam/getProjectDetails").param("projectId", "101").param("status", "Active"))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
//
.andExpect(MockMvcResultMatchers.status().isOk());
verify
(
projectService
).
getProjectDetails
(
"101"
,
"Active"
);
//
verify(projectService).getProjectDetails("101", "Active");
}
//
}
//
@Test
//
@Test
public
void
testgetMyProjectAllocations
()
throws
Exception
{
//
public void testgetMyProjectAllocations() throws Exception {
List
<
ProjectTeamMate
>
projectAllocations
=
createProjectTeamMate
();
//
List<ProjectTeamMate> projectAllocations = createProjectTeamMate();
System
.
out
.
println
(
projectAllocations
);
//
System.out.println(projectAllocations);
when
(
projectService
.
getMyProjectAllocations
(
"16127"
))
//
when(projectService.getMyProjectAllocations("16127"))
.
thenReturn
(
projectAllocations
);
//
.thenReturn(projectAllocations);
mockMvc
.
perform
(
get
(
"/projectTeam/getMyProjectAllocations"
)
//
mockMvc.perform(get("/projectTeam/getMyProjectAllocations")
.
param
(
"employeeId"
,
"16127"
))
//
.param("employeeId", "16127"))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
//
.andExpect(MockMvcResultMatchers.status().isOk());
// verify(projectService).getMyProjectAllocations("16127");
//
// verify(projectService).getMyProjectAllocations("16127");
}
//
}
//
@Test
//
@Test
public
void
testaddEmployeeBilling
()
throws
Exception
{
//
public void testaddEmployeeBilling() throws Exception {
BillingDetails
billingDetails
=
new
BillingDetails
(
//
BillingDetails billingDetails = new BillingDetails(
new
ObjectId
(
"9976ef15874c902c98b8a05d"
),
"16389"
,
"Mahesh Mudrakola"
,
"Acc001"
,
"Pro001"
,
"Macys"
,
//
new ObjectId("9976ef15874c902c98b8a05d"), "16389","Mahesh Mudrakola", "Acc001","Pro001","Macys",
"Y"
,
new
Date
(
2017
-
11
-
29
),
//
"Y", new Date(2017 - 11 - 29),
new
Date
(
2017
-
12
-
20
),
"Comments"
,
true
,
new
Date
(
2017
-
11
-
29
));
//
new Date(2017 - 12 - 20),"Comments",true,new Date(2017 - 11 - 29));
String
jsonvalue
=
(
new
ObjectMapper
())
//
String jsonvalue = (new ObjectMapper())
.
writeValueAsString
(
billingDetails
).
toString
();
//
.writeValueAsString(billingDetails).toString();
when
(
projectService
.
addEmployeeBillingDetails
(
billingDetails
))
//
when(projectService.addEmployeeBillingDetails(billingDetails))
.
thenReturn
(
billingDetails
);
//
.thenReturn(billingDetails);
mockMvc
.
perform
(
post
(
"/projectTeam/addEmployeeBilling"
)
//
mockMvc.perform(post("/projectTeam/addEmployeeBilling")
.
contentType
(
MediaType
.
APPLICATION_JSON_VALUE
)
//
.contentType(MediaType.APPLICATION_JSON_VALUE)
.
content
(
jsonvalue
))
//
.content(jsonvalue))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
//
.andExpect(MockMvcResultMatchers.status().isOk());
}
//
}
//
@Test
//
@Test
public
void
testupdateEmployeeBilling
()
throws
Exception
{
//
public void testupdateEmployeeBilling() throws Exception {
BillingDetails
billingDetails
=
new
BillingDetails
(
//
BillingDetails billingDetails = new BillingDetails(
new
ObjectId
(
"9976ef15874c902c98b8a05d"
),
"16389"
,
"Mahesh Mudrakola"
,
"Acc001"
,
"Pro001"
,
"Macys"
,
//
new ObjectId("9976ef15874c902c98b8a05d"), "16389","Mahesh Mudrakola", "Acc001","Pro001","Macys",
"Y"
,
new
Date
(
2017
-
11
-
29
),
//
"Y", new Date(2017 - 11 - 29),
new
Date
(
2017
-
12
-
20
),
"Comments"
,
true
,
new
Date
(
2017
-
11
-
29
));
//
new Date(2017 - 12 - 20),"Comments",true,new Date(2017 - 11 - 29));
String
jsonvalue
=
(
new
ObjectMapper
())
//
String jsonvalue = (new ObjectMapper())
.
writeValueAsString
(
billingDetails
).
toString
();
//
.writeValueAsString(billingDetails).toString();
when
(
projectService
.
updateEmployeeBilling
(
billingDetails
))
//
when(projectService.updateEmployeeBilling(billingDetails))
.
thenReturn
(
billingDetails
);
//
.thenReturn(billingDetails);
mockMvc
.
perform
(
post
(
"/projectTeam/updateEmployeeBilling"
)
//
mockMvc.perform(post("/projectTeam/updateEmployeeBilling")
.
contentType
(
MediaType
.
APPLICATION_JSON_VALUE
)
//
.contentType(MediaType.APPLICATION_JSON_VALUE)
.
content
(
jsonvalue
))
//
.content(jsonvalue))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
//
.andExpect(MockMvcResultMatchers.status().isOk());
}
//
}
//
//
@Test
//
@Test
public
void
testgetEmployeesDashBoard
()
throws
Exception
{
//
public void testgetEmployeesDashBoard() throws Exception {
List
<
EmployeeDashboardVO
>
dashboard
=
null
;
//
List<EmployeeDashboardVO> dashboard = null;
when
(
projectService
.
getEmployeesDashBoard
()).
thenReturn
(
dashboard
);
//
when(projectService.getEmployeesDashBoard()).thenReturn(dashboard);
mockMvc
.
perform
(
get
(
"/projectTeam/getEmployeesDashBoard"
))
//
mockMvc.perform(get("/projectTeam/getEmployeesDashBoard"))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
//
.andExpect(MockMvcResultMatchers.status().isOk());
verify
(
projectService
).
getEmployeesDashBoard
();
//
verify(projectService).getEmployeesDashBoard();
}
//
}
//
@Test
//
@Test
public
void
testgetEmployeeBillingDetails
()
throws
Exception
{
//
public void testgetEmployeeBillingDetails() throws Exception {
List
<
BillingDetails
>
billings
=
CreateTeamMateBilling
();
//
List<BillingDetails> billings = CreateTeamMateBilling();
System
.
out
.
println
(
billings
);
//
System.out.println(billings);
when
(
projectService
.
getEmployeeBillingDetails
(
"16127"
,
"101"
))
//
when(projectService.getEmployeeBillingDetails("16127", "101"))
.
thenReturn
(
billings
);
//
.thenReturn(billings);
mockMvc
.
perform
(
get
(
"/projectTeam/getEmployeeBillingDetails"
)
//
mockMvc.perform(get("/projectTeam/getEmployeeBillingDetails")
.
param
(
"employeeId"
,
"16127"
).
param
(
"projectId"
,
"101"
))
//
.param("employeeId", "16127").param("projectId", "101"))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
//
.andExpect(MockMvcResultMatchers.status().isOk());
verify
(
projectService
).
getEmployeeBillingDetails
(
"16127"
,
"101"
);
//
verify(projectService).getEmployeeBillingDetails("16127", "101");
}
//
}
//
private
List
<
BillingDetails
>
CreateTeamMateBilling
()
{
//
private List<BillingDetails> CreateTeamMateBilling() {
List
<
BillingDetails
>
data
=
new
ArrayList
<>();
//
List<BillingDetails> data = new ArrayList<>();
//
BillingDetails
team1
=
new
BillingDetails
();
//
BillingDetails team1 = new BillingDetails();
team1
.
setId
(
new
ObjectId
(
"5976ef15874c902c98b8a05d"
));
//
team1.setId(new ObjectId("5976ef15874c902c98b8a05d"));
team1
.
setEmployeeId
(
"16127"
);
//
team1.setEmployeeId("16127");
team1
.
setEmployeeName
(
"Employee1"
);
//
team1.setEmployeeName("Employee1");
team1
.
setProjectId
(
"101"
);
//
team1.setProjectId("101");
team1
.
setProjectName
(
"MOSAIC"
);
//
team1.setProjectName("MOSAIC");
team1
.
setBillingStartDate
(
new
Date
(
2017
-
01
-
10
));
//
team1.setBillingStartDate(new Date(2017 - 01 - 10));
team1
.
setBillingEndDate
(
new
Date
(
2017
-
02
-
10
));
//
team1.setBillingEndDate(new Date(2017 - 02 - 10));
team1
.
setActive
(
true
);
//
team1.setActive(true);
data
.
add
(
team1
);
//
data.add(team1);
//
BillingDetails
team2
=
new
BillingDetails
();
//
BillingDetails team2 = new BillingDetails();
team2
.
setId
(
new
ObjectId
(
"1976ef15874c902c98b8a05d"
));
//
team2.setId(new ObjectId("1976ef15874c902c98b8a05d"));
team2
.
setEmployeeId
(
"16128"
);
//
team2.setEmployeeId("16128");
team2
.
setEmployeeName
(
"Employee2"
);
//
team2.setEmployeeName("Employee2");
team2
.
setProjectId
(
"102"
);
//
team2.setProjectId("102");
team2
.
setProjectName
(
"OMS"
);
//
team2.setProjectName("OMS");
team2
.
setBillingStartDate
(
new
Date
(
2017
-
01
-
15
));
//
team2.setBillingStartDate(new Date(2017 - 01 - 15));
team2
.
setBillingEndDate
(
new
Date
(
2017
-
02
-
15
));
//
team2.setBillingEndDate(new Date(2017 - 02 - 15));
team2
.
setActive
(
false
);
//
team2.setActive(false);
data
.
add
(
team2
);
//
data.add(team2);
//
return
data
;
//
return data;
//
}
//
}
//
private
List
<
Project
>
CreateProjectDetails
()
{
//
private List<Project> CreateProjectDetails() {
List
<
Project
>
data
=
new
ArrayList
<>();
//
List<Project> data = new ArrayList<>();
//
Project
data1
=
new
Project
();
//
Project data1 = new Project();
data1
.
setId
(
new
ObjectId
(
"5976ef15874c902c98b8a05d"
));
//
data1.setId(new ObjectId("5976ef15874c902c98b8a05d"));
data1
.
setProjectId
(
"101"
);
//
data1.setProjectId("101");
data1
.
setProjectName
(
"MOSAIC"
);
//
data1.setProjectName("MOSAIC");
//data1.setManagerId("16110");
//
//data1.setManagerId("16110");
// data1.setManagerName("Rajeshekar");
//
// data1.setManagerName("Rajeshekar");
data1
.
setStatus
(
"Billable"
);
//
data1.setStatus("Billable");
//data1.setAccount("Gap");
//
//data1.setAccount("Gap");
List
<
String
>
list
=
new
ArrayList
<>();
//
List<String> list = new ArrayList<>();
list
.
add
(
"16101"
);
//
list.add("16101");
list
.
add
(
"16102"
);
//
list.add("16102");
list
.
add
(
"16103"
);
//
list.add("16103");
data1
.
setEmployeeIds
(
list
);
//
data1.setEmployeeIds(list);
//
Project
data2
=
new
Project
();
//
Project data2 = new Project();
data2
.
setId
(
new
ObjectId
(
"9976ef15874c902c98b8a05d"
));
//
data2.setId(new ObjectId("9976ef15874c902c98b8a05d"));
data2
.
setProjectId
(
"102"
);
//
data2.setProjectId("102");
data2
.
setProjectName
(
"OMS"
);
//
data2.setProjectName("OMS");
//data2.setManagerId("16111");
//
//data2.setManagerId("16111");
//data2.setManagerName("Reshma");
//
//data2.setManagerName("Reshma");
data2
.
setStatus
(
"Billable"
);
//
data2.setStatus("Billable");
//data2.setAccount("Macys");
//
//data2.setAccount("Macys");
List
<
String
>
lists
=
new
ArrayList
<>();
//
List<String> lists = new ArrayList<>();
lists
.
add
(
"16104"
);
//
lists.add("16104");
lists
.
add
(
"16105"
);
//
lists.add("16105");
lists
.
add
(
"16106"
);
//
lists.add("16106");
data2
.
setEmployeeIds
(
lists
);
//
data2.setEmployeeIds(lists);
//
data
.
add
(
data1
);
//
data.add(data1);
data
.
add
(
data2
);
//
data.add(data2);
//
return
data
;
//
return data;
}
//
}
//
private
List
<
ProjectTeamMate
>
createProjectTeamMate
()
{
//
private List<ProjectTeamMate> createProjectTeamMate() {
List
<
ProjectTeamMate
>
data
=
new
ArrayList
<>();
//
List<ProjectTeamMate> data = new ArrayList<>();
//
ProjectTeamMate
record1
=
new
ProjectTeamMate
();
//
ProjectTeamMate record1 = new ProjectTeamMate();
record1
.
setId
(
new
ObjectId
(
"3976ef15874c902c98b8a05d"
));
//
record1.setId(new ObjectId("3976ef15874c902c98b8a05d"));
record1
.
setEmployeeId
(
"16127"
);
//
record1.setEmployeeId("16127");
record1
.
setEmployeeName
(
"Monika Srivastava"
);
//
record1.setEmployeeName("Monika Srivastava");
record1
.
setEmailId
(
"msrivastava@nisum.com"
);
//
record1.setEmailId("msrivastava@nisum.com");
record1
.
setRole
(
"Employee"
);
//
record1.setRole("Employee");
record1
.
setShift
(
"09:00-06:00"
);
//
record1.setShift("09:00-06:00");
record1
.
setProjectId
(
"101"
);
//
record1.setProjectId("101");
record1
.
setProjectName
(
"Mosaic"
);
//
record1.setProjectName("Mosaic");
record1
.
setAccount
(
"Gap"
);
//
record1.setAccount("Gap");
//record1.setManagerId("16081");
//
//record1.setManagerId("16081");
//record1.setManagerName("Rajeshekar");
//
//record1.setManagerName("Rajeshekar");
record1
.
setExperience
(
"01 Year"
);
//
record1.setExperience("01 Year");
record1
.
setDesignation
(
"Software Engineer"
);
//
record1.setDesignation("Software Engineer");
record1
.
setBillableStatus
(
"Non-Billable"
);
//
record1.setBillableStatus("Non-Billable");
record1
.
setMobileNumber
(
"8765588388"
);
//
record1.setMobileNumber("8765588388");
//
ProjectTeamMate
record2
=
new
ProjectTeamMate
();
//
ProjectTeamMate record2 = new ProjectTeamMate();
record2
.
setId
(
new
ObjectId
(
"2976ef15874c902c98b8a05d"
));
//
record2.setId(new ObjectId("2976ef15874c902c98b8a05d"));
record2
.
setEmployeeId
(
"16111"
);
//
record2.setEmployeeId("16111");
record2
.
setEmployeeName
(
"Vinay Singh"
);
//
record2.setEmployeeName("Vinay Singh");
record2
.
setEmailId
(
"vsingh@nisum.com"
);
//
record2.setEmailId("vsingh@nisum.com");
record2
.
setRole
(
"Employee"
);
//
record2.setRole("Employee");
record2
.
setShift
(
"09:00-06:00"
);
//
record2.setShift("09:00-06:00");
record2
.
setProjectId
(
"101"
);
//
record2.setProjectId("101");
record2
.
setProjectName
(
"Mosaic"
);
//
record2.setProjectName("Mosaic");
record2
.
setAccount
(
"Gap"
);
//
record2.setAccount("Gap");
//record2.setManagerId("16081");
//
//record2.setManagerId("16081");
//record2.setManagerName("Rajeshekar");
//
//record2.setManagerName("Rajeshekar");
record2
.
setExperience
(
"07 Year"
);
//
record2.setExperience("07 Year");
record2
.
setDesignation
(
"Senoir Software Engineer"
);
//
record2.setDesignation("Senoir Software Engineer");
record2
.
setBillableStatus
(
"Billable"
);
//
record2.setBillableStatus("Billable");
record2
.
setMobileNumber
(
"8765588399"
);
//
record2.setMobileNumber("8765588399");
//
data
.
add
(
record1
);
//
data.add(record1);
data
.
add
(
record2
);
//
data.add(record2);
//
return
data
;
//
return data;
}
//
}
//
private
List
<
EmployeeRoles
>
createEmployeeRoles
()
{
//
private List<EmployeeRoles> createEmployeeRoles() {
List
<
EmployeeRoles
>
data
=
new
ArrayList
<>();
//
List<EmployeeRoles> data = new ArrayList<>();
//
EmployeeRoles
record1
=
new
EmployeeRoles
();
//
EmployeeRoles record1 = new EmployeeRoles();
record1
.
setId
(
"5976ef15874c902c98b8a05d"
);
//
record1.setId("5976ef15874c902c98b8a05d");
record1
.
setEmployeeId
(
"16127"
);
//
record1.setEmployeeId("16127");
record1
.
setEmployeeName
(
"Monika Srivastava"
);
//
record1.setEmployeeName("Monika Srivastava");
record1
.
setEmailId
(
"msrivastava@nisum.com"
);
//
record1.setEmailId("msrivastava@nisum.com");
record1
.
setRole
(
"Employee"
);
//
record1.setRole("Employee");
record1
.
setShift
(
"09:00-06:00"
);
//
record1.setShift("09:00-06:00");
record1
.
setBaseTechnology
(
"Spring"
);
//
record1.setBaseTechnology("Spring");
record1
.
setTechnologyKnown
(
"Java"
);
//
record1.setTechnologyKnown("Java");
record1
.
setMobileNumber
(
"9900786755"
);
//
record1.setMobileNumber("9900786755");
record1
.
setAlternateMobileNumber
(
"7689009876"
);
//
record1.setAlternateMobileNumber("7689009876");
record1
.
setPersonalEmailId
(
"msrivastava@gmail.com"
);
//
record1.setPersonalEmailId("msrivastava@gmail.com");
record1
.
setCreatedOn
(
new
Date
(
2017
-
11
-
18
));
//
record1.setCreatedOn(new Date(2017 - 11 - 18));
record1
.
setLastModifiedOn
(
new
Date
(
2017
-
12
-
13
));
//
record1.setLastModifiedOn(new Date(2017 - 12 - 13));
//
EmployeeRoles
record2
=
new
EmployeeRoles
();
//
EmployeeRoles record2 = new EmployeeRoles();
record2
.
setId
(
"8976ef15874c902c98b8a05d"
);
//
record2.setId("8976ef15874c902c98b8a05d");
record2
.
setEmployeeId
(
"16081"
);
//
record2.setEmployeeId("16081");
record2
.
setEmployeeName
(
"Rajeshekar"
);
//
record2.setEmployeeName("Rajeshekar");
record2
.
setEmailId
(
"manager@nisum.com"
);
//
record2.setEmailId("manager@nisum.com");
record2
.
setRole
(
"Manager"
);
//
record2.setRole("Manager");
record2
.
setShift
(
"03:00-12:00"
);
//
record2.setShift("03:00-12:00");
record2
.
setBaseTechnology
(
"Hibernate"
);
//
record2.setBaseTechnology("Hibernate");
record2
.
setTechnologyKnown
(
"EJB"
);
//
record2.setTechnologyKnown("EJB");
record2
.
setMobileNumber
(
"9109897867"
);
//
record2.setMobileNumber("9109897867");
record2
.
setAlternateMobileNumber
(
"9129098767"
);
//
record2.setAlternateMobileNumber("9129098767");
record2
.
setPersonalEmailId
(
"manager@gmail.com"
);
//
record2.setPersonalEmailId("manager@gmail.com");
record2
.
setCreatedOn
(
new
Date
(
2017
-
11
-
18
));
//
record2.setCreatedOn(new Date(2017 - 11 - 18));
record2
.
setLastModifiedOn
(
new
Date
(
2017
-
12
-
21
));
//
record2.setLastModifiedOn(new Date(2017 - 12 - 21));
//
data
.
add
(
record1
);
//
data.add(record1);
data
.
add
(
record2
);
//
data.add(record2);
return
data
;
//
return data;
}
//
}
}
//
}
src/test/java/com/nisum/mytime/controllertest/UserControllerTest.java
View file @
65c9aaa9
...
@@ -32,9 +32,9 @@ import com.fasterxml.jackson.databind.ObjectMapper;
...
@@ -32,9 +32,9 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import
com.nisum.mytime.controller.UserController
;
import
com.nisum.mytime.controller.UserController
;
import
com.nisum.mytime.model.Account
;
import
com.nisum.mytime.model.Account
;
import
com.nisum.mytime.model.Designation
;
import
com.nisum.mytime.model.Designation
;
import
com.nisum.mytime.model.Domain
s
;
import
com.nisum.mytime.model.Domain
;
import
com.nisum.mytime.model.EmployeeLocationDetails
;
import
com.nisum.mytime.model.EmployeeLocationDetails
;
import
com.nisum.mytime.model.Employee
Roles
;
import
com.nisum.mytime.model.Employee
;
import
com.nisum.mytime.model.Location
;
import
com.nisum.mytime.model.Location
;
import
com.nisum.mytime.model.MasterData
;
import
com.nisum.mytime.model.MasterData
;
import
com.nisum.mytime.model.Shift
;
import
com.nisum.mytime.model.Shift
;
...
@@ -63,7 +63,7 @@ public class UserControllerTest {
...
@@ -63,7 +63,7 @@ public class UserControllerTest {
@Test
@Test
public
void
testgetEmployeeRoleAsAdmin
()
throws
Exception
{
public
void
testgetEmployeeRoleAsAdmin
()
throws
Exception
{
Employee
Roles
employeesRole
=
new
EmployeeRoles
(
"5b307d7e708ef705c4ca64d8"
,
"16694"
,
"Mahesh Deekonda"
,
Employee
employeesRole
=
new
Employee
(
"5b307d7e708ef705c4ca64d8"
,
"16694"
,
"Mahesh Deekonda"
,
"mdeekonda@nisum.com"
,
"Admin"
,
"Senior software engineer"
,
null
,
null
,
"Support"
,
"Hyderabad"
,
null
,
"mdeekonda@nisum.com"
,
"Admin"
,
"Senior software engineer"
,
null
,
null
,
"Support"
,
"Hyderabad"
,
null
,
null
,
null
,
null
,
"ACI - Support"
,
"Active"
,
null
,
new
Date
(
2017
-
11
-
20
),
new
Date
(
2107
-
12
-
23
),
null
,
null
,
null
,
"ACI - Support"
,
"Active"
,
null
,
new
Date
(
2017
-
11
-
20
),
new
Date
(
2107
-
12
-
23
),
"Male"
,
null
,
new
Date
(
2020
-
01
-
01
),
null
,
new
Date
(
2018
-
01
-
01
),
new
Date
(
2018
-
02
-
15
),
"Male"
,
null
,
new
Date
(
2020
-
01
-
01
),
null
,
new
Date
(
2018
-
01
-
01
),
new
Date
(
2018
-
02
-
15
),
...
@@ -77,7 +77,7 @@ public class UserControllerTest {
...
@@ -77,7 +77,7 @@ public class UserControllerTest {
@Test
@Test
public
void
testgetEmployeeRoleAsEmp
()
throws
Exception
{
public
void
testgetEmployeeRoleAsEmp
()
throws
Exception
{
Employee
Roles
employeesRole
=
new
EmployeeRoles
(
"5b307d7e708ef705c4ca64d8"
,
"16694"
,
"Mahesh Deekonda"
,
Employee
employeesRole
=
new
Employee
(
"5b307d7e708ef705c4ca64d8"
,
"16694"
,
"Mahesh Deekonda"
,
"mdeekonda@nisum.com"
,
"Employee"
,
"Senior software engineer"
,
null
,
null
,
"Support"
,
"Hyderabad"
,
null
,
"mdeekonda@nisum.com"
,
"Employee"
,
"Senior software engineer"
,
null
,
null
,
"Support"
,
"Hyderabad"
,
null
,
null
,
null
,
null
,
"ACI - Support"
,
"Active"
,
null
,
new
Date
(
2017
-
11
-
20
),
new
Date
(
2107
-
12
-
23
),
null
,
null
,
null
,
"ACI - Support"
,
"Active"
,
null
,
new
Date
(
2017
-
11
-
20
),
new
Date
(
2107
-
12
-
23
),
"Male"
,
null
,
new
Date
(
2020
-
01
-
01
),
null
,
new
Date
(
2018
-
01
-
01
),
new
Date
(
2018
-
02
-
15
),
"Male"
,
null
,
new
Date
(
2020
-
01
-
01
),
null
,
new
Date
(
2018
-
01
-
01
),
new
Date
(
2018
-
02
-
15
),
...
@@ -92,7 +92,7 @@ public class UserControllerTest {
...
@@ -92,7 +92,7 @@ public class UserControllerTest {
@Test
@Test
public
void
testassigingEmployeeRole
()
throws
Exception
{
public
void
testassigingEmployeeRole
()
throws
Exception
{
Employee
Roles
employeeRole
=
new
EmployeeRoles
(
"5976ef15874c902c98b8a05d"
,
null
,
null
,
null
,
null
,
null
,
null
,
Employee
employeeRole
=
new
Employee
(
"5976ef15874c902c98b8a05d"
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
"user@nisum.com"
,
null
,
null
,
null
,
new
Date
(
2017
-
11
-
20
),
null
,
null
,
null
,
null
,
null
,
null
,
"user@nisum.com"
,
null
,
null
,
null
,
new
Date
(
2017
-
11
-
20
),
new
Date
(
2107
-
12
-
23
),
null
,
null
,
null
,
null
,
new
Date
(
2020
-
01
-
01
),
new
Date
(
2018
-
01
-
01
),
new
Date
(
2107
-
12
-
23
),
null
,
null
,
null
,
null
,
new
Date
(
2020
-
01
-
01
),
new
Date
(
2018
-
01
-
01
),
new
Date
(
2018
-
02
-
15
),
new
Date
(
2018
-
02
-
15
),
"Mahesh"
,
"Mahesh"
);
new
Date
(
2018
-
02
-
15
),
new
Date
(
2018
-
02
-
15
),
"Mahesh"
,
"Mahesh"
);
...
@@ -107,7 +107,7 @@ public class UserControllerTest {
...
@@ -107,7 +107,7 @@ public class UserControllerTest {
@Test
@Test
public
void
testupdateEmployeeRole
()
throws
Exception
{
public
void
testupdateEmployeeRole
()
throws
Exception
{
Employee
Roles
employeeRole2
=
new
EmployeeRoles
(
"5976ef15874c902c98b8a05d"
,
null
,
null
,
null
,
null
,
null
,
null
,
Employee
employeeRole2
=
new
Employee
(
"5976ef15874c902c98b8a05d"
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
"user@nisum.com"
,
null
,
null
,
null
,
new
Date
(
2017
-
11
-
20
),
null
,
null
,
null
,
null
,
null
,
null
,
"user@nisum.com"
,
null
,
null
,
null
,
new
Date
(
2017
-
11
-
20
),
new
Date
(
2107
-
12
-
23
),
null
,
null
,
null
,
null
,
new
Date
(
2020
-
01
-
01
),
new
Date
(
2018
-
01
-
01
),
new
Date
(
2107
-
12
-
23
),
null
,
null
,
null
,
null
,
new
Date
(
2020
-
01
-
01
),
new
Date
(
2018
-
01
-
01
),
new
Date
(
2018
-
02
-
15
),
new
Date
(
2018
-
02
-
15
),
"Mahesh"
,
"Mahesh"
);
new
Date
(
2018
-
02
-
15
),
new
Date
(
2018
-
02
-
15
),
"Mahesh"
,
"Mahesh"
);
...
@@ -129,7 +129,7 @@ public class UserControllerTest {
...
@@ -129,7 +129,7 @@ public class UserControllerTest {
@Test
@Test
public
void
testgetUserRoles
()
throws
Exception
{
public
void
testgetUserRoles
()
throws
Exception
{
List
<
Employee
Roles
>
employeesRole3
=
CreateUserRoles
();
List
<
Employee
>
employeesRole3
=
CreateUserRoles
();
when
(
userService
.
getEmployeeRoles
()).
thenReturn
(
employeesRole3
);
when
(
userService
.
getEmployeeRoles
()).
thenReturn
(
employeesRole3
);
mockMvc
.
perform
(
get
(
"/user/getUserRoles"
).
contentType
(
MediaType
.
APPLICATION_JSON_VALUE
))
mockMvc
.
perform
(
get
(
"/user/getUserRoles"
).
contentType
(
MediaType
.
APPLICATION_JSON_VALUE
))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
...
@@ -138,7 +138,7 @@ public class UserControllerTest {
...
@@ -138,7 +138,7 @@ public class UserControllerTest {
@Test
@Test
public
void
testgetEmployeeRoleData
()
throws
Exception
{
public
void
testgetEmployeeRoleData
()
throws
Exception
{
Employee
Roles
employeesRole
=
new
EmployeeRoles
(
"5b307d7e708ef705c4ca64d8"
,
"16694"
,
"Mahesh Deekonda"
,
Employee
employeesRole
=
new
Employee
(
"5b307d7e708ef705c4ca64d8"
,
"16694"
,
"Mahesh Deekonda"
,
"mdeekonda@nisum.com"
,
"Admin"
,
"Senior software engineer"
,
null
,
null
,
"Support"
,
"Hyderabad"
,
null
,
"mdeekonda@nisum.com"
,
"Admin"
,
"Senior software engineer"
,
null
,
null
,
"Support"
,
"Hyderabad"
,
null
,
null
,
null
,
null
,
"ACI - Support"
,
"Active"
,
null
,
new
Date
(
2017
-
11
-
20
),
new
Date
(
2107
-
12
-
23
),
null
,
null
,
null
,
"ACI - Support"
,
"Active"
,
null
,
new
Date
(
2017
-
11
-
20
),
new
Date
(
2107
-
12
-
23
),
"Male"
,
null
,
new
Date
(
2020
-
01
-
01
),
null
,
new
Date
(
2018
-
01
-
01
),
new
Date
(
2018
-
02
-
15
),
"Male"
,
null
,
new
Date
(
2020
-
01
-
01
),
null
,
new
Date
(
2018
-
01
-
01
),
new
Date
(
2018
-
02
-
15
),
...
@@ -168,7 +168,7 @@ public class UserControllerTest {
...
@@ -168,7 +168,7 @@ public class UserControllerTest {
@Test
@Test
public
void
testgetEmployeeRoleDataForEmailIdSearch
()
throws
Exception
{
public
void
testgetEmployeeRoleDataForEmailIdSearch
()
throws
Exception
{
Employee
Roles
employeesRole
=
new
EmployeeRoles
(
"5b307d7d708ef705c4ca5c90"
,
"16209"
,
"Mahesh Kumar Gutam"
,
Employee
employeesRole
=
new
Employee
(
"5b307d7d708ef705c4ca5c90"
,
"16209"
,
"Mahesh Kumar Gutam"
,
"dummy@nisum.com"
,
"Employee"
,
"Software Engineer"
,
null
,
null
,
"Sell"
,
"Hyderabad"
,
null
,
null
,
null
,
"dummy@nisum.com"
,
"Employee"
,
"Software Engineer"
,
null
,
null
,
"Sell"
,
"Hyderabad"
,
null
,
null
,
null
,
null
,
"APPS"
,
"Active"
,
"Full Time"
,
new
Date
(
2017
-
11
-
20
),
new
Date
(
2107
-
12
-
23
),
"Male"
,
null
,
null
,
"APPS"
,
"Active"
,
"Full Time"
,
new
Date
(
2017
-
11
-
20
),
new
Date
(
2107
-
12
-
23
),
"Male"
,
null
,
null
,
null
,
new
Date
(
2020
-
01
-
01
),
new
Date
(
2018
-
01
-
01
),
new
Date
(
2018
-
02
-
15
),
null
,
null
,
new
Date
(
2020
-
01
-
01
),
new
Date
(
2018
-
01
-
01
),
new
Date
(
2018
-
02
-
15
),
...
@@ -183,7 +183,7 @@ public class UserControllerTest {
...
@@ -183,7 +183,7 @@ public class UserControllerTest {
@Test
@Test
public
void
testgetEmployeeRoleDataForEmployeeNameSearch
()
throws
Exception
{
public
void
testgetEmployeeRoleDataForEmployeeNameSearch
()
throws
Exception
{
Employee
Roles
employeesRole
=
new
EmployeeRoles
(
"5b307d7d708ef705c4ca5c90"
,
"16209"
,
"Mahesh Kumar Gutam"
,
Employee
employeesRole
=
new
Employee
(
"5b307d7d708ef705c4ca5c90"
,
"16209"
,
"Mahesh Kumar Gutam"
,
"dummy@nisum.com"
,
"Employee"
,
"Software Engineer"
,
null
,
null
,
"Sell"
,
"Hyderabad"
,
null
,
null
,
null
,
"dummy@nisum.com"
,
"Employee"
,
"Software Engineer"
,
null
,
null
,
"Sell"
,
"Hyderabad"
,
null
,
null
,
null
,
null
,
"APPS"
,
"Active"
,
"Full Time"
,
new
Date
(
2017
-
11
-
20
),
new
Date
(
2107
-
12
-
23
),
"Male"
,
null
,
null
,
"APPS"
,
"Active"
,
"Full Time"
,
new
Date
(
2017
-
11
-
20
),
new
Date
(
2107
-
12
-
23
),
"Male"
,
null
,
null
,
null
,
new
Date
(
2020
-
01
-
01
),
new
Date
(
2018
-
01
-
01
),
new
Date
(
2018
-
02
-
15
),
null
,
null
,
new
Date
(
2020
-
01
-
01
),
new
Date
(
2018
-
01
-
01
),
new
Date
(
2018
-
02
-
15
),
...
@@ -224,7 +224,7 @@ public class UserControllerTest {
...
@@ -224,7 +224,7 @@ public class UserControllerTest {
@Test
@Test
public
void
testgetManagers
()
throws
Exception
{
public
void
testgetManagers
()
throws
Exception
{
List
<
Employee
Roles
>
employeesRole4
=
CreateUserRoles
();
List
<
Employee
>
employeesRole4
=
CreateUserRoles
();
System
.
out
.
println
(
employeesRole4
);
System
.
out
.
println
(
employeesRole4
);
when
(
userService
.
getEmployeeRoles
()).
thenReturn
(
employeesRole4
);
when
(
userService
.
getEmployeeRoles
()).
thenReturn
(
employeesRole4
);
mockMvc
.
perform
(
get
(
"/user/getManagers"
)).
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
mockMvc
.
perform
(
get
(
"/user/getManagers"
)).
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
...
@@ -265,7 +265,7 @@ public class UserControllerTest {
...
@@ -265,7 +265,7 @@ public class UserControllerTest {
@Test
@Test
public
void
testupdateProfile
()
throws
Exception
{
public
void
testupdateProfile
()
throws
Exception
{
Employee
Roles
employeeRole
=
new
EmployeeRoles
(
"5976ef15874c902c98b8a05d"
,
null
,
null
,
null
,
null
,
null
,
null
,
Employee
employeeRole
=
new
Employee
(
"5976ef15874c902c98b8a05d"
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
"user@nisum.com"
,
null
,
null
,
null
,
new
Date
(
2017
-
11
-
20
),
null
,
null
,
null
,
null
,
null
,
null
,
"user@nisum.com"
,
null
,
null
,
null
,
new
Date
(
2017
-
11
-
20
),
new
Date
(
2107
-
12
-
23
),
null
,
null
,
null
,
null
,
new
Date
(
2020
-
01
-
01
),
new
Date
(
2018
-
01
-
01
),
new
Date
(
2107
-
12
-
23
),
null
,
null
,
null
,
null
,
new
Date
(
2020
-
01
-
01
),
new
Date
(
2018
-
01
-
01
),
new
Date
(
2018
-
02
-
15
),
new
Date
(
2018
-
02
-
15
),
"Mahesh"
,
"Mahesh"
);
new
Date
(
2018
-
02
-
15
),
new
Date
(
2018
-
02
-
15
),
"Mahesh"
,
"Mahesh"
);
...
@@ -298,7 +298,7 @@ public class UserControllerTest {
...
@@ -298,7 +298,7 @@ public class UserControllerTest {
@Test
@Test
public
void
testGetEmployeeByStatus
()
throws
Exception
{
public
void
testGetEmployeeByStatus
()
throws
Exception
{
List
<
Employee
Roles
>
empRolesList
=
employeeRoles
();
List
<
Employee
>
empRolesList
=
employeeRoles
();
when
(
userService
.
getEmployeesByStatus
(
"Active"
)).
thenReturn
(
empRolesList
);
when
(
userService
.
getEmployeesByStatus
(
"Active"
)).
thenReturn
(
empRolesList
);
mockMvc
.
perform
(
get
(
"/user/getEmployeeByStatus"
).
param
(
"status"
,
"Active"
))
mockMvc
.
perform
(
get
(
"/user/getEmployeeByStatus"
).
param
(
"status"
,
"Active"
))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
...
@@ -418,10 +418,10 @@ public class UserControllerTest {
...
@@ -418,10 +418,10 @@ public class UserControllerTest {
return
data
;
return
data
;
}
}
private
List
<
Employee
Roles
>
CreateUserRoles
()
{
private
List
<
Employee
>
CreateUserRoles
()
{
List
<
Employee
Roles
>
data
=
new
ArrayList
<>();
List
<
Employee
>
data
=
new
ArrayList
<>();
Employee
Roles
data1
=
new
EmployeeRoles
();
Employee
data1
=
new
Employee
();
data1
.
setId
(
"3976ef15874c902c98b8a05d"
);
data1
.
setId
(
"3976ef15874c902c98b8a05d"
);
data1
.
setEmployeeId
(
"16101"
);
data1
.
setEmployeeId
(
"16101"
);
data1
.
setEmployeeName
(
"Abc"
);
data1
.
setEmployeeName
(
"Abc"
);
...
@@ -437,7 +437,7 @@ public class UserControllerTest {
...
@@ -437,7 +437,7 @@ public class UserControllerTest {
data1
.
setCreatedOn
(
new
Date
(
2017
-
11
-
21
));
data1
.
setCreatedOn
(
new
Date
(
2017
-
11
-
21
));
data1
.
setLastModifiedOn
(
new
Date
(
2017
-
12
-
22
));
data1
.
setLastModifiedOn
(
new
Date
(
2017
-
12
-
22
));
Employee
Roles
data2
=
new
EmployeeRoles
();
Employee
data2
=
new
Employee
();
data2
.
setId
(
"4976ef15874c902c98b8a05d"
);
data2
.
setId
(
"4976ef15874c902c98b8a05d"
);
data2
.
setEmployeeId
(
"16102"
);
data2
.
setEmployeeId
(
"16102"
);
data2
.
setEmployeeName
(
"Xyz"
);
data2
.
setEmployeeName
(
"Xyz"
);
...
@@ -483,14 +483,14 @@ public class UserControllerTest {
...
@@ -483,14 +483,14 @@ public class UserControllerTest {
return
masterDataList
;
return
masterDataList
;
}
}
private
List
<
Employee
Roles
>
employeeRoles
()
{
private
List
<
Employee
>
employeeRoles
()
{
List
<
Employee
Roles
>
employeeRoles
=
new
ArrayList
<
EmployeeRoles
>();
List
<
Employee
>
employeeRoles
=
new
ArrayList
<
Employee
>();
Employee
Roles
employeesRole1
=
new
EmployeeRoles
(
"5b307d7d708ef705c4ca5c90"
,
null
,
null
,
null
,
null
,
null
,
null
,
Employee
employeesRole1
=
new
Employee
(
"5b307d7d708ef705c4ca5c90"
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
"dummy@nisum.com"
,
null
,
null
,
null
,
new
Date
(
2017
-
11
-
20
),
null
,
null
,
null
,
null
,
null
,
null
,
"dummy@nisum.com"
,
null
,
null
,
null
,
new
Date
(
2017
-
11
-
20
),
new
Date
(
2107
-
12
-
23
),
null
,
null
,
null
,
null
,
new
Date
(
2020
-
01
-
01
),
new
Date
(
2018
-
01
-
01
),
new
Date
(
2107
-
12
-
23
),
null
,
null
,
null
,
null
,
new
Date
(
2020
-
01
-
01
),
new
Date
(
2018
-
01
-
01
),
new
Date
(
2018
-
02
-
15
),
new
Date
(
2018
-
02
-
15
),
"Mahesh"
,
"Mahesh"
);
new
Date
(
2018
-
02
-
15
),
new
Date
(
2018
-
02
-
15
),
"Mahesh"
,
"Mahesh"
);
Employee
Roles
employeesRole2
=
new
EmployeeRoles
(
"5976ef15874c902c98b8a05d"
,
null
,
null
,
null
,
null
,
null
,
null
,
Employee
employeesRole2
=
new
Employee
(
"5976ef15874c902c98b8a05d"
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
"user@nisum.com"
,
null
,
null
,
null
,
new
Date
(
2017
-
11
-
20
),
null
,
null
,
null
,
null
,
null
,
null
,
"user@nisum.com"
,
null
,
null
,
null
,
new
Date
(
2017
-
11
-
20
),
new
Date
(
2107
-
12
-
23
),
null
,
null
,
null
,
null
,
new
Date
(
2020
-
01
-
01
),
new
Date
(
2018
-
01
-
01
),
new
Date
(
2107
-
12
-
23
),
null
,
null
,
null
,
null
,
new
Date
(
2020
-
01
-
01
),
new
Date
(
2018
-
01
-
01
),
new
Date
(
2018
-
02
-
15
),
new
Date
(
2018
-
02
-
15
),
"Mahesh"
,
"Mahesh"
);
new
Date
(
2018
-
02
-
15
),
new
Date
(
2018
-
02
-
15
),
"Mahesh"
,
"Mahesh"
);
...
@@ -511,7 +511,7 @@ public class UserControllerTest {
...
@@ -511,7 +511,7 @@ public class UserControllerTest {
return
empLocation
;
return
empLocation
;
}
}
private
List
<
Domain
s
>
domains
()
{
private
List
<
Domain
>
domains
()
{
List
<
String
>
dl1
=
new
ArrayList
<
String
>();
List
<
String
>
dl1
=
new
ArrayList
<
String
>();
dl1
.
add
(
"16120"
);
dl1
.
add
(
"16120"
);
dl1
.
add
(
"16121"
);
dl1
.
add
(
"16121"
);
...
@@ -520,11 +520,11 @@ public class UserControllerTest {
...
@@ -520,11 +520,11 @@ public class UserControllerTest {
dl2
.
add
(
"16122"
);
dl2
.
add
(
"16122"
);
dl2
.
add
(
"16123"
);
dl2
.
add
(
"16123"
);
List
<
Domain
s
>
domains
=
new
ArrayList
<
Domains
>();
List
<
Domain
>
domains
=
new
ArrayList
<
Domain
>();
Domain
s
d1
=
new
Domains
(
new
ObjectId
(
"5b61be677c43a53a634f77b1"
),
"DOM001"
,
"Customer"
,
"Acc001"
,
"Active"
,
Domain
d1
=
new
Domain
(
"DOM001"
,
"Customer"
,
"Acc001"
,
"Active"
,
dl1
);
dl1
);
Domain
s
d2
=
new
Domains
(
new
ObjectId
(
"5b76b7f5094e433005abbede"
),
"DOM005"
,
"rajesh"
,
"Acc001"
,
"Active"
,
dl2
);
Domain
d2
=
new
Domain
(
"DOM005"
,
"rajesh"
,
"Acc001"
,
"Active"
,
dl2
);
domains
.
add
(
d1
);
domains
.
add
(
d1
);
domains
.
add
(
d2
);
domains
.
add
(
d2
);
...
...
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