Skip to content

Commit

Permalink
Merge pull request #57 from dnd-side-project/feature/#53
Browse files Browse the repository at this point in the history
test: feedback, project entity 테스트 #53
  • Loading branch information
woo0doo authored Jul 15, 2024
2 parents b5af477 + 5b1c7e6 commit ccfc33d
Show file tree
Hide file tree
Showing 2 changed files with 177 additions and 0 deletions.
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 src/test/java/com/sendback/domain/project/entity/ProjectTest.java
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();
}
}


}

0 comments on commit ccfc33d

Please sign in to comment.