-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: feedback, project entity 테스트 #53
- Loading branch information
Showing
2 changed files
with
177 additions
and
0 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
src/test/java/com/sendback/domain/feedback/entity/FeedbackTest.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,52 @@ | ||
package com.sendback.domain.feedback.entity; | ||
|
||
import com.sendback.domain.project.entity.Project; | ||
import com.sendback.domain.user.entity.User; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Nested; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static com.sendback.domain.feedback.fixture.FeedbackFixture.createDummyFeedback; | ||
import static com.sendback.domain.project.fixture.ProjectFixture.createDummyProject; | ||
import static com.sendback.domain.user.fixture.UserFixture.createDummyUser; | ||
import static com.sendback.domain.user.fixture.UserFixture.createDummyUser_B; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public class FeedbackTest { | ||
|
||
@Nested | ||
@DisplayName("피드백 작성자인지 확인") | ||
class CheckAuthorTest { | ||
|
||
@Test | ||
@DisplayName("참") | ||
public void true_checkAuthor() throws Exception { | ||
//given | ||
User user = createDummyUser(); | ||
Project project = createDummyProject(user); | ||
Feedback feedback = createDummyFeedback(user, project); | ||
|
||
//when | ||
boolean isAuthor = feedback.isAuthor(user); | ||
|
||
//then | ||
assertThat(isAuthor).isTrue(); | ||
} | ||
|
||
@Test | ||
@DisplayName("거짓") | ||
public void false_checkAuthor() throws Exception { | ||
//given | ||
User user = createDummyUser(); | ||
User userB = createDummyUser_B(); | ||
Project project = createDummyProject(user); | ||
Feedback feedback = createDummyFeedback(user, project); | ||
|
||
//when | ||
boolean isAuthor = feedback.isAuthor(userB); | ||
|
||
//then | ||
assertThat(isAuthor).isFalse(); | ||
} | ||
} | ||
} |
125 changes: 125 additions & 0 deletions
125
src/test/java/com/sendback/domain/project/entity/ProjectTest.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,125 @@ | ||
package com.sendback.domain.project.entity; | ||
|
||
import com.sendback.domain.user.entity.User; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Nested; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static com.sendback.domain.project.fixture.ProjectFixture.createDummyProject; | ||
import static com.sendback.domain.user.fixture.UserFixture.createDummyUser; | ||
|
||
import static com.sendback.domain.user.fixture.UserFixture.createDummyUser_B; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
|
||
public class ProjectTest { | ||
|
||
@Nested | ||
@DisplayName("프로젝트 작성자인지 확인") | ||
class CheckAuthorTest { | ||
|
||
|
||
@Test | ||
@DisplayName("참") | ||
public void true_checkAuthor() throws Exception { | ||
//given | ||
User user = createDummyUser(); | ||
Project project = createDummyProject(user); | ||
|
||
//when | ||
boolean isAuthor = project.isAuthor(user); | ||
|
||
//then | ||
assertThat(isAuthor).isTrue(); | ||
} | ||
|
||
@Test | ||
@DisplayName("거짓") | ||
public void false_checkAuthor() throws Exception { | ||
//given | ||
User user = createDummyUser(); | ||
User userB = createDummyUser_B(); | ||
Project project = createDummyProject(user); | ||
|
||
//when | ||
boolean isAuthor = project.isAuthor(userB); | ||
|
||
//then | ||
assertThat(isAuthor).isFalse(); | ||
} | ||
} | ||
|
||
@Nested | ||
@DisplayName("끌어올릴 수 있는 지 여부") | ||
class AvailablePullUp { | ||
|
||
@Test | ||
@DisplayName("참") | ||
public void true_checkAvailablePullUp() throws Exception { | ||
//given | ||
User user = createDummyUser(); | ||
Project project = createDummyProject(user); | ||
|
||
//when | ||
boolean isAvailablePullUp = project.isAvailablePulledUp(); | ||
|
||
//then | ||
assertThat(isAvailablePullUp).isTrue(); | ||
} | ||
|
||
@Test | ||
@DisplayName("거짓 (끌어 올린 상태)") | ||
public void false_alreadyPullUp_checkAvailablePullUp() throws Exception { | ||
//given | ||
User user = createDummyUser(); | ||
Project project = createDummyProject(user); | ||
project.pullUp(); | ||
|
||
//when | ||
boolean isAvailablePullUp = project.isAvailablePulledUp(); | ||
|
||
//then | ||
assertThat(isAvailablePullUp).isFalse(); | ||
} | ||
} | ||
|
||
@Nested | ||
@DisplayName("끌어올릴 수 있는 최대를 넘었는지 여부") | ||
class isOverPullUpCnt { | ||
|
||
@Test | ||
@DisplayName("참 (project 15번 끌어올린 상태)") | ||
public void true_checkIsOverPullUpCnt() throws Exception { | ||
//given | ||
User user = createDummyUser(); | ||
Project project = createDummyProject(user); | ||
for (int cnt = 0; cnt < 16; cnt++) { | ||
project.pullUp(); | ||
} | ||
|
||
//when | ||
System.out.println(project.getProjectPull().getPullUpCnt()); | ||
boolean isOverPullUpCnt = project.isOverPullUpCnt(); | ||
|
||
//then | ||
assertThat(isOverPullUpCnt).isTrue(); | ||
} | ||
|
||
@Test | ||
@DisplayName("거짓 (project 15번 이하로 끌어올린 상태)") | ||
public void false_checkIsOverPullUpCnt() throws Exception { | ||
//given | ||
User user = createDummyUser(); | ||
Project project = createDummyProject(user); | ||
|
||
//when | ||
System.out.println(project.getProjectPull().getPullUpCnt()); | ||
boolean isOverPullUpCnt = project.isOverPullUpCnt(); | ||
|
||
//then | ||
assertThat(isOverPullUpCnt).isFalse(); | ||
} | ||
} | ||
|
||
|
||
} |