Skip to content

Commit

Permalink
[Fix] 사용하지 않는 테스트 코드 삭제, GroupServiceTest 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
NARUBROWN committed Mar 25, 2024
1 parent 726459f commit 6c3c882
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 478 deletions.
98 changes: 49 additions & 49 deletions src/test/java/server/inuappcenter/kr/service/GroupServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,24 +77,24 @@ public void getGroupFailTest() {
assertThrows(CustomNotFoundException.class, () -> groupService.getGroup(givenId));
}

// @DisplayName("모든 그룹 가져오기 테스트")
// @Test
// public void findAllGroupTest() {
// // given
// for (int i = 0; i < 10; i++) {
// expectedResList.add(expectedResDto);
// expectedEntityList.add(givenEntity);
// }
// given(groupRepository.findAll()).willReturn(expectedEntityList);
// // when
// List<GroupResponseDto> result = groupService.findAllGroup();
// // then
// for (int i = 0; i < 10; i++) {
// assertEquals(expectedResList.get(i).getGroup_id(), result.get(i).getGroup_id());
// assertEquals(expectedResList.get(i).getMember(), result.get(i).getMember());
// assertEquals(expectedResList.get(i).getRole(), result.get(i).getRole());
// }
// }
@DisplayName("모든 그룹 가져오기 테스트")
@Test
public void findAllGroupTest() {
// given
for (int i = 0; i < 10; i++) {
expectedResList.add(expectedResDto);
expectedEntityList.add(givenEntity);
}
given(groupRepository.findAllByYearAndPartOrderByYear(14.5, "Android")).willReturn(expectedEntityList);
// when
List<GroupResponseDto> result = groupService.findAllGroup(14.5, "Android");
// then
for (int i = 0; i < 10; i++) {
assertEquals(expectedResList.get(i).getGroup_id(), result.get(i).getGroup_id());
assertEquals(expectedResList.get(i).getMember(), result.get(i).getMember());
assertEquals(expectedResList.get(i).getRole(), result.get(i).getRole());
}
}

@DisplayName("그룹 저장 테스트")
@Test
Expand Down Expand Up @@ -146,37 +146,37 @@ public void assignGroupFailTest() {
assertThrows(CustomNotFoundException.class, () -> groupService.assignGroup(givenId, givenId, givenDto));
}

// @DisplayName("그룹 내용 수정 테스트")
// @Test
// public void updateGroup() {
// // given
// given(groupRepository.findById(givenId)).willReturn(Optional.ofNullable(givenEntity));
// givenEntity.updateGroup(givenId, givenDto);
// given(groupRepository.save(Mockito.any(Group.class))).willReturn(givenEntity);
// // when
// GroupResponseDto result = groupService.updateGroup(givenDto, givenId);
// // then
// assertEquals(1L, result.getGroup_id());
// assertEquals(expectedResDto.getMember(), result.getMember());
// assertEquals(expectedResDto.getProfileImage(), result.getProfileImage());
// assertEquals(expectedResDto.getEmail(), result.getEmail());
// assertEquals(expectedResDto.getBlogLink(), result.getBlogLink());
// assertEquals(expectedResDto.getGitRepositoryLink(), result.getGitRepositoryLink());
// assertEquals(expectedResDto.getRole(), result.getRole());
// assertEquals(expectedResDto.getPart(), result.getPart());
// assertEquals(expectedResDto.getYear(), result.getYear());
// assertEquals(expectedResDto.getCreatedDate(), result.getCreatedDate());
// assertEquals(expectedResDto.getLastModifiedDate(), result.getLastModifiedDate());
// }
//
// @DisplayName("그룹 내용 수정 실패 테스트")
// @Test
// public void updateFailGroup() {
// // given
// given(groupRepository.findById(givenId)).willReturn(Optional.empty());
// // when, then
// assertThrows(CustomNotFoundException.class, () -> groupService.updateGroup(givenDto, givenId));
// }
@DisplayName("그룹 내용 수정 테스트")
@Test
public void updateGroup() {
// given
given(groupRepository.findById(givenId)).willReturn(Optional.ofNullable(givenEntity));
givenEntity.updateGroup(givenId, givenDto, null);
given(groupRepository.save(Mockito.any(Group.class))).willReturn(givenEntity);
// when
GroupResponseDto result = groupService.updateGroup(givenDto, givenId, null);
// then
assertEquals(1L, result.getGroup_id());
assertEquals(expectedResDto.getMember(), result.getMember());
assertEquals(expectedResDto.getProfileImage(), result.getProfileImage());
assertEquals(expectedResDto.getEmail(), result.getEmail());
assertEquals(expectedResDto.getBlogLink(), result.getBlogLink());
assertEquals(expectedResDto.getGitRepositoryLink(), result.getGitRepositoryLink());
assertEquals(expectedResDto.getRole(), result.getRole());
assertEquals(expectedResDto.getPart(), result.getPart());
assertEquals(expectedResDto.getYear(), result.getYear());
assertEquals(expectedResDto.getCreatedDate(), result.getCreatedDate());
assertEquals(expectedResDto.getLastModifiedDate(), result.getLastModifiedDate());
}

@DisplayName("그룹 내용 수정 실패 테스트")
@Test
public void updateFailGroup() {
// given
given(groupRepository.findById(givenId)).willReturn(Optional.empty());
// when, then
assertThrows(CustomNotFoundException.class, () -> groupService.updateGroup(givenDto, givenId, null));
}

@DisplayName("그룹 삭제 테스트")
@Test
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit 6c3c882

Please sign in to comment.