Skip to content

Commit 80a6fc2

Browse files
committed
[PeerTube] Fix testGetCommentsFromCommentsInfo test of PeertubeCommentsExtractorTest.Default
The tested comment has been removed, so it couldn't be found in the comments list. This comment has been replaced by a new one from the current comments of the video. Also, in the parent class PeertubeCommentsExtractorTest, final has been used as much as possible and for-each loops of lists have been replaced by their forEach method or the Stream API, in order to simplify code.
1 parent 5a9b6ed commit 80a6fc2

1 file changed

Lines changed: 23 additions & 23 deletions

File tree

extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubeCommentsExtractorTest.java

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ void testGetComments() throws IOException, ExtractionException {
4848

4949
@Test
5050
void testGetCommentsFromCommentsInfo() throws IOException, ExtractionException {
51-
final String comment = "great video";
51+
final String comment = "Thanks for creating such an informative video";
5252

5353
final CommentsInfo commentsInfo =
5454
CommentsInfo.getInfo("https://framatube.org/w/kkGMgK9ZtnKfYAgnEtQxbv");
@@ -69,33 +69,33 @@ void testGetCommentsFromCommentsInfo() throws IOException, ExtractionException {
6969

7070
@Test
7171
void testGetCommentsAllData() throws IOException, ExtractionException {
72-
InfoItemsPage<CommentsInfoItem> comments = extractor.getInitialPage();
73-
for (CommentsInfoItem c : comments.getItems()) {
74-
assertFalse(Utils.isBlank(c.getUploaderUrl()));
75-
assertFalse(Utils.isBlank(c.getUploaderName()));
76-
assertFalse(Utils.isBlank(c.getUploaderAvatarUrl()));
77-
assertFalse(Utils.isBlank(c.getCommentId()));
78-
assertFalse(Utils.isBlank(c.getCommentText().getContent()));
79-
assertFalse(Utils.isBlank(c.getName()));
80-
assertFalse(Utils.isBlank(c.getTextualUploadDate()));
81-
assertFalse(Utils.isBlank(c.getThumbnailUrl()));
82-
assertFalse(Utils.isBlank(c.getUrl()));
83-
assertEquals(-1, c.getLikeCount());
84-
assertTrue(Utils.isBlank(c.getTextualLikeCount()));
85-
}
72+
extractor.getInitialPage()
73+
.getItems()
74+
.forEach(commentsInfoItem -> {
75+
assertFalse(Utils.isBlank(commentsInfoItem.getUploaderUrl()));
76+
assertFalse(Utils.isBlank(commentsInfoItem.getUploaderName()));
77+
assertFalse(Utils.isBlank(commentsInfoItem.getUploaderAvatarUrl()));
78+
assertFalse(Utils.isBlank(commentsInfoItem.getCommentId()));
79+
assertFalse(Utils.isBlank(commentsInfoItem.getCommentText().getContent()));
80+
assertFalse(Utils.isBlank(commentsInfoItem.getName()));
81+
assertFalse(Utils.isBlank(commentsInfoItem.getTextualUploadDate()));
82+
assertFalse(Utils.isBlank(commentsInfoItem.getThumbnailUrl()));
83+
assertFalse(Utils.isBlank(commentsInfoItem.getUrl()));
84+
assertEquals(-1, commentsInfoItem.getLikeCount());
85+
assertTrue(Utils.isBlank(commentsInfoItem.getTextualLikeCount()));
86+
});
8687
}
8788

88-
private boolean findInComments(InfoItemsPage<CommentsInfoItem> comments, String comment) {
89+
private boolean findInComments(final InfoItemsPage<CommentsInfoItem> comments,
90+
final String comment) {
8991
return findInComments(comments.getItems(), comment);
9092
}
9193

92-
private boolean findInComments(List<CommentsInfoItem> comments, String comment) {
93-
for (CommentsInfoItem c : comments) {
94-
if (c.getCommentText().getContent().contains(comment)) {
95-
return true;
96-
}
97-
}
98-
return false;
94+
private boolean findInComments(final List<CommentsInfoItem> comments,
95+
final String comment) {
96+
return comments.stream()
97+
.anyMatch(commentsInfoItem ->
98+
commentsInfoItem.getCommentText().getContent().contains(comment));
9999
}
100100
}
101101

0 commit comments

Comments
 (0)