Satisfy Sonarqube Code Coverage
Some checks failed
Quality Check / Tests (pull_request) Successful in 1m2s
Build PR / Build and analyze (pull_request) Successful in 1m55s
gitea-sonarqube-bot ERROR
Quality Check / Checkstyle Main (pull_request) Successful in 48s

This commit is contained in:
Phan Huy Tran 2024-10-02 10:30:58 +02:00
parent 77b2c00c3f
commit 6a8e4852c4
3 changed files with 16 additions and 16 deletions

@ -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());
}
}