-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathAccountServiceTest.java
More file actions
50 lines (39 loc) · 1.57 KB
/
AccountServiceTest.java
File metadata and controls
50 lines (39 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package com.cleanengine.coin.user.info.application;
import com.cleanengine.coin.common.CommonValues;
import com.cleanengine.coin.user.domain.Account;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import static org.assertj.core.api.Assertions.assertThat;
@ActiveProfiles({"dev", "h2-mem"})
@DisplayName("계좌 서비스 - h2 통합테스트")
@SpringBootTest
class AccountServiceTest {
@Autowired
private AccountService accountService;
@DisplayName("유저 ID와 예수금으로 신규 계좌를 생성한다.")
@Test
void createNewAccount() {
// given
int userId = Integer.MAX_VALUE;
double cash = CommonValues.INITIAL_USER_CASH;
// when
Account account = accountService.createNewAccount(userId, cash);
assertThat(account).isNotNull();
Account retrievedAccount = accountService.retrieveAccountByUserId(userId);
// then
assertThat(retrievedAccount).isNotNull()
.extracting(Account::getUserId, Account::getCash)
.containsExactly(userId, cash);
}
@DisplayName("존재하지 않는 userId로 조회 시 null을 반환한다.")
@Test
void retrieveAccountByInvalidUserId() {
// given, when
Account account = accountService.retrieveAccountByUserId(Integer.MAX_VALUE - 1);
// then
assertThat(account).isNull();
}
}