Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ public PresignedProfileImageInfo issuePresignedUrl(
return PresignedProfileImageInfo.of(member.getId(), info.tmpKey(), info.presignedUrl());
}

@CacheEvict(
cacheNames = MEMBER,
key = "T(com.ject.studytrip.global.common.factory.CacheKeyFactory).member(#memberId)")
@Transactional
public void confirmImage(Long memberId, ConfirmProfileImageRequest request) {
Member member = memberQueryService.getValidMember(memberId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public Mission getValidMission(Long stampId, Long missionId) {

MissionPolicy.validateMissionBelongsToStamp(stampId, mission);
MissionPolicy.validateNotDeleted(mission);
MissionPolicy.validateCompleted(mission);

return mission;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public Stamp getValidStamp(Long tripId, Long stampId) {

StampPolicy.validateStampBelongsToTrip(tripId, stamp);
StampPolicy.validateNotDeleted(stamp);
StampPolicy.validateCompleted(stamp);

return stamp;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ public PresignedStudyLogImageInfo issuePresignedUrl(
return PresignedStudyLogImageInfo.of(studyLog.getId(), info.tmpKey(), info.presignedUrl());
}

@CacheEvict(cacheNames = STUDY_LOGS, allEntries = true)
@Transactional
public void confirmImage(Long studyLogId, ConfirmStudyLogImageRequest request) {
StudyLog studyLog = studyLogQueryService.getValidStudyLog(studyLogId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public Trip getValidTrip(Long memberId, Long tripId) {

TripPolicy.validateOwner(memberId, trip);
TripPolicy.validateNotDeleted(trip);
TripPolicy.validateCompleted(trip);

return trip;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,21 @@ void shouldThrowExceptionWhenMissionIsDeleted() {
.hasMessage(MissionErrorCode.MISSION_ALREADY_DELETED.getMessage());
}

@Test
@DisplayName("미션이 이미 완료된 경우 예외가 발생한다.")
void shouldThrowExceptionWhenMissionIsCompleted() {
// given
exploreMission1.updateCompleted();
Long stampId = exploreStamp.getId();
Long missionId = exploreMission1.getId();
given(missionRepository.findById(missionId)).willReturn(Optional.of(exploreMission1));

// when & then
assertThatThrownBy(() -> missionQueryService.getValidMission(stampId, missionId))
.isInstanceOf(CustomException.class)
.hasMessage(MissionErrorCode.MISSION_ALREADY_COMPLETED.getMessage());
}

@Test
@DisplayName("특정 스탬프에 속하고 삭제되지 않은 미션이 존재하면, 해당 미션을 반환한다.")
void shouldReturnValidMission() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,31 @@ void shouldThrowExceptionWhenStampDoesNotBelongToTrip() {
void shouldThrowExceptionWhenStampAlreadyDeleted() {
// given
courseStamp1.updateDeletedAt();
given(stampRepository.findById(any())).willReturn(Optional.ofNullable(courseStamp1));
Long tripId = courseTrip.getId();
Long stampId = courseStamp1.getId();
given(stampRepository.findById(stampId)).willReturn(Optional.ofNullable(courseStamp1));

// when & then
assertThatThrownBy(
() ->
stampQueryService.getValidStamp(
courseStamp1.getId(), courseStamp1.getId()))
assertThatThrownBy(() -> stampQueryService.getValidStamp(tripId, stampId))
.isInstanceOf(CustomException.class)
.hasMessage(StampErrorCode.STAMP_ALREADY_DELETED.getMessage());
}

@Test
@DisplayName("완료된 스탬프일 경우 예외가 발생한다.")
void shouldThrowExceptionWhenStampAlreadyCompleted() {
// given
courseStamp1.updateCompleted();
Long tripId = courseTrip.getId();
Long stampId = courseStamp1.getId();
given(stampRepository.findById(stampId)).willReturn(Optional.ofNullable(courseStamp1));

// when & then
assertThatThrownBy(() -> stampQueryService.getValidStamp(tripId, stampId))
.isInstanceOf(CustomException.class)
.hasMessage(StampErrorCode.STAMP_ALREADY_COMPLETED.getMessage());
}

@Test
@DisplayName("스탬프 ID로 스탬프를 조회하고, 여행 소속 및 삭제 여부를 검증하고 반환한다")
void shouldGetStampReturnValidStamp() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,20 @@ void shouldThrowExceptionWhenAlreadyTrip() {
.hasMessage(TripErrorCode.TRIP_ALREADY_DELETED.getMessage());
}

@Test
@DisplayName("이미 완료된 여행일 경우 예외가 발생한다")
void shouldThrowExceptionWhenTripAlreadyCompleted() {
// given
trip.updateCompleted();
Long tripId = trip.getId();
given(tripRepository.findById(tripId)).willReturn(Optional.of(trip));

// when & then
assertThatThrownBy(() -> tripQueryService.getValidTrip(member.getId(), tripId))
.isInstanceOf(CustomException.class)
.hasMessage(TripErrorCode.TRIP_ALREADY_COMPLETED.getMessage());
}

@Test
@DisplayName("특정 여행 ID로 DB에서 조회한 후 유효한 여행을 반환한다")
void shouldGetTripByTripIdReturnValidTrip() {
Expand Down