Skip to content

Commit

Permalink
[Fix] Errorcode 변경 및, controller, service errorcode변경
Browse files Browse the repository at this point in the history
  • Loading branch information
wonie committed Dec 30, 2024
1 parent 023a5a7 commit 0cdf722
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public PublicSchedule updatePublicSchedule(Long scheduleId, PublicScheduleUpdate

private static void checkAuthor(String author, User user) {
if (!user.getIntraId().equals(author)) {
throw new InvalidParameterException(ErrorCode.CALENDAR_AUTHOR_NOT_MATCH);
throw new ForbiddenException(ErrorCode.CALENDAR_AUTHOR_NOT_MATCH);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import gg.data.calendar.PublicSchedule;
import gg.data.calendar.type.DetailClassification;
import gg.data.calendar.type.EventTag;
import gg.data.calendar.type.ScheduleStatus;
import gg.data.user.User;
import gg.repo.calendar.PublicScheduleRepository;
import gg.repo.user.UserRepository;
Expand Down Expand Up @@ -178,6 +179,7 @@ void updatePublicScheduleSuccess() throws Exception {
.link("http://updated.com")
.startTime(LocalDateTime.now())
.endTime(LocalDateTime.now().plusDays(2))
.status(ScheduleStatus.ACTIVATE)
.build();

// when
Expand Down Expand Up @@ -224,10 +226,7 @@ void updatePublicScheduleFailNotMatchAuthor() throws Exception {
put("/calendar/public/" + publicSchedule.getId()).header("Authorization", "Bearer " + accssToken)
.contentType(MediaType.APPLICATION_JSON)
.content(objectMapper.writeValueAsString(updateDto)))
.andExpect(status().isBadRequest())
.andExpect(result -> {
status().isBadRequest();
})
.andExpect(status().isForbidden())
.andDo(print());

// then
Expand Down Expand Up @@ -265,10 +264,7 @@ void updatePublicScheduleFailExistingAuthorNotMatch() throws Exception {
put("/calendar/public/" + publicSchedule.getId()).header("Authorization", "Bearer " + accssToken)
.contentType(MediaType.APPLICATION_JSON)
.content(objectMapper.writeValueAsString(updateDto)))
.andExpect(status().isBadRequest())
.andExpect(result -> {
status().isBadRequest();
})
.andExpect(status().isForbidden())
.andDo(print());

List<PublicSchedule> schedules = publicScheduleRepository.findByAuthor(user.getIntraId());
Expand Down Expand Up @@ -376,7 +372,6 @@ void updatePublicScheduleFailTitleTooLong() throws Exception {
.contentType(MediaType.APPLICATION_JSON)
.content(objectMapper.writeValueAsString(updateDto)))
.andExpect(status().isBadRequest())
.andExpect(jsonPath("$.message").value("제목은 50자이하로 입력해주세요."))
.andDo(print());

//then
Expand Down Expand Up @@ -417,7 +412,6 @@ void updatePublicScheduleFailContentTooLong() throws Exception {
.contentType(MediaType.APPLICATION_JSON)
.content(objectMapper.writeValueAsString(updateDto)))
.andExpect(status().isBadRequest())
.andExpect(jsonPath("$.message").value("내용은 2000자이하로 입력해주세요."))
.andDo(print());

//then
Expand Down
2 changes: 1 addition & 1 deletion gg-utils/src/main/java/gg/utils/exception/ErrorCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public enum ErrorCode {
CALENDAR_BEFORE_DATE(400, "CA201", "종료 시간이 시작 시간보다 빠를 수 없습니다."),
CALENDAR_AFTER_DATE(400, "CA202", "시작 시간이 종료 시간보다 늦을 수 없습니다."),
CALENDAR_EQUAL_DATE(400, "CA203", "시작 시간과 종료 시간이 같을 수 없습니다."),
CALENDAR_AUTHOR_NOT_MATCH(400, "CA205", "잘못된 사용자입니다."),
CALENDAR_AUTHOR_NOT_MATCH(403, "CA205", "잘못된 사용자입니다."),
PRIVATE_SCHEDULE_NOT_FOUND(404, "CA101", "개인 일정을 찾을 수 없습니다."),
PUBLIC_SCHEDULE_NOT_FOUND(404, "CA102", "공유 일정을 찾을 수 없습니다."),
SCHEDULE_GROUP_NOT_FOUND(404, "CA103", "스캐줄 그룹을 찾을 수 없습니다.");
Expand Down

0 comments on commit 0cdf722

Please sign in to comment.