Skip to content

Commit

Permalink
[feat] 스탬프 삭제시 PokeEvent 발생 스탬프 삭제 및 s3이미지 삭제 검증 테스트 추가 (#336)
Browse files Browse the repository at this point in the history
  • Loading branch information
kseysh committed Oct 31, 2024
1 parent a4e71ff commit 994c024
Showing 1 changed file with 34 additions and 8 deletions.
42 changes: 34 additions & 8 deletions src/test/java/org/sopt/app/application/StampServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.sopt.app.common.fixtures.SoptampFixture.MISSION_ID;
import static org.sopt.app.common.fixtures.SoptampFixture.STAMP_CONTENTS;
import static org.sopt.app.common.fixtures.SoptampFixture.STAMP_IMG_PATHS;
import static org.sopt.app.common.fixtures.SoptampFixture.USER_ID;
import static org.sopt.app.common.fixtures.SoptampFixture.getEditStampRequest;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.verify;
import static org.sopt.app.common.fixtures.SoptampFixture.*;

import java.time.LocalDateTime;
import java.util.List;
Expand All @@ -22,6 +20,7 @@
import org.mockito.junit.jupiter.MockitoExtension;
import org.sopt.app.application.stamp.StampInfo;
import org.sopt.app.application.stamp.StampService;
import org.sopt.app.common.event.EventPublisher;
import org.sopt.app.common.exception.BadRequestException;
import org.sopt.app.common.fixtures.SoptampFixture;
import org.sopt.app.domain.entity.soptamp.Stamp;
Expand All @@ -36,6 +35,9 @@ class StampServiceTest {
@Mock
private StampRepository stampRepository;

@Mock
private EventPublisher eventPublisher;

@InjectMocks
private StampService stampService;

Expand Down Expand Up @@ -405,6 +407,18 @@ void SUCCESS_deleteStampById() {
});
}

@Test
void SUCCESS_모든_스탬프_삭제시_스탬프_삭제_이벤트_발생(){
// given
final Long userId = anyLong();

// when
stampService.deleteAllStamps(userId);

// then
verify(eventPublisher).raise(any());
}

@Test
@DisplayName("FAIL_스탬프를 찾지 못하면 BadRequestException 발생")
void FAIL_deleteStampById() {
Expand All @@ -420,16 +434,28 @@ void FAIL_deleteStampById() {
});
}

@Test
void SUCCESS_스탬프_삭제시_스탬프_삭제_이벤트_발생(){
// given
final Stamp stamp = Stamp.builder().build();
final Long stampId = anyLong();
given(stampRepository.findById(stampId)).willReturn(Optional.of(stamp));

// when
stampService.deleteStampById(stampId);

// then
verify(eventPublisher).raise(any());
}

@Test
@DisplayName("SUCCESS_모든 스탬프 삭제")
void SUCCESS_deleteAllStamps() {
//given
final Long anyUserId = anyLong();

//then
Assertions.assertDoesNotThrow(() -> {
stampService.deleteAllStamps(anyUserId);
});
Assertions.assertDoesNotThrow(() -> stampService.deleteAllStamps(anyUserId));
}

@Test
Expand Down

0 comments on commit 994c024

Please sign in to comment.