-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d8a840d
commit 8fa9578
Showing
6 changed files
with
87 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
Server/src/test/java/com/server/domain/adjustment/service/AdjustmentServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package com.server.domain.adjustment.service; | ||
|
||
import com.server.domain.account.domain.Account; | ||
import com.server.domain.adjustment.service.dto.request.AccountUpdateServiceRequest; | ||
import com.server.domain.member.entity.Member; | ||
import com.server.global.testhelper.ServiceTest; | ||
import org.assertj.core.api.Assertions; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.DynamicTest; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.TestFactory; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
||
import java.util.Collection; | ||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
import static org.assertj.core.api.Assertions.*; | ||
import static org.junit.jupiter.api.Assertions.*; | ||
import static org.junit.jupiter.api.DynamicTest.*; | ||
|
||
class AdjustmentServiceTest extends ServiceTest { | ||
|
||
@Autowired AdjustmentService adjustmentService; | ||
|
||
@TestFactory | ||
@DisplayName("계좌 정보를 수정한다.") | ||
Collection<DynamicTest> updateAccount() { | ||
//given | ||
Member member = createMemberWithChannel(); | ||
|
||
em.flush(); | ||
em.clear(); | ||
|
||
return List.of( | ||
dynamicTest("계좌정보가 없다면 생성한다.", ()-> { | ||
//given | ||
String accountNumber = "123456789"; | ||
String bank = "신한은행"; | ||
String name = "홍길동"; | ||
|
||
AccountUpdateServiceRequest request = new AccountUpdateServiceRequest(name, accountNumber, bank); | ||
|
||
//when | ||
adjustmentService.updateAccount(member.getMemberId(), request); | ||
|
||
//then | ||
Account account = accountRepository.findByMemberId(member.getMemberId()).orElseThrow(); | ||
assertThat(account.getAccount()).isEqualTo(accountNumber); | ||
}), | ||
dynamicTest("계좌정보가 있다면 수정한다.", ()-> { | ||
//given | ||
String accountNumber = "1234567892"; | ||
String bank = "신한은행2"; | ||
String name = "홍길동2"; | ||
|
||
AccountUpdateServiceRequest request = new AccountUpdateServiceRequest(name, accountNumber, bank); | ||
|
||
//when | ||
adjustmentService.updateAccount(member.getMemberId(), request); | ||
|
||
//then | ||
Account account = accountRepository.findByMemberId(member.getMemberId()).orElseThrow(); | ||
assertThat(account.getAccount()).isEqualTo(accountNumber); | ||
assertThat(accountRepository.findAll().size()).isEqualTo(1); | ||
}) | ||
); | ||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters