Skip to content

Commit

Permalink
Merge pull request #149 from YAPP-Github/fix/143
Browse files Browse the repository at this point in the history
  • Loading branch information
akalswl14 authored Jun 1, 2023
2 parents 208c29c + 9c997e1 commit de64beb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,10 @@ public Category findCategoryWithUser(Long id, Long userId) {
}

public List<CategoryDto> categoriesOf(Long userId) {
UserJpaEntity user = findUser(userId);
List<CategoryDto> categories = categoryRepository.findCategoriesByUserOrderBySequence(user)
.stream().map(this::buildCategoryDto).collect(
Collectors.toList());
validateExistAtLeastOneCategory(categories);

return categories;
return categoryRepository.findCategoriesByUserOrderBySequence(findUser(userId))
.stream()
.map(this::buildCategoryDto)
.collect(Collectors.toList());
}

@Transactional
Expand Down Expand Up @@ -110,12 +107,6 @@ private int getSequence(UserJpaEntity user) {
return categoryRepository.countCategoriesByUser(user);
}

private void validateExistAtLeastOneCategory(List<CategoryDto> categories) {
if (categories.size() == 0) {
throw new CategoryNotFoundException();
}
}

private void validateDuplicateCategory(String name, UserJpaEntity user) {
List<CategoryDto> categories = categoryRepository.findCategoryDto(user);
long count = categories.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,9 @@ private Category findCategory(Long id) {
}

@Test
public void categoriesOf_์นดํ…Œ๊ณ ๋ฆฌ๊ฐ€_ํ•˜๋‚˜๋„_์กด์žฌํ•˜์ง€_์•Š์œผ๋ฉด_์˜ˆ์™ธ๋ฅผ_๋ฐœ์ƒํ•œ๋‹ค() throws Exception {
assertThatThrownBy(() -> {
categoryService.categoriesOf(findUser("1").getId());
}).isInstanceOf(CategoryNotFoundException.class);
public void categoriesOf_์นดํ…Œ๊ณ ๋ฆฌ๊ฐ€_ํ•˜๋‚˜๋„_์กด์žฌํ•˜์ง€_์•Š๋Š”๋‹ค๋ฉด_๋นˆ_๋ฆฌ์ŠคํŠธ๋ฅผ_๋ฐ˜ํ™˜ํ•œ๋‹ค() throws Exception {
List<CategoryDto> actual = categoryService.categoriesOf(findUser("1").getId());
assertThat(actual.size()).isEqualTo(0);
}

@Test
Expand Down

0 comments on commit de64beb

Please sign in to comment.