Skip to content

Commit

Permalink
#85 - SonarIssue: moving constant to enum
Browse files Browse the repository at this point in the history
  • Loading branch information
iakunin committed Apr 25, 2020
1 parent 5780f6d commit 01f780b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public void run() {
this.codexiaReviewNotificationRepository
.findAllByLastStatusExcludingResponseCode(
CodexiaReviewNotification.Status.SUCCESS,
CodexiaClient.REVIEW_ALREADY_EXISTS_STATUS
CodexiaClient.ReviewStatus.ALREADY_EXISTS.httpStatus()
)
.stream()
.map(CodexiaReviewNotification::getCodexiaReview)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
)
public interface CodexiaClient {

int REVIEW_ALREADY_EXISTS_STATUS = 404;

@GetMapping(
value = "/recent.json",
produces = { "application/json" }
Expand Down Expand Up @@ -73,4 +71,18 @@ class Project {
// @todo #6 replace `Date` with `ZonedDateTime`
private Date created;
}

enum ReviewStatus {
ALREADY_EXISTS(404);

private final int httpStatus;

ReviewStatus(int httpStatus) {
this.httpStatus = httpStatus;
}

public int httpStatus() {
return this.httpStatus;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ private void saveExceptionalNotification(
notification
.setStatus(
// @todo #19 rewrite via custom Feign exceptions
e.status() == CodexiaClient.REVIEW_ALREADY_EXISTS_STATUS
e.status() == CodexiaClient.ReviewStatus.ALREADY_EXISTS.httpStatus()
? CodexiaReviewNotification.Status.SUCCESS
: CodexiaReviewNotification.Status.ERROR
)
Expand Down

0 comments on commit 01f780b

Please sign in to comment.