File tree Expand file tree Collapse file tree 2 files changed +51
-0
lines changed
src/test/java/com/somemore/volunteer Expand file tree Collapse file tree 2 files changed +51
-0
lines changed Original file line number Diff line number Diff line change 1+ package com .somemore .volunteer .repository ;
2+
3+ import com .somemore .IntegrationTestSupport ;
4+ import com .somemore .auth .oauth .OAuthProvider ;
5+ import com .somemore .center .domain .Center ;
6+ import com .somemore .volunteer .domain .Volunteer ;
7+ import org .junit .jupiter .api .DisplayName ;
8+ import org .junit .jupiter .api .Test ;
9+ import org .springframework .beans .factory .annotation .Autowired ;
10+ import org .springframework .transaction .annotation .Transactional ;
11+
12+ import static org .assertj .core .api .AssertionsForClassTypes .assertThat ;
13+
14+ @ Transactional
15+ public class VolunteerRepositoryTest extends IntegrationTestSupport {
16+ @ Autowired
17+ private VolunteerRepository volunteerRepository ;
18+
19+ @ DisplayName ("봉사자의 id로 닉네임을 조회한다. (Repository)" )
20+ @ Test
21+ void findNicknameById () {
22+ //given
23+ String oAuthId = "example-oauth-id" ;
24+ Volunteer volunteer = Volunteer .createDefault (OAuthProvider .NAVER , oAuthId );
25+
26+ volunteerRepository .save (volunteer );
27+
28+ //when
29+ String volunteerNickname = volunteerRepository .findNicknameById (volunteer .getId ());
30+
31+ //then
32+ assertThat (volunteerNickname ).isEqualTo (volunteer .getNickname ());
33+ }
34+ }
Original file line number Diff line number Diff line change @@ -57,4 +57,21 @@ void throwExceptionWhenVolunteerNotFound() {
5757 assertThatThrownBy (() -> findVolunteerIdService .findVolunteerIdByOAuthId (oAuthId ))
5858 .isInstanceOf (EntityNotFoundException .class );
5959 }
60+
61+ @ DisplayName ("봉사자의 id로 nickname을 조회한다." )
62+ @ Test
63+ void getNicknameById () {
64+
65+ //given
66+ String oAuthId = "example-oauth-id" ;
67+ Volunteer volunteer = Volunteer .createDefault (OAuthProvider .NAVER , oAuthId );
68+
69+ volunteerRepository .save (volunteer );
70+
71+ //when
72+ String nickname = findVolunteerIdService .getNicknameById (volunteer .getId ());
73+
74+ //then
75+ assertThat (nickname ).isEqualTo (volunteer .getNickname ());
76+ }
6077}
You can’t perform that action at this time.
0 commit comments