Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TemplateTagServiceTest 추가 #663

Merged
merged 6 commits into from
Sep 20, 2024
Merged

Conversation

jminkkk
Copy link
Contributor

@jminkkk jminkkk commented Sep 18, 2024

⚡️ 관련 이슈

close #645

📍주요 변경 사항

  1. TemplateTagServiceTest 작성

🎸기타

  1. TemplateTagService, TagService 분리 [REFACTOR] Service Layer 리팩토링 #650 (comment)
  2. 사용되지 않는 메서드 [REFACTOR] Service Layer 리팩토링 #650 (comment)
  3. 탬플릿 태그 삭제로 사용되지 않는 태그가 있는 경우 처리에 대해 논의해봐요
    [REFACTOR] Service Layer 리팩토링 #650 (comment)

@jminkkk jminkkk self-assigned this Sep 18, 2024
@jminkkk jminkkk added refactor 요구사항이 바뀌지 않은 변경사항 BE 백엔드 labels Sep 18, 2024
@jminkkk jminkkk added this to the 5차 스프린트🍗 milestone Sep 18, 2024
Copy link
Contributor

@kyum-q kyum-q left a comment

Choose a reason for hiding this comment

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

몰리 짱 ! 수고하셨어요 !
간단한 코멘트 남겨놨아요 ~ 확인 부탁드려요 ~

Copy link
Contributor

@zangsu zangsu left a comment

Choose a reason for hiding this comment

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

고생하셨어요 몰리!
간단한 코멘트만 남겨 두었습니다~

Copy link
Contributor

@HoeSeong123 HoeSeong123 left a comment

Choose a reason for hiding this comment

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

고생하셨습니다 몰리!!
몰리는 정말 큼직한 것들만 맡아서 했네요....
늘 그랬지만 이번에도 정말 고생 많았습니다.
몰리가 열심히 하신만큼 저도 최선을 다해서 꼼꼼하게 리뷰해봤습니다!

}

@Test
@DisplayName("성공: 이미 있는 템플릿 태그가 포함된 경우 중복 저장하지 않고 새 태그만 생성")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
@DisplayName("성공: 이미 있는 템플릿 태그가 포함된 경우 중복 저장하지 않고 새 태그만 생성")
@DisplayName("성공: 이미 있는 태그가 포함된 경우 중복 저장하지 않고 새 태그만 생성")

// given
Template template = createTemplate();
Tag existTag = tagRepository.save(new Tag("tag1"));
TemplateTag existTemplateTag = new TemplateTag(template, existTag);
Copy link
Contributor

Choose a reason for hiding this comment

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

해당 코드는 없어도 될 것 같은데 만약 필요하다면 다음과 같이 수정해야 할 것 같네요

Suggested change
TemplateTag existTemplateTag = new TemplateTag(template, existTag);
TemplateTag existTemplateTag = templateTagRepository.save(new TemplateTag(template, existTag));

Copy link
Contributor Author

Choose a reason for hiding this comment

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

와우 꼼꼼쓰 정꼼꼼으로 개명 어때요?

);
}

private List<String> getSavedTagNames(Template template) {
Copy link
Contributor

Choose a reason for hiding this comment

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

getSavedTagNames라고 해서 저장된 모든 태그 목록이 나오는 줄 알았는데 템플릿 태그가 나오는 거였군요
getSavedTemplateTagNames로 조금 더 명확하게 네이밍해보는 건 어떤가요?

Suggested change
private List<String> getSavedTagNames(Template template) {
private List<String> getSavedTemplateTagNames(Template template) {

// then
List<String> afterTemplateTags = getSavedTagNames(template);
assertAll(
() -> assertThat(beforeTemplateTags).doesNotContain(existTag.getName()),
Copy link
Contributor

Choose a reason for hiding this comment

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

저장 전에는 tag2, tag3도 포함되어 있지 않다는 것도 추가되면 좋을 것 같아요!!

Suggested change
() -> assertThat(beforeTemplateTags).doesNotContain(existTag.getName()),
() -> assertThat(beforeTemplateTags).doesNotContainAnyElementsOf(tagNames),



@Transactional
class TemplateTagServiceTest extends ServiceTest {
Copy link
Contributor

Choose a reason for hiding this comment

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

전체적으로 빈 리스트가 온 경우에 대한 테스트도 있으면 좋을 것 같아요!!

Copy link
Contributor Author

@jminkkk jminkkk Sep 20, 2024

Choose a reason for hiding this comment

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

GetByTemplate에는 작성이 되어있어
FindAllByTemplates 에 빈 목록 추가해두었고 조회는 아니지만 UpdateTags에 전체 태그를 삭제했을 경우 빈 목록 테스트 추가했습니답!

추가 테스트가 더 필요할 부분 있다면 편하게 말씀 부탁드려용

Copy link
Contributor

Choose a reason for hiding this comment

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

좋네요!! 훌륭합니다 몰리!! 훌몰

templateTagService.deleteByIds(List.of(template.getId()));

// then
assertThat(templateTagRepository.findAllByTemplate(template)).isEmpty();
Copy link
Contributor

Choose a reason for hiding this comment

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

템플릿태그에서는 삭제됐지만 태그에서는 살아있다는 것도 보여주면 좋을 것 같네요

Copy link
Contributor

@zeus6768 zeus6768 left a comment

Choose a reason for hiding this comment

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

테스트가 깔끔해서 읽기 편했어요~!

개선할 부분은 다른 분들이 다 말해준 것 같아 간단한 코멘트만 남겼습니다.

Copy link
Contributor

@zeus6768 zeus6768 left a comment

Choose a reason for hiding this comment

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

꼼꼼한 테스트 보고 많이 배워가요 몰리 ~~

Copy link
Contributor

@HoeSeong123 HoeSeong123 left a comment

Choose a reason for hiding this comment

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

변경사항 확인했습니다.
고생하셨습니다 몰리!

Copy link
Contributor

@kyum-q kyum-q left a comment

Choose a reason for hiding this comment

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

초롱 짱 수고하셨습니다 ~!

Copy link
Contributor

@zangsu zangsu left a comment

Choose a reason for hiding this comment

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

홀리몰리~~ 고생 많으셨어요!
이번 PR 도 이만 approve & merge 때려버리겠습니닷

@zangsu zangsu merged commit 95f90d0 into dev/be Sep 20, 2024
8 checks passed
@zangsu zangsu deleted the test/645-template-tag-service-layer branch September 20, 2024 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BE 백엔드 refactor 요구사항이 바뀌지 않은 변경사항
Projects
Status: Weekend Done
Development

Successfully merging this pull request may close these issues.

5 participants