-
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.
feat : project repository 테스트코드 추가 #25
- Loading branch information
1 parent
b751a02
commit 4725a4a
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
src/test/java/com/sendback/domain/project/repository/ProjectRepositoryTest.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,50 @@ | ||
package com.sendback.domain.project.repository; | ||
|
||
import com.sendback.domain.project.entity.Project; | ||
import com.sendback.domain.project.entity.ProjectImage; | ||
import com.sendback.domain.user.entity.User; | ||
import com.sendback.global.RepositoryTest; | ||
import static com.sendback.domain.user.fixture.UserFixture.createDummyUser; | ||
|
||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public class ProjectRepositoryTest extends RepositoryTest { | ||
|
||
@Autowired | ||
ProjectRepository projectRepository; | ||
|
||
@Test | ||
@DisplayName("특정 userId를 외래키로 가지는 프로젝트의 개수를 반환한다.") | ||
public void countByUserId() { | ||
//given | ||
User user = userTestPersister.save(); | ||
Project project = projectTestPersister.user(user).save(); | ||
|
||
//when | ||
Long projectCount = projectRepository.countByUserId(user.getId()); | ||
|
||
//then | ||
assertThat(projectCount).isEqualTo(1); | ||
} | ||
|
||
@Test | ||
@DisplayName("특정 uerId를 가지는 프로젝트들을 반환한다.") | ||
public void findByUserId() { | ||
//given | ||
User user = userTestPersister.save(); | ||
Project project = projectTestPersister.user(user).save(); | ||
|
||
//when | ||
List<Project> findProject = projectRepository.findByUserId(user.getId()); | ||
|
||
//then | ||
assertThat(findProject.size()).isEqualTo(1); | ||
} | ||
} |