From 1afb0f51b46fda49a0c7ea8c551f824d51edf49f Mon Sep 17 00:00:00 2001 From: haerong22 Date: Sun, 13 Feb 2022 19:36:00 +0900 Subject: [PATCH] refactoring : mysterious name - change method declaration --- .../_00_before/StudyDashboard.java | 45 +++++++++++++++++ .../StudyDashboard.java | 49 +++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 refactoring/src/main/java/com/example/refactoring/_01_mysterious_name/_00_before/StudyDashboard.java create mode 100644 refactoring/src/main/java/com/example/refactoring/_01_mysterious_name/_01_change_method_declaration/StudyDashboard.java diff --git a/refactoring/src/main/java/com/example/refactoring/_01_mysterious_name/_00_before/StudyDashboard.java b/refactoring/src/main/java/com/example/refactoring/_01_mysterious_name/_00_before/StudyDashboard.java new file mode 100644 index 00000000..bb4d690d --- /dev/null +++ b/refactoring/src/main/java/com/example/refactoring/_01_mysterious_name/_00_before/StudyDashboard.java @@ -0,0 +1,45 @@ +package com.example.refactoring._01_mysterious_name._00_before; + +import org.kohsuke.github.GHIssue; +import org.kohsuke.github.GHIssueComment; +import org.kohsuke.github.GHRepository; +import org.kohsuke.github.GitHub; + +import java.io.IOException; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public class StudyDashboard { + + private Set usernames = new HashSet<>(); + + private Set reviews = new HashSet<>(); + + private void studyReviews(GHIssue issue) throws IOException { + List comments = issue.getComments(); + for (GHIssueComment comment : comments) { + usernames.add(comment.getUserName()); + reviews.add(comment.getBody()); + } + } + + public Set getUsernames() { + return usernames; + } + + public Set getReviews() { + return reviews; + } + + public static void main(String[] args) throws IOException { + GitHub gitHub = GitHub.connect(); + GHRepository repository = gitHub.getRepository("haerong22/Study"); + GHIssue issue = repository.getIssue(1); + + StudyDashboard studyDashboard = new StudyDashboard(); + studyDashboard.studyReviews(issue); + studyDashboard.getUsernames().forEach(System.out::println); + studyDashboard.getReviews().forEach(System.out::println); + } +} diff --git a/refactoring/src/main/java/com/example/refactoring/_01_mysterious_name/_01_change_method_declaration/StudyDashboard.java b/refactoring/src/main/java/com/example/refactoring/_01_mysterious_name/_01_change_method_declaration/StudyDashboard.java new file mode 100644 index 00000000..3b78343c --- /dev/null +++ b/refactoring/src/main/java/com/example/refactoring/_01_mysterious_name/_01_change_method_declaration/StudyDashboard.java @@ -0,0 +1,49 @@ +package com.example.refactoring._01_mysterious_name._01_change_method_declaration; + +import org.kohsuke.github.GHIssue; +import org.kohsuke.github.GHIssueComment; +import org.kohsuke.github.GHRepository; +import org.kohsuke.github.GitHub; + +import java.io.IOException; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public class StudyDashboard { + + private Set usernames = new HashSet<>(); + + private Set reviews = new HashSet<>(); + + /** + * 이슈에 작성된 리뷰어의 목록과 리뷰를 읽어옵니다. + * @throws IOException + */ + private void loadReviews() throws IOException { // 메소드의 목적에 맞게 메소드명을 변경 + GitHub gitHub = GitHub.connect(); + GHRepository repository = gitHub.getRepository("haerong22/Study"); + GHIssue issue = repository.getIssue(1); + + List comments = issue.getComments(); + for (GHIssueComment comment : comments) { + usernames.add(comment.getUserName()); + reviews.add(comment.getBody()); + } + } + + public Set getUsernames() { + return usernames; + } + + public Set getReviews() { + return reviews; + } + + public static void main(String[] args) throws IOException { + StudyDashboard studyDashboard = new StudyDashboard(); + studyDashboard.loadReviews(); + studyDashboard.getUsernames().forEach(System.out::println); + studyDashboard.getReviews().forEach(System.out::println); + } +}