我有一個函數可以更新 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); } }(我已經在設置中創(chuàng)建了對象)我得到的狀態(tài)是 405,當我放置問題密鑰時,我得到的狀態(tài)是 200(即使問題密鑰不存在)它必須拋出狀態(tài) 500
添加回答
舉報
0/150
提交
取消