Skip to content

Commit

Permalink
test: fix the test cases as code is refacotered
Browse files Browse the repository at this point in the history
  • Loading branch information
JIUNG9 committed Dec 9, 2023
1 parent fa31803 commit f6ad2b2
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.bit.lotte.flower.user.store.entity.StoreManager;
import com.bit.lotte.flower.user.store.exception.StoreUserDomainException;
import com.bit.lotte.flower.user.store.repository.StoreManagerJpaRepository;
import com.bit.lotte.flower.user.store.service.FindStoreMangerByLongIdService;
import com.bit.lotte.flower.user.store.service.StoreManagerLoginResponseService;
import java.util.Optional;
import org.junit.jupiter.api.DisplayName;
Expand All @@ -25,10 +26,13 @@
@ExtendWith(MockitoExtension.class)
class StoreManagerLoginResponseTest {

@InjectMocks
StoreManagerLoginResponseService loginResponseService;
@Mock
StoreManagerJpaRepository repository;
@Mock
FindStoreMangerByLongIdService findStoreMangerByLongIdService;
@InjectMocks
StoreManagerLoginResponseService loginResponseService;

private final Long validStoreManagerId = 1L;


Expand All @@ -40,7 +44,7 @@ private StoreManager initUser() {
@DisplayName("스토어 매니저 로그인시 유저가 존재할 때 유저 네임 반환")
@Test
void UserNameResponse_WhenUserIsExist_GetUserName() {
when(repository.findById(validStoreManagerId)).thenReturn(Optional.of(initUser()));
when(findStoreMangerByLongIdService.findByLongId(validStoreManagerId)).thenReturn(initUser());

StoreManagerLoginResponse response = loginResponseService.getStoreManagerResponse(
validStoreManagerId);
Expand All @@ -51,8 +55,7 @@ void UserNameResponse_WhenUserIsExist_GetUserName() {
@Test
void UserNameResponse_WhenUserIsExist_ThrowStoreUserDomainException() {

when(repository.findById(anyLong())).thenReturn(Optional.empty());

when(findStoreMangerByLongIdService.findByLongId(validStoreManagerId)).thenThrow(StoreUserDomainException.class);
assertThrows(StoreUserDomainException.class, () -> {
loginResponseService.getStoreManagerResponse(validStoreManagerId);
});
Expand Down

0 comments on commit f6ad2b2

Please sign in to comment.