Skip to content

Commit e6791d8

Browse files
committed
test(center): 기관 조회, 저장 테스트 추가
1 parent 7d552c7 commit e6791d8

File tree

2 files changed

+77
-0
lines changed

2 files changed

+77
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package com.somemore.center.repository;
2+
3+
import com.somemore.center.domain.NEWCenter;
4+
import com.somemore.support.IntegrationTestSupport;
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 NEWCenterRepositoryImplTest extends IntegrationTestSupport {
16+
17+
@Autowired
18+
private NEWCenterRepositoryImpl centerRepository;
19+
20+
@DisplayName("유저 아이디로 기관을 등록할 수 있다.")
21+
@Test
22+
void saveVolunteerByUserId() {
23+
// given
24+
UUID userId = UUID.randomUUID();
25+
NEWCenter center = NEWCenter.createDefault(userId);
26+
27+
// when
28+
centerRepository.save(center);
29+
30+
// then
31+
NEWCenter centerByUserId = centerRepository.findByUserId(userId).orElseThrow();
32+
NEWCenter centerById = centerRepository.findById(center.getId()).orElseThrow();
33+
34+
assertThat(center)
35+
.isEqualTo(centerByUserId)
36+
.isEqualTo(centerById);
37+
38+
}
39+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package com.somemore.center.service;
2+
3+
import com.somemore.center.domain.NEWCenter;
4+
import com.somemore.center.repository.NEWCenterRepository;
5+
import com.somemore.support.IntegrationTestSupport;
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 NEWRegisterCenterServiceTest extends IntegrationTestSupport {
17+
18+
@Autowired
19+
private NEWRegisterCenterService registerCenterService;
20+
21+
@Autowired
22+
private NEWCenterRepository centerRepository;
23+
24+
@Test
25+
@DisplayName("유저 아이디로 센터가 등록될 수 있다.")
26+
void registerByUserId() {
27+
// given
28+
UUID userId = UUID.randomUUID();
29+
30+
// when
31+
NEWCenter savedCenter = registerCenterService.register(userId);
32+
33+
// then
34+
NEWCenter foundCenter = centerRepository.findByUserId(userId).orElseThrow();
35+
assertThat(savedCenter).isEqualTo(foundCenter);
36+
}
37+
38+
}

0 commit comments

Comments
 (0)