-
Notifications
You must be signed in to change notification settings - Fork 300
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
안녕하세요 페드로! 이렇게 다시 만나게 됐네요 ㅎㅎ
깔끔하게 잘 구현해주신 것 같아 간단한 리뷰만 남겼습니다~
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; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
인덴트를 줄일 수 있을까요?
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
쿼리 실패, 매핑 실패 케이스에 대한 테스트도 추가되면 좋을 것 같아요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
쿼리 실패와 매핑 실패를 따로 테스트하기에는 모킹한 것을 그대로 테스트하는 모습이 될 것 같았어요. 초점을 두고 검증해야 할 부분은 Checked Exception을 Unchecked Exception으로 래핑하는 부분이라고 생각해서 해당 부분에 대한 테스트를 추가했습니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
미션 요구사항 잘 구현해주신 것 같아 이만 Approve & Merge 하겠습니다!
안녕하세요 우주 🚀
지난 미션에서는 제가 리뷰어였는데 이번에는 반대로 만나게 됐네요ㅋㅋㅋ
1단계는 요구사항이 많지 않아 간단히 구현해 봤어요.
리뷰 잘 부탁드립니다!