1+ package com .somemore .volunteer .repository ;
2+
3+ import com .somemore .IntegrationTestSupport ;
4+ import com .somemore .volunteer .domain .Gender ;
5+ import com .somemore .volunteer .domain .VolunteerDetail ;
6+ import org .junit .jupiter .api .DisplayName ;
7+ import org .junit .jupiter .api .Test ;
8+ import org .springframework .beans .factory .annotation .Autowired ;
9+ import org .springframework .transaction .annotation .Transactional ;
10+
11+ import java .util .Optional ;
12+ import java .util .UUID ;
13+
14+ import static org .assertj .core .api .Assertions .assertThat ;
15+
16+ @ Transactional
17+ class VolunteerDetailRepositoryTest extends IntegrationTestSupport {
18+
19+ @ Autowired
20+ private VolunteerDetailRepository volunteerDetailRepository ;
21+
22+ @ DisplayName ("봉사자 ID로 봉사자 상세 정보를 조회한다." )
23+ @ Test
24+ void findByVolunteerId () {
25+ // given
26+ UUID volunteerId = UUID .randomUUID ();
27+ VolunteerDetail volunteerDetail = createVolunteerDetail (volunteerId );
28+
29+ volunteerDetailRepository .save (volunteerDetail );
30+
31+ // when
32+ Optional <VolunteerDetail > foundDetail = volunteerDetailRepository .findByVolunteerId (volunteerId );
33+
34+ // then
35+ assertThat (foundDetail ).isPresent ();
36+ assertThat (foundDetail .get ().getVolunteerId ()).isEqualTo (volunteerId );
37+ assertThat (foundDetail .get ().getName ()).isEqualTo (volunteerDetail .getName ());
38+ }
39+
40+ @ DisplayName ("봉사자 상세 정보를 저장한다." )
41+ @ Test
42+ void saveVolunteerDetail () {
43+ // given
44+ UUID volunteerId = UUID .randomUUID ();
45+ VolunteerDetail volunteerDetail = createVolunteerDetail (volunteerId );
46+
47+ // when
48+ VolunteerDetail savedDetail = volunteerDetailRepository .save (volunteerDetail );
49+
50+ // then
51+ assertThat (savedDetail ).isNotNull ();
52+ assertThat (savedDetail .getVolunteerId ()).isEqualTo (volunteerId );
53+ assertThat (savedDetail .getName ()).isEqualTo (volunteerDetail .getName ());
54+ }
55+
56+ private VolunteerDetail createVolunteerDetail (UUID volunteerId ) {
57+ return VolunteerDetail .builder ()
58+ .volunteerId (volunteerId )
59+ .name ("making" )
60+ 61+ .gender (Gender .MALE )
62+ .birthDate ("1998-06-08" )
63+ .contactNumber ("010-1234-5678" )
64+ .build ();
65+ }
66+ }
0 commit comments