-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
79 additions
and
15 deletions.
There are no files selected for viewing
30 changes: 23 additions & 7 deletions
30
src/test/java/org/sopt/app/application/FriendServiceTest.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 |
---|---|---|
@@ -1,21 +1,37 @@ | ||
package org.sopt.app.application; | ||
|
||
import static org.mockito.ArgumentMatchers.anyLong; | ||
import static org.mockito.Mockito.when; | ||
|
||
import java.util.List; | ||
import org.junit.jupiter.api.Assertions; | ||
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.sopt.app.application.poke.FriendService; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.sopt.app.interfaces.postgres.FriendRepository; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
class FriendServiceTest { | ||
|
||
@SpringBootTest | ||
public class FriendServiceTest { | ||
@Mock | ||
private FriendRepository friendRepository; | ||
|
||
@Autowired | ||
@InjectMocks | ||
private FriendService friendService; | ||
|
||
@Test | ||
@DisplayName("200 - getIsNewUserSuccess") | ||
@DisplayName("SUCCESS_친구가 없다면 새로운 유저로 판단하여 true 반환") | ||
void getIsNewUserSuccess() { | ||
Assertions.assertEquals(true, friendService.getIsNewUser(1L)); | ||
//given | ||
final Long anyUserId = anyLong(); | ||
//when | ||
when(friendRepository.findAllByFriendUserId(anyUserId)).thenReturn(List.of()); | ||
when(friendRepository.findAllByUserIdAndFriendUserIdIn(anyUserId, List.of())).thenReturn(List.of()); | ||
//then | ||
Assertions.assertTrue(friendService.getIsNewUser(anyUserId)); | ||
} | ||
} |
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