Satisfy Sonarqube Code Coverage
This commit is contained in:
parent
1c393ead47
commit
ee123f5543
@ -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"
|
||||
}
|
||||
Authorization: Bearer {{auth_token}}
|
@ -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());
|
||||
}
|
||||
}
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user