Skip to content

Commit 007c501

Browse files
committed
[duplicated subtitle][unit test] Fix ./gradlew test --no-configuration-cache errors after moving from NewPipeExtractor to NewPipe repository.
- "error: static import only from classes and interfaces" - Changed `package` and `import` statements to adapt to NewPipe main repository. - Name 'containsDuplicatedEntries_exactDuplicate_shouldReturnTrue' must match pattern '^[a-z][a-zA-Z0-9]*$'. - Variable 'expected' should be declared final. - '+' should be on a new line. - Line is longer than 100 characters
1 parent 5f53c68 commit 007c501

1 file changed

Lines changed: 39 additions & 39 deletions

File tree

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
package org.schabi.newpipe.extractor.utils;
1+
package org.schabi.newpipe.util.subtitle;
22

3-
import org.junit.jupiter.api.Test;
3+
import org.junit.Test;
44

5-
import static org.junit.jupiter.api.Assertions.assertEquals;
6-
import static org.junit.jupiter.api.Assertions.assertTrue;
7-
import static org.junit.jupiter.api.Assertions.assertFalse;
5+
import static org.junit.Assert.assertEquals;
6+
import static org.junit.Assert.assertTrue;
7+
import static org.junit.Assert.assertFalse;
88

99
public class SubtitleDeduplicatorTest {
1010

1111
@Test
12-
public void deduplicate_exactDuplicateEntries_shouldRemoveDuplicate() {
13-
String input =
14-
"<p begin=\"00:00:01.000\" end=\"00:00:02.000\">Hello</p>\n" +
15-
"<p begin=\"00:00:01.000\" end=\"00:00:02.000\">Hello</p>";
12+
public void deduplicateExactDuplicateEntriesShouldRemoveDuplicate() {
13+
final String input =
14+
"<p begin=\"00:00:01.000\" end=\"00:00:02.000\">Hello</p>\n"
15+
+ "<p begin=\"00:00:01.000\" end=\"00:00:02.000\">Hello</p>";
1616

17-
String output = SubtitleDeduplicator.deduplicateContent(input);
17+
final String output = SubtitleDeduplicator.deduplicateContent(input);
1818

19-
String expected =
19+
final String expected =
2020
"<p begin=\"00:00:01.000\" end=\"00:00:02.000\">Hello</p>";
2121

2222
// The `strip()` method is used here to remove the trailing
@@ -27,72 +27,72 @@ public void deduplicate_exactDuplicateEntries_shouldRemoveDuplicate() {
2727
}
2828

2929
@Test
30-
public void deduplicate_sameTimeDifferentText_shouldNotDeduplicate() {
31-
String input =
32-
"<p begin=\"00:00:01.000\" end=\"00:00:02.000\">Hello</p>\n" +
33-
"<p begin=\"00:00:01.000\" end=\"00:00:02.000\">World</p>";
30+
public void deduplicateSameTimeDifferentTextShouldNotDeduplicate() {
31+
final String input =
32+
"<p begin=\"00:00:01.000\" end=\"00:00:02.000\">Hello</p>\n"
33+
+ "<p begin=\"00:00:01.000\" end=\"00:00:02.000\">World</p>";
3434

35-
String output = SubtitleDeduplicator.deduplicateContent(input);
35+
final String output = SubtitleDeduplicator.deduplicateContent(input);
3636

37-
String expected = input;
37+
final String expected = input;
3838

3939
assertEquals(expected, output);
4040
}
4141

4242
@Test
43-
public void deduplicate_sameTextDifferentTime_shouldNotDeduplicate() {
44-
String input =
45-
"<p begin=\"00:00:01.000\" end=\"00:00:02.000\">Hello</p>\n" +
46-
"<p begin=\"00:00:02.000\" end=\"00:00:03.000\">Hello</p>";
43+
public void deduplicateSameTextDifferentTimeShouldNotDeduplicate() {
44+
final String input =
45+
"<p begin=\"00:00:01.000\" end=\"00:00:02.000\">Hello</p>\n"
46+
+ "<p begin=\"00:00:02.000\" end=\"00:00:03.000\">Hello</p>";
4747

48-
String output = SubtitleDeduplicator.deduplicateContent(input);
48+
final String output = SubtitleDeduplicator.deduplicateContent(input);
4949

50-
String expected = input;
50+
final String expected = input;
5151

5252
assertEquals(expected, output);
5353
}
5454

5555
@Test
56-
public void containsDuplicatedEntries_exactDuplicate_shouldReturnTrue() {
57-
String input =
58-
"<p begin=\"00:00:01.000\" end=\"00:00:02.000\">Hello</p>\n" +
59-
"<p begin=\"00:00:01.000\" end=\"00:00:02.000\">Hello</p>";
56+
public void containsDuplicatedEntriesExactDuplicateShouldReturnTrue() {
57+
final String input =
58+
"<p begin=\"00:00:01.000\" end=\"00:00:02.000\">Hello</p>\n"
59+
+ "<p begin=\"00:00:01.000\" end=\"00:00:02.000\">Hello</p>";
6060

6161
assertTrue(SubtitleDeduplicator.containsDuplicatedEntries(input));
6262
}
6363

6464
@Test
65-
public void containsDuplicatedEntries_noDuplicate_shouldReturnFalse() {
66-
String input =
67-
"<p begin=\"00:00:01.000\" end=\"00:00:02.000\">Hello</p>\n" +
68-
"<p begin=\"00:00:02.000\" end=\"00:00:03.000\">World</p>";
65+
public void containsDuplicatedEntriesNoDuplicateShouldReturnFalse() {
66+
final String input =
67+
"<p begin=\"00:00:01.000\" end=\"00:00:02.000\">Hello</p>\n"
68+
+ "<p begin=\"00:00:02.000\" end=\"00:00:03.000\">World</p>";
6969

7070
assertFalse(SubtitleDeduplicator.containsDuplicatedEntries(input));
7171
}
7272

7373
@Test
74-
public void containsDuplicatedEntries_normalizeLeadingAndTrailingWhitespace_shouldConsiderAsSame() {
74+
public void containsDuplicatesNormalizeLeadingAndTrailingWhitespaceShouldConsiderAsSame() {
7575
// Note:
7676
// This test verifies that the deduplication logic normalizes
7777
// leading and trailing whitespace, and considers the content
7878
// as the same after this normalization, without modifying
7979
// the original subtitle content.
80-
String input =
81-
"<p begin=\"00:00:01.000\" end=\"00:00:02.000\"> Hello world </p>\n" +
82-
"<p begin=\"00:00:01.000\" end=\"00:00:02.000\">Hello world</p>";
80+
final String input =
81+
"<p begin=\"00:00:01.000\" end=\"00:00:02.000\"> Hello world </p>\n"
82+
+ "<p begin=\"00:00:01.000\" end=\"00:00:02.000\">Hello world</p>";
8383
assertTrue(SubtitleDeduplicator.containsDuplicatedEntries(input));
8484
}
8585

8686
@Test
87-
public void containsDuplicatedEntries_normalizeMultipleSpaces_shouldConsiderAsSingleSpace() {
87+
public void containsDuplicatedEntriesNormalizeMultipleSpacesShouldConsiderAsSingleSpace() {
8888
// Note:
8989
// This test verifies that the deduplication logic normalizes
9090
// multiple consecutive spaces into a single space,
9191
// considering the content as the same after this normalization,
9292
// without modifying the original subtitle content.
93-
String input =
94-
"<p begin=\"00:00:01.000\" end=\"00:00:02.000\">Hello world</p>\n" +
95-
"<p begin=\"00:00:01.000\" end=\"00:00:02.000\">Hello world</p>";
93+
final String input =
94+
"<p begin=\"00:00:01.000\" end=\"00:00:02.000\">Hello world</p>\n"
95+
+ "<p begin=\"00:00:01.000\" end=\"00:00:02.000\">Hello world</p>";
9696
assertTrue(SubtitleDeduplicator.containsDuplicatedEntries(input));
9797
}
9898
}

0 commit comments

Comments
 (0)