Use final where possible
This commit is contained in:
parent
d306513319
commit
87228673b4
132 changed files with 1024 additions and 1005 deletions
|
|
@ -20,35 +20,35 @@ import static org.junit.Assert.fail;
|
|||
public class ImportExportJsonHelperTest {
|
||||
@Test
|
||||
public void testEmptySource() throws Exception {
|
||||
String emptySource =
|
||||
final String emptySource =
|
||||
"{\"app_version\":\"0.11.6\",\"app_version_int\": 47,\"subscriptions\":[]}";
|
||||
|
||||
List<SubscriptionItem> items = ImportExportJsonHelper.readFrom(new ByteArrayInputStream(
|
||||
emptySource.getBytes(StandardCharsets.UTF_8)), null);
|
||||
final List<SubscriptionItem> items = ImportExportJsonHelper.readFrom(
|
||||
new ByteArrayInputStream(emptySource.getBytes(StandardCharsets.UTF_8)), null);
|
||||
assertTrue(items.isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvalidSource() {
|
||||
List<String> invalidList = Arrays.asList(
|
||||
final List<String> invalidList = Arrays.asList(
|
||||
"{}",
|
||||
"",
|
||||
null,
|
||||
"gibberish");
|
||||
|
||||
for (String invalidContent : invalidList) {
|
||||
for (final String invalidContent : invalidList) {
|
||||
try {
|
||||
if (invalidContent != null) {
|
||||
byte[] bytes = invalidContent.getBytes(StandardCharsets.UTF_8);
|
||||
final byte[] bytes = invalidContent.getBytes(StandardCharsets.UTF_8);
|
||||
ImportExportJsonHelper.readFrom((new ByteArrayInputStream(bytes)), null);
|
||||
} else {
|
||||
ImportExportJsonHelper.readFrom(null, null);
|
||||
}
|
||||
|
||||
fail("didn't throw exception");
|
||||
} catch (Exception e) {
|
||||
boolean isExpectedException = e
|
||||
instanceof SubscriptionExtractor.InvalidSourceException;
|
||||
} catch (final Exception e) {
|
||||
final boolean isExpectedException
|
||||
= e instanceof SubscriptionExtractor.InvalidSourceException;
|
||||
assertTrue("\"" + e.getClass().getSimpleName()
|
||||
+ "\" is not the expected exception", isExpectedException);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ public class TabTest {
|
|||
public void checkIdDuplication() {
|
||||
final Set<Integer> usedIds = new HashSet<>();
|
||||
|
||||
for (Tab.Type type : Tab.Type.values()) {
|
||||
for (final Tab.Type type : Tab.Type.values()) {
|
||||
final boolean added = usedIds.add(type.getTabId());
|
||||
assertTrue("Id was already used: " + type.getTabId(), added);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,13 +53,14 @@ public class TabsJsonHelperTest {
|
|||
"{}"
|
||||
);
|
||||
|
||||
for (String invalidContent : invalidList) {
|
||||
for (final String invalidContent : invalidList) {
|
||||
try {
|
||||
TabsJsonHelper.getTabsFromJson(invalidContent);
|
||||
|
||||
fail("didn't throw exception");
|
||||
} catch (Exception e) {
|
||||
boolean isExpectedException = e instanceof TabsJsonHelper.InvalidJsonException;
|
||||
} catch (final Exception e) {
|
||||
final boolean isExpectedException
|
||||
= e instanceof TabsJsonHelper.InvalidJsonException;
|
||||
assertTrue("\"" + e.getClass().getSimpleName()
|
||||
+ "\" is not the expected exception", isExpectedException);
|
||||
}
|
||||
|
|
@ -78,7 +79,7 @@ public class TabsJsonHelperTest {
|
|||
}
|
||||
|
||||
private boolean isTabsArrayEmpty(final String returnedJson) throws JsonParserException {
|
||||
JsonObject jsonObject = JsonParser.object().from(returnedJson);
|
||||
final JsonObject jsonObject = JsonParser.object().from(returnedJson);
|
||||
assertTrue(jsonObject.containsKey(JSON_TABS_ARRAY_KEY));
|
||||
return jsonObject.getArray(JSON_TABS_ARRAY_KEY).size() == 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,9 +82,9 @@ public class ListHelperTest {
|
|||
// Don't show Higher resolutions //
|
||||
//////////////////////////////////
|
||||
|
||||
List<VideoStream> result = ListHelper.getSortedStreamVideosList(MediaFormat.MPEG_4,
|
||||
final List<VideoStream> result = ListHelper.getSortedStreamVideosList(MediaFormat.MPEG_4,
|
||||
false, VIDEO_STREAMS_TEST_LIST, VIDEO_ONLY_STREAMS_TEST_LIST, false);
|
||||
List<String> expected = Arrays.asList(
|
||||
final List<String> expected = Arrays.asList(
|
||||
"1080p60", "1080p", "720p60", "720p", "480p", "360p", "240p", "144p");
|
||||
assertEquals(result.size(), expected.size());
|
||||
for (int i = 0; i < result.size(); i++) {
|
||||
|
|
@ -94,7 +94,7 @@ public class ListHelperTest {
|
|||
|
||||
@Test
|
||||
public void getDefaultResolutionTest() {
|
||||
List<VideoStream> testList = Arrays.asList(
|
||||
final List<VideoStream> testList = Arrays.asList(
|
||||
new VideoStream("", MediaFormat.MPEG_4, /**/ "720p"),
|
||||
new VideoStream("", MediaFormat.v3GPP, /**/ "240p"),
|
||||
new VideoStream("", MediaFormat.WEBM, /**/ "480p"),
|
||||
|
|
@ -290,7 +290,7 @@ public class ListHelperTest {
|
|||
|
||||
@Test
|
||||
public void getVideoDefaultStreamIndexCombinations() {
|
||||
List<VideoStream> testList = Arrays.asList(
|
||||
final List<VideoStream> testList = Arrays.asList(
|
||||
new VideoStream("", MediaFormat.MPEG_4, /**/ "1080p"),
|
||||
new VideoStream("", MediaFormat.MPEG_4, /**/ "720p60"),
|
||||
new VideoStream("", MediaFormat.MPEG_4, /**/ "720p"),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue