-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* test: RegionTest 리팩토링 * test: AuctionRegionTest 리팩토링 * test: RestTemplateInitRegionProcessorTest Fixture 추가 및 테스트 케이스 리팩토링 * test: JpaRegionRepositoryTest Fixture 추가 및 테스트 케이스 리팩토링 * test: RegionServiceTest Fixture 추가 및 테스트 케이스 리팩토링 * rename: 잘못된 메서드 이름 변경 * test: RegionControllerTest Fixture 추가 및 테스트 케이스 리팩토링 * test: 컨트롤러에서 사용하는 픽스처 객체의 아이디가 중복되지 않도록 변경 * test: 원하는 테스트 결과인지 아이디를 통해 비교하도록 변경 * style: 개행 수정 * test: 모든 픽스처 객체를 `@BeforeEach`로 세팅하도록 변경 * test: 실패하는 테스트 케이스 수정 * test: 테스트 픽스처 추가, 네이밍 변경, 코드 스타일 개선 * test: 픽스처 네이밍 변경 및 접근 제어자 변경
- Loading branch information
1 parent
4b9673b
commit 2639865
Showing
12 changed files
with
407 additions
and
434 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
39 changes: 39 additions & 0 deletions
39
.../ddang/src/test/java/com/ddang/ddang/region/application/fixture/RegionServiceFixture.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,39 @@ | ||
package com.ddang.ddang.region.application.fixture; | ||
|
||
import com.ddang.ddang.region.domain.Region; | ||
import com.ddang.ddang.region.infrastructure.persistence.JpaRegionRepository; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
||
@SuppressWarnings("NonAsciiCharacters") | ||
public class RegionServiceFixture { | ||
|
||
@Autowired | ||
private JpaRegionRepository regionRepository; | ||
|
||
protected Region 서울특별시; | ||
protected Region 두번째_지역이_없는_첫번째_지역; | ||
protected Region 서울특별시_강남구; | ||
protected Region 세번째_지역이_없는_두번째_지역; | ||
protected Region 서울특별시_강남구_삼성동; | ||
protected Region 서울특별시_강남구_대치동; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
서울특별시 = new Region("서울특별시"); | ||
두번째_지역이_없는_첫번째_지역 = new Region("두번째 지역이 없는 첫번째 지역"); | ||
서울특별시_강남구 = new Region("강남구"); | ||
세번째_지역이_없는_두번째_지역 = new Region("세번째 지역이 없는 두번째 지역"); | ||
서울특별시_강남구_삼성동 = new Region("삼성동"); | ||
서울특별시_강남구_대치동 = new Region("대치동"); | ||
|
||
서울특별시.addSecondRegion(서울특별시_강남구); | ||
서울특별시.addSecondRegion(세번째_지역이_없는_두번째_지역); | ||
|
||
서울특별시_강남구.addThirdRegion(서울특별시_강남구_삼성동); | ||
서울특별시_강남구.addThirdRegion(서울특별시_강남구_대치동); | ||
|
||
regionRepository.save(서울특별시); | ||
regionRepository.save(두번째_지역이_없는_첫번째_지역); | ||
} | ||
} |
25 changes: 7 additions & 18 deletions
25
backend/ddang/src/test/java/com/ddang/ddang/region/domain/AuctionRegionTest.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 |
---|---|---|
@@ -1,36 +1,25 @@ | ||
package com.ddang.ddang.region.domain; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import com.ddang.ddang.auction.domain.Auction; | ||
import com.ddang.ddang.region.domain.fixture.AuctionRegionFixture; | ||
import org.junit.jupiter.api.DisplayNameGeneration; | ||
import org.junit.jupiter.api.DisplayNameGenerator; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
@DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) | ||
@SuppressWarnings("NonAsciiCharacters") | ||
class AuctionRegionTest { | ||
class AuctionRegionTest extends AuctionRegionFixture { | ||
|
||
@Test | ||
void 직거래_지역과_경매의_연관관계를_세팅한다() { | ||
// given | ||
final Region firstRegion = new Region("서울특별시"); | ||
final Region secondRegion = new Region("강남구"); | ||
final Region thirdRegion = new Region("역삼동"); | ||
|
||
secondRegion.addThirdRegion(thirdRegion); | ||
firstRegion.addSecondRegion(secondRegion); | ||
|
||
final AuctionRegion auctionRegion = new AuctionRegion(firstRegion); | ||
|
||
final Auction auction = Auction.builder() | ||
.title("title") | ||
.build(); | ||
final AuctionRegion auctionRegion = new AuctionRegion(서울특별시_하위_강남구_하위_역삼동); | ||
|
||
// when | ||
auctionRegion.initAuction(auction); | ||
auctionRegion.initAuction(경매); | ||
|
||
// then | ||
assertThat(auctionRegion.getAuction()).isNotNull(); | ||
assertThat(auctionRegion.getAuction().getTitle()).isEqualTo(경매.getTitle()); | ||
} | ||
} |
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
26 changes: 26 additions & 0 deletions
26
backend/ddang/src/test/java/com/ddang/ddang/region/domain/fixture/AuctionRegionFixture.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,26 @@ | ||
package com.ddang.ddang.region.domain.fixture; | ||
|
||
import com.ddang.ddang.auction.domain.Auction; | ||
import com.ddang.ddang.region.domain.Region; | ||
import org.junit.jupiter.api.BeforeEach; | ||
|
||
@SuppressWarnings("NonAsciiCharacters") | ||
public class AuctionRegionFixture { | ||
|
||
protected Region 서울특별시_하위_강남구_하위_역삼동; | ||
protected Auction 경매; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
Region 서울특별시 = new Region("서울특별시"); | ||
Region 서울특별시_하위_강남구 = new Region("강남구"); | ||
서울특별시_하위_강남구_하위_역삼동 = new Region("역삼동"); | ||
|
||
서울특별시_하위_강남구.addThirdRegion(서울특별시_하위_강남구_하위_역삼동); | ||
서울특별시.addSecondRegion(서울특별시_하위_강남구); | ||
|
||
경매 = Auction.builder() | ||
.title("title") | ||
.build(); | ||
} | ||
} |
Oops, something went wrong.