package ctbrec.recorder.postprocessing;

import static org.junit.Assert.*;

import java.io.IOException;

import org.junit.Test;

import ctbrec.Config;
import ctbrec.Recording;

public class CopyTest extends AbstractPpTest {

    @Test
    public void testCopySingleFile() throws IOException, InterruptedException {
        Config config = mockConfig();
        Recording rec = new Recording();
        rec.setModel(mockModel());
        rec.setAbsoluteFile(original);
        rec.setStartDate(now);
        rec.setSingleFile(false);
        Copy pp = new Copy();
        pp.postprocess(rec, recordingManager, config);

        assertNotEquals(rec.getAbsoluteFile(), rec.getPostProcessedFile());
        assertTrue(original.exists());
        assertTrue(rec.getPostProcessedFile().exists());
    }

    @Test
    public void testCopyDirectory() throws IOException, InterruptedException {
        Config config = mockConfig();
        Recording rec = new Recording();
        rec.setModel(mockModel());
        rec.setAbsoluteFile(originalDir);
        rec.setStartDate(now);
        rec.setSingleFile(false);
        Copy pp = new Copy();
        pp.postprocess(rec, recordingManager, config);

        assertNotEquals(rec.getAbsoluteFile(), rec.getPostProcessedFile());
        assertTrue(originalDir.exists());
        assertTrue(rec.getPostProcessedFile().exists());
    }

    @Test
    public void testGetName() {
        assertEquals("create a copy", new Copy().getName());
    }
}
