Satisfy Sonarqube Issues
Some checks failed
Quality Check / Tests (pull_request) Successful in 1m3s
Build PR / Build and analyze (pull_request) Successful in 1m58s
gitea-sonarqube-bot ERROR
Quality Check / Checkstyle Main (pull_request) Successful in 45s

This commit is contained in:
Phan Huy Tran 2024-10-02 10:34:21 +02:00
parent 6a8e4852c4
commit aaa8c286aa
3 changed files with 21 additions and 3 deletions

@ -1,3 +1,15 @@
### GET request to example server
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"
}

@ -6,6 +6,7 @@ import io.swagger.v3.oas.annotations.responses.ApiResponses;
import jakarta.validation.ConstraintViolationException;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
@ -40,6 +41,13 @@ public class GlobalExceptionHandler {
return new ResponseEntity<>(errorDetails, HttpStatus.BAD_REQUEST);
}
@ExceptionHandler(HttpMessageNotReadableException.class)
public ResponseEntity<ErrorDetails> handleHttpMessageNotReadableException(HttpMessageNotReadableException ex, WebRequest request) {
ErrorDetails errorDetails = new ErrorDetails(new Date(), ex.getMessage(), request.getDescription(false));
return new ResponseEntity<>(errorDetails, HttpStatus.BAD_REQUEST);
}
@ExceptionHandler(ConstraintViolationException.class)
public ResponseEntity<ErrorDetails> handleConstraintViolationException(ConstraintViolationException ex, WebRequest request) {
String errorMessage = ex.getConstraintViolations().stream().findFirst().get().getMessage();

@ -16,8 +16,6 @@ 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;