-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feature/Inhabas#252] 내가 쓴 글,댓글, 예산신청 조회 DTO test 구현
- Loading branch information
1 parent
4191092
commit e55b1f7
Showing
7 changed files
with
263 additions
and
11 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
73 changes: 73 additions & 0 deletions
73
resource-server/src/test/java/com/inhabas/api/domain/myInfo/dto/MyBoardsDtoTest.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,73 @@ | ||
package com.inhabas.api.domain.myInfo.dto; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.Set; | ||
|
||
import javax.validation.ConstraintViolation; | ||
import javax.validation.Validation; | ||
import javax.validation.Validator; | ||
import javax.validation.ValidatorFactory; | ||
|
||
import org.junit.jupiter.api.AfterAll; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class MyBoardsDtoTest { | ||
|
||
private static ValidatorFactory validatorFactory; | ||
private static Validator validator; | ||
|
||
@BeforeAll | ||
public static void init() { | ||
validatorFactory = Validation.buildDefaultValidatorFactory(); | ||
validator = validatorFactory.getValidator(); | ||
} | ||
|
||
@AfterAll | ||
public static void close() { | ||
validatorFactory.close(); | ||
} | ||
|
||
@DisplayName("MyBoardsDto 객체를 정상적으로 생성한다.") | ||
@Test | ||
public void MyBoardsDto_is_OK() { | ||
// given | ||
MyBoardsDto myBoardsDto = | ||
MyBoardsDto.builder() | ||
.id(1L) | ||
.menuId(16) | ||
.menuName("알파 테스터") | ||
.title("title") | ||
.dateCreated(LocalDateTime.now()) | ||
.build(); | ||
|
||
// when | ||
Set<ConstraintViolation<MyBoardsDto>> violations = validator.validate(myBoardsDto); | ||
|
||
// then | ||
assertThat(violations).isEmpty(); | ||
} | ||
|
||
@DisplayName("MyBoardsDto menuName 필드가 null 이면 validation 실패") | ||
@Test | ||
public void MenuName_is_null() { | ||
// given | ||
MyBoardsDto myBoardsDto = | ||
MyBoardsDto.builder() | ||
.id(1L) | ||
.menuId(16) | ||
.menuName(null) | ||
.title("title") | ||
.dateCreated(LocalDateTime.now()) | ||
.build(); | ||
|
||
// when | ||
Set<ConstraintViolation<MyBoardsDto>> violations = validator.validate(myBoardsDto); | ||
|
||
// then | ||
assertThat(violations).hasSize(1); | ||
} | ||
} |
79 changes: 79 additions & 0 deletions
79
...rver/src/test/java/com/inhabas/api/domain/myInfo/dto/MyBudgetSupportApplicationsTest.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,79 @@ | ||
package com.inhabas.api.domain.myInfo.dto; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.Set; | ||
|
||
import javax.validation.ConstraintViolation; | ||
import javax.validation.Validation; | ||
import javax.validation.Validator; | ||
import javax.validation.ValidatorFactory; | ||
|
||
import com.inhabas.api.auth.domain.oauth2.member.domain.valueObject.RequestStatus; | ||
|
||
import org.junit.jupiter.api.AfterAll; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class MyBudgetSupportApplicationsTest { | ||
|
||
private static ValidatorFactory validatorFactory; | ||
private static Validator validator; | ||
|
||
@BeforeAll | ||
public static void init() { | ||
validatorFactory = Validation.buildDefaultValidatorFactory(); | ||
validator = validatorFactory.getValidator(); | ||
} | ||
|
||
@AfterAll | ||
public static void close() { | ||
validatorFactory.close(); | ||
} | ||
|
||
@DisplayName("MyBudgetSupportApplicationsDto 객체를 정상적으로 생성한다.") | ||
@Test | ||
public void MyBoardsDto_is_OK() { | ||
// given | ||
MyBudgetSupportApplicationDto myBudgetSupportApplicationDto = | ||
MyBudgetSupportApplicationDto.builder() | ||
.id(1L) | ||
.status(RequestStatus.COMPLETED) | ||
.title("예산신청 제목") | ||
.dateCreated(LocalDateTime.now()) | ||
.dateChecked(LocalDateTime.now()) | ||
.dateDeposited(LocalDateTime.now()) | ||
.build(); | ||
|
||
// when | ||
Set<ConstraintViolation<MyBudgetSupportApplicationDto>> violations = | ||
validator.validate(myBudgetSupportApplicationDto); | ||
|
||
// then | ||
assertThat(violations).isEmpty(); | ||
} | ||
|
||
@DisplayName("MyBudgetSupportApplicationsDto status 필드가 null 이면 validation 실패") | ||
@Test | ||
public void MenuName_is_null() { | ||
// given | ||
MyBudgetSupportApplicationDto myBudgetSupportApplicationDto = | ||
MyBudgetSupportApplicationDto.builder() | ||
.id(1L) | ||
.status(null) | ||
.title("예산신청 제목") | ||
.dateCreated(LocalDateTime.now()) | ||
.dateChecked(LocalDateTime.now()) | ||
.dateDeposited(LocalDateTime.now()) | ||
.build(); | ||
|
||
// when | ||
Set<ConstraintViolation<MyBudgetSupportApplicationDto>> violations = | ||
validator.validate(myBudgetSupportApplicationDto); | ||
|
||
// then | ||
assertThat(violations).hasSize(1); | ||
} | ||
} |
73 changes: 73 additions & 0 deletions
73
resource-server/src/test/java/com/inhabas/api/domain/myInfo/dto/MyCommentsDtoTest.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,73 @@ | ||
package com.inhabas.api.domain.myInfo.dto; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.Set; | ||
|
||
import javax.validation.ConstraintViolation; | ||
import javax.validation.Validation; | ||
import javax.validation.Validator; | ||
import javax.validation.ValidatorFactory; | ||
|
||
import org.junit.jupiter.api.AfterAll; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class MyCommentsDtoTest { | ||
|
||
private static ValidatorFactory validatorFactory; | ||
private static Validator validator; | ||
|
||
@BeforeAll | ||
public static void init() { | ||
validatorFactory = Validation.buildDefaultValidatorFactory(); | ||
validator = validatorFactory.getValidator(); | ||
} | ||
|
||
@AfterAll | ||
public static void close() { | ||
validatorFactory.close(); | ||
} | ||
|
||
@DisplayName("MyCommentsDto 객체를 정상적으로 생성한다.") | ||
@Test | ||
public void MyCommentsDto_is_OK() { | ||
// given | ||
MyCommentsDto myCommentsDto = | ||
MyCommentsDto.builder() | ||
.id(1L) | ||
.menuId(16) | ||
.menuName("알파 테스터") | ||
.content("댓글 내용") | ||
.dateCreated(LocalDateTime.now()) | ||
.build(); | ||
|
||
// when | ||
Set<ConstraintViolation<MyCommentsDto>> violations = validator.validate(myCommentsDto); | ||
|
||
// then | ||
assertThat(violations).isEmpty(); | ||
} | ||
|
||
@DisplayName("MyCommentsDto content 필드가 blank 이면 validation 실패") | ||
@Test | ||
public void Content_is_blank() { | ||
// given | ||
MyCommentsDto myCommentsDto = | ||
MyCommentsDto.builder() | ||
.id(1L) | ||
.menuId(16) | ||
.menuName("알파 테스터") | ||
.content("") | ||
.dateCreated(LocalDateTime.now()) | ||
.build(); | ||
|
||
// when | ||
Set<ConstraintViolation<MyCommentsDto>> violations = validator.validate(myCommentsDto); | ||
|
||
// then | ||
assertThat(violations).hasSize(1); | ||
} | ||
} |