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
5d02439c
Unverified
Commit
5d02439c
authored
Aug 21, 2018
by
rsayannagari-nisum-com
Committed by
GitHub
Aug 21, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #162 from nisum-inc/feature/JUnit_TestCases
JUnit_TestCases_for_Controllers
parents
f7577984
f77d5061
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
262 additions
and
51 deletions
+262
-51
EmployeeBillingControllerTest.java
.../mytime/controllertest/EmployeeBillingControllerTest.java
+137
-0
ProjectControllerTest.java
...om/nisum/mytime/controllertest/ProjectControllerTest.java
+14
-7
ProjectTeamControllerTest.java
...isum/mytime/controllertest/ProjectTeamControllerTest.java
+7
-6
UserControllerTest.java
...a/com/nisum/mytime/controllertest/UserControllerTest.java
+104
-38
No files found.
src/test/java/com/nisum/mytime/controllertest/EmployeeBillingControllerTest.java
0 → 100644
View file @
5d02439c
package
com
.
nisum
.
mytime
.
controllertest
;
import
static
org
.
mockito
.
Mockito
.
verify
;
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
.
post
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
org.bson.types.ObjectId
;
import
org.junit.Test
;
import
org.mockito.InjectMocks
;
import
org.mockito.Mock
;
import
org.springframework.http.MediaType
;
import
org.springframework.test.web.servlet.MockMvc
;
import
org.springframework.test.web.servlet.result.MockMvcResultMatchers
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.nisum.mytime.controller.ProjectTeamController
;
import
com.nisum.mytime.model.BillingDetails
;
import
com.nisum.mytime.model.EmployeeDashboardVO
;
import
com.nisum.mytime.repository.EmployeeVisaRepo
;
import
com.nisum.mytime.service.ProjectService
;
import
com.nisum.mytime.service.UserService
;
public
class
EmployeeBillingControllerTest
{
@Mock
UserService
userService
;
@Mock
ProjectService
projectService
;
@Mock
EmployeeVisaRepo
employeeVisaRepo
;
@InjectMocks
ProjectTeamController
projectTeamController
;
private
MockMvc
mockMvc
;
@Test
public
void
testgetEmployeeBillingDetails
()
throws
Exception
{
List
<
BillingDetails
>
billings
=
CreateTeamMateBilling
();
when
(
projectService
.
getEmployeeBillingDetailsAll
(
"16167"
)).
thenReturn
(
billings
);
mockMvc
.
perform
(
get
(
"/projectTeam/getProjectAllocations"
).
param
(
"employeeId"
,
"16167"
))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
verify
(
projectService
).
getEmployeeBillingDetailsAll
(
"16167"
);
}
@Test
public
void
testaddEmployeeBilling
()
throws
Exception
{
BillingDetails
billingDetails
=
new
BillingDetails
(
new
ObjectId
(
"9976ef15874c902c98b8a05d"
),
"16389"
,
"Mahesh Mudrakola"
,
"Acc001"
,
"Pro001"
,
"Macys"
,
"Y"
,
new
Date
(
2017
-
11
-
29
),
new
Date
(
2017
-
12
-
20
),
"Comments"
,
true
,
new
Date
(
2017
-
11
-
29
));
String
jsonvalue
=
(
new
ObjectMapper
())
.
writeValueAsString
(
billingDetails
).
toString
();
when
(
projectService
.
addEmployeeBillingDetails
(
billingDetails
))
.
thenReturn
(
billingDetails
);
mockMvc
.
perform
(
post
(
"/projectTeam/addEmployeeBilling"
)
.
contentType
(
MediaType
.
APPLICATION_JSON_VALUE
)
.
content
(
jsonvalue
))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
}
@Test
public
void
testupdateEmployeeBilling
()
throws
Exception
{
BillingDetails
billingDetails
=
new
BillingDetails
(
new
ObjectId
(
"9976ef15874c902c98b8a05d"
),
"16389"
,
"Mahesh Mudrakola"
,
"Acc001"
,
"Pro001"
,
"Macys"
,
"Y"
,
new
Date
(
2017
-
11
-
29
),
new
Date
(
2017
-
12
-
20
),
"Comments"
,
true
,
new
Date
(
2017
-
11
-
29
));
String
jsonvalue
=
(
new
ObjectMapper
())
.
writeValueAsString
(
billingDetails
).
toString
();
when
(
projectService
.
updateEmployeeBilling
(
billingDetails
))
.
thenReturn
(
billingDetails
);
mockMvc
.
perform
(
post
(
"/projectTeam/updateEmployeeBilling"
)
.
contentType
(
MediaType
.
APPLICATION_JSON_VALUE
)
.
content
(
jsonvalue
))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
}
@Test
public
void
testdeleteTeammate
()
throws
Exception
{
BillingDetails
billingDetails
=
new
BillingDetails
(
new
ObjectId
(
"9976ef15874c902c98b8a05d"
),
"16389"
,
"Mahesh Mudrakola"
,
"Acc001"
,
"Pro001"
,
"Macys"
,
"Y"
,
new
Date
(
2017
-
11
-
29
),
new
Date
(
2017
-
12
-
20
),
"Comments"
,
true
,
new
Date
(
2017
-
11
-
29
));
String
jsonvalue
=
(
new
ObjectMapper
())
.
writeValueAsString
(
billingDetails
).
toString
();
mockMvc
.
perform
(
post
(
"/projectTeam/deleteEmployeeBilling"
)
.
contentType
(
MediaType
.
APPLICATION_JSON_VALUE
)
.
content
(
jsonvalue
))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
verify
(
projectService
).
deleteEmployeeBilling
(
billingDetails
);
}
@Test
public
void
testgetEmployeesDashBoard
()
throws
Exception
{
List
<
EmployeeDashboardVO
>
dashboard
=
null
;
when
(
projectService
.
getEmployeesDashBoard
()).
thenReturn
(
dashboard
);
mockMvc
.
perform
(
get
(
"/projectTeam/getEmployeesDashBoard"
))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
verify
(
projectService
).
getEmployeesDashBoard
();
}
private
List
<
BillingDetails
>
CreateTeamMateBilling
()
{
List
<
BillingDetails
>
data
=
new
ArrayList
<>();
BillingDetails
team1
=
new
BillingDetails
();
team1
.
setId
(
new
ObjectId
(
"5b307d7d708ef705c4ca59cc"
));
team1
.
setEmployeeId
(
"16167"
);
team1
.
setEmployeeName
(
"Mogana Kurmaran"
);
team1
.
setProjectId
(
"Nisum0000"
);
team1
.
setProjectName
(
"Free Pool"
);
team1
.
setBillingStartDate
(
new
Date
(
2017
-
01
-
10
));
team1
.
setBillingEndDate
(
new
Date
(
2017
-
02
-
10
));
team1
.
setActive
(
true
);
data
.
add
(
team1
);
BillingDetails
team2
=
new
BillingDetails
();
team2
.
setId
(
new
ObjectId
(
"5b2f4a969ed316fef01adcce"
));
team2
.
setEmployeeId
(
"16050"
);
team2
.
setEmployeeName
(
"Rajeshekar Sayannagari"
);
team2
.
setProjectId
(
"Nisum0000"
);
team2
.
setProjectName
(
"Free Pool"
);
team2
.
setBillingStartDate
(
new
Date
(
2017
-
01
-
15
));
team2
.
setBillingEndDate
(
new
Date
(
2017
-
02
-
15
));
team2
.
setActive
(
false
);
data
.
add
(
team2
);
return
data
;
}
}
src/test/java/com/nisum/mytime/controllertest/ProjectControllerTest.java
View file @
5d02439c
...
...
@@ -61,7 +61,7 @@ public class ProjectControllerTest {
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
new
Date
(
2017
-
11
-
12
),
new
Date
(
2017
-
12
-
12
),
null
,
null
,
null
,
null
,
new
Date
(
2020
-
01
-
01
),
new
Date
(
2018
-
01
-
01
),
new
Date
(
2018
-
02
-
15
));
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"
))
.
thenReturn
(
employeesRole
);
mockMvc
.
perform
(
...
...
@@ -77,8 +77,9 @@ public class ProjectControllerTest {
//list.add("16632");
Project
employeeRole1
=
new
Project
(
new
ObjectId
(
"9976ef15874c902c98b8a05d"
),
"102"
,
"OMS"
,
"Marketing"
,
"Active"
,
list
,
list
,
"Acc002"
,
"DOM002"
,
list
);
new
ObjectId
(
"9976ef15874c902c98b8a05d"
),
"102"
,
"Macys"
,
"OMS"
,
"Active"
,
list
,
list
,
"Gap"
,
"Billable"
,
new
Date
(
2017
-
11
-
29
),
new
Date
(
2017
-
12
-
20
),
list
);
Account
account
=
new
Account
(
new
ObjectId
(
"5b62cca250e71a6eecc8c682"
),
"Acc002"
,
"Macys"
,
2
,
"Y"
,
"Macys"
,
"Retail"
,
list
);
...
...
@@ -110,7 +111,10 @@ public class ProjectControllerTest {
deliveryLeadIds
.
add
(
"16654"
);
Project
project
=
new
Project
(
new
ObjectId
(
"5976ef15874c902c98b8a05d"
),
"Gap0026"
,
"Mosaic"
,
"Move"
,
"Active"
,
employeeIds
,
managerIds
,
"Acc002"
,
"DOM002"
,
deliveryLeadIds
);
Project
project
=
new
Project
(
new
ObjectId
(
"5976ef15874c902c98b8a05d"
),
"Gap0026"
,
"Mosaic"
,
"Move"
,
"Active"
,
employeeIds
,
managerIds
,
"Acc002"
,
"DOM002"
,
new
Date
(
2017
-
11
-
29
),
new
Date
(
2017
-
12
-
20
),
deliveryLeadIds
);
ObjectMapper
mapper
=
new
ObjectMapper
();
String
jsonString
=
mapper
.
writeValueAsString
(
project
);
when
(
projectService
.
updateProject
(
any
())).
thenReturn
(
project
);
...
...
@@ -143,9 +147,12 @@ public class ProjectControllerTest {
@Test
public
void
testgetEmployeeRoleData
()
throws
Exception
{
EmployeeRoles
employeesRole
=
new
EmployeeRoles
(
"5b307d7e708ef705c4ca6429"
,
"16999"
,
"B.V.S Satyanarayana"
,
"bsatyanarayana@nisum.com"
,
"Employee"
,
"Employee"
,
""
,
"Java J2EE"
,
null
,
"Hyderabad"
,
"java, Spring, SpringBoot"
,
"9848012345"
,
"9848012345"
,
"test@test.com"
,
"ES"
,
"Active"
,
"Full Time"
,
new
Date
(),
new
Date
(),
"Male"
,
null
,
null
,
null
,
null
,
new
Date
(),
new
Date
());
EmployeeRoles
employeesRole
=
new
EmployeeRoles
(
"5976ef15874c902c98b8a05d"
,
null
,
null
,
null
,
null
,
null
,
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
,
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
);
mockMvc
.
perform
(
get
(
"/project/getEmployeeRoleData"
).
param
(
"empId"
,
"16127"
)
...
...
src/test/java/com/nisum/mytime/controllertest/ProjectTeamControllerTest.java
View file @
5d02439c
...
...
@@ -58,7 +58,7 @@ public class ProjectTeamControllerTest {
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
));
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"
))
.
thenReturn
(
employeesRole
);
...
...
@@ -76,7 +76,8 @@ public class ProjectTeamControllerTest {
list
.
add
(
"16103"
);
Project
employeeRole1
=
new
Project
(
new
ObjectId
(
"9976ef15874c902c98b8a05d"
),
"102"
,
"Macys"
,
"OMS"
,
"Active"
,
list
,
list
,
"Gap"
,
"Billable"
,
list
);
list
,
"Gap"
,
"Billable"
,
new
Date
(
2017
-
11
-
29
),
new
Date
(
2017
-
12
-
20
),
list
);
String
jsonvalue
=
(
new
ObjectMapper
())
.
writeValueAsString
(
employeeRole1
).
toString
();
when
(
projectService
.
addProject
(
employeeRole1
))
...
...
@@ -95,7 +96,7 @@ public class ProjectTeamControllerTest {
"Testing"
,
"8755672341"
,
"8800543678"
,
"vsingh@gmail.com"
,
null
,
null
,
null
,
null
,
null
,
new
Date
(
2017
-
11
-
29
),
new
Date
(
2017
-
12
-
20
),
null
,
null
,
null
,
null
,
new
Date
(
2020
-
01
-
01
),
new
Date
(
2018
-
01
-
01
),
new
Date
(
2018
-
02
-
15
));
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
();
String
jsonString
=
mapper
.
writeValueAsString
(
employeesRoles2
);
when
(
userService
.
updateEmployeeRole
(
anyObject
(),
anyObject
())).
thenReturn
(
employeesRoles2
);
...
...
@@ -120,7 +121,7 @@ public class ProjectTeamControllerTest {
"5976ef15874c902c98b8a05d"
,
"16127"
,
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
,
null
,
null
,
new
Date
(
2020
-
01
-
01
),
new
Date
(
2018
-
01
-
01
),
new
Date
(
2018
-
02
-
15
));
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
);
mockMvc
.
perform
(
...
...
@@ -176,10 +177,10 @@ public class ProjectTeamControllerTest {
String
jsonvalue
=
(
new
ObjectMapper
())
.
writeValueAsString
(
updatedTeammate
).
toString
();
when
(
projectService
.
updateTeammate
(
updatedTeammate
))
.
thenReturn
(
updatedTeammat
e
);
.
thenReturn
(
jsonvalu
e
);
mockMvc
.
perform
(
post
(
"/projectTeam/updateTeammate"
)
.
contentType
(
MediaType
.
APPLICATION_JSON_VALUE
)
.
content
(
jsonvalue
))
.
content
(
jsonvalue
))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
}
...
...
src/test/java/com/nisum/mytime/controllertest/UserControllerTest.java
View file @
5d02439c
...
...
@@ -30,6 +30,7 @@ import com.nisum.mytime.controller.UserController;
import
com.nisum.mytime.model.Account
;
import
com.nisum.mytime.model.Designation
;
import
com.nisum.mytime.model.EmployeeRoles
;
import
com.nisum.mytime.model.MasterData
;
import
com.nisum.mytime.model.Shift
;
import
com.nisum.mytime.model.Skill
;
import
com.nisum.mytime.service.UserService
;
...
...
@@ -52,12 +53,13 @@ public class UserControllerTest {
@Test
public
void
testgetEmployeeRole
()
throws
Exception
{
EmployeeRoles
employeesRole
=
new
EmployeeRoles
(
"5
b62caea50e71a6eecc8c67f"
,
"16694"
,
"Mahesh Deekonda"
,
"mdeekonda@nisum.com"
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
new
Date
(
2017
-
11
-
20
),
new
Date
(
2
01
7
-
12
-
23
),
EmployeeRoles
employeesRole
=
new
EmployeeRoles
(
"5
976ef15874c902c98b8a05d"
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
"user@nisum.com"
,
null
,
null
,
null
,
new
Date
(
2017
-
11
-
20
),
new
Date
(
2
10
7
-
12
-
23
),
null
,
null
,
null
,
null
,
new
Date
(
2020
-
01
-
01
),
new
Date
(
2018
-
01
-
01
),
new
Date
(
2018
-
02
-
15
));
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
);
mockMvc
.
perform
(
...
...
@@ -69,13 +71,12 @@ public class UserControllerTest {
@Test
public
void
testassigingEmployeeRole
()
throws
Exception
{
EmployeeRoles
employeeRole
=
new
EmployeeRoles
(
"5976ef15874c902c98b8a05c"
,
"16135"
,
"Monika"
,
"user1@nisum.com"
,
"HR"
,
"Human Resource Lead"
,
"06:00-09:00"
,
"Java/J2EE"
,
"Spring"
,
"8767893452"
,
"5687234567"
,
"user1@gmail.com"
,
null
,
null
,
null
,
null
,
null
,
new
Date
(
2017
-
11
-
20
),
new
Date
(
2017
-
12
-
23
),
null
,
null
,
null
,
null
,
new
Date
(
2020
-
01
-
01
),
new
Date
(
2018
-
01
-
01
),
new
Date
(
2018
-
02
-
15
));
ObjectMapper
mapper
=
new
ObjectMapper
();
"5976ef15874c902c98b8a05d"
,
null
,
null
,
null
,
null
,
null
,
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
,
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
();
String
jsonString
=
mapper
.
writeValueAsString
(
employeeRole
);
when
(
userService
.
assigingEmployeeRole
(
anyObject
(),
anyObject
()))
.
thenReturn
(
employeeRole
);
...
...
@@ -89,13 +90,12 @@ public class UserControllerTest {
@Test
public
void
testupdateEmployeeRole
()
throws
Exception
{
EmployeeRoles
employeeRole2
=
new
EmployeeRoles
(
"5976ef15874c902c98b8a05d"
,
"67890"
,
"Sonika"
,
"user2@nisum.com"
,
"Manager"
,
"Senior Software Engineer"
,
"09:00am-06:00am"
,
"php"
,
"Hibernate"
,
"9878678956"
,
"9989782210"
,
"user2@gmail.com"
,
null
,
null
,
null
,
null
,
null
,
new
Date
(
2017
-
11
-
20
),
new
Date
(
2017
-
12
-
23
),
null
,
null
,
null
,
null
,
new
Date
(
2020
-
01
-
01
),
new
Date
(
2018
-
01
-
01
),
new
Date
(
2018
-
02
-
15
));
ObjectMapper
mapper
=
new
ObjectMapper
();
"5976ef15874c902c98b8a05d"
,
null
,
null
,
null
,
null
,
null
,
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
,
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
();
String
jsonString
=
mapper
.
writeValueAsString
(
employeeRole2
);
when
(
userService
.
updateEmployeeRole
(
anyObject
(),
anyObject
()))
.
thenReturn
(
employeeRole2
);
...
...
@@ -126,10 +126,11 @@ public class UserControllerTest {
@Test
public
void
testgetEmployeeRoleData
()
throws
Exception
{
EmployeeRoles
employeesRole
=
new
EmployeeRoles
(
"5976ef15874c902c98b8a05d"
,
"16127"
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
new
Date
(
2017
-
11
-
13
),
new
Date
(
2017
-
12
-
20
),
null
,
null
,
null
,
null
,
new
Date
(
2020
-
01
-
01
),
new
Date
(
2018
-
01
-
01
),
new
Date
(
2018
-
02
-
15
));
"5976ef15874c902c98b8a05d"
,
null
,
null
,
null
,
null
,
null
,
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
,
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
);
mockMvc
.
perform
(
get
(
"/user/getEmployeeRoleData"
).
param
(
"empId"
,
"16127"
)
...
...
@@ -143,11 +144,12 @@ public class UserControllerTest {
@Test
public
void
testgetEmployeeRoleDataForEmailIdSearch
()
throws
Exception
{
EmployeeRoles
employeesRole
=
new
EmployeeRoles
(
"5976ef15874c902c98b8a05d"
,
"16209"
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
new
Date
(
2017
-
11
-
13
),
new
Date
(
2017
-
12
-
20
),
null
,
null
,
null
,
null
,
new
Date
(
2020
-
01
-
01
),
new
Date
(
2018
-
01
-
01
),
new
Date
(
2018
-
02
-
15
));
when
(
userService
.
getEmployeeRoleDataForSearchCriteria
(
"dummy@nisum.com"
,
"5976ef15874c902c98b8a05d"
,
null
,
null
,
null
,
null
,
null
,
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
,
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
);
mockMvc
.
perform
(
get
(
"/user/getEmployeeRoleDataForSearchCriteria"
)
.
param
(
"searchId"
,
"dummy@nisum.com"
)
...
...
@@ -164,10 +166,12 @@ public class UserControllerTest {
public
void
testgetEmployeeRoleDataForEmployeeNameSearch
()
throws
Exception
{
EmployeeRoles
employeesRole
=
new
EmployeeRoles
(
"5976ef15874c902c98b8a05d"
,
"16209"
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
new
Date
(
2017
-
11
-
13
),
new
Date
(
2017
-
12
-
20
),
null
,
null
,
null
,
null
,
new
Date
(
2020
-
01
-
01
),
new
Date
(
2018
-
01
-
01
),
new
Date
(
2018
-
02
-
15
));
"5976ef15874c902c98b8a05d"
,
null
,
null
,
null
,
null
,
null
,
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
,
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"
))
.
thenReturn
(
employeesRole
);
...
...
@@ -250,12 +254,11 @@ public class UserControllerTest {
@Test
public
void
testupdateProfile
()
throws
Exception
{
EmployeeRoles
employeeRole
=
new
EmployeeRoles
(
"5996ef15874c902c98b8a05d"
,
"16127"
,
"Monika Srivastava"
,
"msrivastava@nisum.com"
,
"Employee"
,
"Software Engineer"
,
"09:00-06:00"
,
"Java/J2EE"
,
"Spring"
,
"8765588388"
,
"9978567723"
,
"msrivastava@gmail.com"
,
null
,
null
,
null
,
null
,
null
,
new
Date
(
2017
-
01
-
01
),
new
Date
(
2017
-
03
-
01
),
null
,
null
,
null
,
null
,
new
Date
(
2020
-
01
-
01
),
new
Date
(
2018
-
01
-
01
),
new
Date
(
2018
-
02
-
15
));
"5976ef15874c902c98b8a05d"
,
null
,
null
,
null
,
null
,
null
,
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
,
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
);
ObjectMapper
mapper
=
new
ObjectMapper
();
String
jsonString
=
mapper
.
writeValueAsString
(
employeeRole
);
...
...
@@ -277,6 +280,24 @@ public class UserControllerTest {
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
verify
(
userService
).
getAccounts
();
}
@Test
public
void
testGetMasterData
()
throws
Exception
{
List
<
MasterData
>
masterDataMap
=
masterData
();
when
(
userService
.
getMasterData
()).
thenReturn
(
masterDataMap
);
mockMvc
.
perform
(
get
(
"/user/getMasterData"
)).
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
verify
(
userService
).
getMasterData
();
}
@Test
public
void
testGetEmployeeByStatus
()
throws
Exception
{
List
<
EmployeeRoles
>
empRolesList
=
employeeRoles
();
when
(
userService
.
getEmployeesByStatus
(
"Active"
)).
thenReturn
(
empRolesList
);
mockMvc
.
perform
(
get
(
"/user/getEmployeeByStatus"
).
param
(
"status"
,
"Active"
))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
verify
(
userService
).
getEmployeesByStatus
(
"Active"
);
}
private
List
<
Account
>
CreateAccount
()
{
List
<
Account
>
data
=
new
ArrayList
<>();
...
...
@@ -398,4 +419,49 @@ public class UserControllerTest {
return
data
;
}
private
List
<
MasterData
>
masterData
()
{
List
<
MasterData
>
masterDataList
=
new
ArrayList
<
MasterData
>();
MasterData
md1
=
new
MasterData
();
md1
.
setActiveStatus
(
true
);
md1
.
setId
(
new
ObjectId
(
"5af31b08ed59fba43518ed84"
));
md1
.
setMasterDataId
(
"1"
);
md1
.
setMasterDataName
(
"Java"
);
md1
.
setMasterDataType
(
"skills"
);
md1
.
setComments
(
null
);
MasterData
md2
=
new
MasterData
();
md2
.
setActiveStatus
(
true
);
md2
.
setId
(
new
ObjectId
(
"5af32e8fed59fba43518ed88"
));
md2
.
setMasterDataId
(
"1"
);
md2
.
setMasterDataName
(
"Full Time"
);
md2
.
setMasterDataType
(
"EmpType"
);
md2
.
setComments
(
null
);
masterDataList
.
add
(
md1
);
masterDataList
.
add
(
md2
);
return
masterDataList
;
}
private
List
<
EmployeeRoles
>
employeeRoles
()
{
List
<
EmployeeRoles
>
employeeRoles
=
new
ArrayList
<
EmployeeRoles
>();
EmployeeRoles
employeesRole1
=
new
EmployeeRoles
(
"5b307d7d708ef705c4ca5c90"
,
null
,
null
,
null
,
null
,
null
,
null
,
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
(
2018
-
02
-
15
),
new
Date
(
2018
-
02
-
15
),
"Mahesh"
,
"Mahesh"
);
EmployeeRoles
employeesRole2
=
new
EmployeeRoles
(
"5976ef15874c902c98b8a05d"
,
null
,
null
,
null
,
null
,
null
,
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
,
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
(
employeesRole2
);
return
employeeRoles
;
}
}
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