diff --git a/requests/updateProject.http b/requests/updateProject.http index dfa5f0b..d1ae70c 100644 --- a/requests/updateProject.http +++ b/requests/updateProject.http @@ -1,15 +1,3 @@ ### GET request to example server PUT http://localhost:8080/projects/1 -Authorization: Bearer {{auth_token}} -Content-Type: application/json - -{ - "name": "newName", - "leading_employee": 2, - "employees": [], - "contractor": 9, - "contractor_name": "New Contractor name", - "comment": "new goal of project", - "start_date": "01.01.2010", - "planned_end_date": "01.01.2021" -} \ No newline at end of file +Authorization: Bearer {{auth_token}} \ No newline at end of file diff --git a/src/test/java/de/szut/lf8_starter/integration/project/FindProjectActionTest.java b/src/test/java/de/szut/lf8_starter/integration/project/GetProjectActionTest.java similarity index 89% rename from src/test/java/de/szut/lf8_starter/integration/project/FindProjectActionTest.java rename to src/test/java/de/szut/lf8_starter/integration/project/GetProjectActionTest.java index dacb171..c8e17cc 100644 --- a/src/test/java/de/szut/lf8_starter/integration/project/FindProjectActionTest.java +++ b/src/test/java/de/szut/lf8_starter/integration/project/GetProjectActionTest.java @@ -18,14 +18,14 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. @SpringBootTest @AutoConfigureMockMvc(addFilters = false) -class FindProjectActionTest { +class GetProjectActionTest { @Autowired private MockMvc mockMvc; @Autowired private ProjectRepository projectRepository; @Test - void createProjectTest() throws Exception { + void getProjectTest() throws Exception { var project = new ProjectEntity(); project.setId(1); project.setComment("comment"); @@ -51,4 +51,9 @@ class FindProjectActionTest { .andExpect(jsonPath("employees").isArray()) .andExpect(jsonPath("employees", hasSize(3))); } + + @Test + void getProjectShouldReturnNotFoundResponseWhenProjectIsNotFound() throws Exception { + this.mockMvc.perform(get("/projects/2")).andExpect(status().isNotFound()); + } } diff --git a/src/test/java/de/szut/lf8_starter/integration/project/UpdateProjectActionTest.java b/src/test/java/de/szut/lf8_starter/integration/project/UpdateProjectActionTest.java index b50c15d..5fb4c02 100644 --- a/src/test/java/de/szut/lf8_starter/integration/project/UpdateProjectActionTest.java +++ b/src/test/java/de/szut/lf8_starter/integration/project/UpdateProjectActionTest.java @@ -16,6 +16,8 @@ import java.util.List; import static org.assertj.core.api.Assertions.assertThat; import static org.hamcrest.Matchers.is; +import static org.hamcrest.collection.IsCollectionWithSize.hasSize; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @@ -29,7 +31,7 @@ class UpdateProjectActionTest { private ProjectRepository projectRepository; @Test - void updateProjectTest() throws Exception { + void updateProjectShouldUpdateProject() throws Exception { ProjectEntity project = new ProjectEntity(); project.setId(1); project.setComment("comment"); @@ -83,4 +85,9 @@ class UpdateProjectActionTest { assertThat(existingProject.get().getPlannedEndDate()).isEqualTo(LocalDate.of(2022, 1, 1)); } + + @Test + void updateProjectShouldReturnNotFoundResponseWhenProjectIsNotFound() throws Exception { + this.mockMvc.perform(put("/projects/2").content("{}").contentType(MediaType.APPLICATION_JSON)).andExpect(status().isNotFound()); + } }