Skip to content

Commit

Permalink
Test: add get userinfo business
Browse files Browse the repository at this point in the history
  • Loading branch information
emost22 committed Jun 22, 2024
1 parent f7964ff commit 9d279aa
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.sirius.spurt.store.provider.user.vo;

import com.sirius.spurt.common.meta.JobGroup;
import lombok.Builder;
import lombok.Data;

@Data
@Builder
public class UserVo {
private String userId;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.sirius.spurt.service.business.user;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import com.sirius.spurt.service.business.user.UserInfoBusiness.Dto;
import com.sirius.spurt.service.business.user.UserInfoBusiness.Result;
import com.sirius.spurt.store.provider.user.UserProvider;
import com.sirius.spurt.store.provider.user.vo.UserVo;
import com.sirius.spurt.test.UserTest;
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;

@ExtendWith(MockitoExtension.class)
class UserInfoBusinessTest implements UserTest {
@InjectMocks private UserInfoBusiness userInfoBusiness;

@Mock private UserProvider userProvider;

@Test
void 유저_정보_조회_테스트() {
// given
Dto dto = Dto.builder().userId(TEST_USER_ID).build();
UserVo userVo = UserVo.builder().userId(TEST_USER_ID).jobGroup(TEST_JOB_GROUP).build();
when(userProvider.getUserInfo(any())).thenReturn(userVo);

// when
Result result = userInfoBusiness.execute(dto);

// then
verify(userProvider).getUserInfo(any());
assertThat(result.getUserId()).isEqualTo(TEST_USER_ID);
assertThat(result.getJobGroup()).isEqualTo(TEST_JOB_GROUP);
}
}

0 comments on commit 9d279aa

Please sign in to comment.