1+ package com .programmers .vouchermanagement .wallet ;
2+
3+ import com .programmers .vouchermanagement .wallet .repository .WalletJDBCRepository ;
4+ import com .zaxxer .hikari .HikariDataSource ;
5+ import org .junit .jupiter .api .*;
6+ import org .springframework .beans .factory .annotation .Autowired ;
7+ import org .springframework .boot .jdbc .DataSourceBuilder ;
8+ import org .springframework .context .annotation .Bean ;
9+ import org .springframework .context .annotation .ComponentScan ;
10+ import org .springframework .context .annotation .Configuration ;
11+ import org .springframework .jdbc .core .JdbcTemplate ;
12+ import org .springframework .jdbc .core .namedparam .NamedParameterJdbcTemplate ;
13+ import org .springframework .test .context .junit .jupiter .SpringJUnitConfig ;
14+
15+ import javax .sql .DataSource ;
16+
17+ @ SpringJUnitConfig
18+ @ TestMethodOrder (MethodOrderer .OrderAnnotation .class )
19+ @ TestInstance (TestInstance .Lifecycle .PER_CLASS )
20+ class WalletJDBCRepositoryTest {
21+ @ Autowired
22+ WalletJDBCRepository walletJDBCRepository ;
23+ @ Autowired
24+ DataSource dataSource ;
25+
26+ @ Test
27+ @ DisplayName ("고객 id와 바우처 id 정보를 함께 저장할 수 있다." )
28+ void save () {
29+ }
30+
31+ @ Test
32+ @ DisplayName ("고객 id로 고객이 가진 바우처 id를 가져올 수 있다." )
33+ void findAllVoucherByCustomerId () {
34+ }
35+
36+ @ Test
37+ @ DisplayName ("함께 저장된 고객 id와 바우처 id 정보를 삭제할 수 있다." )
38+ void delete () {
39+ }
40+
41+ @ Test
42+ @ DisplayName ("바우처 id로 바우처를 가진 고객 id를 가져올 수 있다." )
43+ void findCustomerByVoucherId () {
44+ }
45+
46+ @ Configuration
47+ @ ComponentScan (
48+ basePackages = {"com.programmers.vouchermanagement.wallet.repository" }
49+ )
50+ static class Config {
51+ @ Bean
52+ public DataSource dataSource () {
53+ var dataSource = DataSourceBuilder .create ()
54+ .url ("jdbc:mysql://localhost:3306/test" )
55+ .username ("root" )
56+ .password ("980726" )
57+ .type (HikariDataSource .class )
58+ .build ();
59+ dataSource .setMaximumPoolSize (1000 );
60+ dataSource .setMinimumIdle (100 );
61+ return dataSource ;
62+ }
63+
64+ @ Bean
65+ public JdbcTemplate jdbcTemplate (DataSource dataSource ) {
66+ return new JdbcTemplate (dataSource );
67+ }
68+
69+ @ Bean
70+ public NamedParameterJdbcTemplate namedParameterJdbcTemplate (JdbcTemplate jdbcTemplate ) {
71+ return new NamedParameterJdbcTemplate (jdbcTemplate );
72+ }
73+ }
74+ }
0 commit comments