Skip to content
This repository has been archived by the owner on Aug 13, 2022. It is now read-only.

[#29] Service Layer 단위테스트 작성 #30

Merged
merged 24 commits into from Dec 18, 2020
Merged

[#29] Service Layer 단위테스트 작성 #30

merged 24 commits into from Dec 18, 2020

Conversation

cyj199637
Copy link
Collaborator

  • UserServiceTest의 일부 테스트 메소드 로직 수정
  • PostServiceTest 작성
  • SessionLoginServiceTest 작성

- UserServiceTest의 일부 테스트 메소드 로직 수정
- PostServiceTest 작성
- SessionLoginServiceTest 작성
@cyj199637 cyj199637 self-assigned this Oct 17, 2020
- 팔로우 기능 구현
- 언팔로우 기능 구현
- 팔로잉된 사용자에게 알림이 가도록 FollowController의 followUser()에 알림 추가 기능을 추가
verify(postMapper).getPostsByUserId("test2");
}

@DisplayName("자신이 작성한 게시물 수정")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

전체적으로 보면 성공하는 상황에 대한 테스트는 있지만 실패하는 상황에 대한 테스트는 없네요~ 잘못된 인자를 넘겼을 때 에러가 발생한다거나, S3에서 에러가 발생했을 때 어떻게 되는지 등의 시나리오들을 보충해주시면 좋을 것 같아요

- FollowController URL 수정
- FollowService에서 알림 기능을 처리하도록 수정
- FollowService 인터페이스 제거
- 실패 시나리오에 대한 테스트 추가
boolean isExistUserId = userMapper.isExistUserId(userId);

if (isExistUserId) {
throw new NotUniqueIdException("중복된 아이디입니다.");
throw new NotUniqueUserIdException("중복된 아이디입니다.");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

예외 메세지에 어떤 유저번호가 중복되었는지 알려주면 나중에 디버깅할때 더 좋지 않을까요?
예외 메세지는 최대한 디버깅에 용이하게 써주는게 좋습니다~

}

@DisplayName("로그아웃")
@DisplayName("로그아웃 성공")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

테스트는 코드의 명세서니까 이런 케이스도 있을 수 있겠네요. 로그인이 안되어있어도 로그아웃을 실패하면 성공한다

cyj199637 and others added 10 commits November 21, 2020 23:52
- 각 테스트마다 어떤 상황에 대한 테스트인지 자세한 설명 추가
- SessionLoginServiceTest에 새로운 테스트 케이스 추가
* [#37] Firebase를 활용한 푸시 서비스

- Firebase를 활용하여 푸시 서비스 구현
- 푸시 메시지 전송을 비동기로 처리

* [#37] Firebase 푸시 서비스 수정

- 각 클래스마다 사용한 어노테이션에 대한 주석 추가
- AccessToken을 Redis에 저장하여 관리하도록 로직 변경

* [#37] Firebase 푸시 서비스 수정

- 로그인 / 로그아웃에 AccessToken 등록 / 삭제 로직 추가

* [#37] Firebase 푸시 서비스 빠트린 주석 추가 및 테스트 코드 수정

* [#37] 피드백 반영

- MessageSource와 LocaleResolver를 이용하여 사용자의 위치에 따라 푸시 메시지의 언어가 다르게 나오도록 수정
- Redis에 저장되는 토큰 만료시간 설정
- 팩토리 메소드를 사용하여 스레드풀 생성

* [#37] 피드백 반영

- @async 대신 sendAsync() 메소드로 비동기 처리
[#31] 팔로우 / 언팔로우 기능 구현
@cyj199637
Copy link
Collaborator Author

이 PR에서 테스트가 실패하는 이유는 이 이슈에서는 테스트 코드만 수정하고 이에 대한 서비스 로직은 #43 에서 변경되었기 때문입니다~

cyj199637 and others added 2 commits December 7, 2020 01:47
* [#43] 추가된 단위 테스트에 따른 Service Layer 로직 수정

- 각 DTO 별로 필드 유효성 제약 조건 추가
- PostController 사용자가 존재하지 않는 게시물이나 존재하지 않는 사용자의 피드 조회를 요청하면 Not Found 응답을 반환하도록 로직 수정

* [#43] 피드백 반영

- 일부 응답 객체 팩토리 메소드로 생성
- SessionLoginServiceTest의 추가된 테스트에 따른 SessionLoginService, UserController 로직 수정

* [#43] Jenkins Failed Test Code 수정
@PostConstruct
public void initialize() {
try {
InputStream serviceAccount = new ClassPathResource(apiKeyPath).getInputStream();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이것을 이제 발견했네요. 이렇게하면 classpath에서만 불러올 수 있기 때문에 나중에 jar 외부에서 apiKey를 불러올 수 없게됩니다~ 이것은 외부에서 가져올 수 있도록 별도의 이슈를 빼서 작업해주세요~

FirebaseApp.initializeApp(options);
}
} catch (IOException e) {
e.printStackTrace();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 코드는 사용하면 안됍니다~ 이유도 알아두시면 좋을 것 같네요

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

넵! 해당 코드는 #40 에서 수정하였습니다!

public StringEncryptor jasyptStringEncryptor() {
PooledPBEStringEncryptor encryptor = new PooledPBEStringEncryptor();
SimpleStringPBEConfig config = new SimpleStringPBEConfig();
config.setPassword("yulbamgom");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 값은 외부에서 주입받아야하지 않을까요?

googleCredential.refreshToken();
return googleCredential.getAccessToken();
} catch (IOException e) {
e.printStackTrace();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 코드들은 전부 정리해주세요~ 실제로 업무를 할 때 이 코드를 사용하면 큰일납니다

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 코드들도 마찬가지로 #40 에서 수정하였습니다~

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

그럼 외부주입쪽만 수정해주시면 될 것 같네요~

@cyj199637 cyj199637 changed the base branch from feature/27 to develop December 18, 2020 06:53
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants