Skip to content

Commit 6ed46c6

Browse files
committed
test(volunteer): 봉사자 조회, 저장 테스트 추가
1 parent e6791d8 commit 6ed46c6

File tree

2 files changed

+77
-0
lines changed

2 files changed

+77
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package com.somemore.volunteer.repository;
2+
3+
import com.somemore.support.IntegrationTestSupport;
4+
import com.somemore.volunteer.domain.NEWVolunteer;
5+
import org.junit.jupiter.api.DisplayName;
6+
import org.junit.jupiter.api.Test;
7+
import org.springframework.beans.factory.annotation.Autowired;
8+
import org.springframework.transaction.annotation.Transactional;
9+
10+
import java.util.UUID;
11+
12+
import static org.assertj.core.api.Assertions.assertThat;
13+
14+
@Transactional
15+
class NEWVolunteerRepositoryImplTest extends IntegrationTestSupport {
16+
17+
@Autowired
18+
private NEWVolunteerRepositoryImpl volunteerRepository;
19+
20+
@DisplayName("유저 아이디로 봉사자를 등록할 수 있다.")
21+
@Test
22+
void saveVolunteerByUserId() {
23+
// given
24+
UUID userId = UUID.randomUUID();
25+
NEWVolunteer volunteer = NEWVolunteer.createDefault(userId);
26+
27+
// when
28+
volunteerRepository.save(volunteer);
29+
30+
// then
31+
NEWVolunteer volunteerByUserId = volunteerRepository.findByUserId(userId).orElseThrow();
32+
NEWVolunteer volunteerById = volunteerRepository.findById(volunteer.getId()).orElseThrow();
33+
34+
35+
assertThat(volunteer)
36+
.isEqualTo(volunteerByUserId)
37+
.isEqualTo(volunteerById);
38+
39+
}
40+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.somemore.volunteer.service;
2+
3+
import com.somemore.support.IntegrationTestSupport;
4+
import com.somemore.volunteer.domain.NEWVolunteer;
5+
import com.somemore.volunteer.repository.NEWVolunteerRepository;
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.UUID;
12+
13+
import static org.assertj.core.api.Assertions.assertThat;
14+
15+
@Transactional
16+
class NEWRegisterVolunteerServiceTest extends IntegrationTestSupport {
17+
18+
@Autowired
19+
private NEWRegisterVolunteerService registerVolunteerService;
20+
21+
@Autowired
22+
private NEWVolunteerRepository volunteerRepository;
23+
24+
@Test
25+
@DisplayName("유저 아이디로 봉사자가 등록될 수 있다.")
26+
void registerByUserId() {
27+
// given
28+
UUID userId = UUID.randomUUID();
29+
30+
// when
31+
NEWVolunteer savedVolunteer = registerVolunteerService.register(userId);
32+
33+
// then
34+
NEWVolunteer foundVolunteer = volunteerRepository.findByUserId(userId).orElseThrow();
35+
assertThat(savedVolunteer).isEqualTo(foundVolunteer);
36+
}
37+
}

0 commit comments

Comments
 (0)