Commit 73b00024 authored by mmudrakola-nisum-com's avatar mmudrakola-nisum-com Committed by rbonthala-nisum-com

JUnitTestCases_Updated :: SNS :: Test Cases for Account and Domain along with All. (#157)

parent f72a693a
package com.nisum.mytime.controllertest;
import java.util.Map;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.verify;
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.get;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.bson.types.ObjectId;
import org.junit.Before;
import org.junit.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.nisum.mytime.controller.AccountController;
import com.nisum.mytime.model.Account;
import com.nisum.mytime.service.AccountService;
import com.nisum.mytime.service.AccountServiceImpl;
public class AccountControllerTest {
@Mock
AccountServiceImpl Accountserviceimpl;
@InjectMocks
AccountController AccountController;
private MockMvc mockMvc;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
mockMvc = MockMvcBuilders.standaloneSetup(AccountController).build();
}
@Test
public void testaddAccount() throws Exception {
List<String> list = new ArrayList<>();
list.add("16620");
list.add("16632");
String responce=null;
Account account = new Account(
new ObjectId("5b62b00950e71a6eecc8c98c"), "Acc003", "Nisum", 3,
"Y","HYD","RetailS",list);
when(Accountserviceimpl.addAccount(account,"N"))
.thenReturn(responce);
String jsonvalue = (new ObjectMapper())
.writeValueAsString(account).toString();
mockMvc.perform(post("/account/accounts").param("action","N")
.contentType(MediaType.APPLICATION_JSON_VALUE)
.content(jsonvalue))
.andExpect(MockMvcResultMatchers.status().isOk());
}
@Test
public void testgetAccountNames() throws Exception {
List<Map<Object, Object>> Account = CreateAccountDetails();
when(Accountserviceimpl.getAccountsList()).thenReturn(Account);
mockMvc.perform(get("/account/accountNames")
.contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(MockMvcResultMatchers.status().isOk());
}
@Test
public void testgetAccount() throws Exception {
List<Account> Account = null;
when(Accountserviceimpl.getAccounts()).thenReturn(Account);
mockMvc.perform(get("/account/accounts")
.contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(MockMvcResultMatchers.status().isOk());
}
@Test
public void testupdateAccount() throws Exception {
List<String> list = new ArrayList<>();
list.add("16620");
list.add("16632");
String responce=null;
Account account = new Account(
new ObjectId("5b62b00950e71a6eecc8c98c"), "Acc003", "Nisum", 3,
"Y","HYD","RetailS",list);
when(Accountserviceimpl.addAccount(account,"U"))
.thenReturn(responce);
String jsonvalue = (new ObjectMapper())
.writeValueAsString(account).toString();
mockMvc.perform(post("/account/accounts").param("action","U")
.contentType(MediaType.APPLICATION_JSON_VALUE)
.content(jsonvalue))
.andExpect(MockMvcResultMatchers.status().isOk());
}
@Test
public void testdeleteAccount() throws Exception {
mockMvc.perform(
delete("/account/accounts").param("accountId", "Acc002"))
.andExpect(MockMvcResultMatchers.status().isOk());
verify(Accountserviceimpl).deleteAccount("Acc002");
}
private List<Map<Object,Object>>CreateAccountDetails() {
List<Map<Object,Object>> data = new ArrayList<Map<Object,Object>> ();
HashMap<Object,Object> map1 = new HashMap<Object,Object>();
HashMap<Object,Object> map2 = new HashMap<Object,Object>();
Account data1 = new Account();
data1.setId(new ObjectId("5976ef15874c902c98b8a05d"));
data1.setAccountId("Acc004");
data1.setAccountName("Govt");
data1.setAccountProjectSequence(4);
data1.setClientAddress("BNG");
data1.setIndustryType("Telecom");
data1.setStatus("Y");
List<String> list = new ArrayList<>();
list.add("16101");
list.add("16102");
list.add("16103");
data1.setDeliveryManagers(list);
Account data2 = new Account();
data2.setId(new ObjectId("9976ef15874c902c98b8a05d"));
data2.setAccountId("Acc004");
data2.setAccountName("Govt");
data2.setAccountProjectSequence(4);
data2.setClientAddress("HYD");
data2.setIndustryType("Telecom");
data2.setStatus("Y");
List<String> list2 = new ArrayList<>();
list2.add("16103");
list2.add("16105");
list2.add("16107");
data1.setDeliveryManagers(list);
map1.put(new ObjectId("5976ef15874c902c98b8a05d"), data1);
map2.put(new ObjectId("9976ef15874c902c98b8a05d"), data2);
data.add(map1);
data.add(map2);
return data;
}
}
...@@ -30,3 +30,4 @@ public class ApplicationControllerTest { ...@@ -30,3 +30,4 @@ public class ApplicationControllerTest {
} }
} }
\ No newline at end of file
...@@ -74,7 +74,6 @@ public class AttendanceControllerTest { ...@@ -74,7 +74,6 @@ public class AttendanceControllerTest {
mockMvc.perform(post("/attendance/employeesDataSave/2018-01-01")).andExpect(MockMvcResultMatchers.status().isOk()); mockMvc.perform(post("/attendance/employeesDataSave/2018-01-01")).andExpect(MockMvcResultMatchers.status().isOk());
verify(userService).fetchEmployeesData("2018-01-01",false); verify(userService).fetchEmployeesData("2018-01-01",false);
} }
private List<AttendenceData> createAttendenceData() { private List<AttendenceData> createAttendenceData() {
List<AttendenceData> data = new ArrayList<>(); List<AttendenceData> data = new ArrayList<>();
......
package com.nisum.mytime.controllertest;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.verify;
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.get;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.bson.types.ObjectId;
import org.junit.Before;
import org.junit.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.nisum.mytime.controller.DomainController;
import com.nisum.mytime.model.Domains;
import com.nisum.mytime.service.DomainService;
public class DomainControllerTest {
@Mock
DomainService domainService;
@InjectMocks
DomainController domainController;
private MockMvc mockMvc;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
mockMvc = MockMvcBuilders.standaloneSetup(domainController).build();
}
@Test
public void testaddDomain() throws Exception {
List<String> list = new ArrayList<>();
list.add("16620");
list.add("16632");
String responce=null;
Domains domains = new Domains(
new ObjectId("9976ef15874c902c98b8a05d"), "DOM002", "Marketing", "Acc002",
"Active",list);
when(domainService.addDomains(domains))
.thenReturn(responce);
String jsonvalue = (new ObjectMapper())
.writeValueAsString(domains).toString();
mockMvc.perform(post("/domains")
.contentType(MediaType.APPLICATION_JSON_VALUE)
.content(jsonvalue))
.andExpect(MockMvcResultMatchers.status().isOk());
}
@Test
public void testgetDomains() throws Exception {
List<HashMap<Object,Object>> domains = CreateDomainDetails();
when(domainService.getAllDomains()).thenReturn(domains);
mockMvc.perform(get("/domains")
.contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(MockMvcResultMatchers.status().isOk());
verify(domainService).getAllDomains();
}
@Test
public void testupdateDomains() throws Exception {
List<String> employeeIds = new ArrayList<>();
employeeIds.add("16649");
employeeIds.add("16650");
employeeIds.add("16651");
String responce=null;
Domains Domain = new Domains(new ObjectId("9976ef15874c902c98b8a05d"), "DOM002", "Marketing", "Acc002",
"Active",employeeIds);
ObjectMapper mapper = new ObjectMapper();
String jsonString = mapper.writeValueAsString(Domain);
when(domainService.updateDomain(any())).thenReturn(responce);
mockMvc.perform(put("/domains")
.contentType(MediaType.APPLICATION_JSON_VALUE)
.content(jsonString))
.andExpect(MockMvcResultMatchers.status().isOk());
verify(domainService).updateDomain(any());
}
@Test
public void testdeleteDomain() throws Exception {
mockMvc.perform(
delete("/domains").param("domainId", "DOM001"))
.andExpect(MockMvcResultMatchers.status().isOk());
verify(domainService).deleteDomain("DOM001");
}
private List<HashMap<Object,Object>>CreateDomainDetails() {
List<HashMap<Object,Object>> data = new ArrayList<HashMap<Object,Object>> ();
HashMap<Object,Object> map1 = new HashMap<Object,Object>();
HashMap<Object,Object> map2 = new HashMap<Object,Object>();
Domains data1 = new Domains();
data1.setId(new ObjectId("5976ef15874c902c98b8a05d"));
data1.setDomainId("DOM003");
data1.setDomainName("MOC");
data1.setAccountId("ACC001");
data1.setStatus("Active");
List<String> list = new ArrayList<>();
list.add("16101");
list.add("16102");
list.add("16103");
data1.setDeliveryManagers(list);
map1.put(new ObjectId("5976ef15874c902c98b8a05d"), data1);
Domains data2 = new Domains();
data2.setId(new ObjectId("9976ef15874c902c98b8a05d"));
data2.setDomainId("DOM004");
data2.setDomainName("BIGTICKET");
data2.setAccountId("ACC001");
data2.setStatus("Active");
List<String> list2 = new ArrayList<>();
list2.add("16103");
list2.add("16105");
list2.add("16107");
data1.setDeliveryManagers(list);
map1.put(new ObjectId("5976ef15874c902c98b8a05d"), data1);
map2.put(new ObjectId("9976ef15874c902c98b8a05d"), data2);
data.add(map1);
data.add(map2);
return data;
}
}
...@@ -56,38 +56,37 @@ public class ProjectControllerTest { ...@@ -56,38 +56,37 @@ public class ProjectControllerTest {
@Test @Test
public void testgetEmployeeRole() throws Exception { public void testgetEmployeeRole() throws Exception {
EmployeeRoles employeesRole = new EmployeeRoles(); EmployeeRoles employeesRole = new EmployeeRoles(
employeesRole.setEmailId("bsatyanarayana@nisum.com"); "5976ef15874c902c98b8a05d", null, null, "user@nisum.com", null,
when(userService.getEmployeesRole("bsatyanarayana@nisum.com")) 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));
when(userService.getEmployeesRole("user@nisum.com"))
.thenReturn(employeesRole); .thenReturn(employeesRole);
mockMvc.perform( mockMvc.perform(
get("/project/employee").param("emailId", "bsatyanarayana@nisum.com")) get("/project/employee").param("emailId", "user@nisum.com"))
.andExpect(MockMvcResultMatchers.status().isOk()); .andExpect(MockMvcResultMatchers.status().isOk());
verify(userService).getEmployeesRole("bsatyanarayana@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("16620");
list.add("16102"); //list.add("16632");
list.add("16103");
Project employeeRole1 = new Project(
Project project = new Project(); new ObjectId("9976ef15874c902c98b8a05d"), "102", "OMS", "Marketing",
project.setProjectName("Test"); "Active",list,list, "Acc002", "DOM002", list);
project.setDomainId("DOM001");
project.setAccountId("Acc001"); Account account = new Account(new ObjectId("5b62cca250e71a6eecc8c682"),
project.setStatus("Active"); "Acc002", "Macys", 2, "Y","Macys","Retail",list);
project.setManagerIds(list); when(projectService.addProject(employeeRole1))
.thenReturn(employeeRole1);
when(accountRepo.findByAccountId("Acc002")).thenReturn(account);
String jsonvalue = (new ObjectMapper())
String jsonvalue = (new ObjectMapper()) .writeValueAsString(project).toString(); .writeValueAsString(employeeRole1).toString();
Account account = new Account(new ObjectId("5a4f03661dca211ea7f94c02"),"Acc001", "Macys", 1, "Active","Hyderabad","Retail",list);
when(projectService.addProject(project)).thenReturn(project);
when(accountRepo.findByAccountName("Macys")).thenReturn(account);
mockMvc.perform(post("/project/addProject") mockMvc.perform(post("/project/addProject")
.contentType(MediaType.APPLICATION_JSON_VALUE) .contentType(MediaType.APPLICATION_JSON_VALUE)
.content(jsonvalue)) .content(jsonvalue))
...@@ -96,20 +95,22 @@ public class ProjectControllerTest { ...@@ -96,20 +95,22 @@ public class ProjectControllerTest {
@Test @Test
public void testupdateEmployeeRole() throws Exception { public void testupdateEmployeeRole() throws Exception {
List<String> list1 = new ArrayList<>(); List<String> employeeIds = new ArrayList<>();
list1.add("16104"); List<String> managerIds = new ArrayList<>();
list1.add("16105"); List<String> deliveryLeadIds = new ArrayList<>();
list1.add("16106");
employeeIds.add("16649");
employeeIds.add("16650");
employeeIds.add("16651");
// Project project = new Project(new ObjectId("5b697949eb429617f41df26b"),"Nisum0000","Bench","Nisum","Active",list1,list1,"Acc001","DOM001",null,null,list1);
Project project = new Project();
project.setProjectId("Nisum0000");
project.setDomainId("DOM001");
project.setAccountId("Acc001");
project.setEmployeeIds(list1); managerIds.add("16652");
project.setDeliveryLeadIds(list1);
deliveryLeadIds.add("16653");
deliveryLeadIds.add("16654");
Project project = new Project(new ObjectId("5976ef15874c902c98b8a05d"),"Gap0026", "Mosaic", "Move", "Active", employeeIds, managerIds,"Acc002","DOM002",deliveryLeadIds);
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
String jsonString = mapper.writeValueAsString(project); String jsonString = mapper.writeValueAsString(project);
when(projectService.updateProject(any())).thenReturn(project); when(projectService.updateProject(any())).thenReturn(project);
...@@ -144,8 +145,7 @@ public class ProjectControllerTest { ...@@ -144,8 +145,7 @@ public class ProjectControllerTest {
public void testgetEmployeeRoleData() throws Exception { public void testgetEmployeeRoleData() throws Exception {
EmployeeRoles employeesRole = new EmployeeRoles("5b307d7e708ef705c4ca6429", "16999", "B.V.S Satyanarayana", "bsatyanarayana@nisum.com", "Employee", "Employee", "", EmployeeRoles employeesRole = new EmployeeRoles("5b307d7e708ef705c4ca6429", "16999", "B.V.S Satyanarayana", "bsatyanarayana@nisum.com", "Employee", "Employee", "",
"Java J2EE", null, "Hyderabad", "java, Spring, SpringBoot", "9848012345", "9848012345", "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(), null, "16000", "16000"); "test@test.com", "ES", "Active", "Full Time", new Date(), new Date(), "Male", null, null, null, null, new Date(), new Date());
when(userService.getEmployeesRoleData("16127")) .thenReturn(employeesRole); when(userService.getEmployeesRoleData("16127")) .thenReturn(employeesRole);
mockMvc.perform( mockMvc.perform(
get("/project/getEmployeeRoleData").param("empId", "16127") get("/project/getEmployeeRoleData").param("empId", "16127")
......
...@@ -57,7 +57,9 @@ public class ProjectTeamControllerTest { ...@@ -57,7 +57,9 @@ public class ProjectTeamControllerTest {
"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, null, null, null, null, null); null,
null, null,null,new Date(2020 - 01 - 01),new Date(2018 - 01 - 01),new Date(2018 - 02 - 15));
when(userService.getEmployeesRole("user@nisum.com")) when(userService.getEmployeesRole("user@nisum.com"))
.thenReturn(employeesRole); .thenReturn(employeesRole);
mockMvc.perform( mockMvc.perform(
...@@ -73,8 +75,8 @@ public class ProjectTeamControllerTest { ...@@ -73,8 +75,8 @@ public class ProjectTeamControllerTest {
list.add("16102"); list.add("16102");
list.add("16103"); list.add("16103");
Project employeeRole1 = new Project( Project employeeRole1 = new Project(
new ObjectId("9976ef15874c902c98b8a05d"), "102", "OMS", "16101", new ObjectId("9976ef15874c902c98b8a05d"), "102","Macys", "OMS","Active",list,
"Srikanth", list, list, "Gap", "Billable", null, null, list); list, "Gap", "Billable", list);
String jsonvalue = (new ObjectMapper()) String jsonvalue = (new ObjectMapper())
.writeValueAsString(employeeRole1).toString(); .writeValueAsString(employeeRole1).toString();
when(projectService.addProject(employeeRole1)) when(projectService.addProject(employeeRole1))
...@@ -92,7 +94,8 @@ public class ProjectTeamControllerTest { ...@@ -92,7 +94,8 @@ public class ProjectTeamControllerTest {
"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, null, null, null, null, null, null, null, null, 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));
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);
...@@ -117,7 +120,7 @@ public class ProjectTeamControllerTest { ...@@ -117,7 +120,7 @@ public class ProjectTeamControllerTest {
"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, null, null, null, null, null, null); null, null,null,new Date(2020 - 01 - 01),new Date(2018 - 01 - 01),new Date(2018 - 02 - 15));
when(userService.getEmployeesRoleData("16127")) when(userService.getEmployeesRoleData("16127"))
.thenReturn(employeesRole); .thenReturn(employeesRole);
mockMvc.perform( mockMvc.perform(
...@@ -148,7 +151,11 @@ public class ProjectTeamControllerTest { ...@@ -148,7 +151,11 @@ public class ProjectTeamControllerTest {
@Test @Test
public void testaddEmployeeToTeam() throws Exception { public void testaddEmployeeToTeam() throws Exception {
ProjectTeamMate projectTeamMate = new ProjectTeamMate(); ProjectTeamMate projectTeamMate = new ProjectTeamMate(
new ObjectId("1976ef15874c902c98b8a05d"), "16127",
"Monika Srivastava", "msrivastava@nisum.com", "Employee",
"09:00-06:00", "101", "MOSAIC", "GAP", "04", "Software Engineer", "Non-Billable", "8765588388",
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))
...@@ -164,9 +171,8 @@ public class ProjectTeamControllerTest { ...@@ -164,9 +171,8 @@ public class ProjectTeamControllerTest {
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", "09:00-06:00", "101", "MOSAIC", "GAP", "04", "Software Engineer", "Non-Billable", "8765588388",
"01", "Software Engineer", "Non-Billable", "8765588388", new Date(), new Date(),new Date(), true,null,null);
new Date(), new Date(),new Date(), true,"ACC01","DOM1");
String jsonvalue = (new ObjectMapper()) String jsonvalue = (new ObjectMapper())
.writeValueAsString(updatedTeammate).toString(); .writeValueAsString(updatedTeammate).toString();
when(projectService.updateTeammate(updatedTeammate)) when(projectService.updateTeammate(updatedTeammate))
...@@ -182,9 +188,8 @@ public class ProjectTeamControllerTest { ...@@ -182,9 +188,8 @@ public class ProjectTeamControllerTest {
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", "09:00-06:00", "101", "MOSAIC", "GAP", "04", "Software Engineer", "Non-Billable", "8765588388",
"01", "Software Engineer", "Non-Billable", "8765588388", new Date(), new Date(),new Date(), true,null,null);
new Date(), new Date(),new Date(), true,"ACC01","DOM1");
String jsonvalue = (new ObjectMapper()) String jsonvalue = (new ObjectMapper())
.writeValueAsString(deleteTeamMate).toString(); .writeValueAsString(deleteTeamMate).toString();
mockMvc.perform(post("/projectTeam/deleteTeammate") mockMvc.perform(post("/projectTeam/deleteTeammate")
...@@ -316,10 +321,10 @@ public class ProjectTeamControllerTest { ...@@ -316,10 +321,10 @@ public class ProjectTeamControllerTest {
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");
...@@ -330,10 +335,10 @@ public class ProjectTeamControllerTest { ...@@ -330,10 +335,10 @@ public class ProjectTeamControllerTest {
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");
...@@ -359,7 +364,7 @@ public class ProjectTeamControllerTest { ...@@ -359,7 +364,7 @@ public class ProjectTeamControllerTest {
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");
...@@ -376,7 +381,7 @@ public class ProjectTeamControllerTest { ...@@ -376,7 +381,7 @@ public class ProjectTeamControllerTest {
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");
......
...@@ -53,16 +53,17 @@ public class UserControllerTest { ...@@ -53,16 +53,17 @@ public class UserControllerTest {
@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", "Admin", "5b62caea50e71a6eecc8c67f", "16694", "Mahesh Deekonda", "mdeekonda@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 - 20), new Date(2017 - 12 - 23), null, null, new Date(2017 - 11 - 20), new Date(2017 - 12 - 23),
null, null, null, null, null, null, null, null, null, null); null,
when(userService.getEmployeesRole("user@nisum.com")) null, null,null,new Date(2020 - 01 - 01),new Date(2018 - 01 - 01),new Date(2018 - 02 - 15));
when(userService.getEmployeesRole("mdeekonda@nisum.com"))
.thenReturn(employeesRole); .thenReturn(employeesRole);
mockMvc.perform( mockMvc.perform(
get("/user/employee").param("emailId", "user@nisum.com")) get("/user/employee").param("emailId", "mdeekonda@nisum.com"))
.andExpect(MockMvcResultMatchers.status().isOk()); .andExpect(MockMvcResultMatchers.status().isOk());
verify(userService).getEmployeesRole("user@nisum.com"); verify(userService).getEmployeesRole("mdeekonda@nisum.com");
} }
@Test @Test
...@@ -72,8 +73,8 @@ public class UserControllerTest { ...@@ -72,8 +73,8 @@ public class UserControllerTest {
"user1@nisum.com", "HR", "Human Resource Lead", "06:00-09:00", "user1@nisum.com", "HR", "Human Resource Lead", "06:00-09:00",
"Java/J2EE", "Spring", "8767893452", "5687234567", "Java/J2EE", "Spring", "8767893452", "5687234567",
"user1@gmail.com", null, null, null, null, null, "user1@gmail.com", null, null, null, null, null,
new Date(2017 - 11 - 20), new Date(2017 - 12 - 23), null, null, new Date(2017 - 11 - 20), new Date(2017 - 12 - 23),null,
null, null, null, null, null, null, null, null); null, null,null,new Date(2020 - 01 - 01),new Date(2018 - 01 - 01),new Date(2018 - 02 - 15));
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()))
...@@ -92,8 +93,8 @@ public class UserControllerTest { ...@@ -92,8 +93,8 @@ public class UserControllerTest {
"user2@nisum.com", "Manager", "Senior Software Engineer", "user2@nisum.com", "Manager", "Senior Software Engineer",
"09:00am-06:00am", "php", "Hibernate", "9878678956", "09:00am-06:00am", "php", "Hibernate", "9878678956",
"9989782210", "user2@gmail.com", null, null, null, null, null, "9989782210", "user2@gmail.com", null, null, null, null, null,
new Date(2017 - 11 - 20), new Date(2017 - 12 - 23), null, null, new Date(2017 - 11 - 20), new Date(2017 - 12 - 23), null,
null, null, null, null, null, null, null, null); null, null,null,new Date(2020 - 01 - 01),new Date(2018 - 01 - 01),new Date(2018 - 02 - 15));
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()))
...@@ -128,7 +129,7 @@ public class UserControllerTest { ...@@ -128,7 +129,7 @@ public class UserControllerTest {
"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 - 13), new Date(2017 - 12 - 20), null, null, new Date(2017 - 11 - 13), new Date(2017 - 12 - 20), null,
null, null, null, null, null, null, null, null, null); null, null,null,new Date(2020 - 01 - 01),new Date(2018 - 01 - 01),new Date(2018 - 02 - 15));
when(userService.getEmployeesRoleData("16127")) when(userService.getEmployeesRoleData("16127"))
.thenReturn(employeesRole); .thenReturn(employeesRole);
mockMvc.perform(get("/user/getEmployeeRoleData").param("empId", "16127") mockMvc.perform(get("/user/getEmployeeRoleData").param("empId", "16127")
...@@ -145,7 +146,7 @@ public class UserControllerTest { ...@@ -145,7 +146,7 @@ public class UserControllerTest {
"5976ef15874c902c98b8a05d", "16209", null, null, null, null, "5976ef15874c902c98b8a05d", "16209", 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 - 13), new Date(2017 - 12 - 20), null, null, new Date(2017 - 11 - 13), new Date(2017 - 12 - 20), null,
null, null, null, null, null, null, null, null, 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", when(userService.getEmployeeRoleDataForSearchCriteria("dummy@nisum.com",
"emailId")).thenReturn(employeesRole); "emailId")).thenReturn(employeesRole);
mockMvc.perform(get("/user/getEmployeeRoleDataForSearchCriteria") mockMvc.perform(get("/user/getEmployeeRoleDataForSearchCriteria")
...@@ -166,7 +167,7 @@ public class UserControllerTest { ...@@ -166,7 +167,7 @@ public class UserControllerTest {
"5976ef15874c902c98b8a05d", "16209", null, null, null, null, "5976ef15874c902c98b8a05d", "16209", 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 - 13), new Date(2017 - 12 - 20), null, null, new Date(2017 - 11 - 13), new Date(2017 - 12 - 20), null,
null, null, null, null, null, null, null, null, null); null, null,null,new Date(2020 - 01 - 01),new Date(2018 - 01 - 01),new Date(2018 - 02 - 15));
when(userService.getEmployeeRoleDataForSearchCriteria( when(userService.getEmployeeRoleDataForSearchCriteria(
"Mahesh Kumar Gutam", "employeeName")) "Mahesh Kumar Gutam", "employeeName"))
.thenReturn(employeesRole); .thenReturn(employeesRole);
...@@ -254,7 +255,7 @@ public class UserControllerTest { ...@@ -254,7 +255,7 @@ public class UserControllerTest {
"09:00-06:00", "Java/J2EE", "Spring", "8765588388", "09:00-06:00", "Java/J2EE", "Spring", "8765588388",
"9978567723", "msrivastava@gmail.com", null, null, null, null, "9978567723", "msrivastava@gmail.com", null, null, null, null,
null, new Date(2017 - 01 - 01), new Date(2017 - 03 - 01), null, null, new Date(2017 - 01 - 01), new Date(2017 - 03 - 01), null,
null, null, null, null, null, null, null, null, null); null, null,null,new Date(2020 - 01 - 01),new Date(2018 - 01 - 01),new Date(2018 - 02 - 15));
System.out.println(employeeRole); System.out.println(employeeRole);
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
String jsonString = mapper.writeValueAsString(employeeRole); String jsonString = mapper.writeValueAsString(employeeRole);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment