Commit 963f6644 authored by Rajeshekar's avatar Rajeshekar

Fixed the compilation errors in test cases and now the build is

successful
parent ac5da2a9
......@@ -53,68 +53,94 @@ public class ProjectControllerTest {
mockMvc = MockMvcBuilders.standaloneSetup(projectController).build();
}
@Test
public void testgetEmployeeRole() throws Exception{
EmployeeRoles employeesRole = new EmployeeRoles("5976ef15874c902c98b8a05d",null,null,"user@nisum.com",null, null,null,null,null,null,null,null,null, new Date(2017-11-12),new Date(2017-12-12));
when(userService.getEmployeesRole("user@nisum.com")).thenReturn(employeesRole);
mockMvc.perform(get("/project/employee").param("emailId", "user@nisum.com")).andExpect(MockMvcResultMatchers.status().isOk());
public void testgetEmployeeRole() throws Exception {
EmployeeRoles employeesRole = new EmployeeRoles(
"5976ef15874c902c98b8a05d", null, null, "user@nisum.com", null,
null, null, null, null, null, null, null, null, null, null,
null, null, new Date(2017 - 11 - 12), new Date(2017 - 12 - 12));
when(userService.getEmployeesRole("user@nisum.com"))
.thenReturn(employeesRole);
mockMvc.perform(
get("/project/employee").param("emailId", "user@nisum.com"))
.andExpect(MockMvcResultMatchers.status().isOk());
verify(userService).getEmployeesRole("user@nisum.com");
}
@Test
public void testaddProject() throws Exception{
public void testaddProject() throws Exception {
List<String> list = new ArrayList<>();
list.add("16101");
list.add("16102");
list.add("16103");
Project employeeRole1 = new Project(new ObjectId ("9976ef15874c902c98b8a05d"),"102","OMS","16101","Srikanth","Macys","Billable",list);
String jsonvalue =(new ObjectMapper()).writeValueAsString(employeeRole1).toString();
Account account = new Account(new ObjectId("5a4f03661dca211ea7f94c02"),"2", "Macys", 0,"Y");
when(projectService.addProject(employeeRole1)).thenReturn(employeeRole1);
Project employeeRole1 = new Project(
new ObjectId("9976ef15874c902c98b8a05d"), "102", "OMS", "16101",
"Srikanth", "Macys", "Billable", list);
String jsonvalue = (new ObjectMapper())
.writeValueAsString(employeeRole1).toString();
Account account = new Account(new ObjectId("5a4f03661dca211ea7f94c02"),
"2", "Macys", 0, "Y");
when(projectService.addProject(employeeRole1))
.thenReturn(employeeRole1);
when(accountRepo.findByAccountName("Macys")).thenReturn(account);
mockMvc.perform(post("/project/addProject").contentType(MediaType.APPLICATION_JSON_VALUE).content(jsonvalue)).andExpect(MockMvcResultMatchers.status().isOk());
mockMvc.perform(post("/project/addProject")
.contentType(MediaType.APPLICATION_JSON_VALUE)
.content(jsonvalue))
.andExpect(MockMvcResultMatchers.status().isOk());
}
@Test
public void testupdateEmployeeRole() throws Exception{
public void testupdateEmployeeRole() throws Exception {
List<String> list1 = new ArrayList<>();
list1.add("16104");
list1.add("16105");
list1.add("16106");
Project project = new Project(new ObjectId ("5976ef15874c902c98b8a05d"),"101","MOSAIC","16100","Rajeshekar","Gap","Billable",list1);
Project project = new Project(new ObjectId("5976ef15874c902c98b8a05d"),
"101", "MOSAIC", "16100", "Rajeshekar", "Gap", "Billable",
list1);
ObjectMapper mapper = new ObjectMapper();
String jsonString = mapper.writeValueAsString(project);
when(projectService.updateProject(any())).thenReturn(project);
mockMvc.perform(post("/project/updateProject").contentType(MediaType.APPLICATION_JSON_VALUE).content(jsonString)).andExpect(MockMvcResultMatchers.status().isOk());
mockMvc.perform(post("/project/updateProject")
.contentType(MediaType.APPLICATION_JSON_VALUE)
.content(jsonString))
.andExpect(MockMvcResultMatchers.status().isOk());
verify(projectService).updateProject(any());
}
@Test
public void testdeleteProject() throws Exception{
mockMvc.perform(delete("/project/deleteProject").param("projectId", "101")).andExpect(MockMvcResultMatchers.status().isOk());
public void testdeleteProject() throws Exception {
mockMvc.perform(
delete("/project/deleteProject").param("projectId", "101"))
.andExpect(MockMvcResultMatchers.status().isOk());
verify(projectService).deleteProject("101");
}
@Test
public void testgetProjects() throws Exception{
public void testgetProjects() throws Exception {
List<Project> projects = CreateProjectDetails();
when(projectService.getProjects()).thenReturn(projects);
mockMvc.perform(get("/project/getProjects").contentType(MediaType.APPLICATION_JSON_VALUE)).andExpect(MockMvcResultMatchers.status().isOk());
mockMvc.perform(get("/project/getProjects")
.contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(MockMvcResultMatchers.status().isOk());
verify(projectService).getProjects();
}
@Test
public void testgetEmployeeRoleData() throws Exception{
EmployeeRoles employeesRole = new EmployeeRoles("5976ef15874c902c98b8a05d","16127",null,null,null,null, null,null,null,null,null,null,null, new Date(2017-11-18),new Date(2017-12-18));
when(userService.getEmployeesRoleData("16127")).thenReturn(employeesRole);
mockMvc.perform(get("/project/getEmployeeRoleData").param("empId", "16127").contentType(MediaType.APPLICATION_JSON_VALUE)).andExpect(MockMvcResultMatchers.status().isOk());
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 - 18), new Date(2017 - 12 - 18));
when(userService.getEmployeesRoleData("16127"))
.thenReturn(employeesRole);
mockMvc.perform(
get("/project/getEmployeeRoleData").param("empId", "16127")
.contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(MockMvcResultMatchers.status().isOk());
verify(userService).getEmployeesRoleData("16127");
}
private List<Project> CreateProjectDetails() {
List<Project> data = new ArrayList<>();
......@@ -132,7 +158,6 @@ public class ProjectControllerTest {
list.add("16103");
data1.setEmployeeIds(list);
Project data2 = new Project();
data2.setId(new ObjectId("9976ef15874c902c98b8a05d"));
data2.setProjectId("102");
......
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