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

[JDBC 라이브러리 구현하기 - 1단계] 페드로(류형욱) 미션 제출합니다. #612

Merged
merged 6 commits into from
Oct 6, 2024

Conversation

hw0603
Copy link
Member

@hw0603 hw0603 commented Oct 2, 2024

안녕하세요 우주 🚀

지난 미션에서는 제가 리뷰어였는데 이번에는 반대로 만나게 됐네요ㅋㅋㅋ
1단계는 요구사항이 많지 않아 간단히 구현해 봤어요.

리뷰 잘 부탁드립니다!

@hw0603 hw0603 self-assigned this Oct 2, 2024
@hw0603 hw0603 changed the base branch from main to hw0603 October 2, 2024 07:05
Copy link

@tsulocalize tsulocalize left a comment

Choose a reason for hiding this comment

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

안녕하세요 페드로! 이렇게 다시 만나게 됐네요 ㅎㅎ
깔끔하게 잘 구현해주신 것 같아 간단한 리뷰만 남겼습니다~

Comment on lines 38 to 51
public <T> List<T> query(String sql, Function<ResultSet, T> rowMapper, Object... args) {
List<T> results = new ArrayList<>();
try (PreparedStatement ps = dataSource.getConnection().prepareStatement(sql)) {
setParameters(ps, args);
try (ResultSet rs = ps.executeQuery()) {
while (rs.next()) {
results.add(rowMapper.apply(rs));
}
}
} catch (SQLException e) {
throw new RuntimeException("Query 실패", e);
}
return results;
}

Choose a reason for hiding this comment

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

인덴트를 줄일 수 있을까요?

Copy link
Member Author

Choose a reason for hiding this comment

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

메서드 추출로 줄여보았습니다!

import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;

class JdbcTemplateTest {

Choose a reason for hiding this comment

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

쿼리 실패, 매핑 실패 케이스에 대한 테스트도 추가되면 좋을 것 같아요!

Copy link
Member Author

Choose a reason for hiding this comment

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

쿼리 실패와 매핑 실패를 따로 테스트하기에는 모킹한 것을 그대로 테스트하는 모습이 될 것 같았어요. 초점을 두고 검증해야 할 부분은 Checked Exception을 Unchecked Exception으로 래핑하는 부분이라고 생각해서 해당 부분에 대한 테스트를 추가했습니다!

Copy link

@tsulocalize tsulocalize left a comment

Choose a reason for hiding this comment

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

미션 요구사항 잘 구현해주신 것 같아 이만 Approve & Merge 하겠습니다!

@tsulocalize tsulocalize merged commit 4a4acbd into woowacourse:hw0603 Oct 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants