package com.avg.zaap.crashlibrary.offline.publisher;

import org.junit.Before;
import org.junit.Test;

import java.io.File;
import java.io.FilenameFilter;

import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock;

/**
 * A test class for {@link OfflineReportFilenameFilter}.
 * <p/>
 * Created by marek.osvald on 8.8.2016.
 */
public class OfflineReportFilenameFilterTests {

    private static final String FILE_NAME_CORRECT = "filename.bp";
    private static final String FILE_NAME_INCORRECT = "filename.metadata";

    private FilenameFilter mOfflineFilenameFilter;
    private File mDirectory;

    @Before
    public void setUp() throws Exception {
        mDirectory = mock(File.class);
        mOfflineFilenameFilter = new OfflineReportFilenameFilter();
    }

    @Test
    public void accept_correctExtension_returnsTrue() throws Exception {
        // act
        final boolean result = mOfflineFilenameFilter.accept(mDirectory, FILE_NAME_CORRECT);

        // assert
        assertThat(result, is(true));
    }

    @Test
    public void accept_incorrectExtension_returnsFalse() throws Exception {
        // act
        final boolean result = mOfflineFilenameFilter.accept(mDirectory, FILE_NAME_INCORRECT);

        // assert
        assertThat(result, is(false));
    }

}
