Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
package org.schabi.newpipe.extractor.services.youtube;

import static org.junit.jupiter.api.Assertions.assertAll;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.schabi.newpipe.downloader.DownloaderFactory.getMockPath;

import com.grack.nanojson.JsonParser;
import com.grack.nanojson.JsonParserException;

import org.junit.jupiter.api.Test;
import org.schabi.newpipe.extractor.localization.Localization;
import org.schabi.newpipe.extractor.localization.TimeAgoPatternsManager;
Expand All @@ -20,10 +11,20 @@

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.time.LocalDateTime;
import java.time.OffsetDateTime;
import java.time.ZoneOffset;
import java.util.TimeZone;

public class YoutubeStreamInfoItemTest {
import static org.junit.jupiter.api.Assertions.assertAll;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.schabi.newpipe.downloader.DownloaderFactory.getMockPath;

class YoutubeStreamInfoItemTest {
@Test
void videoRendererPremiere() throws FileNotFoundException, JsonParserException {
final var json = JsonParser.object().from(new FileInputStream(getMockPath(
Expand All @@ -40,10 +41,14 @@ void videoRendererPremiere() throws FileNotFoundException, JsonParserException {
() -> assertEquals("https://www.youtube.com/channel/UCUPrbbdnot-aPgNM65svgOg", extractor.getUploaderUrl()),
() -> assertFalse(extractor.getUploaderAvatars().isEmpty()),
() -> assertTrue(extractor.isUploaderVerified()),
() -> assertEquals("2026-03-15 13:12", extractor.getTextualUploadDate()),
() -> {
TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
assertEquals("2026-03-15 13:12", extractor.getTextualUploadDate());
},
() -> {
assertNotNull(extractor.getUploadDate());
assertEquals(OffsetDateTime.of(2026, 3, 15, 13, 12, 0, 0, ZoneOffset.UTC), extractor.getUploadDate().offsetDateTime());
final var expected = LocalDateTime.of(2026, 3, 15, 13, 12).atOffset(ZoneOffset.UTC);
assertEquals(expected, extractor.getUploadDate().offsetDateTime());
},
() -> assertEquals(-1, extractor.getViewCount()),
() -> assertFalse(extractor.getThumbnails().isEmpty()),
Expand Down