Satisfy Sonarqube Code Coverage
This commit is contained in:
parent
77b2c00c3f
commit
6a8e4852c4
@ -1,15 +1,3 @@
|
|||||||
### GET request to example server
|
### GET request to example server
|
||||||
PUT http://localhost:8080/projects/1
|
PUT http://localhost:8080/projects/1
|
||||||
Authorization: Bearer {{auth_token}}
|
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"
|
|
||||||
}
|
|
@ -18,14 +18,14 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
|||||||
|
|
||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
@AutoConfigureMockMvc(addFilters = false)
|
@AutoConfigureMockMvc(addFilters = false)
|
||||||
class FindProjectActionTest {
|
class GetProjectActionTest {
|
||||||
@Autowired
|
@Autowired
|
||||||
private MockMvc mockMvc;
|
private MockMvc mockMvc;
|
||||||
@Autowired
|
@Autowired
|
||||||
private ProjectRepository projectRepository;
|
private ProjectRepository projectRepository;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void createProjectTest() throws Exception {
|
void getProjectTest() throws Exception {
|
||||||
var project = new ProjectEntity();
|
var project = new ProjectEntity();
|
||||||
project.setId(1);
|
project.setId(1);
|
||||||
project.setComment("comment");
|
project.setComment("comment");
|
||||||
@ -51,4 +51,9 @@ class FindProjectActionTest {
|
|||||||
.andExpect(jsonPath("employees").isArray())
|
.andExpect(jsonPath("employees").isArray())
|
||||||
.andExpect(jsonPath("employees", hasSize(3)));
|
.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.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.hamcrest.Matchers.is;
|
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.request.MockMvcRequestBuilders.put;
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||||
@ -29,7 +31,7 @@ class UpdateProjectActionTest {
|
|||||||
private ProjectRepository projectRepository;
|
private ProjectRepository projectRepository;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void updateProjectTest() throws Exception {
|
void updateProjectShouldUpdateProject() throws Exception {
|
||||||
ProjectEntity project = new ProjectEntity();
|
ProjectEntity project = new ProjectEntity();
|
||||||
project.setId(1);
|
project.setId(1);
|
||||||
project.setComment("comment");
|
project.setComment("comment");
|
||||||
@ -83,4 +85,9 @@ class UpdateProjectActionTest {
|
|||||||
assertThat(existingProject.get().getPlannedEndDate()).isEqualTo(LocalDate.of(2022, 1, 1));
|
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