-
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.
Merge pull request #127 from kakao-tech-campus-2nd-step3/weekly
오류 일부 수정
- Loading branch information
Showing
6 changed files
with
211 additions
and
76 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
144 changes: 144 additions & 0 deletions
144
src/test/java/team1/be/seamless/mapper/ProjectMapperTest.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,144 @@ | ||
package team1.be.seamless.mapper; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
import org.assertj.core.api.Assertions; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import team1.be.seamless.dto.ProjectDTO; | ||
import team1.be.seamless.dto.ProjectDTO.ProjectCreate; | ||
import team1.be.seamless.dto.ProjectDTO.ProjectDate; | ||
import team1.be.seamless.dto.ProjectDTO.ProjectDetail; | ||
import team1.be.seamless.dto.ProjectDTO.ProjectManager; | ||
import team1.be.seamless.dto.ProjectDTO.ProjectUpdate; | ||
import team1.be.seamless.entity.OptionEntity; | ||
import team1.be.seamless.entity.ProjectEntity; | ||
import team1.be.seamless.entity.ProjectOptionEntity; | ||
import team1.be.seamless.entity.UserEntity; | ||
|
||
public class ProjectMapperTest { | ||
|
||
private ProjectMapper projectMapper; | ||
|
||
private OptionEntity optionEntity1; | ||
|
||
private OptionEntity optionEntity2; | ||
|
||
private List<ProjectOptionEntity> projectOptions; | ||
|
||
private UserEntity userEntity; | ||
|
||
private ProjectEntity projectEntity1; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
projectMapper = new ProjectMapper(); | ||
userEntity = new UserEntity( | ||
"사용자1", "[email protected]", "user1Image.jpg" | ||
); | ||
|
||
optionEntity1 = new OptionEntity("옵션1", "옵션 설명1", "타입1"); | ||
optionEntity2 = new OptionEntity("옵션2", "옵션 설명2", "타입2"); | ||
|
||
ProjectOptionEntity projectOption1 = new ProjectOptionEntity(optionEntity1); | ||
ProjectOptionEntity projectOption2 = new ProjectOptionEntity(optionEntity2); | ||
projectOptions = List.of(projectOption1, projectOption2); | ||
|
||
projectEntity1 = new ProjectEntity( | ||
"프로젝트1", | ||
"프로젝트 설명1", | ||
"https://example.com/project1.jpg", | ||
userEntity, | ||
projectOptions, | ||
LocalDateTime.of(2024,11,21,0,0,0), | ||
LocalDateTime.of(2025,11,21,0,0,0) | ||
); | ||
} | ||
|
||
@Test | ||
void 생성_시_ProjectCreate_에서_Entity_로_변환_검증() { | ||
// Given | ||
ProjectDTO.ProjectCreate create = new ProjectCreate( | ||
"프로젝트1", | ||
"프로젝트 설명1", | ||
"https://example.com/project1.jpg", | ||
List.of(1L, 2L), | ||
LocalDateTime.of(2024, 10, 1, 0, 0, 0), | ||
LocalDateTime.of(2025, 10, 1, 0, 0, 0) | ||
); | ||
|
||
//When | ||
ProjectEntity projectEntity = projectMapper.toEntity(create, userEntity, projectOptions); | ||
|
||
//Then | ||
Assertions.assertThat(projectEntity.getName()).isEqualTo("프로젝트1"); | ||
Assertions.assertThat(projectEntity.getDescription()).isEqualTo("프로젝트 설명1"); | ||
Assertions.assertThat(projectEntity.getImageURL()).isEqualTo("https://example.com/project1.jpg"); | ||
Assertions.assertThat(projectEntity.getStartDate()).isEqualTo(LocalDateTime.of(2024, 10, 1, 0, 0, 0)); | ||
Assertions.assertThat(projectEntity.getEndDate()).isEqualTo(LocalDateTime.of(2025, 10, 1, 0, 0, 0)); | ||
Assertions.assertThat(projectEntity.getUserEntity()).isEqualTo(userEntity); | ||
Assertions.assertThat(projectEntity.isActive()).isTrue(); | ||
Assertions.assertThat(projectEntity.isExpired()).isFalse(); | ||
} | ||
|
||
@Test | ||
void 수정시_해당_Entity가_업데이트_되는지_검증() { | ||
// Given | ||
ProjectDTO.ProjectUpdate update = new ProjectUpdate( | ||
"프로젝트2", | ||
"프로젝트 설명2", | ||
"https://example.com/project2.jpg", | ||
List.of(1L, 2L), | ||
LocalDateTime.of(2024, 10, 1, 0, 0, 0), | ||
LocalDateTime.of(2026, 10, 1, 0, 0, 0) | ||
); | ||
|
||
// When | ||
ProjectEntity projectEntity = projectMapper.toUpdate(projectEntity1, update, projectOptions); | ||
|
||
//Then | ||
Assertions.assertThat(projectEntity.getName()).isEqualTo("프로젝트2"); | ||
Assertions.assertThat(projectEntity.getDescription()).isEqualTo("프로젝트 설명2"); | ||
Assertions.assertThat(projectEntity.getImageURL()).isEqualTo("https://example.com/project2.jpg"); | ||
Assertions.assertThat(projectEntity.getStartDate()).isEqualTo(LocalDateTime.of(2024, 10, 1, 0, 0, 0)); | ||
Assertions.assertThat(projectEntity.getEndDate()).isEqualTo(LocalDateTime.of(2026, 10, 1, 0, 0, 0)); | ||
} | ||
|
||
@Test | ||
void ProjectEntity가_ProjectDetail로_반환_되는_지_검증() { | ||
// Given & When | ||
ProjectDetail projectDetail = projectMapper.toDetail(projectEntity1); | ||
|
||
// Then | ||
Assertions.assertThat(projectDetail.getName()).isEqualTo("프로젝트1"); | ||
Assertions.assertThat(projectDetail.getDescription()).isEqualTo("프로젝트 설명1"); | ||
Assertions.assertThat(projectDetail.getImageURL()).isEqualTo("https://example.com/project1.jpg"); | ||
Assertions.assertThat(projectDetail.getTotalMembers()).isEqualTo(0); | ||
Assertions.assertThat(projectDetail.getProjectManager().getName()).isEqualTo(userEntity.getName()); | ||
Assertions.assertThat(projectDetail.getProjectManager().getImageURL()).isEqualTo(userEntity.getPicture()); | ||
Assertions.assertThat(projectDetail.getStartDate()).isEqualTo(LocalDateTime.of(2024,11,21,0,0,0)); | ||
Assertions.assertThat(projectDetail.getEndDate()).isEqualTo(LocalDateTime.of(2025,11,21,0,0,0)); | ||
} | ||
|
||
@Test | ||
void ProjectEntity가_ProjectDate로_반환_되는_지_검증() { | ||
// Given & When | ||
ProjectDate projectDate = projectMapper.toDate(projectEntity1); | ||
|
||
// Then | ||
Assertions.assertThat(projectDate.getName()).isEqualTo("프로젝트1"); | ||
Assertions.assertThat(projectDate.getStartDate()).isEqualTo(LocalDateTime.of(2024,11,21,0,0,0)); | ||
Assertions.assertThat(projectDate.getEndDate()).isEqualTo(LocalDateTime.of(2025,11,21,0,0,0)); | ||
} | ||
|
||
@Test | ||
void UserEntity가_ProjectManager로_반환_되는_지_검증() { | ||
// Given & When | ||
ProjectManager projectManager = projectMapper.toManager(userEntity); | ||
|
||
// Then | ||
Assertions.assertThat(projectManager.getName()).isEqualTo("사용자1"); | ||
Assertions.assertThat(projectManager.getImageURL()).isEqualTo("user1Image.jpg"); | ||
} | ||
|
||
} |
Oops, something went wrong.