package com.github.kokorin.jaffree;

import com.github.kokorin.jaffree.cli.StreamSpecifier;
import com.github.kokorin.jaffree.ffprobe.xml.FFprobeType;
import com.github.kokorin.jaffree.ffprobe.xml.StreamType;
import org.junit.Assert;
import org.junit.Test;

import java.nio.file.Path;
import java.nio.file.Paths;

public class FFprobeTest {
    public static final Path bin = Paths.get("D:\\Projects\\ffmpeg\\bin");
    public static final Path input = Paths.get("D:\\Projects\\Jaffree\\target\\samples\\MPEG-4\\video.mp4");

    @Test
    public void testShowStreams() throws Exception {
        FFprobeType result = FFprobe.atPath(bin)
                .setInputPath(input)
                .setShowStreams(true)
                .execute();

        Assert.assertNotNull(result);
        Assert.assertEquals(6, result.getStreams().getStream().size());
    }

    @Test
    public void testSelectStreamWithShowStreams() throws Exception {
        FFprobeType result = FFprobe.atPath(bin)
                .setInputPath(input)
                .setShowStreams(true)
                .setSelectStreams(new StreamSpecifier("v"))
                .execute();

        Assert.assertNotNull(result);
        Assert.assertEquals(1, result.getStreams().getStream().size());

        StreamType stream = result.getStreams().getStream().get(0);
        Assert.assertEquals("video", stream.getCodecType());
    }

    @Test
    public void testSelectStreamWithShowPackets() throws Exception {
        FFprobeType result = FFprobe.atPath(bin)
                .setInputPath(input)
                .setShowPackets(true)
                .setSelectStreams(new StreamSpecifier(5))
                .execute();

        Assert.assertNotNull(result);
        Assert.assertEquals(1, result.getPackets().getPacket().size());
    }
}

@@ -248,14 +248,72 @@
 nit.
-Test;%0A
+BeforeClass;%0Aimport org.junit.Test;%0A%0Aimport java.nio.file.Files;
 %0Aimp
@@ -414,173 +414,649 @@
 tic 
-final Path bin = Paths.get(%22D:%5C%5CProjects%5C%5Cffmpeg%5C%5Cbin%22);%0A    public static final Path input = Paths.get(%22D:%5C%5CProjects%5C%5CJaffree%5C%5Ctarget%5C%5Csamples%5C%5CMPEG-4%5C%5Cvideo.mp4%22);
+Path bin;%0A    public static Path samples = Paths.get(%22target/samples%22);%0A    public static Path videoMP4 = samples.resolve(%22MPEG-4/video.mp4%22);%0A%0A    @BeforeClass%0A    public static void setUp() throws Exception %7B%0A        String ffmpegHome = System.getProperty(%22FFMPEG_BIN%22);%0A        if (ffmpegHome == null) %7B%0A            ffmpegHome = System.getenv(%22FFMPEG_BIN%22);%0A        %7D%0A        Assert.assertNotNull(%22Nor command line property, neither system variable FFMPEG_BIN is set up%22, ffmpegHome);%0A        bin = Paths.get(ffmpegHome);%0A%0A        Assert.assertTrue(%22Sample videos weren't found: %22 + samples.toAbsolutePath(), Files.exists(samples));%0A    %7D
 %0A%0A  
@@ -1187,37 +1187,40 @@
   .setInputPath(
-input
+videoMP4
 )%0A              
@@ -1539,37 +1539,40 @@
   .setInputPath(
-input
+videoMP4
 )%0A              
@@ -2093,13 +2093,16 @@
 ath(
-input
+videoMP4
 )%0A  

Remove hardcoded paths from tests