org.eclipse.egit.github.core.Comment Java Examples
The following examples show how to use
org.eclipse.egit.github.core.Comment.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GithubCommentManager.java From cover-checker with Apache License 2.0 | 6 votes |
public int deleteComment(Predicate<Comment> commentPredicate) throws IOException { List<Comment> comments = issueService.getComments(repoId, issueNumber); int delCount = 0; for (Comment c : comments) { if (logger.isDebugEnabled()) { logger.debug("pre filtered comment {} : {}/{}", c.getUser().getLogin(), c.getId(), c.getBody()); } if (!commentPredicate.test(c)) { continue; } logger.debug("delete comment {} {}", repoId, c.getId()); issueService.deleteComment(repoId, c.getId()); delCount++; } logger.debug("delete {} comments", delCount); return delCount; }
Example #2
Source File: IssueMetadataTests.java From HubTurbo with GNU Lesser General Public License v3.0 | 6 votes |
@Test public void immutability() { List<TurboIssueEvent> events = stubEvents(); List<Comment> comments = stubComments(); IssueMetadata metadata = IssueMetadata.intermediate(events, comments, "", ""); assertEquals(3, metadata.getEvents().size()); assertEquals(3, metadata.getComments().size()); events.addAll(stubEvents()); comments.addAll(stubComments()); assertEquals(3, metadata.getEvents().size()); assertEquals(3, metadata.getComments().size()); metadata.getEvents().addAll(stubEvents()); metadata.getComments().addAll(stubComments()); assertEquals(3, metadata.getEvents().size()); assertEquals(3, metadata.getComments().size()); }
Example #3
Source File: GitHubGovernorClient.java From arquillian-governor with Apache License 2.0 | 6 votes |
@Override public void close(String issueId) { Validate.notNull(gitHubClient, "GitHub REST client must be specified."); Comment comment = null; try { final Issue issue = getIssue(issueId); issue.setState(IssueService.STATE_CLOSED); comment = this.issueService.createComment(this.gitHubGovernorConfiguration.getRepositoryUser(), this.gitHubGovernorConfiguration.getRepository(), issueId, getClosingMessage()); this.issueService.editIssue(this.gitHubGovernorConfiguration.getRepositoryUser(), this.gitHubGovernorConfiguration.getRepository(), issue); } catch (Exception e) { if (comment != null) { deleteComment(comment); } logger.warning(String.format("An exception has occured while closing the issue %s. Exception: %s", issueId, e.getMessage())); } }
Example #4
Source File: IssuePanelTests.java From HubTurbo with GNU Lesser General Public License v3.0 | 5 votes |
@Test public void testCreateLabelUpdateEventNodesForSampleEvents() throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { Method layoutMethod = ListPanelCard.class.getDeclaredMethod( "layoutEvents", GuiElement.class, List.class, List.class); layoutMethod.setAccessible(true); List<TurboLabel> labels = new ArrayList<>(); labels.add(new TurboLabel("test/test", "aaaaaa", "A1")); labels.add(new TurboLabel("test/test", "aaaaaa", "A2")); labels.add(new TurboLabel("test/test", "bbbbbb", "B1")); labels.add(new TurboLabel("test/test", "bbbbbb", "B2")); labels.add(new TurboLabel("test/test", "cccccc", "C1")); labels.add(new TurboLabel("test/test", "dddddd", "D1")); GuiElement guiElement = new GuiElement( new TurboIssue("test/test", 1, "issue"), labels, Optional.empty(), Optional.empty(), Optional.empty()); List<TurboIssueEvent> events = new ArrayList<>(new TurboIssueEventTests().sampleEvents); List<Node> nodes = TurboIssueEvent.createLabelUpdateEventNodes(guiElement, events); assertEquals(5, TurboIssueEvent.createLabelUpdateEventNodes(guiElement, events).size()); assertEquals(5, ((HBox) nodes.get(0)).getChildren().size()); assertEquals(5, ((HBox) nodes.get(1)).getChildren().size()); assertEquals(4, ((HBox) nodes.get(2)).getChildren().size()); assertEquals(4, ((HBox) nodes.get(3)).getChildren().size()); assertEquals(4, ((HBox) nodes.get(4)).getChildren().size()); assertEquals(5, ((VBox) layoutMethod.invoke(null, guiElement, events, new ArrayList<Comment>())) .getChildren().size()); }
Example #5
Source File: IssueMetadataTests.java From HubTurbo with GNU Lesser General Public License v3.0 | 5 votes |
@Test public void update() { List<TurboIssueEvent> originalEvents = stubEvents(); List<Comment> originalComments = stubComments(); IssueMetadata original = IssueMetadata.intermediate(originalEvents, originalComments, "events", "comments"); IssueMetadata derived = original.full("test"); assertEquals(originalEvents, derived.getEvents()); assertEquals(originalComments, derived.getComments()); assertEquals("events", derived.getEventsETag()); assertEquals("comments", derived.getCommentsETag()); // Computed properties are non-empty assertEquals(Utility.dateToLocalDateTime(now), derived.getNonSelfUpdatedAt()); assertEquals(2, derived.getNonSelfCommentCount()); LocalDateTime rightNow = LocalDateTime.now(); // Failed update List<TurboIssueEvent> newEvents = stubEvents(); IssueMetadata updated = derived.reconcile(rightNow, newEvents, "events2"); assertEquals(originalEvents, updated.getEvents()); assertEquals(originalComments, updated.getComments()); assertEquals("events", updated.getEventsETag()); assertEquals("comments", updated.getCommentsETag()); // Successful update updated = derived.reconcile(rightNow, newEvents, "events"); assertEquals(newEvents, updated.getEvents()); assertEquals(originalComments, updated.getComments()); assertEquals("events", updated.getEventsETag()); assertEquals("comments", updated.getCommentsETag()); }
Example #6
Source File: IssueMetadata.java From HubTurbo with GNU Lesser General Public License v3.0 | 5 votes |
private static LocalDateTime computeNonSelfUpdatedAt(List<TurboIssueEvent> events, List<Comment> comments, String user) { Date result = new Date(0); for (TurboIssueEvent event : events) { if (isEventByOthers(event, user) && event.getDate().after(result)) { result = event.getDate(); } } for (Comment comment : comments) { if (isCommentByOthers(comment, user) && comment.getCreatedAt().after(result)) { result = comment.getCreatedAt(); } } return Utility.dateToLocalDateTime(result); }
Example #7
Source File: IssueMetadata.java From HubTurbo with GNU Lesser General Public License v3.0 | 5 votes |
/** * Full metadata constructor with nonSelfUpdateTime left out */ private IssueMetadata(List<TurboIssueEvent> events, List<Comment> comments, boolean isLatest, String eventsETag, String commentsETag, LocalDateTime nonSelfUpdatedAt, String user) { this.events = new ArrayList<>(events); this.comments = new ArrayList<>(comments); this.isLatest = isLatest; this.eventsETag = eventsETag; this.commentsETag = commentsETag; this.user = user; this.nonSelfUpdatedAt = nonSelfUpdatedAt; this.nonSelfCommentCount = countCommentsByOthers(comments, user); }
Example #8
Source File: IssueMetadata.java From HubTurbo with GNU Lesser General Public License v3.0 | 5 votes |
/** * Full metadata constructor (user provided, computed properties present) */ private IssueMetadata(List<TurboIssueEvent> events, List<Comment> comments, boolean isLatest, String eventsETag, String commentsETag, String user) { this(events, comments, isLatest, eventsETag, commentsETag, computeNonSelfUpdatedAt(events, comments, user), user); }
Example #9
Source File: IssueMetadata.java From HubTurbo with GNU Lesser General Public License v3.0 | 5 votes |
/** * Intermediate metadata constructor (no user provided, empty computed properties) */ private IssueMetadata(List<TurboIssueEvent> events, List<Comment> comments, boolean isLatest, String eventsETag, String commentsETag) { this.events = new ArrayList<>(events); this.comments = new ArrayList<>(comments); this.isLatest = isLatest; this.eventsETag = eventsETag; this.commentsETag = commentsETag; this.user = ""; this.nonSelfUpdatedAt = LocalDateTime.ofEpochSecond(0, 0, ZoneOffset.ofHours(0)); this.nonSelfCommentCount = 0; }
Example #10
Source File: DownloadMetadataTask.java From HubTurbo with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void run() { Map<Integer, IssueMetadata> result = new HashMap<>(); issuesToUpdate.forEach(issue -> { String currEventsETag = issue.getMetadata().getEventsETag(); String currCommentsETag = issue.getMetadata().getCommentsETag(); int id = issue.getId(); ImmutablePair<List<TurboIssueEvent>, String> changes = repo.getUpdatedEvents(repoId, id, currEventsETag); List<TurboIssueEvent> events = changes.getLeft(); String updatedEventsETag = changes.getRight(); List<Comment> comments = repo.getAllComments(repoId, issue); IssueMetadata metadata = IssueMetadata.intermediate(events, comments, updatedEventsETag, currCommentsETag); result.put(id, metadata); }); logger.info(HTLog.format(repoId, "Downloaded " + result.entrySet().stream() .map(entry -> "(" + entry.getValue().summarise() + ") " + "for #" + entry.getKey()) .collect(Collectors.joining(", ")))); response.complete(result); }
Example #11
Source File: GithubCommentManagerTest.java From cover-checker with Apache License 2.0 | 5 votes |
@Test public void deleteComment() throws IOException { when(mockIssue.getComments(repositoryId, prNum)) .thenReturn(Collections.singletonList(new Comment().setId(1).setBody("test") .setUser(new User().setId(1)))); doNothing().when(mockIssue) .deleteComment(repositoryId, 1); GithubCommentManager manager = new GithubCommentManager(mockIssue, repositoryId, prNum); assertEquals(1, manager.deleteComment(c -> c.getBody().equals("test"))); }
Example #12
Source File: ListPanelCard.java From HubTurbo with GNU Lesser General Public License v3.0 | 4 votes |
/** * Given a list of issue events, returns a JavaFX node laying them out properly. * * @param events * @param comments * @return */ private static Node layoutEvents(GuiElement guiElement, List<TurboIssueEvent> events, List<Comment> comments) { TurboIssue issue = guiElement.getIssue(); VBox result = new VBox(); result.setSpacing(3); VBox.setMargin(result, new Insets(3, 0, 0, 0)); // Label update events List<TurboIssueEvent> labelUpdateEvents = events.stream() .filter(TurboIssueEvent::isLabelUpdateEvent) .collect(Collectors.toList()); List<Node> labelUpdateEventNodes = TurboIssueEvent.createLabelUpdateEventNodes(guiElement, labelUpdateEvents); labelUpdateEventNodes.forEach(node -> result.getChildren().add(node)); // Other events beside label updates events.stream() .filter(e -> !e.isLabelUpdateEvent()) .map(e -> e.display(guiElement, issue)) .forEach(e -> result.getChildren().add(e)); // Comments if (!comments.isEmpty()) { String names = comments.stream() .map(comment -> comment.getUser().getLogin()) .distinct() .collect(Collectors.joining(", ")); HBox commentDisplay = new HBox(); commentDisplay.getChildren().addAll( TurboIssueEvent.octicon(TurboIssueEvent.OCTICON_QUOTE), new javafx.scene.control.Label( String.format("%d comments since, involving %s.", comments.size(), names)) ); result.getChildren().add(commentDisplay); } return result; }
Example #13
Source File: GitHubGovernorClient.java From arquillian-governor with Apache License 2.0 | 4 votes |
private void deleteComment(Comment comment) { try { this.issueService.deleteComment(this.gitHubGovernorConfiguration.getRepositoryUser(), this.gitHubGovernorConfiguration.getRepository(), comment.getId()); } catch (IOException e1) { } }
Example #14
Source File: IssueMetadata.java From HubTurbo with GNU Lesser General Public License v3.0 | 4 votes |
private static boolean isCommentBySelf(Comment comment, String user) { return comment.getUser().getLogin().equalsIgnoreCase(user); }
Example #15
Source File: IssueMetadata.java From HubTurbo with GNU Lesser General Public License v3.0 | 4 votes |
private static boolean isCommentByOthers(Comment comment, String user) { return !isCommentBySelf(comment, user); }
Example #16
Source File: IssueMetadata.java From HubTurbo with GNU Lesser General Public License v3.0 | 4 votes |
private static int countCommentsBySelf(List<Comment> comments, String user) { return Math.toIntExact(comments.stream() .filter(c -> isCommentBySelf(c, user)) .count()); }
Example #17
Source File: IssueMetadata.java From HubTurbo with GNU Lesser General Public License v3.0 | 4 votes |
private static int countCommentsByOthers(List<Comment> comments, String user) { return comments.size() - countCommentsBySelf(comments, user); }
Example #18
Source File: IssueMetadata.java From HubTurbo with GNU Lesser General Public License v3.0 | 4 votes |
public List<Comment> getComments() { return new ArrayList<>(comments); }
Example #19
Source File: GithubPullRequestReporter.java From cover-checker with Apache License 2.0 | 4 votes |
Predicate<Comment> oldReport(User watcher) { return c -> c.getUser().getId() == watcher.getId() && c.getBody().contains(REPORT_HEADER); }
Example #20
Source File: GithubCommentManagerTest.java From cover-checker with Apache License 2.0 | 3 votes |
@Test public void insertComment() throws IOException { when(mockIssue.createComment(repositoryId, prNum, "test2")).thenReturn(new Comment().setBody("test2")); GithubCommentManager manager = new GithubCommentManager(mockIssue, repositoryId, prNum); manager.addComment("test2"); verify(mockIssue).createComment(repositoryId, prNum, "test2"); }
Example #21
Source File: IssueMetadata.java From HubTurbo with GNU Lesser General Public License v3.0 | 2 votes |
/** * Constructs an intermediate metadata instance. Intermediate metadata does not have * computed properties filled in; the name of the current user is required for that. * Intermediate instances are constructed immediately upon download. The current user * is filled in later. */ public static IssueMetadata intermediate(List<TurboIssueEvent> events, List<Comment> comments, String eventsETag, String commentsETag) { return new IssueMetadata(events, comments, false, eventsETag, commentsETag); }
Example #22
Source File: Repo.java From HubTurbo with GNU Lesser General Public License v3.0 | votes |
List<Comment> getAllComments(String repoId, TurboIssue issue);
Example #23
Source File: Repo.java From HubTurbo with GNU Lesser General Public License v3.0 | votes |
List<Comment> getComments(String repoId, int issueId);