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
a54c15af
Commit
a54c15af
authored
Aug 30, 2018
by
Rajashekar jadala
Committed by
rbonthala-nisum-com
Aug 30, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
JUnit test cases (#168)
parent
254a5363
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
448 additions
and
381 deletions
+448
-381
UserControllerTest.java
...a/com/nisum/mytime/controllertest/UserControllerTest.java
+448
-381
No files found.
src/test/java/com/nisum/mytime/controllertest/UserControllerTest.java
View file @
a54c15af
...
@@ -2,6 +2,7 @@ package com.nisum.mytime.controllertest;
...
@@ -2,6 +2,7 @@ package com.nisum.mytime.controllertest;
import
static
org
.
hamcrest
.
CoreMatchers
.
is
;
import
static
org
.
hamcrest
.
CoreMatchers
.
is
;
import
static
org
.
mockito
.
Matchers
.
anyObject
;
import
static
org
.
mockito
.
Matchers
.
anyObject
;
import
static
org
.
mockito
.
Mockito
.
atLeastOnce
;
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
;
...
@@ -12,7 +13,9 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
...
@@ -12,7 +13,9 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
org.bson.types.ObjectId
;
import
org.bson.types.ObjectId
;
import
org.junit.Before
;
import
org.junit.Before
;
...
@@ -29,10 +32,14 @@ import com.fasterxml.jackson.databind.ObjectMapper;
...
@@ -29,10 +32,14 @@ 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.Domains
;
import
com.nisum.mytime.model.EmployeeLocationDetails
;
import
com.nisum.mytime.model.EmployeeRoles
;
import
com.nisum.mytime.model.EmployeeRoles
;
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
;
import
com.nisum.mytime.model.Skill
;
import
com.nisum.mytime.model.Skill
;
import
com.nisum.mytime.service.RoleMappingService
;
import
com.nisum.mytime.service.UserService
;
import
com.nisum.mytime.service.UserService
;
public
class
UserControllerTest
{
public
class
UserControllerTest
{
...
@@ -40,6 +47,9 @@ public class UserControllerTest {
...
@@ -40,6 +47,9 @@ public class UserControllerTest {
@Mock
@Mock
UserService
userService
;
UserService
userService
;
@Mock
RoleMappingService
roleMappingService
;
@InjectMocks
@InjectMocks
UserController
userController
;
UserController
userController
;
...
@@ -52,58 +62,62 @@ public class UserControllerTest {
...
@@ -52,58 +62,62 @@ public class UserControllerTest {
}
}
@Test
@Test
public
void
testgetEmployeeRole
()
throws
Exception
{
public
void
testgetEmployeeRoleAsAdmin
()
throws
Exception
{
EmployeeRoles
employeesRole
=
new
EmployeeRoles
(
EmployeeRoles
employeesRole
=
new
EmployeeRoles
(
"5b307d7e708ef705c4ca64d8"
,
"16694"
,
"Mahesh Deekonda"
,
"5976ef15874c902c98b8a05d"
,
null
,
null
,
null
,
null
,
null
,
null
,
"mdeekonda@nisum.com"
,
"Admin"
,
"Senior software engineer"
,
null
,
null
,
"Support"
,
"Hyderabad"
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
"user@nisum.com"
,
null
,
null
,
null
,
null
,
"ACI - Support"
,
"Active"
,
null
,
new
Date
(
2017
-
11
-
20
),
new
Date
(
2107
-
12
-
23
),
null
,
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
),
null
,
new
Date
(
2018
-
02
-
15
),
null
,
"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
(
"mdeekonda@nisum.com"
)).
thenReturn
(
employeesRole
);
when
(
userService
.
getEmployeesRole
(
"mdeekonda@nisum.com"
))
mockMvc
.
perform
(
get
(
"/user/employee"
).
param
(
"emailId"
,
"mdeekonda@nisum.com"
))
.
thenReturn
(
employeesRole
);
mockMvc
.
perform
(
get
(
"/user/employee"
).
param
(
"emailId"
,
"mdeekonda@nisum.com"
))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
verify
(
userService
).
getEmployeesRole
(
"mdeekonda@nisum.com"
);
verify
(
userService
).
getEmployeesRole
(
"mdeekonda@nisum.com"
);
}
}
@Test
public
void
testgetEmployeeRoleAsEmp
()
throws
Exception
{
EmployeeRoles
employeesRole
=
new
EmployeeRoles
(
"5b307d7e708ef705c4ca64d8"
,
"16694"
,
"Mahesh Deekonda"
,
"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
),
"Male"
,
null
,
new
Date
(
2020
-
01
-
01
),
null
,
new
Date
(
2018
-
01
-
01
),
new
Date
(
2018
-
02
-
15
),
new
Date
(
2018
-
02
-
15
),
null
,
"Mahesh"
,
"Mahesh"
);
when
(
userService
.
getEmployeesRole
(
"mdeekonda@nisum.com"
)).
thenReturn
(
employeesRole
);
when
(
roleMappingService
.
getEmployeeRole
(
employeesRole
.
getEmployeeId
())).
thenReturn
(
"Delivery Lead"
);
mockMvc
.
perform
(
get
(
"/user/employee"
).
param
(
"emailId"
,
"mdeekonda@nisum.com"
))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
verify
(
userService
).
getEmployeesRole
(
"mdeekonda@nisum.com"
);
verify
(
roleMappingService
).
getEmployeeRole
(
"16694"
);
}
@Test
@Test
public
void
testassigingEmployeeRole
()
throws
Exception
{
public
void
testassigingEmployeeRole
()
throws
Exception
{
EmployeeRoles
employeeRole
=
new
EmployeeRoles
(
EmployeeRoles
employeeRole
=
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
,
new
Date
(
2017
-
11
-
20
),
null
,
null
,
null
,
null
,
null
,
null
,
"user@nisum.com"
,
null
,
new
Date
(
2107
-
12
-
23
),
null
,
null
,
null
,
null
,
new
Date
(
2020
-
01
-
01
),
new
Date
(
2018
-
01
-
01
),
null
,
null
,
new
Date
(
2017
-
11
-
20
),
new
Date
(
2107
-
12
-
23
),
new
Date
(
2018
-
02
-
15
),
new
Date
(
2018
-
02
-
15
),
"Mahesh"
,
"Mahesh"
);
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"
);
ObjectMapper
mapper
=
new
ObjectMapper
();
ObjectMapper
mapper
=
new
ObjectMapper
();
String
jsonString
=
mapper
.
writeValueAsString
(
employeeRole
);
String
jsonString
=
mapper
.
writeValueAsString
(
employeeRole
);
when
(
userService
.
assigingEmployeeRole
(
anyObject
(),
anyObject
()))
when
(
userService
.
assigingEmployeeRole
(
anyObject
(),
anyObject
())).
thenReturn
(
employeeRole
);
.
thenReturn
(
employeeRole
);
mockMvc
.
perform
(
post
(
"/user/assignEmployeeRole"
).
param
(
"empId"
,
"16999"
)
mockMvc
.
perform
(
post
(
"/user/assignEmployeeRole"
).
param
(
"empId"
,
"16999"
)
.
contentType
(
MediaType
.
APPLICATION_JSON_VALUE
)
.
contentType
(
MediaType
.
APPLICATION_JSON_VALUE
).
content
(
jsonString
))
.
content
(
jsonString
))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
verify
(
userService
).
assigingEmployeeRole
(
anyObject
(),
anyObject
());
verify
(
userService
).
assigingEmployeeRole
(
anyObject
(),
anyObject
());
}
}
@Test
@Test
public
void
testupdateEmployeeRole
()
throws
Exception
{
public
void
testupdateEmployeeRole
()
throws
Exception
{
EmployeeRoles
employeeRole2
=
new
EmployeeRoles
(
EmployeeRoles
employeeRole2
=
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
,
new
Date
(
2017
-
11
-
20
),
null
,
null
,
null
,
null
,
null
,
null
,
"user@nisum.com"
,
null
,
new
Date
(
2107
-
12
-
23
),
null
,
null
,
null
,
null
,
new
Date
(
2020
-
01
-
01
),
new
Date
(
2018
-
01
-
01
),
null
,
null
,
new
Date
(
2017
-
11
-
20
),
new
Date
(
2107
-
12
-
23
),
new
Date
(
2018
-
02
-
15
),
new
Date
(
2018
-
02
-
15
),
"Mahesh"
,
"Mahesh"
);
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"
);
ObjectMapper
mapper
=
new
ObjectMapper
();
ObjectMapper
mapper
=
new
ObjectMapper
();
String
jsonString
=
mapper
.
writeValueAsString
(
employeeRole2
);
String
jsonString
=
mapper
.
writeValueAsString
(
employeeRole2
);
when
(
userService
.
updateEmployeeRole
(
anyObject
(),
anyObject
()))
when
(
userService
.
updateEmployeeRole
(
anyObject
(),
anyObject
())).
thenReturn
(
employeeRole2
);
.
thenReturn
(
employeeRole2
);
mockMvc
.
perform
(
post
(
"/user/updateEmployeeRole"
).
param
(
"empId"
,
"16999"
)
mockMvc
.
perform
(
post
(
"/user/updateEmployeeRole"
).
param
(
"empId"
,
"16999"
)
.
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
...
@@ -117,73 +131,71 @@ public class UserControllerTest {
...
@@ -117,73 +131,71 @@ public class UserControllerTest {
public
void
testgetUserRoles
()
throws
Exception
{
public
void
testgetUserRoles
()
throws
Exception
{
List
<
EmployeeRoles
>
employeesRole3
=
CreateUserRoles
();
List
<
EmployeeRoles
>
employeesRole3
=
CreateUserRoles
();
when
(
userService
.
getEmployeeRoles
()).
thenReturn
(
employeesRole3
);
when
(
userService
.
getEmployeeRoles
()).
thenReturn
(
employeesRole3
);
mockMvc
.
perform
(
get
(
"/user/getUserRoles"
)
mockMvc
.
perform
(
get
(
"/user/getUserRoles"
).
contentType
(
MediaType
.
APPLICATION_JSON_VALUE
))
.
contentType
(
MediaType
.
APPLICATION_JSON_VALUE
))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
verify
(
userService
).
getEmployeeRoles
();
verify
(
userService
).
getEmployeeRoles
();
}
}
@Test
@Test
public
void
testgetEmployeeRoleData
()
throws
Exception
{
public
void
testgetEmployeeRoleData
()
throws
Exception
{
EmployeeRoles
employeesRole
=
new
EmployeeRoles
(
EmployeeRoles
employeesRole
=
new
EmployeeRoles
(
"5b307d7e708ef705c4ca64d8"
,
"16694"
,
"Mahesh Deekonda"
,
"5976ef15874c902c98b8a05d"
,
null
,
null
,
null
,
null
,
null
,
null
,
"mdeekonda@nisum.com"
,
"Admin"
,
"Senior software engineer"
,
null
,
null
,
"Support"
,
"Hyderabad"
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
"user@nisum.com"
,
null
,
null
,
null
,
null
,
"ACI - Support"
,
"Active"
,
null
,
new
Date
(
2017
-
11
-
20
),
new
Date
(
2107
-
12
-
23
),
null
,
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
),
null
,
new
Date
(
2018
-
02
-
15
),
null
,
"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
(
"16694"
)).
thenReturn
(
employeesRole
);
when
(
userService
.
getEmployeesRoleData
(
"16127"
))
mockMvc
.
perform
(
.
thenReturn
(
employeesRole
);
get
(
"/user/getEmployeeRoleData"
).
param
(
"empId"
,
"16694"
).
contentType
(
MediaType
.
APPLICATION_JSON_VALUE
))
mockMvc
.
perform
(
get
(
"/user/getEmployeeRoleData"
).
param
(
"empId"
,
"16127"
)
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
()).
andExpect
(
jsonPath
(
"$.employeeId"
,
is
(
"16694"
)))
.
contentType
(
MediaType
.
APPLICATION_JSON_VALUE
))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
())
.
andExpect
(
jsonPath
(
"$.employeeId"
,
is
(
"16127"
)))
.
andDo
(
print
());
.
andDo
(
print
());
verify
(
userService
).
getEmployeesRoleData
(
"16127"
);
verify
(
userService
).
getEmployeesRoleData
(
"16694"
);
}
@Test
public
void
testgetEmployeeLocations
()
throws
Exception
{
List
<
EmployeeLocationDetails
>
empLocList
=
new
ArrayList
<
EmployeeLocationDetails
>();
EmployeeLocationDetails
empLocation
=
new
EmployeeLocationDetails
(
new
ObjectId
(
"5b307d7d708ef705c4ca59c4"
),
"16090"
,
"Dharmendra Kumar Jampana"
,
"Hyderabad"
,
new
Date
(
2020
-
01
-
01
),
new
Date
(
2018
-
01
-
01
),
new
Date
(
2018
-
02
-
15
),
new
Date
(
2018
-
02
-
15
),
true
);
empLocList
.
add
(
empLocation
);
when
(
userService
.
getEmployeeLocationDetails
(
"16090"
)).
thenReturn
(
empLocList
);
mockMvc
.
perform
(
get
(
"/user/getEmployeeLocations"
).
param
(
"employeeId"
,
"16090"
)
.
contentType
(
MediaType
.
APPLICATION_JSON_VALUE
)).
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
verify
(
userService
).
getEmployeeLocationDetails
(
"16090"
);
}
}
@Test
@Test
public
void
testgetEmployeeRoleDataForEmailIdSearch
()
throws
Exception
{
public
void
testgetEmployeeRoleDataForEmailIdSearch
()
throws
Exception
{
EmployeeRoles
employeesRole
=
new
EmployeeRoles
(
EmployeeRoles
employeesRole
=
new
EmployeeRoles
(
"5b307d7d708ef705c4ca5c90"
,
"16209"
,
"Mahesh Kumar Gutam"
,
"5976ef15874c902c98b8a05d"
,
null
,
null
,
null
,
null
,
null
,
null
,
"dummy@nisum.com"
,
"Employee"
,
"Software Engineer"
,
null
,
null
,
"Sell"
,
"Hyderabad"
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
"user@nisum.com"
,
null
,
null
,
"APPS"
,
"Active"
,
"Full Time"
,
new
Date
(
2017
-
11
-
20
),
new
Date
(
2107
-
12
-
23
),
"Male"
,
null
,
null
,
null
,
new
Date
(
2017
-
11
-
20
),
new
Date
(
2107
-
12
-
23
),
null
,
null
,
new
Date
(
2020
-
01
-
01
),
new
Date
(
2018
-
01
-
01
),
new
Date
(
2018
-
02
-
15
),
null
,
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
.
getEmployeeRoleDataForSearchCriteria
(
"dummy@nisum.com"
,
"emailId"
)).
thenReturn
(
employeesRole
);
when
(
userService
.
getEmployeeRoleDataForSearchCriteria
(
"dummy@nisum.com"
,
mockMvc
.
perform
(
get
(
"/user/getEmployeeRoleDataForSearchCriteria"
).
param
(
"searchId"
,
"dummy@nisum.com"
)
"emailId"
)).
thenReturn
(
employeesRole
);
.
param
(
"searchAttribute"
,
"emailId"
).
contentType
(
MediaType
.
APPLICATION_JSON_VALUE
))
mockMvc
.
perform
(
get
(
"/user/getEmployeeRoleDataForSearchCriteria"
)
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
()).
andExpect
(
jsonPath
(
"$.employeeId"
,
is
(
"16209"
)))
.
param
(
"searchId"
,
"dummy@nisum.com"
)
.
param
(
"searchAttribute"
,
"emailId"
)
.
contentType
(
MediaType
.
APPLICATION_JSON_VALUE
))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
())
.
andExpect
(
jsonPath
(
"$.employeeId"
,
is
(
"16209"
)))
.
andDo
(
print
());
.
andDo
(
print
());
verify
(
userService
).
getEmployeeRoleDataForSearchCriteria
(
verify
(
userService
).
getEmployeeRoleDataForSearchCriteria
(
"dummy@nisum.com"
,
"emailId"
);
"dummy@nisum.com"
,
"emailId"
);
}
}
@Test
@Test
public
void
testgetEmployeeRoleDataForEmployeeNameSearch
()
public
void
testgetEmployeeRoleDataForEmployeeNameSearch
()
throws
Exception
{
throws
Exception
{
EmployeeRoles
employeesRole
=
new
EmployeeRoles
(
"5b307d7d708ef705c4ca5c90"
,
"16209"
,
"Mahesh Kumar Gutam"
,
EmployeeRoles
employeesRole
=
new
EmployeeRoles
(
"dummy@nisum.com"
,
"Employee"
,
"Software Engineer"
,
null
,
null
,
"Sell"
,
"Hyderabad"
,
null
,
null
,
null
,
"5976ef15874c902c98b8a05d"
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
"APPS"
,
"Active"
,
"Full Time"
,
new
Date
(
2017
-
11
-
20
),
new
Date
(
2107
-
12
-
23
),
"Male"
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
"user@nisum.com"
,
null
,
null
,
null
,
new
Date
(
2020
-
01
-
01
),
new
Date
(
2018
-
01
-
01
),
new
Date
(
2018
-
02
-
15
),
null
,
null
,
new
Date
(
2017
-
11
-
20
),
new
Date
(
2107
-
12
-
23
),
new
Date
(
2018
-
02
-
15
),
"Mahesh"
,
"Mahesh"
);
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
.
getEmployeeRoleDataForSearchCriteria
(
"Mahesh Kumar Gutam"
,
"employeeName"
))
;
when
(
userService
.
getEmployeeRoleDataForSearchCriteria
(
"Mahesh Kumar Gutam"
,
"employeeName"
))
.
thenReturn
(
employeesRole
);
.
thenReturn
(
employeesRole
);
mockMvc
.
perform
(
get
(
"/user/getEmployeeRoleDataForSearchCriteria"
)
mockMvc
.
perform
(
get
(
"/user/getEmployeeRoleDataForSearchCriteria"
).
param
(
"searchId"
,
"Mahesh Kumar Gutam"
)
.
param
(
"searchId"
,
"Mahesh Kumar Gutam"
)
.
param
(
"searchAttribute"
,
"employeeName"
).
contentType
(
MediaType
.
APPLICATION_JSON_VALUE
))
.
param
(
"searchAttribute"
,
"employeeName"
)
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
()).
andExpect
(
jsonPath
(
"$.employeeId"
,
is
(
"16209"
)))
.
contentType
(
MediaType
.
APPLICATION_JSON_VALUE
))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
())
.
andExpect
(
jsonPath
(
"$.employeeId"
,
is
(
"16209"
)))
.
andDo
(
print
());
.
andDo
(
print
());
verify
(
userService
).
getEmployeeRoleDataForSearchCriteria
(
verify
(
userService
).
getEmployeeRoleDataForSearchCriteria
(
"Mahesh Kumar Gutam"
,
"employeeName"
);
"Mahesh Kumar Gutam"
,
"employeeName"
);
}
}
@Test
@Test
...
@@ -204,12 +216,9 @@ public class UserControllerTest {
...
@@ -204,12 +216,9 @@ public class UserControllerTest {
details
.
add
(
"16111"
);
details
.
add
(
"16111"
);
details
.
add
(
"Mahesh Mudrakolu"
);
details
.
add
(
"Mahesh Mudrakolu"
);
details
.
add
(
"mmahesh@nisum.com"
);
details
.
add
(
"mmahesh@nisum.com"
);
when
(
userService
.
getEmployeeDetailsForAutocomplete
())
when
(
userService
.
getEmployeeDetailsForAutocomplete
()).
thenReturn
(
details
);
.
thenReturn
(
details
);
mockMvc
.
perform
(
get
(
"/user/getEmployeeDetailsForAutocomplete"
).
contentType
(
MediaType
.
APPLICATION_JSON_VALUE
))
mockMvc
.
perform
(
get
(
"/user/getEmployeeDetailsForAutocomplete"
)
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
()).
andDo
(
print
());
.
contentType
(
MediaType
.
APPLICATION_JSON_VALUE
))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
())
.
andDo
(
print
());
verify
(
userService
).
getEmployeeDetailsForAutocomplete
();
verify
(
userService
).
getEmployeeDetailsForAutocomplete
();
}
}
...
@@ -218,8 +227,7 @@ public class UserControllerTest {
...
@@ -218,8 +227,7 @@ public class UserControllerTest {
List
<
EmployeeRoles
>
employeesRole4
=
CreateUserRoles
();
List
<
EmployeeRoles
>
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"
))
mockMvc
.
perform
(
get
(
"/user/getManagers"
)).
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
verify
(
userService
).
getEmployeeRoles
();
verify
(
userService
).
getEmployeeRoles
();
}
}
...
@@ -227,8 +235,7 @@ public class UserControllerTest {
...
@@ -227,8 +235,7 @@ public class UserControllerTest {
public
void
testgetAllShifts
()
throws
Exception
{
public
void
testgetAllShifts
()
throws
Exception
{
List
<
Shift
>
shifts
=
CreateShifts
();
List
<
Shift
>
shifts
=
CreateShifts
();
when
(
userService
.
getAllShifts
()).
thenReturn
(
shifts
);
when
(
userService
.
getAllShifts
()).
thenReturn
(
shifts
);
mockMvc
.
perform
(
get
(
"/user/getAllShifts"
))
mockMvc
.
perform
(
get
(
"/user/getAllShifts"
)).
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
verify
(
userService
).
getAllShifts
();
verify
(
userService
).
getAllShifts
();
}
}
...
@@ -236,8 +243,7 @@ public class UserControllerTest {
...
@@ -236,8 +243,7 @@ public class UserControllerTest {
public
void
testgetAllDesignations
()
throws
Exception
{
public
void
testgetAllDesignations
()
throws
Exception
{
List
<
Designation
>
designation
=
CreateDesignations
();
List
<
Designation
>
designation
=
CreateDesignations
();
when
(
userService
.
getAllDesignations
()).
thenReturn
(
designation
);
when
(
userService
.
getAllDesignations
()).
thenReturn
(
designation
);
mockMvc
.
perform
(
get
(
"/user/getAllDesignations"
))
mockMvc
.
perform
(
get
(
"/user/getAllDesignations"
)).
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
verify
(
userService
).
getAllDesignations
();
verify
(
userService
).
getAllDesignations
();
}
}
...
@@ -246,27 +252,29 @@ public class UserControllerTest {
...
@@ -246,27 +252,29 @@ public class UserControllerTest {
List
<
Skill
>
skills
=
CreateSkill
();
List
<
Skill
>
skills
=
CreateSkill
();
System
.
out
.
println
(
skills
);
System
.
out
.
println
(
skills
);
when
(
userService
.
getTechnologies
()).
thenReturn
(
skills
);
when
(
userService
.
getTechnologies
()).
thenReturn
(
skills
);
mockMvc
.
perform
(
get
(
"/user/getSkills"
))
mockMvc
.
perform
(
get
(
"/user/getSkills"
)).
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
verify
(
userService
).
getTechnologies
();
verify
(
userService
).
getTechnologies
();
}
}
@Test
public
void
testgetLocations
()
throws
Exception
{
when
(
userService
.
getLocations
()).
thenReturn
(
locations
());
mockMvc
.
perform
(
get
(
"/user/getLocations"
)).
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
verify
(
userService
,
atLeastOnce
()).
getLocations
();
}
@Test
@Test
public
void
testupdateProfile
()
throws
Exception
{
public
void
testupdateProfile
()
throws
Exception
{
EmployeeRoles
employeeRole
=
new
EmployeeRoles
(
EmployeeRoles
employeeRole
=
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
,
new
Date
(
2017
-
11
-
20
),
null
,
null
,
null
,
null
,
null
,
null
,
"user@nisum.com"
,
null
,
new
Date
(
2107
-
12
-
23
),
null
,
null
,
null
,
null
,
new
Date
(
2020
-
01
-
01
),
new
Date
(
2018
-
01
-
01
),
null
,
null
,
new
Date
(
2017
-
11
-
20
),
new
Date
(
2107
-
12
-
23
),
new
Date
(
2018
-
02
-
15
),
new
Date
(
2018
-
02
-
15
),
"Mahesh"
,
"Mahesh"
);
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"
);;
System
.
out
.
println
(
employeeRole
);
System
.
out
.
println
(
employeeRole
);
ObjectMapper
mapper
=
new
ObjectMapper
();
ObjectMapper
mapper
=
new
ObjectMapper
();
String
jsonString
=
mapper
.
writeValueAsString
(
employeeRole
);
String
jsonString
=
mapper
.
writeValueAsString
(
employeeRole
);
System
.
out
.
println
(
jsonString
);
System
.
out
.
println
(
jsonString
);
when
(
userService
.
updateProfile
(
anyObject
())).
thenReturn
(
employeeRole
);
when
(
userService
.
updateProfile
(
anyObject
())).
thenReturn
(
employeeRole
);
mockMvc
.
perform
(
post
(
"/user/updateProfile"
)
mockMvc
.
perform
(
post
(
"/user/updateProfile"
).
contentType
(
MediaType
.
APPLICATION_JSON_VALUE
).
content
(
jsonString
))
.
contentType
(
MediaType
.
APPLICATION_JSON_VALUE
)
.
content
(
jsonString
))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
verify
(
userService
).
updateProfile
(
anyObject
());
verify
(
userService
).
updateProfile
(
anyObject
());
}
}
...
@@ -276,8 +284,7 @@ public class UserControllerTest {
...
@@ -276,8 +284,7 @@ public class UserControllerTest {
List
<
Account
>
account
=
CreateAccount
();
List
<
Account
>
account
=
CreateAccount
();
System
.
out
.
println
(
account
);
System
.
out
.
println
(
account
);
when
(
userService
.
getAccounts
()).
thenReturn
(
account
);
when
(
userService
.
getAccounts
()).
thenReturn
(
account
);
mockMvc
.
perform
(
get
(
"/user/getAccounts"
))
mockMvc
.
perform
(
get
(
"/user/getAccounts"
)).
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
verify
(
userService
).
getAccounts
();
verify
(
userService
).
getAccounts
();
}
}
...
@@ -298,6 +305,38 @@ public class UserControllerTest {
...
@@ -298,6 +305,38 @@ public class UserControllerTest {
verify
(
userService
).
getEmployeesByStatus
(
"Active"
);
verify
(
userService
).
getEmployeesByStatus
(
"Active"
);
}
}
@Test
public
void
testgetdomains
()
throws
Exception
{
when
(
userService
.
getDomains
(
"Acc001"
)).
thenReturn
(
domains
());
mockMvc
.
perform
(
get
(
"/user/getDomains"
).
param
(
"accountId"
,
"Acc001"
))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
verify
(
userService
).
getDomains
(
"Acc001"
);
}
@Test
public
void
testgetDeliveryLeads
()
throws
Exception
{
HashMap
<
String
,
String
>
dl1
=
new
HashMap
<
String
,
String
>();
dl1
.
put
(
"employeeName"
,
"Madhuri Bayyagari"
);
dl1
.
put
(
"employeeId"
,
"16620"
);
HashMap
<
String
,
String
>
dl2
=
new
HashMap
<
String
,
String
>();
dl2
.
put
(
"employeeName"
,
"Sridhar Swamy Perumbaduri"
);
dl2
.
put
(
"employeeId"
,
"16630"
);
List
<
HashMap
<
String
,
String
>>
dlList
=
new
ArrayList
<
HashMap
<
String
,
String
>>();
dlList
.
add
(
dl1
);
dlList
.
add
(
dl2
);
when
(
userService
.
getDeliveryLeads
(
"DOM001"
)).
thenReturn
(
dlList
);
mockMvc
.
perform
(
get
(
"/user/getDeliveryLeads"
).
param
(
"domainId"
,
"DOM001"
))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
verify
(
userService
).
getDeliveryLeads
(
"DOM001"
);
}
private
List
<
Account
>
CreateAccount
()
{
private
List
<
Account
>
CreateAccount
()
{
List
<
Account
>
data
=
new
ArrayList
<>();
List
<
Account
>
data
=
new
ArrayList
<>();
...
@@ -444,24 +483,52 @@ public class UserControllerTest {
...
@@ -444,24 +483,52 @@ public class UserControllerTest {
return
masterDataList
;
return
masterDataList
;
}
}
private
List
<
EmployeeRoles
>
employeeRoles
()
{
private
List
<
EmployeeRoles
>
employeeRoles
()
{
List
<
EmployeeRoles
>
employeeRoles
=
new
ArrayList
<
EmployeeRoles
>();
List
<
EmployeeRoles
>
employeeRoles
=
new
ArrayList
<
EmployeeRoles
>();
EmployeeRoles
employeesRole1
=
new
EmployeeRoles
(
EmployeeRoles
employeesRole1
=
new
EmployeeRoles
(
"5b307d7d708ef705c4ca5c90"
,
null
,
null
,
null
,
null
,
null
,
null
,
"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
,
new
Date
(
2107
-
12
-
23
),
null
,
null
,
null
,
null
,
new
Date
(
2020
-
01
-
01
),
new
Date
(
2018
-
01
-
01
),
null
,
null
,
new
Date
(
2017
-
11
-
20
),
new
Date
(
2107
-
12
-
23
),
new
Date
(
2018
-
02
-
15
),
new
Date
(
2018
-
02
-
15
),
"Mahesh"
,
"Mahesh"
);
null
,
EmployeeRoles
employeesRole2
=
new
EmployeeRoles
(
"5976ef15874c902c98b8a05d"
,
null
,
null
,
null
,
null
,
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
,
null
,
null
,
null
,
"user@nisum.com"
,
null
,
null
,
null
,
new
Date
(
2017
-
11
-
20
),
EmployeeRoles
employeesRole2
=
new
EmployeeRoles
(
new
Date
(
2107
-
12
-
23
),
null
,
null
,
null
,
null
,
new
Date
(
2020
-
01
-
01
),
new
Date
(
2018
-
01
-
01
),
"5976ef15874c902c98b8a05d"
,
null
,
null
,
null
,
null
,
null
,
null
,
new
Date
(
2018
-
02
-
15
),
new
Date
(
2018
-
02
-
15
),
"Mahesh"
,
"Mahesh"
);
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
(
2018
-
02
-
15
),
new
Date
(
2018
-
02
-
15
),
"Mahesh"
,
"Mahesh"
);
employeeRoles
.
add
(
employeesRole1
);
employeeRoles
.
add
(
employeesRole1
);
employeeRoles
.
add
(
employeesRole2
);
employeeRoles
.
add
(
employeesRole2
);
return
employeeRoles
;
return
employeeRoles
;
}
}
private
List
<
Location
>
locations
()
{
List
<
Location
>
empLocation
=
new
ArrayList
<
Location
>();
Location
l1
=
new
Location
(
new
ObjectId
(
"5b307c9c927173017882543b"
),
"IN_HYD"
,
"Hyderabad Appstek Building"
,
"India"
,
"Telangana"
,
"Hyderabad"
,
true
,
"testing"
);
Location
l2
=
new
Location
(
new
ObjectId
(
"5b307c9c927173017882543a"
),
"NY_SF"
,
"Pleasonton Gap Office"
,
"USA"
,
"CA"
,
"SanFransisco"
,
true
,
"testing"
);
empLocation
.
add
(
l1
);
empLocation
.
add
(
l2
);
return
empLocation
;
}
private
List
<
Domains
>
domains
()
{
List
<
String
>
dl1
=
new
ArrayList
<
String
>();
dl1
.
add
(
"16120"
);
dl1
.
add
(
"16121"
);
List
<
String
>
dl2
=
new
ArrayList
<
String
>();
dl2
.
add
(
"16122"
);
dl2
.
add
(
"16123"
);
List
<
Domains
>
domains
=
new
ArrayList
<
Domains
>();
Domains
d1
=
new
Domains
(
new
ObjectId
(
"5b61be677c43a53a634f77b1"
),
"DOM001"
,
"Customer"
,
"Acc001"
,
"Active"
,
dl1
);
Domains
d2
=
new
Domains
(
new
ObjectId
(
"5b76b7f5094e433005abbede"
),
"DOM005"
,
"rajesh"
,
"Acc001"
,
"Active"
,
dl2
);
domains
.
add
(
d1
);
domains
.
add
(
d2
);
return
domains
;
}
}
}
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