-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from softeerbootcamp4th/test/arrival-java
[Test] Redis, Java 선착순 통합/단위 테스트
- Loading branch information
Showing
4 changed files
with
219 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
src/test/java/com/softeer/podoarrival/unit/event/ArrivalEventComplexServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package com.softeer.podoarrival.unit.event; | ||
|
||
import com.softeer.podoarrival.event.model.dto.ArrivalApplicationResponseDto; | ||
import com.softeer.podoarrival.event.model.entity.Role; | ||
import com.softeer.podoarrival.event.repository.ArrivalUserRepository; | ||
import com.softeer.podoarrival.event.service.ArrivalEventReleaseServiceJavaImpl; | ||
import com.softeer.podoarrival.event.service.ArrivalEventReleaseServiceRedisImpl; | ||
import com.softeer.podoarrival.event.service.ArrivalEventService; | ||
import com.softeer.podoarrival.security.AuthInfo; | ||
import org.assertj.core.api.Assertions; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
import org.redisson.api.RedissonClient; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
|
||
import static org.mockito.Mockito.doReturn; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
public class ArrivalEventComplexServiceTest { | ||
|
||
@InjectMocks | ||
private ArrivalEventService arrivalEventService; | ||
|
||
@Mock | ||
private ArrivalEventReleaseServiceJavaImpl redisService; | ||
|
||
@Mock | ||
private ArrivalEventReleaseServiceRedisImpl javaService; | ||
|
||
@Mock | ||
private RedissonClient redissonClient; | ||
|
||
@Mock | ||
private ArrivalUserRepository arrivalUserRepository; | ||
|
||
private AuthInfo authInfo; | ||
private ArrivalApplicationResponseDto expectedResponse; | ||
|
||
@BeforeEach | ||
public void setup() { | ||
authInfo = new AuthInfo("name", "phoneNum", Role.ROLE_USER); | ||
expectedResponse = new ArrivalApplicationResponseDto(true, "name", "phoneNum", 1); | ||
} | ||
|
||
@Test | ||
@DisplayName("다양한 구현체에 대해 선착순 이벤트 테스트 (성공 - Redis)") | ||
public void testApplyEventWithRedisImplementations_Success() { | ||
// given | ||
doReturn(CompletableFuture.completedFuture(expectedResponse)).when(redisService).applyEvent(authInfo); | ||
arrivalEventService = new ArrivalEventService(redisService); | ||
|
||
// when | ||
CompletableFuture<ArrivalApplicationResponseDto> result = arrivalEventService.applyEvent(authInfo); | ||
|
||
// then | ||
Assertions.assertThat(result).isCompletedWithValue(expectedResponse); | ||
} | ||
|
||
@Test | ||
@DisplayName("다양한 구현체에 대해 선착순 이벤트 테스트 (성공 - Java)") | ||
public void testApplyEventWithJavaImplementations_Success() { | ||
// given | ||
doReturn(CompletableFuture.completedFuture(expectedResponse)).when(javaService).applyEvent(authInfo); | ||
arrivalEventService = new ArrivalEventService(javaService); | ||
|
||
// when | ||
CompletableFuture<ArrivalApplicationResponseDto> result = arrivalEventService.applyEvent(authInfo); | ||
|
||
// then | ||
Assertions.assertThat(result).isCompletedWithValue(expectedResponse); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters