diff --git a/core/src/main/java/greencity/constant/HttpStatuses.java b/core/src/main/java/greencity/constant/HttpStatuses.java index 08a3d97eea..f0ddc595b2 100644 --- a/core/src/main/java/greencity/constant/HttpStatuses.java +++ b/core/src/main/java/greencity/constant/HttpStatuses.java @@ -12,5 +12,4 @@ public class HttpStatuses { public static final String NOT_FOUND = "Not Found"; public static final String SEE_OTHER = "See Other"; public static final String FOUND = "Found"; - public static final String INTERNAL_SERVER_ERROR = "Internal Server Error"; } diff --git a/core/src/main/java/greencity/controller/CommitInfoController.java b/core/src/main/java/greencity/controller/CommitInfoController.java index b9ce99d102..bc598974c2 100644 --- a/core/src/main/java/greencity/controller/CommitInfoController.java +++ b/core/src/main/java/greencity/controller/CommitInfoController.java @@ -9,6 +9,7 @@ import io.swagger.v3.oas.annotations.media.ExampleObject; import io.swagger.v3.oas.annotations.responses.ApiResponse; import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; @@ -41,20 +42,20 @@ public class CommitInfoController { "commitDate": "16/12/2024 10:55:00" }"""))) @ApiResponse( - responseCode = "500", - description = HttpStatuses.INTERNAL_SERVER_ERROR, + responseCode = "404", + description = HttpStatuses.NOT_FOUND, content = @Content( mediaType = "application/json", examples = @ExampleObject( value = """ { - "error": "Failed to fetch commit info: Repository not found" + "error": "Git repository not initialized. Commit info is unavailable." }"""))) @GetMapping public ResponseEntity getCommitInfo() { CommitInfoDto commitInfo = commitInfoService.getLatestCommitInfo(); if (commitInfo instanceof CommitInfoErrorDto) { - return ResponseEntity.internalServerError().body(commitInfo); + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(commitInfo); } return ResponseEntity.ok(commitInfo); } diff --git a/core/src/test/java/greencity/controller/CommitInfoControllerTest.java b/core/src/test/java/greencity/controller/CommitInfoControllerTest.java index fa6bbcb77d..0ed5b0c02f 100644 --- a/core/src/test/java/greencity/controller/CommitInfoControllerTest.java +++ b/core/src/test/java/greencity/controller/CommitInfoControllerTest.java @@ -61,7 +61,7 @@ void getCommitInfoReturnsErrorTest() throws Exception { when(commitInfoService.getLatestCommitInfo()).thenReturn(commitInfoDto); mockMvc.perform(get(COMMIT_INFO_URL).accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isInternalServerError()) + .andExpect(status().isNotFound()) .andExpect(jsonPath("$.error").value(ERROR_MESSAGE)); verify(commitInfoService, times(1)).getLatestCommitInfo();