-
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 remote-tracking branch 'upstream/weekly' into week10
- Loading branch information
Showing
8 changed files
with
201 additions
and
311 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
197 changes: 62 additions & 135 deletions
197
src/test/java/team1/be/seamless/mapper/UserMapperTest.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 |
---|---|---|
@@ -1,160 +1,87 @@ | ||
package team1.be.seamless.mapper; | ||
|
||
import org.assertj.core.api.Assertions; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import team1.be.seamless.dto.TaskDTO.TaskCreate; | ||
import team1.be.seamless.dto.TaskDTO.TaskDetail; | ||
import team1.be.seamless.dto.TaskDTO.TaskUpdate; | ||
import team1.be.seamless.dto.TaskDTO.TaskWithOwnerDetail; | ||
import team1.be.seamless.entity.*; | ||
import team1.be.seamless.entity.enums.Priority; | ||
import team1.be.seamless.entity.enums.TaskStatus; | ||
import team1.be.seamless.dto.UserDTO; | ||
import team1.be.seamless.entity.UserEntity; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class UserMapperTest { | ||
|
||
private TaskMapper taskMapper; | ||
private UserMapper userMapper = new UserMapper(); | ||
|
||
private TaskEntity taskEntity; | ||
|
||
private ProjectEntity projectEntity; | ||
|
||
private OptionEntity optionEntity1; | ||
|
||
private OptionEntity optionEntity2; | ||
|
||
private List<ProjectOptionEntity> projectOptions; | ||
@Test | ||
void 유저엔티티생성() { | ||
// given | ||
String userName = "test"; | ||
String eamil = "[email protected]"; | ||
String picture = "https://img.com"; | ||
|
||
private UserEntity userEntity; | ||
// when | ||
UserEntity userEntity = userMapper.toEntity(userName, eamil, picture); | ||
|
||
private MemberEntity memberEntity; | ||
// then | ||
assertEquals(userEntity.getName(), userName); | ||
assertEquals(userEntity.getEmail(), eamil); | ||
assertEquals(userEntity.getPicture(), picture); | ||
|
||
@BeforeEach | ||
void setUp() { | ||
taskMapper = new TaskMapper(); | ||
userEntity = new UserEntity( | ||
"사용자1", "[email protected]", "user1Image.jpg" | ||
); | ||
} | ||
|
||
optionEntity1 = new OptionEntity("옵션1", "옵션 설명1", "타입1"); | ||
optionEntity2 = new OptionEntity("옵션2", "옵션 설명2", "타입2"); | ||
@Test | ||
void 유저업데이트생성() { | ||
// given | ||
String userName = "test"; | ||
String eamil = "[email protected]"; | ||
String picture = "https://img.com"; | ||
|
||
String updateUserName = "test2"; | ||
String updatePicture = "https://img2.com"; | ||
|
||
UserEntity userEntity = userMapper.toEntity(userName, eamil, picture); | ||
UserDTO.UserUpdate update = new UserDTO.UserUpdate(updateUserName, updatePicture); | ||
// when | ||
UserEntity updateUser = userMapper.toUpdate(userEntity, update); | ||
|
||
// then | ||
assertEquals(updateUser.getName(), updateUserName); | ||
assertEquals(updateUser.getEmail(), eamil); | ||
assertEquals(updateUser.getPicture(), updatePicture); | ||
} | ||
|
||
ProjectOptionEntity projectOption1 = new ProjectOptionEntity(optionEntity1); | ||
ProjectOptionEntity projectOption2 = new ProjectOptionEntity(optionEntity2); | ||
projectOptions = List.of(projectOption1, projectOption2); | ||
@Test | ||
void 유저심플생성() { | ||
// given | ||
String userName = "test"; | ||
String eamil = "[email protected]"; | ||
String picture = "https://img.com"; | ||
|
||
projectEntity = new ProjectEntity( | ||
"프로젝트1", | ||
"프로젝트 설명1", | ||
"https://example.com/project1.jpg", | ||
userEntity, | ||
projectOptions, | ||
LocalDateTime.of(2023, 11, 21, 0, 0, 0), | ||
LocalDateTime.of(2025, 11, 21, 0, 0, 0) | ||
); | ||
UserEntity userEntity = userMapper.toEntity(userName, eamil, picture); | ||
// when | ||
UserDTO.UserSimple simple = userMapper.toUserSimple(userEntity); | ||
|
||
memberEntity = new MemberEntity("멤버 1", "MEMBER", "[email protected]", | ||
"https://abcdgef.com", projectEntity); | ||
// then | ||
assertEquals(simple.getUsername(), userName); | ||
assertEquals(simple.getEmail(), eamil); | ||
assertEquals(simple.getPicture(), picture); | ||
|
||
taskEntity = new TaskEntity( | ||
"태스크 1", | ||
"첫번째 태스크 입니다.", | ||
Priority.HIGH, | ||
projectEntity, | ||
memberEntity, | ||
LocalDateTime.of(2023, 12, 22, 0, 0, 0), | ||
LocalDateTime.of(2024, 12, 22, 0, 0, 0), | ||
75, | ||
TaskStatus.PENDING | ||
); | ||
} | ||
|
||
@Test | ||
void 생성_시_taskCreate_에서_Entity로_변환_검증() { | ||
TaskCreate create = new TaskCreate( | ||
"새로운 태스크", | ||
"새로운 태스크 입니다.", | ||
memberEntity.getId(), | ||
LocalDateTime.of(2024, 10, 10, 0, 0), | ||
LocalDateTime.of(2024, 11, 11, 0, 0), | ||
Priority.HIGH, | ||
TaskStatus.IN_PROGRESS, | ||
50); | ||
|
||
TaskEntity created_taskEntity = new TaskMapper().toEntity(projectEntity, memberEntity, | ||
create); | ||
|
||
Assertions.assertThat(created_taskEntity.getName()).isEqualTo("새로운 태스크"); | ||
Assertions.assertThat(created_taskEntity.getDescription()).isEqualTo("새로운 태스크 입니다."); | ||
Assertions.assertThat(created_taskEntity.getStartDate()) | ||
.isEqualTo(LocalDateTime.of(2024, 10, 10, 0, 0)); | ||
Assertions.assertThat(created_taskEntity.getEndDate()) | ||
.isEqualTo(LocalDateTime.of(2024, 11, 11, 0, 0)); | ||
Assertions.assertThat(created_taskEntity.getPriority()).isEqualTo(Priority.HIGH); | ||
Assertions.assertThat(created_taskEntity.getStatus()).isEqualTo(TaskStatus.IN_PROGRESS); | ||
Assertions.assertThat(created_taskEntity.getProgress()).isEqualTo(50); | ||
} | ||
void 유저디테일생성() { | ||
// given | ||
String userName = "test"; | ||
String eamil = "[email protected]"; | ||
String picture = "https://img.com"; | ||
|
||
@Test | ||
void 수정_시_taskUpdate_에서_Entity로_변환_검증() { | ||
TaskUpdate update = new TaskUpdate( | ||
"수정된 태스크", | ||
"", | ||
1, | ||
memberEntity.getId(), | ||
LocalDateTime.of(2024, 10, 10, 0, 0), | ||
LocalDateTime.of(2024, 11, 20, 0, 0), | ||
Priority.LOW, | ||
TaskStatus.IN_PROGRESS | ||
); | ||
|
||
TaskEntity updated_taskEntity = new TaskMapper().toUpdate(taskEntity, update); | ||
|
||
Assertions.assertThat(updated_taskEntity.getName()).isEqualTo("수정된 태스크"); | ||
Assertions.assertThat(updated_taskEntity.getDescription()).isEqualTo(""); | ||
Assertions.assertThat(updated_taskEntity.getStartDate()) | ||
.isEqualTo(LocalDateTime.of(2024, 10, 10, 0, 0)); | ||
Assertions.assertThat(updated_taskEntity.getEndDate()) | ||
.isEqualTo(LocalDateTime.of(2024, 11, 20, 0, 0)); | ||
Assertions.assertThat(updated_taskEntity.getPriority()).isEqualTo(Priority.LOW); | ||
Assertions.assertThat(updated_taskEntity.getStatus()).isEqualTo(TaskStatus.IN_PROGRESS); | ||
Assertions.assertThat(updated_taskEntity.getProgress()).isEqualTo(1); | ||
} | ||
UserEntity userEntity = userMapper.toEntity(userName, eamil, picture); | ||
// when | ||
UserDTO.UserDetails details = userMapper.toUserDetails(userEntity); | ||
|
||
@Test | ||
void TaskEntity가_TaskDetail로_반환_되는지_검증() { | ||
TaskDetail taskDetail = taskMapper.toDetail(taskEntity); | ||
|
||
Assertions.assertThat(taskDetail.getName()).isEqualTo("태스크 1"); | ||
Assertions.assertThat(taskDetail.getDescription()).isEqualTo("첫번째 태스크 입니다."); | ||
Assertions.assertThat(taskDetail.getStartDate()) | ||
.isEqualTo(LocalDateTime.of(2023, 12, 22, 0, 0)); | ||
Assertions.assertThat(taskDetail.getEndDate()) | ||
.isEqualTo(LocalDateTime.of(2024, 12, 22, 0, 0)); | ||
Assertions.assertThat(taskDetail.getPriority()).isEqualTo(Priority.HIGH); | ||
Assertions.assertThat(taskDetail.getStatus()).isEqualTo(TaskStatus.PENDING); | ||
Assertions.assertThat(taskDetail.getProgress()).isEqualTo(75); | ||
} | ||
// then | ||
|
||
@Test | ||
void TaskEntity가_TaskWithOwnerDetail로_반환_되는지_검증() { | ||
TaskWithOwnerDetail taskWithOwnerDetail = taskMapper.toDetailWithOwner(taskEntity); | ||
|
||
Assertions.assertThat(taskWithOwnerDetail.getName()).isEqualTo("태스크 1"); | ||
Assertions.assertThat(taskWithOwnerDetail.getDescription()).isEqualTo("첫번째 태스크 입니다."); | ||
Assertions.assertThat(taskWithOwnerDetail.getOwner().getName()).isEqualTo("멤버 1"); | ||
Assertions.assertThat(taskWithOwnerDetail.getOwner().getRole()).isEqualTo("MEMBER"); | ||
Assertions.assertThat(taskWithOwnerDetail.getOwner().getImageURL()) | ||
.isEqualTo("https://abcdgef.com"); | ||
Assertions.assertThat(taskWithOwnerDetail.getStartDate()) | ||
.isEqualTo(LocalDateTime.of(2023, 12, 22, 0, 0)); | ||
Assertions.assertThat(taskWithOwnerDetail.getEndDate()) | ||
.isEqualTo(LocalDateTime.of(2024, 12, 22, 0, 0)); | ||
Assertions.assertThat(taskWithOwnerDetail.getPriority()).isEqualTo(Priority.HIGH); | ||
Assertions.assertThat(taskWithOwnerDetail.getStatus()).isEqualTo(TaskStatus.PENDING); | ||
Assertions.assertThat(taskWithOwnerDetail.getProgress()).isEqualTo(75); | ||
assertEquals(details.getUsername(), userName); | ||
assertEquals(details.getEmail(), eamil); | ||
assertEquals(details.getPicture(), picture); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -57,7 +57,7 @@ void setup() { | |
void 특정_멤버_정상_조회_테스트() { | ||
Long projectId = 1L; | ||
Long memberId = 1L; | ||
String role = Role.USER.toString(); | ||
String role = Role.ADMIN.toString(); | ||
|
||
ProjectEntity projectEntity = new ProjectEntity(); | ||
projectEntity.setEndDate(LocalDateTime.now().plusDays(10)); | ||
|
@@ -77,7 +77,7 @@ void setup() { | |
@Test // 프로젝트의 모든 멤버를 정상적으로 조회할 수 있는지 검증 | ||
void 프로젝트_멤버_전체_조회_테스트() { | ||
Long projectId = 1L; | ||
String role = Role.USER.toString(); | ||
String role = Role.ADMIN.toString(); | ||
|
||
MemberRequestDTO.getMemberList memberListDTO = new MemberRequestDTO.getMemberList(); | ||
|
||
|
@@ -122,7 +122,7 @@ void setup() { | |
void 멤버_정보_수정_테스트() { | ||
Long projectId = 1L; | ||
Long memberId = 1L; | ||
String role = Role.USER.toString(); | ||
String role = Role.ADMIN.toString(); | ||
MemberRequestDTO.UpdateMember updateMember = new MemberRequestDTO.UpdateMember("New 이름", "New 역할", "[email protected]", "imageURL"); | ||
|
||
ProjectEntity projectEntity = new ProjectEntity(); | ||
|
@@ -142,7 +142,7 @@ void setup() { | |
void 멤버_삭제_테스트() { | ||
Long projectId = 1L; | ||
Long memberId = 1L; | ||
String role = Role.USER.toString(); | ||
String role = Role.ADMIN.toString(); | ||
|
||
ProjectEntity projectEntity = new ProjectEntity(); | ||
MemberEntity memberEntity = new MemberEntity(projectEntity); | ||
|
Oops, something went wrong.