Skip to content

Commit

Permalink
style: spotless
Browse files Browse the repository at this point in the history
  • Loading branch information
kdomo committed Jan 8, 2024
1 parent 5f03e84 commit 86ccbe5
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import com.depromeet.global.util.MemberUtil;
import com.depromeet.global.util.SpringEnvironmentUtil;
import com.depromeet.infra.config.storage.StorageProperties;

import java.util.Date;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
Expand Down Expand Up @@ -63,8 +62,8 @@ public PresignedUrlResponse createMissionRecordPresignedUrl(

private MissionRecord findMissionRecordByMissionRecordId(Long request) {
return missionRecordRepository
.findById(request)
.orElseThrow(() -> new CustomException(ErrorCode.MISSION_RECORD_NOT_FOUND));
.findById(request)
.orElseThrow(() -> new CustomException(ErrorCode.MISSION_RECORD_NOT_FOUND));
}

@Transactional
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ public enum ErrorCode {
MISSION_RECORD_NOT_FOUND(HttpStatus.NOT_FOUND, "해당 미션 기록을 찾을 수 없습니다."),
MISSION_RECORD_USER_MISMATCH(HttpStatus.BAD_REQUEST, "미션을 생성한 유저와 로그인된 계정이 일치하지 않습니다"),
MISSION_RECORD_DURATION_OVERBALANCE(HttpStatus.BAD_REQUEST, "미션 참여 시간이 지정 된 시간보다 초과하였습니다"),
MISSION_RECORD_UPLOAD_STATUS_IS_NOT_NONE(HttpStatus.BAD_REQUEST, "미션 기록의 이미지 업로드 상태가 NONE이 아닙니다."),
MISSION_RECORD_UPLOAD_STATUS_ALREADY_COMPLETED(HttpStatus.BAD_REQUEST, "미션 기록의 이미지 업로드 상태가 이미 완료되어있습니다."),
MISSION_RECORD_UPLOAD_STATUS_IS_NOT_NONE(
HttpStatus.BAD_REQUEST, "미션 기록의 이미지 업로드 상태가 NONE이 아닙니다."),
MISSION_RECORD_UPLOAD_STATUS_ALREADY_COMPLETED(
HttpStatus.BAD_REQUEST, "미션 기록의 이미지 업로드 상태가 이미 완료되어있습니다."),
;

private final HttpStatus status;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import com.depromeet.domain.mission.service.MissionService;
import com.depromeet.domain.missionRecord.dto.request.MissionRecordCreateRequest;
import com.depromeet.domain.missionRecord.service.MissionRecordService;
import com.depromeet.global.config.security.PrincipalDetails;
import com.depromeet.global.error.exception.CustomException;
import com.depromeet.global.error.exception.ErrorCode;
import java.time.LocalDateTime;
Expand All @@ -26,9 +25,6 @@
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.test.context.ActiveProfiles;

@SpringBootTest
Expand Down Expand Up @@ -74,49 +70,53 @@ class 미션_기록_이미지_PresignedUrl을_생성할_때 {
.hasMessage(ErrorCode.MISSION_RECORD_NOT_FOUND.getMessage());
}

// TODO: SecurityUtil setMockAuthentication메서드 제거 후 주석해제 예정
// @Test
// void 미션을_생성한_유저와_로그인_유저가_일치하지_않는다면_예외를_발생시킨다() {
// // given
// memberRepository.save(
// Member.createNormalMember(new Profile("testNickname", "testImageUrl")));
// MissionCreateRequest missionCreateRequest =
// new MissionCreateRequest(
// "testMissionName",
// "testMissionContent",
// MissionCategory.STUDY,
// MissionVisibility.ALL);
// MissionCreateResponse missionCreateResponse =
// missionService.createMission(missionCreateRequest);
//
// SecurityContextHolder.clearContext();
// PrincipalDetails principal = new PrincipalDetails(2L, "USER");
// Authentication authentication =
// new UsernamePasswordAuthenticationToken(
// principal, "password", principal.getAuthorities());
// SecurityContextHolder.getContext().setAuthentication(authentication);
//
//
// LocalDateTime missionRecordStartedAt = LocalDateTime.of(2023, 12, 15, 1, 5, 0);
// LocalDateTime missionRecordFinishedAt =
// missionRecordStartedAt.plusMinutes(32).plusSeconds(14);
// MissionRecordCreateRequest missionRecordCreateRequest =
// new MissionRecordCreateRequest(
// missionCreateResponse.missionId(),
// missionRecordStartedAt,
// missionRecordFinishedAt,
// 32,
// 14);
// Long missionRecord =
// missionRecordService.createMissionRecord(missionRecordCreateRequest);
// MissionRecordImageCreateRequest request =
// new MissionRecordImageCreateRequest(missionRecord, ImageFileExtension.JPEG);
//
// // when, then
// assertThatThrownBy(() -> imageService.createMissionRecordPresignedUrl(request))
// .isInstanceOf(CustomException.class)
// .hasMessage(ErrorCode.MISSION_RECORD_USER_MISMATCH.getMessage());
// }
// TODO: SecurityUtil setMockAuthentication메서드 제거 후 주석해제 예정
// @Test
// void 미션을_생성한_유저와_로그인_유저가_일치하지_않는다면_예외를_발생시킨다() {
// // given
// memberRepository.save(
// Member.createNormalMember(new Profile("testNickname",
// "testImageUrl")));
// MissionCreateRequest missionCreateRequest =
// new MissionCreateRequest(
// "testMissionName",
// "testMissionContent",
// MissionCategory.STUDY,
// MissionVisibility.ALL);
// MissionCreateResponse missionCreateResponse =
// missionService.createMission(missionCreateRequest);
//
// SecurityContextHolder.clearContext();
// PrincipalDetails principal = new PrincipalDetails(2L, "USER");
// Authentication authentication =
// new UsernamePasswordAuthenticationToken(
// principal, "password", principal.getAuthorities());
// SecurityContextHolder.getContext().setAuthentication(authentication);
//
//
// LocalDateTime missionRecordStartedAt = LocalDateTime.of(2023, 12, 15, 1, 5,
// 0);
// LocalDateTime missionRecordFinishedAt =
// missionRecordStartedAt.plusMinutes(32).plusSeconds(14);
// MissionRecordCreateRequest missionRecordCreateRequest =
// new MissionRecordCreateRequest(
// missionCreateResponse.missionId(),
// missionRecordStartedAt,
// missionRecordFinishedAt,
// 32,
// 14);
// Long missionRecord =
// missionRecordService.createMissionRecord(missionRecordCreateRequest);
// MissionRecordImageCreateRequest request =
// new MissionRecordImageCreateRequest(missionRecord,
// ImageFileExtension.JPEG);
//
// // when, then
// assertThatThrownBy(() ->
// imageService.createMissionRecordPresignedUrl(request))
// .isInstanceOf(CustomException.class)
// .hasMessage(ErrorCode.MISSION_RECORD_USER_MISMATCH.getMessage());
// }

@Test
void 입력_값이_정상이라면_예외가_발생하지_않는다() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@
import com.depromeet.domain.mission.domain.Mission;
import com.depromeet.domain.mission.domain.MissionCategory;
import com.depromeet.domain.mission.domain.MissionVisibility;

import com.depromeet.global.error.exception.CustomException;
import com.depromeet.global.error.exception.ErrorCode;
import java.lang.reflect.Field;
import java.time.Duration;
import java.time.LocalDateTime;

import com.depromeet.global.error.exception.CustomException;
import com.depromeet.global.error.exception.ErrorCode;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;

Expand Down Expand Up @@ -56,7 +54,8 @@ class 미션기록_생성_시 {
}

@Test
void 업로드_상태를_PENDING으로_변경할때_업로드_상태가_NONE이_아니라면_예외가_발생한다() throws NoSuchFieldException, IllegalAccessException {
void 업로드_상태를_PENDING으로_변경할때_업로드_상태가_NONE이_아니라면_예외가_발생한다()
throws NoSuchFieldException, IllegalAccessException {
// given
LocalDateTime missionRecordStartedAt = LocalDateTime.of(2023, 12, 15, 1, 5, 0);
LocalDateTime missionRecordFinishedAt =
Expand All @@ -77,7 +76,8 @@ class 미션기록_생성_시 {
}

@Test
void 업로드_상태를_COMPLETE로_변경할때_업로드_상태가_이미_COMPLETE라면_예외가_발생한다() throws NoSuchFieldException, IllegalAccessException {
void 업로드_상태를_COMPLETE로_변경할때_업로드_상태가_이미_COMPLETE라면_예외가_발생한다()
throws NoSuchFieldException, IllegalAccessException {
// given
LocalDateTime missionRecordStartedAt = LocalDateTime.of(2023, 12, 15, 1, 5, 0);
LocalDateTime missionRecordFinishedAt =
Expand Down

0 comments on commit 86ccbe5

Please sign in to comment.