-
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: DeviceTokenTest Fixture 추가 및 테스트 케이스 리팩토링 * test: JpaDeviceTokenRepositoryTest Fixture 추가 및 테스트 케이스 리팩토링 * test: DeviceTokenServiceTest Fixture 추가 및 테스트 케이스 리팩토링 * test: DeviceTokenControllerTest Fixture 추가 및 테스트 케이스 리팩토링 * test: 모든 픽스처 객체를 `@BeforeEach`로 세팅하도록 변경 * test: 테스트 픽스처 추가, 네이밍 변경, 코드 스타일 개선 * style: 불필요한 공백 제거 * rename: 테스트하려는 결과의 변수명을 actual로 통일
- Loading branch information
1 parent
9920747
commit 5a4a81e
Showing
8 changed files
with
228 additions
and
198 deletions.
There are no files selected for viewing
81 changes: 18 additions & 63 deletions
81
backend/ddang/src/test/java/com/ddang/ddang/device/application/DeviceTokenServiceTest.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
56 changes: 56 additions & 0 deletions
56
...g/src/test/java/com/ddang/ddang/device/application/fixture/DeviceTokenServiceFixture.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,56 @@ | ||
package com.ddang.ddang.device.application.fixture; | ||
|
||
import com.ddang.ddang.device.application.dto.PersistDeviceTokenDto; | ||
import com.ddang.ddang.device.domain.DeviceToken; | ||
import com.ddang.ddang.device.infrastructure.persistence.JpaDeviceTokenRepository; | ||
import com.ddang.ddang.image.domain.ProfileImage; | ||
import com.ddang.ddang.user.domain.User; | ||
import com.ddang.ddang.user.infrastructure.persistence.JpaUserRepository; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
||
import java.util.List; | ||
|
||
@SuppressWarnings("NonAsciiCharacters") | ||
public class DeviceTokenServiceFixture { | ||
|
||
@Autowired | ||
private JpaDeviceTokenRepository deviceTokenRepository; | ||
|
||
@Autowired | ||
private JpaUserRepository userRepository; | ||
private String 초기_디바이스_토큰_값 = "initialDeviceToken"; | ||
private DeviceToken 사용자의_디바이스_토큰; | ||
|
||
protected String 사용_중인_디바이스_토큰_값 = "usingDeviceToken"; | ||
protected String 갱신된_디바이스_토큰_값 = "newDeviceToken"; | ||
protected Long 존재하지_않는_사용자_아이디 = -999L; | ||
protected User 디바이스_토큰이_있는_사용자; | ||
protected User 디바이스_토큰이_없는_사용자; | ||
protected PersistDeviceTokenDto 디바이스_토큰_저장을_위한_DTO; | ||
protected PersistDeviceTokenDto 디바이스_토큰_갱신을_위한_DTO; | ||
protected PersistDeviceTokenDto 존재하는_디바이스_토큰과_동일한_토큰을_저장하려는_DTO; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
디바이스_토큰이_있는_사용자 = User.builder() | ||
.name("디바이스 토큰이 있는 사용자") | ||
.profileImage(new ProfileImage("upload.png", "store.png")) | ||
.reliability(4.7d) | ||
.oauthId("12345") | ||
.build(); | ||
디바이스_토큰이_없는_사용자 = User.builder() | ||
.name("디바이스 토큰이 없는 사용자") | ||
.profileImage(new ProfileImage("upload.png", "store.png")) | ||
.reliability(4.7d) | ||
.oauthId("12346") | ||
.build(); | ||
사용자의_디바이스_토큰 = new DeviceToken(디바이스_토큰이_있는_사용자, 사용_중인_디바이스_토큰_값); | ||
userRepository.saveAll(List.of(디바이스_토큰이_있는_사용자, 디바이스_토큰이_없는_사용자)); | ||
deviceTokenRepository.save(사용자의_디바이스_토큰); | ||
|
||
디바이스_토큰_저장을_위한_DTO = new PersistDeviceTokenDto(초기_디바이스_토큰_값); | ||
디바이스_토큰_갱신을_위한_DTO = new PersistDeviceTokenDto(갱신된_디바이스_토큰_값); | ||
존재하는_디바이스_토큰과_동일한_토큰을_저장하려는_DTO = new PersistDeviceTokenDto(사용_중인_디바이스_토큰_값); | ||
} | ||
} |
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
23 changes: 23 additions & 0 deletions
23
backend/ddang/src/test/java/com/ddang/ddang/device/domain/fixture/DeviceTokenFixture.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,23 @@ | ||
package com.ddang.ddang.device.domain.fixture; | ||
|
||
import com.ddang.ddang.image.domain.ProfileImage; | ||
import com.ddang.ddang.user.domain.User; | ||
import org.junit.jupiter.api.BeforeEach; | ||
|
||
@SuppressWarnings("NonAsciiCharacters") | ||
public class DeviceTokenFixture { | ||
|
||
protected String 디바이스_토큰 = "deviceToken"; | ||
protected String 새로운_디바이스_토큰 = "newDeviceToken"; | ||
protected User 사용자; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
사용자 = User.builder() | ||
.name("사용자") | ||
.profileImage(new ProfileImage("upload.png", "store.png")) | ||
.reliability(4.7d) | ||
.oauthId("12345") | ||
.build(); | ||
} | ||
} |
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
Oops, something went wrong.