我有一个函数可以更新 jira 中的问题,我想使用 JUnit 抛出捕获。
这是我得到的功能:
@PutMapping (value = "/update/{issueKey}")
public ResponseEntity<ResponseDTO>
updateIssue(@Validated @RequestBody EventDTO eventDTO, BindingResult result, @PathVariable String issueKey)
{
logger.info("Entra en /update con el payload: {}", eventDTO);
if (result.hasErrors())
{
ErrorResponseDTO errorResponseDTO = ErrorResponseDTO.getErrorResponseDTOFromBinding(result, messageSource);
return new ResponseEntity<>(errorResponseDTO, HttpStatus.BAD_REQUEST);
}
try
{
SuccessResponseDTO successResponseDTO = jiraService.update(eventDTO, issueKey);
logger.info("/update response {} ", successResponseDTO);
return new ResponseEntity<>(successResponseDTO, HttpStatus.OK);
}
catch (EywaException eywaException)
{
logger.error("Se ha producido un error en actualizar un issue", eywaException);
ErrorResponseDTO responseDTO = new ErrorResponseDTO();
String errorMessage = messageSource.getMessage(eywaException.getMessage(), null,
LocaleContextHolder.getLocale());
responseDTO.addErrorResponseDTO(eywaException.getMessage().split("\\.")[0], errorMessage);
return new ResponseEntity<>(responseDTO, HttpStatus.INTERNAL_SERVER_ERROR);
}
}
(我已经在设置中创建了对象)我得到的状态是 405,当我放置问题密钥时,我得到的状态是 200(即使问题密钥不存在)
它必须抛出状态 500
慕斯王
智慧大石
相关分类