Skip to content

Commit

Permalink
Project test stub updates
Browse files Browse the repository at this point in the history
  • Loading branch information
dhlevi committed Nov 22, 2024
1 parent 2611135 commit 5b50ef2
Showing 1 changed file with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import org.springframework.test.web.servlet.MockMvc;
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 static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

import ca.bc.gov.nrs.wfprev.controllers.ProjectController;
Expand Down Expand Up @@ -57,12 +59,37 @@ void testGetProject() throws Exception {

@Test
@WithMockUser
void testCreateProject() throws Exception {
void testCreateUpdateProject() throws Exception {
ProjectModel project = new ProjectModel();
when(projectService.createOrUpdateProject(project)).thenReturn(project);

mockMvc.perform(post("/projects", project)
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isCreated());


project.setClosestCommunityName("Test");
when(projectService.createOrUpdateProject(project)).thenReturn(project);

mockMvc.perform(put("/projects", project)
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isCreated());
}

@Test
@WithMockUser
void testDeleteProject() throws Exception {
ProjectModel project = new ProjectModel();
when(projectService.createOrUpdateProject(project)).thenReturn(project);

mockMvc.perform(post("/projects", project)
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isCreated());

when(projectService.deleteProject(project.getProjectGuid())).thenReturn(null);

mockMvc.perform(delete("/projects/{id}", project.getProjectGuid())
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk());
}
}

0 comments on commit 5b50ef2

Please sign in to comment.