package com.atlassian.stash.internal.scm.git.binary;

import com.atlassian.bitbucket.i18n.I18nKey;
import com.atlassian.bitbucket.util.Version;
import org.junit.Test;

import static org.junit.Assert.*;

public class RejectedGitBinaryTest {

    private static final String I18N_KEY_NAME = "some.key.name";
    private static final String BINARY_PATH = "path/to/binary";

    private I18nKey i18nKey = new I18nKey(I18N_KEY_NAME);
    private Version version = new Version(1, 2, 3);
    private GitBinary gitBinary = new SimpleGitBinary(BINARY_PATH, version);

    @Test(expected = NullPointerException.class)
    public void testShouldNotBeCreatedWithoutI18nKey() throws Exception {
        new RejectedGitBinary(null);
    }

    @Test
    public void testShouldNotHaveFoundBinary() throws Exception {
        RejectedGitBinary rejectedGitBinary = new RejectedGitBinary(i18nKey);
        assertFalse(rejectedGitBinary.isFound());
        assertNull(rejectedGitBinary.getBinary());
        assertSame(i18nKey, rejectedGitBinary.getI18nKey());
    }

    @Test
    public void testShouldHaveFoundBinary() throws Exception {
        RejectedGitBinary rejectedGitBinary = new RejectedGitBinary(i18nKey, gitBinary);
        assertTrue(rejectedGitBinary.isFound());
        assertSame(version, rejectedGitBinary.getBinary().getVersion());
        assertSame(i18nKey, rejectedGitBinary.getI18nKey());
    }
}
